check for nil on start/stop

This commit is contained in:
Dmitriy Ryajov 2022-04-19 19:18:20 -06:00
parent 1e0cc290f8
commit 06e043871c
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 22 additions and 8 deletions

View File

@ -44,9 +44,16 @@ type
discovery*: Discovery
proc start*(node: DaggerNodeRef) {.async.} =
if not node.switch.isNil:
await node.switch.start()
if not node.engine.isNil:
await node.engine.start()
if not node.erasure.isNil:
await node.erasure.start()
if not node.discovery.isNil:
await node.discovery.start()
node.networkId = node.switch.peerInfo.peerId
@ -55,9 +62,16 @@ proc start*(node: DaggerNodeRef) {.async.} =
proc stop*(node: DaggerNodeRef) {.async.} =
trace "Stopping node"
if not node.engine.isNil:
await node.engine.stop()
if not node.switch.isNil:
await node.switch.stop()
if not node.erasure.isNil:
await node.erasure.stop()
if not node.discovery.isNil:
await node.discovery.stop()
proc findPeer*(