diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Block.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange/Block.hs b/src/Network/BitTorrent/Exchange/Block.hs index c910a716..32e4f99f 100644 --- a/src/Network/BitTorrent/Exchange/Block.hs +++ b/src/Network/BitTorrent/Exchange/Block.hs | |||
@@ -30,6 +30,7 @@ module Network.BitTorrent.Exchange.Block | |||
30 | , blockSize | 30 | , blockSize |
31 | , blockRange | 31 | , blockRange |
32 | , isPiece | 32 | , isPiece |
33 | , leadingBlock | ||
33 | 34 | ||
34 | -- * Block bucket | 35 | -- * Block bucket |
35 | , Bucket | 36 | , Bucket |
@@ -194,6 +195,15 @@ isPiece pieceLen blk @ (Block i offset _) = | |||
194 | offset == 0 && blockSize blk == pieceLen && i >= 0 | 195 | offset == 0 && blockSize blk == pieceLen && i >= 0 |
195 | {-# INLINE isPiece #-} | 196 | {-# INLINE isPiece #-} |
196 | 197 | ||
198 | -- | First block in the piece. | ||
199 | leadingBlock :: PieceIx -> BlockSize -> BlockIx | ||
200 | leadingBlock pix blockSize = BlockIx | ||
201 | { ixPiece = pix | ||
202 | , ixOffset = 0 | ||
203 | , ixLength = blockSize | ||
204 | } | ||
205 | {-# INLINE leadingBlock #-} | ||
206 | |||
197 | {----------------------------------------------------------------------- | 207 | {----------------------------------------------------------------------- |
198 | -- Bucket | 208 | -- Bucket |
199 | -----------------------------------------------------------------------} | 209 | -----------------------------------------------------------------------} |