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,6 +820,7 @@ 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
|
||||||
|
if prunes.len > 0:
|
||||||
let prune = RPCMsg(control: some(ControlMessage(
|
let prune = RPCMsg(control: some(ControlMessage(
|
||||||
prune: @[ControlPrune(
|
prune: @[ControlPrune(
|
||||||
topicID: t,
|
topicID: t,
|
||||||
|
|
Loading…
Reference in New Issue