summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Exchange
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Exchange')
-rw-r--r--src/Network/BitTorrent/Exchange/Message.hs16
1 files changed, 8 insertions, 8 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'