mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-18 17:37:33 +00:00
Handle missing blocks better in block_pool.getBlockRange
This commit is contained in:
parent
897176761d
commit
8c3ea1cabf
@ -366,7 +366,8 @@ proc getBlockRange*(pool: BlockPool, headBlock: Eth2Digest,
|
|||||||
return
|
return
|
||||||
|
|
||||||
template skip(n: int) =
|
template skip(n: int) =
|
||||||
for i in 0 ..< n:
|
let targetSlot = b.slot - Slot(n)
|
||||||
|
while b.slot > targetSlot:
|
||||||
if b.parent == nil:
|
if b.parent == nil:
|
||||||
trace "stopping at parentless block", slot = b.slot, root = b.root
|
trace "stopping at parentless block", slot = b.slot, root = b.root
|
||||||
return
|
return
|
||||||
@ -391,7 +392,7 @@ proc getBlockRange*(pool: BlockPool, headBlock: Eth2Digest,
|
|||||||
skip blocksToSkip
|
skip blocksToSkip
|
||||||
|
|
||||||
# From here, we can just write out the requested block range:
|
# From here, we can just write out the requested block range:
|
||||||
while b != nil and result > 0:
|
while b != nil and b.slot >= startSlot and result > 0:
|
||||||
dec result
|
dec result
|
||||||
output[result] = b
|
output[result] = b
|
||||||
trace "getBlockRange result", position = result, blockSlot = b.slot
|
trace "getBlockRange result", position = result, blockSlot = b.slot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user