From f068a543121628153acecff537d3818e3e1edf24 Mon Sep 17 00:00:00 2001 From: kdeme Date: Thu, 13 Jun 2019 15:32:06 +0200 Subject: [PATCH] Seperate transport close exceptions in blockchain sync --- eth/p2p/blockchain_sync.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/eth/p2p/blockchain_sync.nim b/eth/p2p/blockchain_sync.nim index a508e1b..361b827 100644 --- a/eth/p2p/blockchain_sync.nim +++ b/eth/p2p/blockchain_sync.nim @@ -164,6 +164,8 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = if bestBlockNumber > syncCtx.endBlockNumber: trace "New sync end block number", number = bestBlockNumber syncCtx.endBlockNumber = bestBlockNumber + except TransportError: + debug "Transport got closed during obtainBlocksFromPeer" except CatchableError: debug "Exception in getBestBlockNumber()", exc = getCurrentException().name, @@ -215,6 +217,8 @@ proc obtainBlocksFromPeer(syncCtx: SyncContext, peer: Peer) {.async.} = dataReceived = true else: warn "Bodies len != headers.len", bodies = bodies.len, headers = workItem.headers.len + except TransportError: + debug "Transport got closed during obtainBlocksFromPeer" except CatchableError: # the success case sets `dataReceived`, so we can just fall back to the # failure path below. If we signal time-outs with exceptions such @@ -322,7 +326,12 @@ proc onPeerConnected(ctx: SyncContext, peer: Peer) = let f = ctx.startSyncWithPeer(peer) f.callback = proc(data: pointer) {.gcsafe.} = if f.failed: - error "startSyncWithPeer failed", msg = f.readError.msg, peer + if f.error of TransportError: + debug "Transport got closed during startSyncWithPeer" + else: + error "startSyncWithPeer failed", msg = f.readError.msg, peer + except TransportError: + debug "Transport got closed during startSyncWithPeer" except CatchableError: debug "Exception in startSyncWithPeer()", exc = getCurrentException().name,