Score correctly on mesh peer unsub (#644)
* Score correctly on mesh peer unsub * remove from mesh before removing from gossipsub
This commit is contained in:
parent
1a97d0a2f5
commit
c18830ad33
|
@ -186,16 +186,16 @@ method unsubscribePeer*(g: GossipSub, peer: PeerId) =
|
||||||
if s[].len == 0:
|
if s[].len == 0:
|
||||||
g.peersInIP.del(pubSubPeer.address.get())
|
g.peersInIP.del(pubSubPeer.address.get())
|
||||||
|
|
||||||
for t in toSeq(g.gossipsub.keys):
|
|
||||||
g.gossipsub.removePeer(t, pubSubPeer)
|
|
||||||
# also try to remove from explicit table here
|
|
||||||
g.explicit.removePeer(t, pubSubPeer)
|
|
||||||
|
|
||||||
for t in toSeq(g.mesh.keys):
|
for t in toSeq(g.mesh.keys):
|
||||||
trace "pruning unsubscribing peer", pubSubPeer, score = pubSubPeer.score
|
trace "pruning unsubscribing peer", pubSubPeer, score = pubSubPeer.score
|
||||||
g.pruned(pubSubPeer, t)
|
g.pruned(pubSubPeer, t)
|
||||||
g.mesh.removePeer(t, pubSubPeer)
|
g.mesh.removePeer(t, pubSubPeer)
|
||||||
|
|
||||||
|
for t in toSeq(g.gossipsub.keys):
|
||||||
|
g.gossipsub.removePeer(t, pubSubPeer)
|
||||||
|
# also try to remove from explicit table here
|
||||||
|
g.explicit.removePeer(t, pubSubPeer)
|
||||||
|
|
||||||
for t in toSeq(g.fanout.keys):
|
for t in toSeq(g.fanout.keys):
|
||||||
g.fanout.removePeer(t, pubSubPeer)
|
g.fanout.removePeer(t, pubSubPeer)
|
||||||
|
|
||||||
|
@ -237,9 +237,14 @@ proc handleSubscribe*(g: GossipSub,
|
||||||
else:
|
else:
|
||||||
trace "peer unsubscribed from topic"
|
trace "peer unsubscribed from topic"
|
||||||
|
|
||||||
|
if g.mesh.hasPeer(topic, peer):
|
||||||
|
#against spec
|
||||||
|
g.mesh.removePeer(topic, peer)
|
||||||
|
g.pruned(peer, topic)
|
||||||
|
|
||||||
# unsubscribe remote peer from the topic
|
# unsubscribe remote peer from the topic
|
||||||
g.gossipsub.removePeer(topic, peer)
|
g.gossipsub.removePeer(topic, peer)
|
||||||
g.mesh.removePeer(topic, peer)
|
|
||||||
g.fanout.removePeer(topic, peer)
|
g.fanout.removePeer(topic, peer)
|
||||||
if peer.peerId in g.parameters.directPeers:
|
if peer.peerId in g.parameters.directPeers:
|
||||||
g.explicit.removePeer(topic, peer)
|
g.explicit.removePeer(topic, peer)
|
||||||
|
|
Loading…
Reference in New Issue