Skip to content

Commit

Permalink
add constant
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Mar 21, 2024
1 parent e0bcc5f commit 1734160
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libp2p/protocols/pubsub/gossipsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ declareCounter(libp2p_gossipsub_received, "number of messages received (deduplic
when defined(libp2p_expensive_metrics):
declareCounter(libp2p_pubsub_received_messages, "number of messages received", labels = ["id", "topic"])

const
DefaultMaxNumElementInNonPriorityQueue = 1024

proc init*(_: type[GossipSubParams]): GossipSubParams =
GossipSubParams(
explicit: true,
Expand Down Expand Up @@ -84,7 +87,7 @@ proc init*(_: type[GossipSubParams]): GossipSubParams =
bandwidthEstimatebps: 100_000_000, # 100 Mbps or 12.5 MBps
overheadRateLimit: Opt.none(tuple[bytes: int, interval: Duration]),
disconnectPeerAboveRateLimit: false,
maxNumElementInNonPriorityQueue: Opt.some(1024)
maxNumElementInNonPriorityQueue: Opt.some(DefaultMaxNumElementInNonPriorityQueue)
)

proc validateParameters*(parameters: GossipSubParams): Result[void, cstring] =
Expand Down Expand Up @@ -764,4 +767,6 @@ method getOrCreatePeer*(
peer.overheadRateLimitOpt = Opt.some(TokenBucket.new(overheadRateLimit.bytes, overheadRateLimit.interval))
g.parameters.maxNumElementInNonPriorityQueue.withValue(value):
peer.maxNumElementInNonPriorityQueue = value
do:
peer.maxNumElementInNonPriorityQueue = DefaultMaxNumElementInNonPriorityQueue
return peer

0 comments on commit 1734160

Please sign in to comment.