diff options
Diffstat (limited to 'src/Network/DHT/Mainline.hs')
-rw-r--r-- | src/Network/DHT/Mainline.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Network/DHT/Mainline.hs b/src/Network/DHT/Mainline.hs index e5517a3a..d68755a7 100644 --- a/src/Network/DHT/Mainline.hs +++ b/src/Network/DHT/Mainline.hs | |||
@@ -154,7 +154,7 @@ read_only_key = "ro" | |||
154 | #ifdef VERSION_bencoding | 154 | #ifdef VERSION_bencoding |
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 queryExtra |
158 | .: read_only_key .=? bool Nothing (Just (1 :: Integer)) (queryIsReadOnly queryExtra) | 158 | .: read_only_key .=? bool Nothing (Just (1 :: Integer)) (queryIsReadOnly queryExtra) |
159 | .: endDict) | 159 | .: endDict) |
160 | (dict (toBEncode queryParams)) | 160 | (dict (toBEncode queryParams)) |
@@ -162,9 +162,9 @@ instance BEncode a => BEncode (Query KMessageOf a) where | |||
162 | dict (BDict d) = d | 162 | dict (BDict d) = d |
163 | dict _ = error "impossible: instance BEncode (Query a)" | 163 | dict _ = error "impossible: instance BEncode (Query a)" |
164 | 164 | ||
165 | fromBEncode v = do | 165 | fromBEncode v = |
166 | Query <$> fromDict (field (req node_id_key)) v | 166 | Query <$> (MainlineQuery <$> fromDict (field (req node_id_key)) v |
167 | <*> fromDict (IsReadOnlyQuery . fromMaybe False <$>? read_only_key) v | 167 | <*> fromDict (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 MainlineResponseData a) = Query nid (IsReadOnlyQuery False) a | 177 | toQuery (Response (MainlineResponse nid) a) = Query (MainlineQuery nid 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 MainlineResponseData a | 181 | fromQuery (Query (MainlineQuery nid _) a) = Response (MainlineResponse nid) 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 |