From 482f4f28b106d08ed20843a81c93efd3995e1439 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sat, 20 Apr 2013 23:40:25 +0400 Subject: + Move message and block to separated files. --- src/Network/Torrent/PeerWire/Block.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/Network/Torrent/PeerWire/Block.hs (limited to 'src/Network/Torrent/PeerWire/Block.hs') diff --git a/src/Network/Torrent/PeerWire/Block.hs b/src/Network/Torrent/PeerWire/Block.hs new file mode 100644 index 00000000..b2fe8c31 --- /dev/null +++ b/src/Network/Torrent/PeerWire/Block.hs @@ -0,0 +1,17 @@ +module Network.Torrent.PeerWire.Block + ( BlockIx(..), Block(..) + ) where + +import Data.ByteString (ByteString) + +data BlockIx = BlockIx { + ixPiece :: {-# UNPACK #-} !Int -- ^ Zero-based piece index. + , ixOffset :: {-# UNPACK #-} !Int -- ^ Zero-based byte offset within the piece. + , ixLength :: {-# UNPACK #-} !Int -- ^ Block size starting from offset. + } deriving (Show, Eq) + +data Block = Block { + blkPiece :: Int -- ^ Zero-based piece index. + , blkOffset :: Int -- ^ Zero-based byte offset within the piece. + , blkData :: ByteString -- ^ Payload. + } deriving (Show, Eq) -- cgit v1.2.3