add an hard cap to PX

This commit is contained in:
Giovanni Petrantoni 2020-08-13 21:21:17 +09:00
parent 585cfc5996
commit ce61d84db4
1 changed files with 2 additions and 0 deletions

View File

@ -330,6 +330,8 @@ proc peerExchangeList(g: GossipSub, topic: string): seq[PeerInfoMsg] =
var peers = g.gossipsub.getOrDefault(topic, initHashSet[PubSubPeer]()).toSeq()
peers.keepIf do (x: PubSubPeer) -> bool:
x.score >= 0.0
# by spec, larger then Dhi, but let's put some hard caps
peers.setLen(min(peers.len, GossipSubDhi * 2))
peers.map do (x: PubSubPeer) -> PeerInfoMsg:
PeerInfoMsg(peerID: x.peerId.getBytes())