mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2025-03-01 08:30:29 +00:00
don't forget to init the proto
This commit is contained in:
parent
8809af9c9d
commit
5d21451d93
@ -30,7 +30,7 @@ type
|
|||||||
running: bool
|
running: bool
|
||||||
sentPeers: TimedCache[PeerInfo]
|
sentPeers: TimedCache[PeerInfo]
|
||||||
|
|
||||||
proc encode(msg: seq[PeerInfo]): ProtoBuffer =
|
proc encode*(msg: seq[PeerInfo]): ProtoBuffer =
|
||||||
result = initProtoBuffer()
|
result = initProtoBuffer()
|
||||||
var peerMsg: ProtoBuffer
|
var peerMsg: ProtoBuffer
|
||||||
for m in msg:
|
for m in msg:
|
||||||
@ -45,7 +45,7 @@ proc encode(msg: seq[PeerInfo]): ProtoBuffer =
|
|||||||
|
|
||||||
result.finish()
|
result.finish()
|
||||||
|
|
||||||
proc decode(msg: seq[byte]): seq[PeerInfo] =
|
proc decode*(msg: seq[byte]): seq[PeerInfo] =
|
||||||
var pb = initProtoBuffer(msg)
|
var pb = initProtoBuffer(msg)
|
||||||
while pb.enterSubMessage() > 0:
|
while pb.enterSubMessage() > 0:
|
||||||
var pubKey: PublicKey
|
var pubKey: PublicKey
|
||||||
@ -78,12 +78,13 @@ proc newBootstrap*(b: type[Bootstrap],
|
|||||||
interval: Duration = DefaultDiscoveryInterval,
|
interval: Duration = DefaultDiscoveryInterval,
|
||||||
peersTimeout: Duration = DefaultPeersTimeout,
|
peersTimeout: Duration = DefaultPeersTimeout,
|
||||||
maxPeers: int = MaxPeers): b =
|
maxPeers: int = MaxPeers): b =
|
||||||
Bootstrap(switch: switch,
|
result = Bootstrap(switch: switch,
|
||||||
bootstrapPeers: bootstrapPeers,
|
bootstrapPeers: bootstrapPeers,
|
||||||
interval: interval,
|
interval: interval,
|
||||||
onNewPeers: onNewPeers,
|
onNewPeers: onNewPeers,
|
||||||
peersTimeout: peersTimeout,
|
peersTimeout: peersTimeout,
|
||||||
maxPeers: maxPeers)
|
maxPeers: maxPeers)
|
||||||
|
result.init()
|
||||||
|
|
||||||
proc getNewPeers(b: Bootstrap) {.async.} =
|
proc getNewPeers(b: Bootstrap) {.async.} =
|
||||||
await b.switch.onStarted.wait() # wait for the switch to start
|
await b.switch.onStarted.wait() # wait for the switch to start
|
||||||
|
Loading…
x
Reference in New Issue
Block a user