don't forget to init the proto

This commit is contained in:
Dmitriy Ryajov 2020-02-21 18:01:20 -06:00
parent 8809af9c9d
commit 5d21451d93
1 changed files with 9 additions and 8 deletions

View File

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