Start libp2p before writing ENR file (#1418)

this makes sure that all libp2p transports are open for business when
the file hits the ground
This commit is contained in:
Jacek Sieka 2020-08-03 19:35:27 +02:00 committed by GitHub
parent 52d9d269d7
commit d22a2cec2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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