From 8e4419d5bf7880ac862675dc4105cf6503c488bc Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Sat, 14 Dec 2013 19:41:18 +0100 Subject: Make PeerAddr polimorphic in its address type --- src/Network/BitTorrent/Exchange/Assembler.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Network/BitTorrent/Exchange/Assembler.hs') diff --git a/src/Network/BitTorrent/Exchange/Assembler.hs b/src/Network/BitTorrent/Exchange/Assembler.hs index 5dc7c5ca..aa009f49 100644 --- a/src/Network/BitTorrent/Exchange/Assembler.hs +++ b/src/Network/BitTorrent/Exchange/Assembler.hs @@ -65,6 +65,7 @@ import Data.IntMap.Strict as IM import Data.List as L import Data.Map as M import Data.Maybe +import Data.IP import Data.Torrent.Piece import Network.BitTorrent.Core @@ -79,7 +80,7 @@ type PieceMap = IntMap data Assembler = Assembler { -- | A set of blocks that have been 'Request'ed but not yet acked. - _inflight :: Map PeerAddr (PieceMap [BlockRange]) + _inflight :: Map (PeerAddr IP) (PieceMap [BlockRange]) -- | A set of blocks that but not yet assembled. , _pending :: PieceMap Bucket @@ -114,7 +115,7 @@ allowPiece pix a @ Assembler {..} = over pending (IM.insert pix bkt) a where bkt = B.empty (piPieceLength info) -allowedSet :: PeerAddr -> Assembler -> [BlockIx] +allowedSet :: (PeerAddr IP) -> Assembler -> [BlockIx] allowedSet = undefined --inflight :: PeerAddr -> BlockIx -> Assembler -> Assembler @@ -123,7 +124,7 @@ allowedSet = undefined -- You should check if a returned by peer block is actually have -- been requested and in-flight. This is needed to avoid "I send -- random corrupted block" attacks. -insert :: PeerAddr -> Block a -> Assembler -> Assembler +insert :: (PeerAddr IP) -> Block a -> Assembler -> Assembler insert = undefined {- @@ -156,4 +157,4 @@ inserta :: Block a -> (PieceMap [Block a], Maybe (Piece a)) inserta = undefined --} \ No newline at end of file +-} -- cgit v1.2.3