From 646a58dbc0ce1f9145f92ea8d1e8d7b1cc35de49 Mon Sep 17 00:00:00 2001 From: kdeme Date: Tue, 9 Jul 2019 17:06:20 +0200 Subject: [PATCH] Cleanup unneeded check in getBlockHeaders --- eth/p2p/blockchain_utils.nim | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/eth/p2p/blockchain_utils.nim b/eth/p2p/blockchain_utils.nim index 23f5c89..024d609 100644 --- a/eth/p2p/blockchain_utils.nim +++ b/eth/p2p/blockchain_utils.nim @@ -10,16 +10,15 @@ proc getBlockHeaders*(db: AbstractChainDB, var foundBlock: BlockHeader if db.getBlockHeader(req.startBlock, foundBlock): result.add foundBlock - # Quick sanity check for lower bounds, code should be safe though without. - if not req.reverse or (foundBlock.blockNumber >= (req.skip + 1).toBlockNumber): - while uint64(result.len) < req.maxResults: - 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 + + while uint64(result.len) < req.maxResults: + 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 template fetcher*(fetcherName, fetchingFunc, InputType, ResultType: untyped) =