make maximum number of IHAVE messages accepted per heartbeat configurable

This commit is contained in:
vyzo 2020-04-20 15:13:15 +03:00
parent 8150843cf3
commit 9ab44c5069

View File

@ -82,6 +82,9 @@ var (
// system is pushing more than 5000 messages in GossipSubHistoryGossip heartbeats; with the
// defaults this is 1666 messages/s.
GossipSubMaxIHaveLength = 5000
// Maximum number of IHAVE messages to accept from a peer within a heartbeat.
GossipSubMaxIHaveMessages = 10
)
// NewGossipSub returns a new PubSub object using GossipSubRouter as the router.
@ -376,7 +379,7 @@ func (gs *GossipSubRouter) handleIHave(p peer.ID, ctl *pb.ControlMessage) []*pb.
}
// IHAVE flood protection
if gs.peerhave[p] > 2 {
if gs.peerhave[p] > GossipSubMaxIHaveMessages {
log.Debugf("IHAVE: peer %s has advertised too many times within this heartbeat interval; ignoring", p)
return nil
}