summaryrefslogtreecommitdiffhomepage
path: root/HTTP/RateLimit.hs
diff options
context:
space:
mode:
Diffstat (limited to 'HTTP/RateLimit.hs')
-rw-r--r--HTTP/RateLimit.hs7
1 files changed, 3 insertions, 4 deletions
diff --git a/HTTP/RateLimit.hs b/HTTP/RateLimit.hs
index 9153664..737f7dc 100644
--- a/HTTP/RateLimit.hs
+++ b/HTTP/RateLimit.hs
@@ -5,7 +5,6 @@
module HTTP.RateLimit where
-import Types
import Types.Cost
import HTTP
import HTTP.ProofOfWork
@@ -107,8 +106,8 @@ fillRate = 60000000 -- 1 token per minute
-- If all buckets are tried and are empty, we must be very overloaded.
-- In this case, the request is still processed, since the client has done
-- quite a lot of work.
-rateLimit :: RateLimiter -> Maybe ProofOfWork -> StorableObjectIdent -> Handler a -> Handler (POWGuarded a)
-rateLimit ratelimiter mpow i a = do
+rateLimit :: POWIdent p => RateLimiter -> Maybe ProofOfWork -> p -> Handler a -> Handler (POWGuarded a)
+rateLimit ratelimiter mpow p a = do
validsalt <- liftIO $ checkValidSalt ratelimiter mpow
bs <- liftIO $ atomically $ readTMVar (buckets ratelimiter)
if validsalt
@@ -123,7 +122,7 @@ rateLimit ratelimiter mpow i a = do
Just mkreq -> case mpow of
Nothing -> assignWork ratelimiter (b:bs)
Just pow@(ProofOfWork _ salt) ->
- if isValidProofOfWork pow (mkreq salt) i
+ if isValidProofOfWork pow (mkreq salt) p
then checkbucket b bs
else assignWork ratelimiter (b:bs)
checkbucket b bs = do