From 88ded1b7c6268acd57b16df7d90a328d4710dfc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Wed, 8 May 2019 01:41:29 +0200 Subject: [PATCH] make block numbers out of sequence a CatchableError and check the Option objects from peer.getBlockBodies(hashes) --- eth/p2p/blockchain_sync.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eth/p2p/blockchain_sync.nim b/eth/p2p/blockchain_sync.nim index cbc3aae..1e09b21 100644 --- a/eth/p2p/blockchain_sync.nim +++ b/eth/p2p/blockchain_sync.nim @@ -192,17 +192,21 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = var nextIndex = workItem.startIndex for i in workItem.headers: if i.blockNumber != nextIndex: - raise newException(Exception, "The block numbers are not in sequence. Not processing this workItem.") + raise newException(CatchableError, "The block numbers are not in sequence. Not processing this workItem.") else: nextIndex = nextIndex + 1 hashes.add(blockHash(i)) if hashes.len == maxBodiesFetch: let b = await peer.getBlockBodies(hashes) + if b.isNone: + raise newException(CatchableError, "Was not able to get the block bodies.") hashes.setLen(0) bodies.add(b.get.blocks) if hashes.len != 0: let b = await peer.getBlockBodies(hashes) + if b.isNone: + raise newException(CatchableError, "Was not able to get the block bodies.") bodies.add(b.get.blocks) if bodies.len == workItem.headers.len: