mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-15 19:31:37 +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)
|
end, _, err := f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch + f.indexedRange.tailPartialEpoch - 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch+f.indexedRange.tailPartialEpoch-1, "error", err)
|
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
|
var start uint64
|
||||||
if f.indexedRange.maps.First()-f.mapsPerEpoch > 0 {
|
if f.indexedRange.maps.First()-f.mapsPerEpoch > 0 {
|
||||||
start, _, err = f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch - 1)
|
start, _, err = f.getLastBlockOfMap(f.indexedRange.maps.First() - f.mapsPerEpoch - 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch-1, "error", err)
|
log.Error("Error fetching last block of map", "mapIndex", f.indexedRange.maps.First()-f.mapsPerEpoch-1, "error", err)
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return end - start
|
return end - start
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue