Skip to content

Commit ebfacf5

Browse files
committed
Review and fix some usages of Future.cancel; Bump Chronos
1 parent 9c5cef3 commit ebfacf5

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

beacon_chain/eth1_monitor.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ proc init*(T: type Eth1Monitor,
404404
let web3Fut = newWeb3(web3Url)
405405
yield web3Fut or sleepAsync(chronos.seconds(5))
406406
if (not web3Fut.finished) or web3Fut.failed:
407-
web3Fut.cancel()
407+
await cancelAndWait(web3Fut)
408408
return err "Failed to setup web3 connection"
409409

410410
let

beacon_chain/eth2_network.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,10 @@ proc dialPeer*(node: Eth2Node, peerAddr: PeerAddr, index = 0) {.async.} =
789789
deadline.cancel()
790790
inc nbc_successful_dials
791791
else:
792-
# TODO(cheatfate): As soon as `nim-libp2p` will be able to handle cancellation
793-
# properly and will have cancellation tests, we need add here cancellation
794-
# of `workfut`.
795-
# workfut.cancel()
796792
debug "Connection to remote peer timed out"
797793
inc nbc_timeout_dials
798794
node.addSeen(peerAddr.peerId, SeenTableTimeTimeout)
795+
await cancelAndWait(workfut)
799796
except CatchableError as exc:
800797
debug "Connection to remote peer failed", msg = exc.msg
801798
inc nbc_failed_dials

0 commit comments

Comments
 (0)