@@ -49,42 +49,80 @@ declareCounter(libp2p_gossipsub_received, "number of messages received (deduplic
49
49
when defined (libp2p_expensive_metrics):
50
50
declareCounter (libp2p_pubsub_received_messages, " number of messages received" , labels = [" id" , " topic" ])
51
51
52
- proc init * (_: type [GossipSubParams ]): GossipSubParams =
52
+ proc init * (
53
+ _: type [GossipSubParams ],
54
+ explicit = true ,
55
+ pruneBackoff = 1 .minutes,
56
+ unsubscribeBackoff = 5 .seconds,
57
+ floodPublish = true ,
58
+ gossipFactor: float64 = 0.25 ,
59
+ d = GossipSubD ,
60
+ dLow = GossipSubDlo ,
61
+ dHigh = GossipSubDhi ,
62
+ dScore = GossipSubDlo ,
63
+ dOut = GossipSubDlo - 1 , # DLow - 1
64
+ dLazy = GossipSubD , # Like D,
65
+ heartbeatInterval = GossipSubHeartbeatInterval ,
66
+ historyLength = GossipSubHistoryLength ,
67
+ historyGossip = GossipSubHistoryGossip ,
68
+ fanoutTTL = GossipSubFanoutTTL ,
69
+ seenTTL = 2 .minutes,
70
+ gossipThreshold = - 100.0 ,
71
+ publishThreshold = - 1000.0 ,
72
+ graylistThreshold = - 10000.0 ,
73
+ opportunisticGraftThreshold = 0.0 ,
74
+ decayInterval = 1 .seconds,
75
+ decayToZero = 0.01 ,
76
+ retainScore = 2 .minutes,
77
+ appSpecificWeight = 0.0 ,
78
+ ipColocationFactorWeight = 0.0 ,
79
+ ipColocationFactorThreshold = 1.0 ,
80
+ behaviourPenaltyWeight = - 1.0 ,
81
+ behaviourPenaltyDecay = 0.999 ,
82
+ directPeers = initTable [PeerId , seq [MultiAddress ]](),
83
+ disconnectBadPeers = false ,
84
+ enablePX = false ,
85
+ bandwidthEstimatebps = 100_000_000 , # 100 Mbps or 12.5 MBps
86
+ overheadRateLimit = Opt .none (tuple [bytes: int , interval: Duration ]),
87
+ disconnectPeerAboveRateLimit = false ,
88
+ maxNumElementsInNonPriorityQueue = DefaultMaxNumElementsInNonPriorityQueue ): GossipSubParams =
89
+
53
90
GossipSubParams (
54
91
explicit: true ,
55
- pruneBackoff: 1 .minutes,
56
- unsubscribeBackoff: 5 .seconds,
57
- floodPublish: true ,
58
- gossipFactor: 0.25 ,
59
- d: GossipSubD ,
60
- dLow: GossipSubDlo ,
61
- dHigh: GossipSubDhi ,
62
- dScore: GossipSubDlo ,
63
- dOut: GossipSubDlo - 1 , # DLow - 1
64
- dLazy: GossipSubD , # Like D
65
- heartbeatInterval: GossipSubHeartbeatInterval ,
66
- historyLength: GossipSubHistoryLength ,
67
- historyGossip: GossipSubHistoryGossip ,
68
- fanoutTTL: GossipSubFanoutTTL ,
69
- seenTTL: 2 .minutes,
70
- gossipThreshold: - 100 ,
71
- publishThreshold: - 1000 ,
72
- graylistThreshold: - 10000 ,
73
- opportunisticGraftThreshold: 0 ,
74
- decayInterval: 1 .seconds,
75
- decayToZero: 0.01 ,
76
- retainScore: 2 .minutes,
77
- appSpecificWeight: 0.0 ,
78
- ipColocationFactorWeight: 0.0 ,
79
- ipColocationFactorThreshold: 1.0 ,
80
- behaviourPenaltyWeight: - 1.0 ,
81
- behaviourPenaltyDecay: 0.999 ,
82
- disconnectBadPeers: false ,
83
- enablePX: false ,
84
- bandwidthEstimatebps: 100_000_000 , # 100 Mbps or 12.5 MBps
85
- overheadRateLimit: Opt .none (tuple [bytes: int , interval: Duration ]),
86
- disconnectPeerAboveRateLimit: false ,
87
- maxNumElementsInNonPriorityQueue: DefaultMaxNumElementsInNonPriorityQueue
92
+ pruneBackoff: pruneBackoff,
93
+ unsubscribeBackoff: unsubscribeBackoff,
94
+ floodPublish: floodPublish,
95
+ gossipFactor: gossipFactor,
96
+ d: d,
97
+ dLow: dLow,
98
+ dHigh: dHigh,
99
+ dScore: dScore,
100
+ dOut: dOut,
101
+ dLazy: dLazy,
102
+ heartbeatInterval: heartbeatInterval,
103
+ historyLength: historyLength,
104
+ historyGossip: historyGossip,
105
+ fanoutTTL: fanoutTTL,
106
+ seenTTL: seenTTL,
107
+ gossipThreshold: gossipThreshold,
108
+ publishThreshold: publishThreshold,
109
+ graylistThreshold: graylistThreshold,
110
+ opportunisticGraftThreshold: opportunisticGraftThreshold,
111
+ decayInterval: decayInterval,
112
+ decayToZero: decayToZero,
113
+ retainScore: retainScore,
114
+ appSpecificWeight: appSpecificWeight,
115
+ ipColocationFactorWeight: ipColocationFactorWeight,
116
+ ipColocationFactorThreshold: ipColocationFactorThreshold,
117
+ behaviourPenaltyWeight: behaviourPenaltyWeight,
118
+ behaviourPenaltyDecay: behaviourPenaltyDecay,
119
+ directPeers: directPeers,
120
+ disconnectBadPeers: disconnectBadPeers,
121
+ enablePX: enablePX,
122
+ bandwidthEstimatebps: bandwidthEstimatebps,
123
+ overheadRateLimit: overheadRateLimit,
124
+ disconnectPeerAboveRateLimit: disconnectPeerAboveRateLimit,
125
+ maxNumElementsInNonPriorityQueue: maxNumElementsInNonPriorityQueue
88
126
)
89
127
90
128
proc validateParameters * (parameters: GossipSubParams ): Result [void , cstring ] =
@@ -115,6 +153,8 @@ proc validateParameters*(parameters: GossipSubParams): Result[void, cstring] =
115
153
err (" gossipsub: behaviourPenaltyWeight parameter error, Must be negative" )
116
154
elif parameters.behaviourPenaltyDecay < 0 or parameters.behaviourPenaltyDecay >= 1 :
117
155
err (" gossipsub: behaviourPenaltyDecay parameter error, Must be between 0 and 1" )
156
+ elif parameters.maxNumElementsInNonPriorityQueue <= 0 :
157
+ err (" gossipsub: maxNumElementsInNonPriorityQueue parameter error, Must be > 0" )
118
158
else :
119
159
ok ()
120
160
0 commit comments