fixes `importRlpBlock` algorithm

it will skip blocks with blockNumber <= than current
head blockNumber
This commit is contained in:
jangko 2021-04-28 22:05:15 +07:00
parent 6e79fa3708
commit 287f1b2ba0
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 6 additions and 2 deletions

View File

@ -33,10 +33,14 @@ proc importRlpBlock*(importFile: string, chainDB: BasechainDB) =
# TODO: probably we need to put it in one struct
var headers: seq[BlockHeader]
var bodies : seq[BlockBody]
let head = chainDB.getCanonicalHead()
while true:
headers.add rlp.read(EthHeader).header
bodies.add rlp.readRecordType(BlockBody, false)
let header = rlp.read(EthHeader).header
let body = rlp.readRecordType(BlockBody, false)
if header.blockNumber > head.blockNumber:
headers.add header
bodies.add body
if not rlp.hasData:
break