From 7add008aa3ed4349192160773e5a1c7619e2c135 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Fri, 17 Jul 2015 19:40:25 +0530
Subject: [PATCH] new type synonym for a Piece Map

---
 src/FuncTorrent/Peer.hs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

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)
-- 
2.45.2