@@ -201,6 +201,14 @@ export interface GossipsubOpts extends GossipsubOptsSpec, PubSubInit {
201
201
* If true, will utilize the libp2p connection manager tagging system to prune/graft connections to peers, defaults to true
202
202
*/
203
203
tagMeshPeers : boolean
204
+
205
+ /**
206
+ * Specify what percent of peers to send gossip to. If the percent results in
207
+ * a number smaller than `Dlazy`, `Dlazy` will be used instead.
208
+ *
209
+ * It should be a number between 0 and 1, with a reasonable default of 0.25
210
+ */
211
+ gossipFactor : number ;
204
212
}
205
213
206
214
export interface GossipsubMessage {
@@ -450,6 +458,7 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
450
458
opportunisticGraftPeers : constants . GossipsubOpportunisticGraftPeers ,
451
459
opportunisticGraftTicks : constants . GossipsubOpportunisticGraftTicks ,
452
460
directConnectTicks : constants . GossipsubDirectConnectTicks ,
461
+ gossipFactor : constants . GossipsubGossipFactor ,
453
462
...options ,
454
463
scoreParams : createPeerScoreParams ( options . scoreParams ) ,
455
464
scoreThresholds : createPeerScoreThresholds ( options . scoreThresholds )
@@ -2498,7 +2507,8 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
2498
2507
2499
2508
if ( candidateToGossip . size === 0 ) return
2500
2509
let target = this . opts . Dlazy
2501
- const factor = constants . GossipsubGossipFactor * candidateToGossip . size
2510
+ const gossipFactor = this . opts . gossipFactor ;
2511
+ const factor = gossipFactor * candidateToGossip . size
2502
2512
let peersToGossip : Set < PeerIdStr > | PeerIdStr [ ] = candidateToGossip
2503
2513
if ( factor > target ) {
2504
2514
target = factor
0 commit comments