mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-09 03:28:14 -05:00
avoid crash when subscribe is received (#333)
...by making subscribeTopic synchronous, avoiding a peer table lookup completely. rebalanceMesh will be called a second later - it's fine
This commit is contained in:
@@ -31,9 +31,9 @@ type
|
||||
method subscribeTopic*(f: FloodSub,
|
||||
topic: string,
|
||||
subscribe: bool,
|
||||
peerId: PeerID) {.gcsafe, async.} =
|
||||
await procCall PubSub(f).subscribeTopic(topic, subscribe, peerId)
|
||||
let peer = f.peers.getOrDefault(peerId)
|
||||
peer: PubsubPeer) {.gcsafe.} =
|
||||
procCall PubSub(f).subscribeTopic(topic, subscribe, peer)
|
||||
|
||||
if topic notin f.floodsub:
|
||||
f.floodsub[topic] = initHashSet[PubSubPeer]()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user