mirror of https://github.com/status-im/nim-eth.git
Support skip and reverse in the GetBlockHeaders request + reactivate getBlockBodies
This commit is contained in:
parent
022139db50
commit
3088cb462e
|
@ -345,7 +345,10 @@ proc getBlockHeader*(db: AbstractChainDB, b: BlockNumber): BlockHeaderRef {.gcsa
|
|||
method getBestBlockHeader*(self: AbstractChainDB): BlockHeader {.base, gcsafe.} =
|
||||
notImplemented()
|
||||
|
||||
method getSuccessorHeader*(db: AbstractChainDB, h: BlockHeader, output: var BlockHeader): bool {.base, gcsafe.} =
|
||||
method getSuccessorHeader*(db: AbstractChainDB, h: BlockHeader, output: var BlockHeader, skip = 0'u): bool {.base, gcsafe.} =
|
||||
notImplemented()
|
||||
|
||||
method getAncestorHeader*(db: AbstractChainDB, h: BlockHeader, output: var BlockHeader, skip = 0'u): bool {.base, gcsafe.} =
|
||||
notImplemented()
|
||||
|
||||
method getBlockBody*(db: AbstractChainDB, blockHash: KeccakHash): BlockBodyRef {.base, gcsafe.} =
|
||||
|
|
|
@ -12,7 +12,11 @@ proc getBlockHeaders*(db: AbstractChainDB,
|
|||
result.add foundBlock
|
||||
|
||||
while uint64(result.len) < req.maxResults:
|
||||
if not db.getSuccessorHeader(foundBlock, foundBlock):
|
||||
if not req.reverse:
|
||||
if not db.getSuccessorHeader(foundBlock, foundBlock, req.skip):
|
||||
break
|
||||
else:
|
||||
if not db.getAncestorHeader(foundBlock, foundBlock, req.skip):
|
||||
break
|
||||
result.add foundBlock
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ p2pProtocol eth(version = protocolVersion,
|
|||
await peer.disconnect(BreachOfProtocol)
|
||||
return
|
||||
|
||||
# TODO: implement `getBlockBodies` and reactivate this code
|
||||
# await response.send(peer.network.chain.getBlockBodies(hashes))
|
||||
await response.send(peer.network.chain.getBlockBodies(hashes))
|
||||
|
||||
proc blockBodies(peer: Peer, blocks: openarray[BlockBody])
|
||||
|
||||
|
|
Loading…
Reference in New Issue