diff options
-rw-r--r-- | CHANGELOG | 7 | ||||
-rw-r--r-- | HTTP/ProofOfWork.hs | 2 | ||||
-rw-r--r-- | Types/Cost.hs | 5 |
3 files changed, 12 insertions, 2 deletions
@@ -1,3 +1,10 @@ +keysafe (0.20160915) UNRELEASED; urgency=medium + + * Reduce number of buckets in rate limiter, avoiding ones with very low + proof of work. + + -- Joey Hess <id@joeyh.name> Wed, 14 Sep 2016 20:19:43 -0400 + keysafe (0.20160914) unstable; urgency=medium * Fix bug that prevented keysafe --server from running when there was no 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) diff --git a/Types/Cost.hs b/Types/Cost.hs index 474db43..08f98eb 100644 --- a/Types/Cost.hs +++ b/Types/Cost.hs @@ -14,7 +14,10 @@ data Cost op deriving (Show, Eq, Ord) newtype Seconds = Seconds Rational - deriving (Num, Fractional, Eq, Ord, Show) + deriving (Num, Fractional, Eq, Ord) + +instance Show Seconds where + show (Seconds n) = show (fromRational n :: Double) ++ "s" -- | How many CPU cores a single run of an operation can be divided amoung. newtype Divisibility = Divisibility Integer |