parent
94c3b005fa
commit
894816fa0c
|
@ -23,11 +23,14 @@ proc init*(T: type BlockRef, root: Eth2Digest, blck: BeaconBlock): BlockRef =
|
|||
|
||||
proc findAncestorBySlot*(blck: BlockRef, slot: Slot): BlockRef =
|
||||
## Find the first ancestor that has a slot number less than or equal to `slot`
|
||||
assert(not blck.isNil)
|
||||
result = blck
|
||||
|
||||
while result != nil and result.slot > slot:
|
||||
while result.parent != nil and result.slot > slot:
|
||||
result = result.parent
|
||||
|
||||
assert(not result.isNil)
|
||||
|
||||
proc init*(T: type BlockPool, db: BeaconChainDB): BlockPool =
|
||||
# TODO we require that the db contains both a head and a tail block -
|
||||
# asserting here doesn't seem like the right way to go about it however..
|
||||
|
|
Loading…
Reference in New Issue