From: Ramakrishnan Muthukrishnan Date: Fri, 17 Jul 2015 14:10:25 +0000 (+0530) Subject: new type synonym for a Piece Map X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/flags/%22doc.html/specifications/something?a=commitdiff_plain;h=7add008aa3ed4349192160773e5a1c7619e2c135;p=functorrent.git new type synonym for a Piece Map --- diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs index 817a9cd..d7197eb 100644 --- a/src/FuncTorrent/Peer.hs +++ b/src/FuncTorrent/Peer.hs @@ -18,6 +18,7 @@ import Control.Monad (replicateM, liftM, forever) import Control.Applicative ((<$>), liftA3) import Data.Bits import Data.Word (Word8) +import Data.Map (Map(..)) import FuncTorrent.Metainfo (Info(..), Metainfo(..)) type ID = String @@ -39,10 +40,13 @@ data PieceState = Pending | Have deriving (Show) -data PieceData = PieceData { index :: Int -- ^ Piece number - , peers :: [Peer] -- ^ list of peers who have this piece +-- todo - map with index to a new data structure (peers who have that piece amd state) +data PieceData = PieceData { peers :: [Peer] -- ^ list of peers who have this piece , state :: PieceState } -- ^ state of the piece from download perspective. +-- which piece is with which peers +type PieceMap = Map Integer PieceData + -- | Peer is a PeerID, IP address, port tuple data Peer = Peer ID IP Port deriving (Show, Eq)