summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/Exchange/Message.hs16
-rw-r--r--tests/Network/BitTorrent/Core/PeerAddrSpec.hs8
2 files changed, 12 insertions, 12 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs
index fb3a5c82..d0b6c19d 100644
--- a/src/Network/BitTorrent/Exchange/Message.hs
+++ b/src/Network/BitTorrent/Exchange/Message.hs
@@ -115,7 +115,7 @@ import Text.PrettyPrint.Class
115 115
116import Data.Torrent.Bitfield 116import Data.Torrent.Bitfield
117import Data.Torrent.InfoHash 117import Data.Torrent.InfoHash
118import qualified Data.Torrent.Piece as Data 118import qualified Data.Torrent.Piece as P
119import Network.BitTorrent.Core 119import Network.BitTorrent.Core
120import Network.BitTorrent.Exchange.Block 120import Network.BitTorrent.Exchange.Block
121 121
@@ -744,7 +744,7 @@ data ExtendedMetadata
744 -- message. 744 -- message.
745 | MetadataData 745 | MetadataData
746 { -- | A piece of 'Data.Torrent.InfoDict'. 746 { -- | A piece of 'Data.Torrent.InfoDict'.
747 piece :: Data.Piece BS.ByteString 747 piece :: P.Piece BS.ByteString
748 748
749 -- | This key has the same semantics as the 'ehsMetadataSize' in 749 -- | This key has the same semantics as the 'ehsMetadataSize' in
750 -- the 'ExtendedHandshake' — it is size of the torrent info 750 -- the 'ExtendedHandshake' — it is size of the torrent info
@@ -780,7 +780,7 @@ instance BEncode ExtendedMetadata where
780 msg_type_key .=! (0 :: MetadataId) 780 msg_type_key .=! (0 :: MetadataId)
781 .: piece_key .=! pix 781 .: piece_key .=! pix
782 .: endDict 782 .: endDict
783 toBEncode (MetadataData (Data.Piece pix _) totalSize) = toDict $ 783 toBEncode (MetadataData (P.Piece pix _) totalSize) = toDict $
784 msg_type_key .=! (1 :: MetadataId) 784 msg_type_key .=! (1 :: MetadataId)
785 .: piece_key .=! pix 785 .: piece_key .=! pix
786 .: total_size_key .=! totalSize 786 .: total_size_key .=! totalSize
@@ -799,7 +799,7 @@ instance BEncode ExtendedMetadata where
799 2 -> MetadataReject <$>! piece_key 799 2 -> MetadataReject <$>! piece_key
800 _ -> pure (MetadataUnknown bval) 800 _ -> pure (MetadataUnknown bval)
801 where 801 where
802 metadataData pix s = MetadataData (Data.Piece pix BS.empty) s 802 metadataData pix s = MetadataData (P.Piece pix BS.empty) s
803 803
804-- | Piece data bytes are omitted. 804-- | Piece data bytes are omitted.
805instance Pretty ExtendedMetadata where 805instance Pretty ExtendedMetadata where
@@ -818,7 +818,7 @@ instance PeerMessage ExtendedMetadata where
818 818
819 stats (MetadataRequest _) = ByteStats (4 + 1 + 1) {- ~ -} 25 0 819 stats (MetadataRequest _) = ByteStats (4 + 1 + 1) {- ~ -} 25 0
820 stats (MetadataData p _) = ByteStats (4 + 1 + 1) {- ~ -} 41 $ 820 stats (MetadataData p _) = ByteStats (4 + 1 + 1) {- ~ -} 41 $
821 BS.length (Data.pieceData p) 821 BS.length (P.pieceData p)
822 stats (MetadataReject _) = ByteStats (4 + 1 + 1) {- ~ -} 25 0 822 stats (MetadataReject _) = ByteStats (4 + 1 + 1) {- ~ -} 25 0
823 stats (MetadataUnknown _) = ByteStats (4 + 1 + 1) {- ? -} 0 0 823 stats (MetadataUnknown _) = ByteStats (4 + 1 + 1) {- ? -} 0 0
824 824
@@ -836,12 +836,12 @@ checkPiece :: ExtendedMetadata -> Bool
836checkPiece = undefined -- FIXME 836checkPiece = undefined -- FIXME
837 837
838setMetadataPayload :: BS.ByteString -> ExtendedMetadata -> ExtendedMetadata 838setMetadataPayload :: BS.ByteString -> ExtendedMetadata -> ExtendedMetadata
839setMetadataPayload bs (MetadataData (Data.Piece pix _) t) = 839setMetadataPayload bs (MetadataData (P.Piece pix _) t) =
840 MetadataData (Data.Piece pix bs) t 840 MetadataData (P.Piece pix bs) t
841setMetadataPayload _ msg = msg 841setMetadataPayload _ msg = msg
842 842
843getMetadataPayload :: ExtendedMetadata -> Maybe BS.ByteString 843getMetadataPayload :: ExtendedMetadata -> Maybe BS.ByteString
844getMetadataPayload (MetadataData (Data.Piece _ bs) _) = Just bs 844getMetadataPayload (MetadataData (P.Piece _ bs) _) = Just bs
845getMetadataPayload _ = Nothing 845getMetadataPayload _ = Nothing
846 846
847-- | Metadata BDict usually contain only 'msg_type_key', 'piece_key' 847-- | Metadata BDict usually contain only 'msg_type_key', 'piece_key'
diff --git a/tests/Network/BitTorrent/Core/PeerAddrSpec.hs b/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
index e5850998..1bc8d4b4 100644
--- a/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
+++ b/tests/Network/BitTorrent/Core/PeerAddrSpec.hs
@@ -171,8 +171,8 @@ spec = do
171 171
172 172
173 it "properly bencoded (ipv4)" $ do 173 it "properly bencoded (ipv4)" $ do
174 BE.decode "d7:peer id20:01234567890123456789\ 174 BE.decode "d2:ip11:168.192.0.1\
175 \2:ip11:168.192.0.1\ 175 \7:peer id20:01234567890123456789\
176 \4:porti6881e\ 176 \4:porti6881e\
177 \e" 177 \e"
178 `shouldBe` 178 `shouldBe`
@@ -181,8 +181,8 @@ spec = do
181 6881) 181 6881)
182 182
183 it "properly bencoded (ipv6)" $ do 183 it "properly bencoded (ipv6)" $ do
184 BE.decode "d7:peer id20:01234567890123456789\ 184 BE.decode "d2:ip3:::1\
185 \2:ip3:::1\ 185 \7:peer id20:01234567890123456789\
186 \4:porti6881e\ 186 \4:porti6881e\
187 \e" 187 \e"
188 `shouldBe` 188 `shouldBe`