triedb/pathdb: use a variable

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-07-22 23:05:53 +08:00
parent 264c06a72c
commit 228d0b653a

View file

@ -392,16 +392,17 @@ func (i *indexIniter) run(lastID uint64) {
select { select {
case signal := <-i.interrupt: case signal := <-i.interrupt:
// The indexing limit can only be extended or shortened continuously. // The indexing limit can only be extended or shortened continuously.
if signal.newLastID != lastID+1 && signal.newLastID != lastID-1 { newLastID := signal.newLastID
signal.result <- fmt.Errorf("invalid history id, last: %d, got: %d", lastID, signal.newLastID) if newLastID != lastID+1 && newLastID != lastID-1 {
signal.result <- fmt.Errorf("invalid history id, last: %d, got: %d", lastID, newLastID)
continue continue
} }
i.last.Store(signal.newLastID) // update indexing range i.last.Store(newLastID) // update indexing range
// The index limit is extended by one, update the limit without // The index limit is extended by one, update the limit without
// interrupting the current background process. // interrupting the current background process.
if signal.newLastID == lastID+1 { if newLastID == lastID+1 {
lastID = signal.newLastID lastID = newLastID
signal.result <- nil signal.result <- nil
log.Debug("Extended state history range", "last", lastID) log.Debug("Extended state history range", "last", lastID)
continue continue
@ -425,7 +426,7 @@ func (i *indexIniter) run(lastID uint64) {
return return
} }
// Adjust the indexing target and relaunch the process // Adjust the indexing target and relaunch the process
lastID = signal.newLastID lastID = newLastID
done, interrupt = make(chan struct{}), new(atomic.Int32) done, interrupt = make(chan struct{}), new(atomic.Int32)
go i.index(done, interrupt, lastID) go i.index(done, interrupt, lastID)
log.Debug("Shortened state history range", "last", lastID) log.Debug("Shortened state history range", "last", lastID)