summaryrefslogtreecommitdiffhomepage
path: root/HTTP
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-14 20:21:01 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-14 20:21:01 -0400
commit1652956786d73f020de534e935126c64c04eebd9 (patch)
tree087836e2c1a466eb453fe27c04a92b1dc138e159 /HTTP
parent9327f597b987b8f6f9595040879e4930dee8cf75 (diff)
downloadkeysafe-1652956786d73f020de534e935126c64c04eebd9.tar.gz
Reduce number of buckets in rate limiter, avoiding ones with very low proof of work.
This got out of whack when sections were converted to rationals; there were buckets that needed trivial proofs of work, and having these extra buckets increased the total possible throughput.
Diffstat (limited to 'HTTP')
-rw-r--r--HTTP/ProofOfWork.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/HTTP/ProofOfWork.hs b/HTTP/ProofOfWork.hs
index 35b5ffd..39073b9 100644
--- a/HTTP/ProofOfWork.hs
+++ b/HTTP/ProofOfWork.hs
@@ -86,7 +86,7 @@ generationTime req =
mkProofOfWorkRequirement :: Seconds -> Maybe (RequestID -> ProofOfWorkRequirement)
mkProofOfWorkRequirement (Seconds n)
- | lz < 1 = Nothing
+ | lz < 1 || n <= 1 = Nothing
| otherwise = Just $ ProofOfWorkRequirement lz its
where
lz = floor (logBase 2 (fromRational (max 1 (n / s))) :: Double)