Skip to content

Commit

Permalink
Make rate limit disable by default if the config isn't provided
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Sep 8, 2023
1 parent 3ffbb1c commit c7884d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions libp2p/protocols/pubsub/gossipsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ proc init*(_: type[GossipSubParams]): GossipSubParams =
enablePX: false,
bandwidthEstimatebps: 100_000_000, # 100 Mbps or 12.5 MBps
iwantTimeout: 3 * GossipSubHeartbeatInterval,
uselessAppBytesRate: (10000, 500.milliseconds)
uselessAppBytesRateConfOpt: Opt.none(tuple[bytes: int, interval: Duration])
)

proc validateParameters*(parameters: GossipSubParams): Result[void, cstring] =
Expand Down Expand Up @@ -728,5 +728,6 @@ method getOrCreatePeer*(
protos: seq[string]): PubSubPeer =

let peer = procCall PubSub(g).getOrCreatePeer(peerId, protos)
peer.uselessAppBytesRateOpt = Opt.some(TokenBucket.new(g.parameters.uselessAppBytesRate.bytes, g.parameters.uselessAppBytesRate.interval))
g.parameters.uselessAppBytesRateConfOpt.withValue(uselessAppBytesRateConf):
peer.uselessAppBytesRateOpt = Opt.some(TokenBucket.new(uselessAppBytesRateConf.bytes, uselessAppBytesRateConf.interval))
return peer
2 changes: 1 addition & 1 deletion libp2p/protocols/pubsub/gossipsub/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type
bandwidthEstimatebps*: int # This is currently used only for limting flood publishing. 0 disables flood-limiting completely
iwantTimeout*: Duration

uselessAppBytesRate*: tuple[bytes: int, interval: Duration]
uselessAppBytesRateConfOpt*: Opt[tuple[bytes: int, interval: Duration]]

BackoffTable* = Table[string, Table[PeerId, Moment]]
ValidationSeenTable* = Table[MessageId, HashSet[PubSubPeer]]
Expand Down

0 comments on commit c7884d5

Please sign in to comment.