diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-13 22:15:18 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-13 22:32:13 -0400 |
commit | 68eb14fdf6debf1e26921a1b2dddf34dbd031471 (patch) | |
tree | b179ae7f113fd89c674862d5c9619282d545a17d /HTTP/RateLimit.hs | |
parent | 27aef01ba665a14924ece95d5ef4674e3945ef7e (diff) | |
download | keysafe-68eb14fdf6debf1e26921a1b2dddf34dbd031471.tar.gz |
use less expensive hash for proof of work
The server has to run the hash once to verify a request, so a hash that
took 4 seconds could make the server do too much work if it's being flooded
with requests.
So, made the hash much less expensive.
This required keeping track of fractional seconds. Actually, I used
Rational for them, to avoid most rounding problems. That turned out nice.
I've only tuned the proofOfWorkHashTunable on my fanless overheating
laptop so far. It seems to be fairly reasonablly tuned though.
Diffstat (limited to 'HTTP/RateLimit.hs')
-rw-r--r-- | HTTP/RateLimit.hs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/HTTP/RateLimit.hs b/HTTP/RateLimit.hs index 45c6b9a..39d7dbc 100644 --- a/HTTP/RateLimit.hs +++ b/HTTP/RateLimit.hs @@ -104,7 +104,7 @@ newRateLimiter cfg storedir logger = do <*> pure minFillInterval return (b:bs) - sdiv (Seconds n) d = Seconds (n `div` d) + sdiv (Seconds n) d = Seconds (n / d) mkBloomFilter :: IO BloomFilter mkBloomFilter = do |