diff options
author | joe <joe@jerkface.net> | 2017-01-25 19:45:12 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-01-25 19:45:12 -0500 |
commit | 5d8576d0ee6a0523ab650afb6c18296761fd5d1a (patch) | |
tree | 2904836bcb350cc47286b006de2cfebd3bf11222 | |
parent | 450c65257185e856ee605857688a378f2473d27c (diff) |
Fixed sort-order in encoding of read-only queries.
-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 |