From d22a2cec2b377c0d54f0c1b03d8d159dd31e6989 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Mon, 3 Aug 2020 19:35:27 +0200 Subject: [PATCH] Start libp2p before writing ENR file (#1418) this makes sure that all libp2p transports are open for business when the file hits the ground --- beacon_chain/beacon_node.nim | 2 +- beacon_chain/eth2_network.nim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 5255b6ab2..a89ac7a05 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -852,7 +852,7 @@ proc createPidFile(filename: string) = addQuitProc proc {.noconv.} = removeFile gPidFile proc initializeNetworking(node: BeaconNode) {.async.} = - node.network.startListening() + await node.network.startListening() let addressFile = node.config.dataDir / "beacon_node.enr" writeFile(addressFile, node.network.announcedENR.toURI) diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index f2402e058..6f10637bd 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -882,14 +882,14 @@ template publicKey*(node: Eth2Node): keys.PublicKey = template addKnownPeer*(node: Eth2Node, peer: enr.Record) = node.discovery.addNode peer -proc startListening*(node: Eth2Node) = +proc startListening*(node: Eth2Node) {.async.} = node.discovery.open() + node.libp2pTransportLoops = await node.switch.start() proc start*(node: Eth2Node) {.async.} = for i in 0 ..< ConcurrentConnections: node.connWorkers.add connectWorker(node) - node.libp2pTransportLoops = await node.switch.start() node.discovery.start() node.discoveryLoop = node.runDiscoveryLoop() traceAsyncErrors node.discoveryLoop