mirror of https://github.com/vacp2p/nim-libp2p.git
avoid triggering unsubscribeAll from unsubscribe (gossip)
This commit is contained in:
parent
4858e0ab15
commit
5e79d3ab9c
|
@ -1251,7 +1251,7 @@ method subscribe*(g: GossipSub,
|
|||
|
||||
g.rebalanceMesh(topic)
|
||||
|
||||
method unsubscribeAll*(g: GossipSub, topic: string) =
|
||||
proc unsubscribe*(g: GossipSub, topic: string) =
|
||||
var
|
||||
msg = RPCMsg.withSubs(@[topic], subscribe = false)
|
||||
gpeers = g.gossipsub.getOrDefault(topic)
|
||||
|
@ -1281,6 +1281,8 @@ method unsubscribeAll*(g: GossipSub, topic: string) =
|
|||
else:
|
||||
g.broadcast(toSeq(gpeers), msg)
|
||||
|
||||
method unsubscribeAll*(g: GossipSub, topic: string) =
|
||||
g.unsubscribe(topic)
|
||||
# finally let's remove from g.topics, do that by calling PubSub
|
||||
procCall PubSub(g).unsubscribeAll(topic)
|
||||
|
||||
|
@ -1292,7 +1294,7 @@ method unsubscribe*(g: GossipSub,
|
|||
# delete from mesh only if no handlers are left
|
||||
# (handlers are removed in pubsub unsubscribe above)
|
||||
if topic notin g.topics:
|
||||
g.unsubscribeAll(topic)
|
||||
g.unsubscribe(topic)
|
||||
|
||||
method publish*(g: GossipSub,
|
||||
topic: string,
|
||||
|
|
Loading…
Reference in New Issue