diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-05-05 02:57:06 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-05-05 02:57:06 +0400 |
commit | 9b6024c9e3eca884d897bd6a3f033ea5648f7df2 (patch) | |
tree | 89c4354cade8ea71ea281a0089b11820a03fea1d /src | |
parent | bf3005952658130aaa83d8e8678c6ea7b36e45cb (diff) |
+ Add some benchs.
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Message.hs | 3 | ||||
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Selection.hs | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Message.hs b/src/Network/BitTorrent/PeerWire/Message.hs index 188f0572..cc771966 100644 --- a/src/Network/BitTorrent/PeerWire/Message.hs +++ b/src/Network/BitTorrent/PeerWire/Message.hs | |||
@@ -12,6 +12,7 @@ import Data.Serialize | |||
12 | import Network.BitTorrent.PeerWire.Block | 12 | import Network.BitTorrent.PeerWire.Block |
13 | import Network.BitTorrent.PeerWire.Bitfield | 13 | import Network.BitTorrent.PeerWire.Bitfield |
14 | 14 | ||
15 | import Data.Array | ||
15 | 16 | ||
16 | -- | Messages used in communication between peers. | 17 | -- | Messages used in communication between peers. |
17 | -- | 18 | -- |
@@ -78,7 +79,7 @@ data Message = KeepAlive | |||
78 | instance Serialize Message where | 79 | instance Serialize Message where |
79 | get = do | 80 | get = do |
80 | len <- getInt | 81 | len <- getInt |
81 | _ <- lookAhead $ ensure len | 82 | -- _ <- lookAhead $ ensure len |
82 | if len == 0 then return KeepAlive | 83 | if len == 0 then return KeepAlive |
83 | else do | 84 | else do |
84 | mid <- getWord8 | 85 | mid <- getWord8 |
diff --git a/src/Network/BitTorrent/PeerWire/Selection.hs b/src/Network/BitTorrent/PeerWire/Selection.hs index 04049812..2e412e06 100644 --- a/src/Network/BitTorrent/PeerWire/Selection.hs +++ b/src/Network/BitTorrent/PeerWire/Selection.hs | |||
@@ -23,7 +23,8 @@ | |||
23 | -- | 23 | -- |
24 | module Network.BitTorrent.PeerWire.Selection | 24 | module Network.BitTorrent.PeerWire.Selection |
25 | ( Selector | 25 | ( Selector |
26 | , strictFirst, rarestFirst, randomFirst, endGame, autoSelector | 26 | , strictFirst, strictLast |
27 | , rarestFirst, randomFirst, endGame, autoSelector | ||
27 | ) where | 28 | ) where |
28 | 29 | ||
29 | import Network.BitTorrent.PeerWire.Block | 30 | import Network.BitTorrent.PeerWire.Block |
@@ -41,6 +42,9 @@ type Selector = Bitfield -- ^ Indices of client "have" pieces. | |||
41 | strictFirst :: Selector | 42 | strictFirst :: Selector |
42 | strictFirst h a _ = findMin (difference a h) | 43 | strictFirst h a _ = findMin (difference a h) |
43 | 44 | ||
45 | -- | Select the last available piece. | ||
46 | strictLast :: Selector | ||
47 | strictLast h a _ = findMax (difference a h) | ||
44 | 48 | ||
45 | -- | | 49 | -- | |
46 | rarestFirst :: Selector | 50 | rarestFirst :: Selector |