mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-14 08:57:14 +00:00
a00f350cd1
* feat: Added simple, configurable rate limit for lightpush and store-query Adjust lightpush rest response to rate limit, added tests ann some fixes Add rest store query test for rate limit checks and proper error response Update apps/wakunode2/external_config.nim Move chronos/tokenbucket to nwaku codebasee with limited and fixed feature set Add meterics counter to lightpush rate limits Co-authored-by: gabrielmer <101006718+gabrielmer@users.noreply.github.com>
29 lines
786 B
Nim
29 lines
786 B
Nim
{.used.}
|
|
|
|
import std/options, chronicles, chronos, libp2p/crypto/crypto
|
|
|
|
import
|
|
../../waku/node/peer_manager,
|
|
../../waku/waku_core,
|
|
../../waku/waku_lightpush,
|
|
../../waku/waku_lightpush/[client, common],
|
|
../testlib/[common, wakucore]
|
|
|
|
proc newTestWakuLightpushNode*(
|
|
switch: Switch,
|
|
handler: PushMessageHandler,
|
|
rateLimitSetting: Option[RateLimitSetting] = none[RateLimitSetting](),
|
|
): Future[WakuLightPush] {.async.} =
|
|
let
|
|
peerManager = PeerManager.new(switch)
|
|
proto = WakuLightPush.new(peerManager, rng, handler, rateLimitSetting)
|
|
|
|
await proto.start()
|
|
switch.mount(proto)
|
|
|
|
return proto
|
|
|
|
proc newTestWakuLightpushClient*(switch: Switch): WakuLightPushClient =
|
|
let peerManager = PeerManager.new(switch)
|
|
WakuLightPushClient.new(peerManager, rng)
|