summaryrefslogtreecommitdiffhomepage
path: root/Storage
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-12 22:59:03 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-12 22:59:03 -0400
commite333a779338ff8bccdc4225fc953d6f4f0226db0 (patch)
treec07f1165ba101c2b10e914170fb07628e1d08d3a /Storage
parent13c408d2295597540f0b2dfb6f7b86e739876c90 (diff)
downloadkeysafe-e333a779338ff8bccdc4225fc953d6f4f0226db0.tar.gz
add proof of work to countobjects
In this case, an empty string is hashed to generate the PoW.
Diffstat (limited to 'Storage')
-rw-r--r--Storage/Network.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/Storage/Network.hs b/Storage/Network.hs
index 6053ff3..9739f2f 100644
--- a/Storage/Network.hs
+++ b/Storage/Network.hs
@@ -74,20 +74,21 @@ obscure :: Server -> IO ObscureResult
obscure _ = return ObscureSuccess
count :: Server -> IO CountResult
-count srv = either CountFailure id <$> serverRequest' srv countObjects
+count srv = serverRequest srv CountFailure id NoPOWIdent countObjects
-- | Not needed for servers.
move :: Server -> Storage -> IO ()
move _ _ = error "move is not implemented for servers"
serverRequest
- :: Server
+ :: POWIdent p
+ => Server
-> (String -> a)
-> (r -> a)
- -> StorableObjectIdent
+ -> p
-> (Maybe ProofOfWork -> Manager -> BaseUrl -> ExceptT ServantError IO (POWGuarded r))
-> IO a
-serverRequest srv onerr onsuccess i a = go Nothing maxProofOfWork
+serverRequest srv onerr onsuccess p a = go Nothing maxProofOfWork
where
go pow (Seconds timeleft)
| timeleft <= 0 = return $ onerr "server asked for too much proof of work; gave up"
@@ -97,7 +98,7 @@ serverRequest srv onerr onsuccess i a = go Nothing maxProofOfWork
Left err -> return $ onerr err
Right (Result r) -> return $ onsuccess r
Right (NeedProofOfWork req) -> go
- (Just $ genProofOfWork req i)
+ (Just $ genProofOfWork req p)
(Seconds timeleft - generationTime req)
serverRequest'