summaryrefslogtreecommitdiffhomepage
path: root/doc/todo/Fix_compiler_errors_in_HEAD.mdwn
blob: 08dbdc83e235ff5362221195d8f7a92394ede0da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
```
From e1fee7bb9dd508b9bef420fd76292f91bb151c8c Mon Sep 17 00:00:00 2001
From: Mitchell Rosen <mitchellwrosen@gmail.com>
Date: Sat, 1 Apr 2017 14:39:41 -0400
Subject: [PATCH 1/1] Fix compiler errors

---
 HTTP/ProofOfWork.hs | 8 ++++----
 HTTP/Server.hs      | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/HTTP/ProofOfWork.hs b/HTTP/ProofOfWork.hs
index 0237347..9a10d39 100644
--- a/HTTP/ProofOfWork.hs
+++ b/HTTP/ProofOfWork.hs
@@ -16,7 +16,7 @@ import ByteStrings
 import GHC.Generics
 import qualified Data.Text as T
 import qualified Data.ByteString as B
-import Data.Text.Encoding (encodeUtf8)
+import Data.Text.Encoding (decodeUtf8, encodeUtf8)
 import Raaz.Core.Encode
 import qualified Raaz
 import Data.BloomFilter.Hash
@@ -55,7 +55,7 @@ instance Hashable RequestID where
 	hashIO64 = hashIO64 . hashRequestID
 
 hashRequestID :: RequestID -> B.ByteString
-hashRequestID rid = encodeUtf8 (fromRandomSalt (randomSalt rid)) 
+hashRequestID rid = encodeUtf8 (fromRandomSalt (randomSalt rid))
 	<> ":" <> encodeUtf8 (requestHMAC rid)
 
 -- | Using Text and not ByteString so that ProofOfWorkRequirement can have a
@@ -80,7 +80,7 @@ maxProofOfWork = Seconds (16*60)
 -- on the very first try. On average, the client will need to work for half
 -- as long as the returned number of Seconds.
 generationTime :: ProofOfWorkRequirement -> Seconds
-generationTime req = 
+generationTime req =
 	let UseArgon2 (CPUCost (Seconds s) _) _ = proofOfWorkHashTunable (addedArgon2Iterations req)
 	in Seconds ((2^(leadingZeros req)) * s)
 
@@ -109,7 +109,7 @@ mkRequestID secret = mkRequeestID' secret <$> mkRandomSalt
 mkRequeestID' :: RequestIDSecret -> RandomSalt -> RequestID
 mkRequeestID' (RequestIDSecret key) salt =
 	let hmac = Raaz.hmacSha256 key (encodeUtf8 $ fromRandomSalt salt)
-	in RequestID salt $ T.toByteString (Raaz.encode hmac :: Base16)
+	in RequestID salt $ decodeUtf8 $ Raaz.toByteString (Raaz.encode hmac :: Base16)
 
 validRequestID :: RequestIDSecret -> RequestID -> Bool
 validRequestID secret rid =
diff --git a/HTTP/Server.hs b/HTTP/Server.hs
index 61bdbfd..12a8f26 100644
--- a/HTTP/Server.hs
+++ b/HTTP/Server.hs
@@ -18,6 +18,7 @@ import CmdLine (ServerConfig(..))
 import Storage.Local
 import Serialization ()
 import Servant
+import Network.Wai (Application)
 import Network.Wai.Handler.Warp
 import Control.Monad.IO.Class
 import Control.Concurrent
@@ -51,7 +52,7 @@ runServer d cfg = do
 	_ <- forkIO $ obscurerThread st
 	runSettings settings (app st)
   where
-	settings = setHost host $ setPort (serverPort cfg) $ defaultSettings 
+	settings = setHost host $ setPort (serverPort cfg) $ defaultSettings
 	host = fromString (serverAddress cfg)
 
 serverStorage :: Maybe LocalStorageDirectory -> Storage
-- 
2.12.1
```

> Thanks for the patch; I applied essentially these fixes although
> untangled the unrelated issues. [[done]] --[[Joey]]