Skip to content

Commit

Permalink
fix side chain import
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jun 28, 2023
1 parent 389ef89 commit aa6d478
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nimbus/core/block_import.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit aa6d478

Please sign in to comment.