mirror of https://github.com/vacp2p/nim-libp2p.git
avoid creating prune message unless we're pruning (#487)
This commit is contained in:
parent
ea6988d380
commit
9e5ba64c48
|
@ -812,7 +812,7 @@ proc heartbeat(g: GossipSub) {.async.} =
|
||||||
let gossipPeers = g.gossipsub.getOrDefault(t)
|
let gossipPeers = g.gossipsub.getOrDefault(t)
|
||||||
# this will be changed by rebalance but does not matter
|
# this will be changed by rebalance but does not matter
|
||||||
totalMeshPeers += meshPeers.len
|
totalMeshPeers += meshPeers.len
|
||||||
totalGossipPeers += gossipPeers.len
|
totalGossipPeers += g.gossipsub.peers(t)
|
||||||
var prunes: seq[PubSubPeer]
|
var prunes: seq[PubSubPeer]
|
||||||
for peer in meshPeers:
|
for peer in meshPeers:
|
||||||
if peer.score < 0.0:
|
if peer.score < 0.0:
|
||||||
|
@ -820,12 +820,13 @@ proc heartbeat(g: GossipSub) {.async.} =
|
||||||
g.pruned(peer, t)
|
g.pruned(peer, t)
|
||||||
g.mesh.removePeer(t, peer)
|
g.mesh.removePeer(t, peer)
|
||||||
prunes &= peer
|
prunes &= peer
|
||||||
let prune = RPCMsg(control: some(ControlMessage(
|
if prunes.len > 0:
|
||||||
prune: @[ControlPrune(
|
let prune = RPCMsg(control: some(ControlMessage(
|
||||||
topicID: t,
|
prune: @[ControlPrune(
|
||||||
peers: g.peerExchangeList(t),
|
topicID: t,
|
||||||
backoff: g.parameters.pruneBackoff.seconds.uint64)])))
|
peers: g.peerExchangeList(t),
|
||||||
g.broadcast(prunes, prune)
|
backoff: g.parameters.pruneBackoff.seconds.uint64)])))
|
||||||
|
g.broadcast(prunes, prune)
|
||||||
|
|
||||||
g.rebalanceMesh(t)
|
g.rebalanceMesh(t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue