Browse Source

do not look for height in older files if we've seen height - 1

Refs #1600
pull/1607/head
Anton Kaliaev 6 years ago
parent
commit
708f35e5c1
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 8 additions and 0 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -0
      consensus/wal.go

+ 1
- 0
CHANGELOG.md View File

@ -8,6 +8,7 @@ IMPROVEMENTS:
- [consensus] consensus reactor now receives events from a separate event bus,
which is not dependant on external RPC load
- [consensus/wal] do not look for height in older files if we've seen height - 1
## 0.19.5


+ 7
- 0
consensus/wal.go View File

@ -151,6 +151,7 @@ type WALSearchOptions struct {
// CONTRACT: caller must close group reader.
func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (gr *auto.GroupReader, found bool, err error) {
var msg *TimedWALMessage
lastHeightFound := int64(-1)
// NOTE: starting from the last file in the group because we're usually
// searching for the last height. See replay.go
@ -166,6 +167,11 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions)
for {
msg, err = dec.Decode()
if err == io.EOF {
// OPTIMISATION: no need to look for height in older files if we've seen h < height
if lastHeightFound > 0 && lastHeightFound < height {
gr.Close()
return nil, false, nil
}
// check next file
break
}
@ -179,6 +185,7 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions)
}
if m, ok := msg.Msg.(EndHeightMessage); ok {
lastHeightFound = m.Height
if m.Height == height { // found
wal.Logger.Debug("Found", "height", height, "index", index)
return gr, true, nil


Loading…
Cancel
Save