mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
do not look for height in older files if we've seen height - 1
Refs #1600
This commit is contained in:
@@ -8,6 +8,7 @@ IMPROVEMENTS:
|
|||||||
|
|
||||||
- [consensus] consensus reactor now receives events from a separate event bus,
|
- [consensus] consensus reactor now receives events from a separate event bus,
|
||||||
which is not dependant on external RPC load
|
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
|
## 0.19.5
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ type WALSearchOptions struct {
|
|||||||
// CONTRACT: caller must close group reader.
|
// CONTRACT: caller must close group reader.
|
||||||
func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (gr *auto.GroupReader, found bool, err error) {
|
func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions) (gr *auto.GroupReader, found bool, err error) {
|
||||||
var msg *TimedWALMessage
|
var msg *TimedWALMessage
|
||||||
|
lastHeightFound := int64(-1)
|
||||||
|
|
||||||
// NOTE: starting from the last file in the group because we're usually
|
// NOTE: starting from the last file in the group because we're usually
|
||||||
// searching for the last height. See replay.go
|
// searching for the last height. See replay.go
|
||||||
@@ -166,6 +167,11 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions)
|
|||||||
for {
|
for {
|
||||||
msg, err = dec.Decode()
|
msg, err = dec.Decode()
|
||||||
if err == io.EOF {
|
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
|
// check next file
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -179,6 +185,7 @@ func (wal *baseWAL) SearchForEndHeight(height int64, options *WALSearchOptions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m, ok := msg.Msg.(EndHeightMessage); ok {
|
if m, ok := msg.Msg.(EndHeightMessage); ok {
|
||||||
|
lastHeightFound = m.Height
|
||||||
if m.Height == height { // found
|
if m.Height == height { // found
|
||||||
wal.Logger.Debug("Found", "height", height, "index", index)
|
wal.Logger.Debug("Found", "height", height, "index", index)
|
||||||
return gr, true, nil
|
return gr, true, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user