diff options
Diffstat (limited to 'src/Network/BitTorrent/Exchange')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Protocol.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Network/BitTorrent/Exchange/Protocol.hs b/src/Network/BitTorrent/Exchange/Protocol.hs index d2d3da6c..5ea104cc 100644 --- a/src/Network/BitTorrent/Exchange/Protocol.hs +++ b/src/Network/BitTorrent/Exchange/Protocol.hs | |||
@@ -220,9 +220,9 @@ instance Serialize BlockIx where | |||
220 | get = BlockIx <$> getInt <*> getInt <*> getInt | 220 | get = BlockIx <$> getInt <*> getInt <*> getInt |
221 | {-# INLINE get #-} | 221 | {-# INLINE get #-} |
222 | 222 | ||
223 | put ix = do putInt (ixPiece ix) | 223 | put i = do putInt (ixPiece i) |
224 | putInt (ixOffset ix) | 224 | putInt (ixOffset i) |
225 | putInt (ixLength ix) | 225 | putInt (ixLength i) |
226 | {-# INLINE put #-} | 226 | {-# INLINE put #-} |
227 | 227 | ||
228 | -- | Format block index in human readable form. | 228 | -- | Format block index in human readable form. |
@@ -277,11 +277,11 @@ blockRange pieceSize blk = (offset, offset + len) | |||
277 | {-# SPECIALIZE blockRange :: Int -> Block -> (Int64, Int64) #-} | 277 | {-# SPECIALIZE blockRange :: Int -> Block -> (Int64, Int64) #-} |
278 | 278 | ||
279 | ixRange :: (Num a, Integral a) => Int -> BlockIx -> (a, a) | 279 | ixRange :: (Num a, Integral a) => Int -> BlockIx -> (a, a) |
280 | ixRange pieceSize ix = (offset, offset + len) | 280 | ixRange pieceSize i = (offset, offset + len) |
281 | where | 281 | where |
282 | offset = fromIntegral pieceSize * fromIntegral (ixPiece ix) | 282 | offset = fromIntegral pieceSize * fromIntegral (ixPiece i) |
283 | + fromIntegral (ixOffset ix) | 283 | + fromIntegral (ixOffset i) |
284 | len = fromIntegral (ixLength ix) | 284 | len = fromIntegral (ixLength i) |
285 | {-# INLINE ixRange #-} | 285 | {-# INLINE ixRange #-} |
286 | {-# SPECIALIZE ixRange :: Int -> BlockIx -> (Int64, Int64) #-} | 286 | {-# SPECIALIZE ixRange :: Int -> BlockIx -> (Int64, Int64) #-} |
287 | 287 | ||
@@ -410,8 +410,8 @@ instance Serialize Message where | |||
410 | put HaveAll = putInt 1 >> putWord8 0x0E | 410 | put HaveAll = putInt 1 >> putWord8 0x0E |
411 | put HaveNone = putInt 1 >> putWord8 0x0F | 411 | put HaveNone = putInt 1 >> putWord8 0x0F |
412 | put (SuggestPiece pix) = putInt 5 >> putWord8 0x0D >> putInt pix | 412 | put (SuggestPiece pix) = putInt 5 >> putWord8 0x0D >> putInt pix |
413 | put (RejectRequest ix) = putInt 13 >> putWord8 0x10 >> put ix | 413 | put (RejectRequest i ) = putInt 13 >> putWord8 0x10 >> put i |
414 | put (AllowedFast ix) = putInt 5 >> putWord8 0x11 >> putInt ix | 414 | put (AllowedFast i ) = putInt 5 >> putWord8 0x11 >> putInt i |
415 | 415 | ||
416 | 416 | ||
417 | -- | Format messages in human readable form. Note that output is | 417 | -- | Format messages in human readable form. Note that output is |
@@ -421,9 +421,9 @@ instance Serialize Message where | |||
421 | ppMessage :: Message -> Doc | 421 | ppMessage :: Message -> Doc |
422 | ppMessage (Bitfield _) = "Bitfield" | 422 | ppMessage (Bitfield _) = "Bitfield" |
423 | ppMessage (Piece blk) = "Piece" <+> ppBlock blk | 423 | ppMessage (Piece blk) = "Piece" <+> ppBlock blk |
424 | ppMessage (Cancel ix) = "Cancel" <+> ppBlockIx ix | 424 | ppMessage (Cancel i ) = "Cancel" <+> ppBlockIx i |
425 | ppMessage (SuggestPiece pix) = "Suggest" <+> int pix | 425 | ppMessage (SuggestPiece pix) = "Suggest" <+> int pix |
426 | ppMessage (RejectRequest ix) = "Reject" <+> ppBlockIx ix | 426 | ppMessage (RejectRequest i ) = "Reject" <+> ppBlockIx i |
427 | ppMessage msg = text (show msg) | 427 | ppMessage msg = text (show msg) |
428 | 428 | ||
429 | {----------------------------------------------------------------------- | 429 | {----------------------------------------------------------------------- |