Commit 235c28ff authored by vyzo's avatar vyzo

truncate per peer message id lists

parent 8bc2c5c0
...@@ -1194,8 +1194,8 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{} ...@@ -1194,8 +1194,8 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
// if we are emitting more than GossipSubMaxIHaveLength mids, truncate the list // if we are emitting more than GossipSubMaxIHaveLength mids, truncate the list
if len(mids) > GossipSubMaxIHaveLength { if len(mids) > GossipSubMaxIHaveLength {
log.Debugf("too many messages for gossip; truncating IHAVE list (%d messages)", len(mids)) // we do the truncation (with shuffling) per peer below
mids = mids[:GossipSubMaxIHaveLength] log.Debugf("too many messages for gossip; will truncate IHAVE list (%d messages)", len(mids))
} }
// Send gossip to GossipFactor peers above threshold, with a minimum of D_lazy. // Send gossip to GossipFactor peers above threshold, with a minimum of D_lazy.
...@@ -1226,7 +1226,16 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{} ...@@ -1226,7 +1226,16 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
// Emit the IHAVE gossip to the selected peers. // Emit the IHAVE gossip to the selected peers.
for _, p := range peers { for _, p := range peers {
gs.enqueueGossip(p, &pb.ControlIHave{TopicID: &topic, MessageIDs: mids}) peerMids := mids
if len(mids) > GossipSubMaxIHaveLength {
// we do this per peer so that we emit a different set for each peer.
// we have enough redundancy in the system that this will significantly increase the message
// coverage when we do truncate.
peerMids = make([]string, GossipSubMaxIHaveLength)
shuffleStrings(mids)
copy(peerMids, mids)
}
gs.enqueueGossip(p, &pb.ControlIHave{TopicID: &topic, MessageIDs: peerMids})
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment