File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
src/main/scala/io/iohk/ethereum Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,15 @@ trait OmmersValidator {
3030 )(implicit blockchainConfig : BlockchainConfig ): Either [OmmersError , OmmersValid ] = {
3131
3232 val getBlockHeaderByHash : ByteString => Option [BlockHeader ] = blockchainReader.getBlockHeaderByHash
33- val bestBranch = blockchainReader.getBestBranch()
3433 val getNBlocksBack : (ByteString , Int ) => List [Block ] =
3534 (tailBlockHash, n) =>
3635 Iterator
3736 .iterate(blockchainReader.getBlockByHash(tailBlockHash))(
38- _.flatMap(block => blockchainReader.getBlockByHash(block.header.parentHash))
37+ _.filter(_.number > 0 ) // avoid trying to fetch parent of genesis
38+ .flatMap(block => blockchainReader.getBlockByHash(block.header.parentHash))
3939 )
40- .take(n)
4140 .collect { case Some (block) => block }
41+ .take(n)
4242 .toList
4343 .reverse
4444
Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ class BlockValidation(
4444 val remaining = n - queuedBlocks.length - 1
4545 val remainingBlocks = Iterator
4646 .iterate(blockchainReader.getBlockByHash(highestBlockInStorage.header.parentHash))(
47- _.flatMap(p => blockchainReader.getBlockByHash(p.header.parentHash))
47+ _.filter(_.number > 0 ) // avoid trying to fetch parent of genesis
48+ .flatMap(p => blockchainReader.getBlockByHash(p.header.parentHash))
4849 )
4950 .take(remaining)
5051 .collect { case Some (block) => block }
You can’t perform that action at this time.
0 commit comments