diff options
Diffstat (limited to 'HTTP/Server.hs')
-rw-r--r-- | HTTP/Server.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/HTTP/Server.hs b/HTTP/Server.hs index f2ecfa8..886fe6f 100644 --- a/HTTP/Server.hs +++ b/HTTP/Server.hs @@ -96,8 +96,13 @@ validObjectsize o = any (sz ==) knownObjectSizes sz = B.length (fromStorableObject o) countObjects :: ServerState -> Maybe ProofOfWork -> Handler (POWGuarded CountResult) -countObjects st pow = rateLimit (rateLimiter st) (logger st) pow NoPOWIdent $ - liftIO $ countShares $ storage st +countObjects st pow = rateLimit (rateLimiter st) (logger st) pow NoPOWIdent $ do + v <- liftIO $ countShares $ storage st + case v of + CountResult n -> return $ + -- Round down to avoid leaking too much detail. + CountResult ((n `div` 1000) * 1000) + CountFailure s -> return (CountFailure s) -- | 1 is a dummy value; the server does not know the actual share numbers. dummyShareNum :: ShareNum |