diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-14 23:26:21 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-14 23:26:21 +0400 |
commit | 254a407eafe53d7d98b55a694b840f1af6fe5e75 (patch) | |
tree | 9464626052e0f05ce7e9d8b6fba147ce033d4498 /src/Network/BitTorrent/Exchange/Assembler.hs | |
parent | c7d84e12184430062305d1d4677a90df558484ea (diff) | |
parent | 8e4419d5bf7880ac862675dc4105cf6503c488bc (diff) |
Merge branch 'dev' of https://github.com/DanielG/bittorrent
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Assembler.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Assembler.hs | 9 |
1 files changed, 5 insertions, 4 deletions
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 | |||
65 | import Data.List as L | 65 | import Data.List as L |
66 | import Data.Map as M | 66 | import Data.Map as M |
67 | import Data.Maybe | 67 | import Data.Maybe |
68 | import Data.IP | ||
68 | 69 | ||
69 | import Data.Torrent.Piece | 70 | import Data.Torrent.Piece |
70 | import Network.BitTorrent.Core | 71 | import Network.BitTorrent.Core |
@@ -79,7 +80,7 @@ type PieceMap = IntMap | |||
79 | 80 | ||
80 | data Assembler = Assembler | 81 | data Assembler = Assembler |
81 | { -- | A set of blocks that have been 'Request'ed but not yet acked. | 82 | { -- | A set of blocks that have been 'Request'ed but not yet acked. |
82 | _inflight :: Map PeerAddr (PieceMap [BlockRange]) | 83 | _inflight :: Map (PeerAddr IP) (PieceMap [BlockRange]) |
83 | 84 | ||
84 | -- | A set of blocks that but not yet assembled. | 85 | -- | A set of blocks that but not yet assembled. |
85 | , _pending :: PieceMap Bucket | 86 | , _pending :: PieceMap Bucket |
@@ -114,7 +115,7 @@ allowPiece pix a @ Assembler {..} = over pending (IM.insert pix bkt) a | |||
114 | where | 115 | where |
115 | bkt = B.empty (piPieceLength info) | 116 | bkt = B.empty (piPieceLength info) |
116 | 117 | ||
117 | allowedSet :: PeerAddr -> Assembler -> [BlockIx] | 118 | allowedSet :: (PeerAddr IP) -> Assembler -> [BlockIx] |
118 | allowedSet = undefined | 119 | allowedSet = undefined |
119 | 120 | ||
120 | --inflight :: PeerAddr -> BlockIx -> Assembler -> Assembler | 121 | --inflight :: PeerAddr -> BlockIx -> Assembler -> Assembler |
@@ -123,7 +124,7 @@ allowedSet = undefined | |||
123 | -- You should check if a returned by peer block is actually have | 124 | -- You should check if a returned by peer block is actually have |
124 | -- been requested and in-flight. This is needed to avoid "I send | 125 | -- been requested and in-flight. This is needed to avoid "I send |
125 | -- random corrupted block" attacks. | 126 | -- random corrupted block" attacks. |
126 | insert :: PeerAddr -> Block a -> Assembler -> Assembler | 127 | insert :: (PeerAddr IP) -> Block a -> Assembler -> Assembler |
127 | insert = undefined | 128 | insert = undefined |
128 | 129 | ||
129 | {- | 130 | {- |
@@ -156,4 +157,4 @@ inserta :: Block a | |||
156 | -> (PieceMap [Block a], Maybe (Piece a)) | 157 | -> (PieceMap [Block a], Maybe (Piece a)) |
157 | inserta = undefined | 158 | inserta = undefined |
158 | 159 | ||
159 | -} \ No newline at end of file | 160 | -} |