Add peers back to gossipsub table, slow down heartbeat (#256)
* Add peers back to gossipsub table, slow down heartbeat * exclude on unsub from mesh and fanout
This commit is contained in:
parent
a52763cc6d
commit
fec507e755
|
@ -168,6 +168,7 @@ proc rebalanceMesh(g: GossipSub, topic: string) {.async.} =
|
|||
# send a graft message to the peer
|
||||
await p.sendPrune(@[topic])
|
||||
g.mesh[topic].excl(id)
|
||||
g.gossipsub[topic].incl(id)
|
||||
|
||||
libp2p_gossipsub_peers_per_topic_gossipsub
|
||||
.set(g.gossipsub.getOrDefault(topic).len.int64,
|
||||
|
@ -274,7 +275,7 @@ proc heartbeat(g: GossipSub) {.async.} =
|
|||
except CatchableError as exc:
|
||||
trace "exception ocurred in gossipsub heartbeat", exc = exc.msg
|
||||
|
||||
await sleepAsync(1.seconds)
|
||||
await sleepAsync(5.seconds)
|
||||
|
||||
method handleDisconnect*(g: GossipSub, peer: PubSubPeer) =
|
||||
## handle peer disconnects
|
||||
|
@ -323,6 +324,10 @@ method subscribeTopic*(g: GossipSub,
|
|||
trace "removing subscription for topic", peer = peerId, name = topic
|
||||
# unsubscribe remote peer from the topic
|
||||
g.gossipsub[topic].excl(peerId)
|
||||
if peerId in g.mesh.getOrDefault(topic):
|
||||
g.mesh[topic].excl(peerId)
|
||||
if peerId in g.fanout.getOrDefault(topic):
|
||||
g.fanout[topic].excl(peerId)
|
||||
|
||||
libp2p_gossipsub_peers_per_topic_gossipsub
|
||||
.set(g.gossipsub[topic].len.int64, labelValues = [topic])
|
||||
|
@ -362,6 +367,7 @@ proc handlePrune(g: GossipSub, peer: PubSubPeer, prunes: seq[ControlPrune]) =
|
|||
|
||||
if prune.topicID in g.mesh:
|
||||
g.mesh[prune.topicID].excl(peer.id)
|
||||
g.gossipsub[prune.topicID].incl(peer.id)
|
||||
libp2p_gossipsub_peers_per_topic_mesh
|
||||
.set(g.mesh[prune.topicID].len.int64, labelValues = [prune.topicID])
|
||||
|
||||
|
|
Loading…
Reference in New Issue