detailed tracing in block_pool.getBlockRange

This commit is contained in:
Zahary Karadjov 2019-11-14 13:19:19 +00:00 committed by zah
parent 4c2ded25a6
commit 258f6f6334
1 changed files with 10 additions and 2 deletions

View File

@ -347,13 +347,20 @@ func getBlockRange*(pool: BlockPool, headBlock: Eth2Digest,
result = output.len
var b = pool.getRef(headBlock)
if b == nil or b.slot < startSlot:
if b == nil:
trace "head block not found"
return
if b.slot < startSlot:
trace "head block is older than startSlot", headBlockSlot = b.slot, startSlot
return
template skip(n: int) =
for i in 0 ..< n:
if b.parent == nil:
trace "stopping at parentless block", slot = b.slot
return
b = b.parent
if b == nil: return
# We must compute the last block that is eligible for inclusion
# in the results. This will be a block with a slot number that's
@ -375,6 +382,7 @@ func getBlockRange*(pool: BlockPool, headBlock: Eth2Digest,
while b != nil and result > 0:
dec result
output[result] = b
trace "getBlockRange result", position = result, blockSlot = b.slot
skip skipStep
proc get*(pool: BlockPool, blck: BlockRef): BlockData =