diff options
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/BitTorrent/DHT/Message.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/DHT/Message.hs b/src/Network/BitTorrent/DHT/Message.hs index d31cce82..1f835fa6 100644 --- a/src/Network/BitTorrent/DHT/Message.hs +++ b/src/Network/BitTorrent/DHT/Message.hs | |||
@@ -84,8 +84,9 @@ module Network.BitTorrent.DHT.Message | |||
84 | ) where | 84 | ) where |
85 | 85 | ||
86 | import Control.Applicative | 86 | import Control.Applicative |
87 | import Data.Bool | ||
87 | import Data.BEncode as BE | 88 | import Data.BEncode as BE |
88 | import Data.BEncode.BDict | 89 | import Data.BEncode.BDict as BDict |
89 | import Data.ByteString (ByteString) | 90 | import Data.ByteString (ByteString) |
90 | import Data.List as L | 91 | import Data.List as L |
91 | import Data.Monoid | 92 | import Data.Monoid |
@@ -121,12 +122,12 @@ data Query a = Query | |||
121 | 122 | ||
122 | instance BEncode a => BEncode (Query a) where | 123 | instance BEncode a => BEncode (Query a) where |
123 | toBEncode Query {..} = toDict $ | 124 | toBEncode Query {..} = toDict $ |
124 | node_id_key .=! queringNodeId .: endDict | 125 | BDict.union ( node_id_key .=! queringNodeId |
125 | <> | 126 | .: read_only_key .=? bool Nothing (Just (1 :: Integer)) queryIsReadOnly |
126 | dict (toBEncode queryParams) | 127 | .: endDict) |
128 | (dict (toBEncode queryParams)) | ||
127 | where | 129 | where |
128 | dict (BDict d) | queryIsReadOnly = Cons read_only_key (BInteger 1) d | 130 | dict (BDict d) = d |
129 | | otherwise = d | ||
130 | dict _ = error "impossible: instance BEncode (Query a)" | 131 | dict _ = error "impossible: instance BEncode (Query a)" |
131 | 132 | ||
132 | fromBEncode v = do | 133 | fromBEncode v = do |