diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Message.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Message.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index d8873f95..f8b76186 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs | |||
@@ -117,10 +117,10 @@ import Network.Socket hiding (KeepAlive) | |||
117 | import Text.PrettyPrint as PP hiding ((<>)) | 117 | import Text.PrettyPrint as PP hiding ((<>)) |
118 | import Text.PrettyPrint.Class | 118 | import Text.PrettyPrint.Class |
119 | 119 | ||
120 | import Data.Torrent.Bitfield | 120 | import Data.Torrent hiding (Piece (..)) |
121 | import Data.Torrent.InfoHash | 121 | import qualified Data.Torrent as P (Piece (..)) |
122 | import qualified Data.Torrent.Piece as P | 122 | import Network.BitTorrent.Address |
123 | import Network.BitTorrent.Core | 123 | import Network.BitTorrent.Exchange.Bitfield |
124 | import Network.BitTorrent.Exchange.Block | 124 | import Network.BitTorrent.Exchange.Block |
125 | 125 | ||
126 | {----------------------------------------------------------------------- | 126 | {----------------------------------------------------------------------- |
@@ -864,7 +864,7 @@ instance PeerMessage ExtendedMetadata where | |||
864 | 864 | ||
865 | -- | All 'Piece's in 'MetadataData' messages MUST have size equal to | 865 | -- | All 'Piece's in 'MetadataData' messages MUST have size equal to |
866 | -- this value. The last trailing piece can be shorter. | 866 | -- this value. The last trailing piece can be shorter. |
867 | metadataPieceSize :: P.PieceSize | 867 | metadataPieceSize :: PieceSize |
868 | metadataPieceSize = 16 * 1024 | 868 | metadataPieceSize = 16 * 1024 |
869 | 869 | ||
870 | isLastPiece :: P.Piece a -> Int -> Bool | 870 | isLastPiece :: P.Piece a -> Int -> Bool |
@@ -877,8 +877,8 @@ isLastPiece P.Piece {..} total = succ pieceIndex == pcnt | |||
877 | -- length; otherwise serialization MUST fail. | 877 | -- length; otherwise serialization MUST fail. |
878 | isValidPiece :: P.Piece BL.ByteString -> Int -> Bool | 878 | isValidPiece :: P.Piece BL.ByteString -> Int -> Bool |
879 | isValidPiece p @ P.Piece {..} total | 879 | isValidPiece p @ P.Piece {..} total |
880 | | isLastPiece p total = P.pieceSize p <= metadataPieceSize | 880 | | isLastPiece p total = pieceSize p <= metadataPieceSize |
881 | | otherwise = P.pieceSize p == metadataPieceSize | 881 | | otherwise = pieceSize p == metadataPieceSize |
882 | 882 | ||
883 | setMetadataPayload :: BS.ByteString -> ExtendedMetadata -> ExtendedMetadata | 883 | setMetadataPayload :: BS.ByteString -> ExtendedMetadata -> ExtendedMetadata |
884 | setMetadataPayload bs (MetadataData (P.Piece pix _) t) = | 884 | setMetadataPayload bs (MetadataData (P.Piece pix _) t) = |