mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
core/filtermaps: return early on error in tailPartialBlocks
When getLastBlockOfMap fails in tailPartialBlocks, the error is logged but the uninitialized/zero end value is still used in the subtraction (end - start), potentially returning a garbage block count to the caller. Return 0 immediately on error to avoid propagating incorrect block counts through the indexing pipeline.
This commit is contained in:
parent
8a3a309fa9
commit
dd9ed2f43d
1 changed files with 2 additions and 0 deletions
|
|
@ -440,12 +440,14 @@ func (f *FilterMaps) tailPartialBlocks() uint64 {
|
|||
end, _, err := f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch + f.indexedRange.tailPartialEpoch - 1)
|
||||
if err != nil {
|
||||
log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch+f.indexedRange.tailPartialEpoch-1, "error", err)
|
||||
return 0
|
||||
}
|
||||
var start uint64
|
||||
if f.indexedRange.maps.First()-f.mapsPerEpoch > 0 {
|
||||
start, _, err = f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch - 1)
|
||||
if err != nil {
|
||||
log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch-1, "error", err)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
return end - start
|
||||
|
|
|
|||
Loading…
Reference in a new issue