avoid creating prune message unless we're pruning (#487)

This commit is contained in:
Jacek Sieka 2020-12-15 22:46:03 +01:00 committed by GitHub
parent ea6988d380
commit 9e5ba64c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -812,7 +812,7 @@ proc heartbeat(g: GossipSub) {.async.} =
let gossipPeers = g.gossipsub.getOrDefault(t)
# this will be changed by rebalance but does not matter
totalMeshPeers += meshPeers.len
totalGossipPeers += gossipPeers.len
totalGossipPeers += g.gossipsub.peers(t)
var prunes: seq[PubSubPeer]
for peer in meshPeers:
if peer.score < 0.0:
@ -820,6 +820,7 @@ proc heartbeat(g: GossipSub) {.async.} =
g.pruned(peer, t)
g.mesh.removePeer(t, peer)
prunes &= peer
if prunes.len > 0:
let prune = RPCMsg(control: some(ControlMessage(
prune: @[ControlPrune(
topicID: t,