From aa6d47864f97641f494fa038ff0f263d10260975 Mon Sep 17 00:00:00 2001 From: jangko Date: Thu, 29 Jun 2023 06:24:37 +0700 Subject: [PATCH] fix side chain import --- nimbus/core/block_import.nim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nimbus/core/block_import.nim b/nimbus/core/block_import.nim index 89d894f6e..986db4bf0 100644 --- a/nimbus/core/block_import.nim +++ b/nimbus/core/block_import.nim @@ -23,16 +23,17 @@ proc importRlpBlock*(blocksRlp: openArray[byte]; com: CommonRef; importFile: str errorCount = 0 header: BlockHeader body: BlockBody - let - head = com.db.getCanonicalHead() + # even though the new imported blocks have block number + # smaller than head, we keep importing it. + # it maybe a side chain. + while rlp.hasData: try: rlp.decompose(header, body) - if header.blockNumber > head.blockNumber: - if chain.persistBlocks([header], [body]) == ValidationResult.Error: - # register one more error and continue - errorCount.inc + if chain.persistBlocks([header], [body]) == ValidationResult.Error: + # register one more error and continue + errorCount.inc except RlpError as e: # terminate if there was a decoding error error "rlp error",