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:
Jacek Sieka
2020-08-17 12:10:22 +02:00
committed by GitHub
parent ab864fc747
commit b12145dff7
3 changed files with 8 additions and 17 deletions

View File

@@ -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]()