From 00a8a6867115cec3bbc89623fd19551a9711a72e Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 9 Oct 2020 16:37:12 +0300 Subject: [PATCH] Address #1695 Better error messages when the beacon node is asked to listen on a reserved port (0) or an already taken one. --- beacon_chain/eth2_network.nim | 14 ++++++++++++-- vendor/nim-confutils | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index b7020a5ab..bf0ac57b4 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -961,8 +961,18 @@ template publicKey*(node: Eth2Node): keys.PublicKey = proc startListening*(node: Eth2Node) {.async.} = if node.discoveryEnabled: - node.discovery.open() - node.libp2pTransportLoops = await node.switch.start() + try: + node.discovery.open() + except CatchableError as err: + fatal "Failed to start discovery service. UDP port may be already in use" + quit 1 + + try: + node.libp2pTransportLoops = await node.switch.start() + except CatchableError: + fatal "Failed to start LibP2P transport. TCP port may be already in use" + quit 1 + await node.pubsub.start() proc start*(node: Eth2Node) {.async.} = diff --git a/vendor/nim-confutils b/vendor/nim-confutils index 5c81aab54..5d8d1ea64 160000 --- a/vendor/nim-confutils +++ b/vendor/nim-confutils @@ -1 +1 @@ -Subproject commit 5c81aab54d00bb4cc0921fc9d3ace828b1fcc09f +Subproject commit 5d8d1ea648884a460518e7819be2d406e3a4ab0f