diff options
author | joe <joe@jerkface.net> | 2017-07-02 16:41:11 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-02 16:41:11 -0400 |
commit | be15a1ceba3b87f845d3b56915207457a94394ee (patch) | |
tree | e0d0bc153dab2ebbcb23a8a4a16b03efe2e43de5 /src/Network/DHT/Mainline.hs | |
parent | de4a5fd744b4744a80e3403f914886ff7df10526 (diff) |
Abstract facility to represent Tox encrypted nonces.
Diffstat (limited to 'src/Network/DHT/Mainline.hs')
-rw-r--r-- | src/Network/DHT/Mainline.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Network/DHT/Mainline.hs b/src/Network/DHT/Mainline.hs index 6ef6d450..e5517a3a 100644 --- a/src/Network/DHT/Mainline.hs +++ b/src/Network/DHT/Mainline.hs | |||
@@ -155,7 +155,7 @@ read_only_key = "ro" | |||
155 | instance BEncode a => BEncode (Query KMessageOf a) where | 155 | instance BEncode a => BEncode (Query KMessageOf a) where |
156 | toBEncode Query {..} = toDict $ | 156 | toBEncode Query {..} = toDict $ |
157 | BDict.union ( node_id_key .=! queringNodeId | 157 | BDict.union ( node_id_key .=! queringNodeId |
158 | .: read_only_key .=? bool Nothing (Just (1 :: Integer)) queryIsReadOnly | 158 | .: read_only_key .=? bool Nothing (Just (1 :: Integer)) (queryIsReadOnly queryExtra) |
159 | .: endDict) | 159 | .: endDict) |
160 | (dict (toBEncode queryParams)) | 160 | (dict (toBEncode queryParams)) |
161 | where | 161 | where |
@@ -164,7 +164,7 @@ instance BEncode a => BEncode (Query KMessageOf a) where | |||
164 | 164 | ||
165 | fromBEncode v = do | 165 | fromBEncode v = do |
166 | Query <$> fromDict (field (req node_id_key)) v | 166 | Query <$> fromDict (field (req node_id_key)) v |
167 | <*> fromDict (fromMaybe False <$>? read_only_key) v | 167 | <*> fromDict (IsReadOnlyQuery . fromMaybe False <$>? read_only_key) v |
168 | <*> fromBEncode v | 168 | <*> fromBEncode v |
169 | #else | 169 | #else |
170 | data Query a = Query a | 170 | data Query a = Query a |
@@ -174,11 +174,11 @@ data Query a = Query a | |||
174 | instance BEncode a => BEncode (Response KMessageOf a) where | 174 | instance BEncode a => BEncode (Response KMessageOf a) where |
175 | toBEncode = toBEncode . toQuery | 175 | toBEncode = toBEncode . toQuery |
176 | where | 176 | where |
177 | toQuery (Response nid a) = Query nid False a | 177 | toQuery (Response nid MainlineResponseData a) = Query nid (IsReadOnlyQuery False) a |
178 | 178 | ||
179 | fromBEncode b = fromQuery <$> fromBEncode b | 179 | fromBEncode b = fromQuery <$> fromBEncode b |
180 | where | 180 | where |
181 | fromQuery (Query nid _ a) = Response nid a | 181 | fromQuery (Query nid _ a) = Response nid MainlineResponseData a |
182 | #else | 182 | #else |
183 | data Response KMessageOf a = Response KMessageOf a | 183 | data Response KMessageOf a = Response KMessageOf a |
184 | #endif | 184 | #endif |