Portability | portable |
---|---|
Stability | experimental |
Maintainer | pxqr.sta@gmail.com |
Safe Haskell | None |
Blocks are used to transfer pieces.
- type PieceIx = Int
- type PieceSize = Int
- type BlockOffset = Int
- type BlockCount = Int
- type BlockSize = Int
- defaultTransferSize :: BlockSize
- data BlockIx = BlockIx {}
- blockIxRange :: (Num a, Integral a) => PieceSize -> BlockIx -> (a, a)
- data Block payload = Block {
- blkPiece :: !PieceIx
- blkOffset :: !BlockOffset
- blkData :: !payload
- blockIx :: Block Lazy.ByteString -> BlockIx
- blockSize :: Block Lazy.ByteString -> BlockSize
- blockRange :: (Num a, Integral a) => PieceSize -> Block Lazy.ByteString -> (a, a)
Piece attributes
Size of piece in bytes. Should be a power of 2.
NOTE: Have max and min size constrained to wide used semi-standard values. This bounds should be used to make decision about piece size for new torrents.
Block attributes
type BlockOffset = IntSource
Offset of a block in a piece in bytes. Should be multiple of the choosen block size.
type BlockCount = IntSource
Number of block in a piece of a torrent. Used to distinguish block count from piece count.
Size of a block in bytes. Should be power of 2.
Normally block size is equal to defaultTransferSize
.
defaultTransferSize :: BlockSizeSource
Widely used semi-official block size. Some clients can ignore if block size of BlockIx in Request message is not equal to this value.
Block index
BlockIx correspond.
blockIxRange :: (Num a, Integral a) => PieceSize -> BlockIx -> (a, a)Source
Get location of payload bytes in the torrent content.
Block data
blockIx :: Block Lazy.ByteString -> BlockIxSource
Get block index of a block.
blockSize :: Block Lazy.ByteString -> BlockSizeSource
Get size of block payload in bytes.
blockRange :: (Num a, Integral a) => PieceSize -> Block Lazy.ByteString -> (a, a)Source
Get location of payload bytes in the torrent content.