Avoid trying to close discv5 transport when discv5 is not enabled (#2713)

This commit is contained in:
Kim De Mey 2021-07-13 09:58:45 +02:00 committed by GitHub
parent 6b07b79427
commit 81d54a3c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1236,10 +1236,10 @@ proc stop*(node: Eth2Node) {.async.} =
# Ignore errors in futures, since we're shutting down (but log them on the
# TRACE level, if a timeout is reached).
let
waitedFutures = @[
node.discovery.closeWait(),
node.switch.stop(),
]
waitedFutures = if node.discoveryEnabled:
@[node.discovery.closeWait(), node.switch.stop()]
else:
@[node.switch.stop()]
timeout = 5.seconds
completed = await withTimeout(allFutures(waitedFutures), timeout)
if not completed: