diff --git a/.env.example b/.env.example index 459d1b67..1112a801 100644 --- a/.env.example +++ b/.env.example @@ -98,4 +98,7 @@ LIGHTNING_RESERVE_FEE_MIN=2000 # Rate limit requests to mint. Make sure that you can see request IPs in the logs. # You may need to adjust your reverse proxy if you only see requests originating from 127.0.0.1 # MINT_RATE_LIMIT=TRUE -# MINT_GLOBAL_RATE_LIMIT_PER_MINUTE=20 +# Determines the number of all requests allowed per minute per IP +# MINT_GLOBAL_RATE_LIMIT_PER_MINUTE=60 +# Determines the number of transactions (mint, melt, swap) allowed per minute per IP +# MINT_TRANSACTION_RATE_LIMIT_PER_MINUTE=20 diff --git a/cashu/mint/limit.py b/cashu/mint/limit.py index 9171dc64..1a8a4c28 100644 --- a/cashu/mint/limit.py +++ b/cashu/mint/limit.py @@ -28,12 +28,14 @@ def get_remote_address_excluding_local(request: Request) -> str: limiter_global = Limiter( key_func=get_remote_address_excluding_local, + strategy="fixed-window-elastic-expiry", default_limits=[f"{settings.mint_global_rate_limit_per_minute}/minute"], enabled=settings.mint_rate_limit, ) limiter = Limiter( key_func=get_remote_address_excluding_local, + strategy="fixed-window-elastic-expiry", default_limits=[f"{settings.mint_transaction_rate_limit_per_minute}/minute"], enabled=settings.mint_rate_limit, )