summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/DHT/Message.hs13
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
86import Control.Applicative 86import Control.Applicative
87import Data.Bool
87import Data.BEncode as BE 88import Data.BEncode as BE
88import Data.BEncode.BDict 89import Data.BEncode.BDict as BDict
89import Data.ByteString (ByteString) 90import Data.ByteString (ByteString)
90import Data.List as L 91import Data.List as L
91import Data.Monoid 92import Data.Monoid
@@ -121,12 +122,12 @@ data Query a = Query
121 122
122instance BEncode a => BEncode (Query a) where 123instance 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