Add skip parameter in getSuccessorHeader + add getAncestorHeader

This commit is contained in:
kdeme 2019-07-08 17:10:59 +02:00
parent 3a0a32a6fe
commit 739f36c640
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
1 changed files with 8 additions and 2 deletions

View File

@ -23,8 +23,14 @@ method getBlockHeader*(c: Chain, b: HashOrNum, output: var BlockHeader): bool {.
method getBestBlockHeader*(c: Chain): BlockHeader {.gcsafe.} =
c.db.getCanonicalHead()
method getSuccessorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader): bool {.gcsafe.} =
let n = h.blockNumber + 1
method getSuccessorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader, skip = 0'u): bool {.gcsafe.} =
let n = if skip > 0'u: h.blockNumber + 1 + skip.toBlockNumber
else: h.blockNumber + 1
result = c.db.getBlockHeader(n, output)
method getAncestorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader, skip = 0'u): bool {.gcsafe.} =
let n = if skip > 0'u: h.blockNumber - 1 - skip.toBlockNumber
else: h.blockNumber - 1
c.db.getBlockHeader(n, output)
method getBlockBody*(c: Chain, blockHash: KeccakHash): BlockBodyRef =