mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-02 21:03:07 +00:00
truncate per peer message id lists
This commit is contained in:
parent
8bc2c5c0f1
commit
235c28ff49
15
gossipsub.go
15
gossipsub.go
@ -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 len(mids) > GossipSubMaxIHaveLength {
|
||||
log.Debugf("too many messages for gossip; truncating IHAVE list (%d messages)", len(mids))
|
||||
mids = mids[:GossipSubMaxIHaveLength]
|
||||
// we do the truncation (with shuffling) per peer below
|
||||
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.
|
||||
@ -1226,7 +1226,16 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
|
||||
|
||||
// Emit the IHAVE gossip to the selected 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})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user