@@ -94,9 +94,11 @@ type handlerConfig struct {
9494 Whitelist map [uint64 ]common.Hash // Hard coded whitelist for sync challenged
9595 ShadowForkPeerIDs []string // List of peer ids that take part in the shadow-fork
9696
97+ // Gossip configs
9798 DisableTxBroadcast bool
9899 DisableTxReceiving bool
99100 EnableBroadcastToAll bool
101+ BroadcastToAllCap int
100102}
101103
102104type handler struct {
@@ -139,6 +141,7 @@ type handler struct {
139141 disableTxBroadcast bool
140142 disableTxReceiving bool
141143 enableBroadcastToAll bool
144+ broadcastToAllCap int
142145}
143146
144147// newHandler returns a handler for all Ethereum chain management protocol.
@@ -162,6 +165,11 @@ func newHandler(config *handlerConfig) (*handler, error) {
162165 disableTxReceiving : config .DisableTxReceiving ,
163166 enableBroadcastToAll : config .EnableBroadcastToAll ,
164167 }
168+ h .broadcastToAllCap = config .BroadcastToAllCap
169+ if config .BroadcastToAllCap == 0 && config .EnableBroadcastToAll {
170+ // Set default broadcast cap to 30 if not specified
171+ h .broadcastToAllCap = 30
172+ }
165173 if config .Sync == downloader .FullSync {
166174 // The database seems empty as the current block is the genesis. Yet the fast
167175 // block is ahead, so fast sync was enabled for this node at a certain point.
@@ -483,7 +491,7 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) {
483491 numDirect := int (math .Sqrt (float64 (len (peers ))))
484492 // If enableBroadcastToAll is true, broadcast blocks directly to all peers (capped at 100).
485493 if h .enableBroadcastToAll {
486- numDirect = min (100 , len (peers ))
494+ numDirect = min (h . broadcastToAllCap , len (peers ))
487495 }
488496 transfer := peers [:numDirect ]
489497 for _ , peer := range transfer {
@@ -528,7 +536,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
528536 numDirect := int (math .Sqrt (float64 (len (peers ))))
529537 // If enableBroadcastToAll is true, broadcast transactions directly to all peers (capped at 100).
530538 if h .enableBroadcastToAll {
531- numDirect = min (100 , len (peers ))
539+ numDirect = min (h . broadcastToAllCap , len (peers ))
532540 }
533541 for _ , peer := range peers [:numDirect ] {
534542 txset [peer ] = append (txset [peer ], tx .Hash ())
0 commit comments