From 5d21451d93d2f36e839f2cbff2a2366399491d12 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Fri, 21 Feb 2020 18:01:20 -0600 Subject: [PATCH] don't forget to init the proto --- libp2p/protocols/discovery/bootstrap.nim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libp2p/protocols/discovery/bootstrap.nim b/libp2p/protocols/discovery/bootstrap.nim index 4973bd7ba..8090b9cb3 100644 --- a/libp2p/protocols/discovery/bootstrap.nim +++ b/libp2p/protocols/discovery/bootstrap.nim @@ -30,7 +30,7 @@ type running: bool sentPeers: TimedCache[PeerInfo] -proc encode(msg: seq[PeerInfo]): ProtoBuffer = +proc encode*(msg: seq[PeerInfo]): ProtoBuffer = result = initProtoBuffer() var peerMsg: ProtoBuffer for m in msg: @@ -45,7 +45,7 @@ proc encode(msg: seq[PeerInfo]): ProtoBuffer = result.finish() -proc decode(msg: seq[byte]): seq[PeerInfo] = +proc decode*(msg: seq[byte]): seq[PeerInfo] = var pb = initProtoBuffer(msg) while pb.enterSubMessage() > 0: var pubKey: PublicKey @@ -78,12 +78,13 @@ proc newBootstrap*(b: type[Bootstrap], interval: Duration = DefaultDiscoveryInterval, peersTimeout: Duration = DefaultPeersTimeout, maxPeers: int = MaxPeers): b = - Bootstrap(switch: switch, - bootstrapPeers: bootstrapPeers, - interval: interval, - onNewPeers: onNewPeers, - peersTimeout: peersTimeout, - maxPeers: maxPeers) + result = Bootstrap(switch: switch, + bootstrapPeers: bootstrapPeers, + interval: interval, + onNewPeers: onNewPeers, + peersTimeout: peersTimeout, + maxPeers: maxPeers) + result.init() proc getNewPeers(b: Bootstrap) {.async.} = await b.switch.onStarted.wait() # wait for the switch to start