diff options
author | joe <joe@jerkface.net> | 2017-07-20 00:01:29 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-07-20 00:01:29 -0400 |
commit | fbd053967c814697ad21fde2dc8e95f7a4683302 (patch) | |
tree | 5aa07550819aedb74c4a806bd4fc3147d5cb4da4 /src/Network/BitTorrent | |
parent | b3c832ebd86281bfaa4fe6bb88aaacacbed0eadc (diff) |
Update MinMaxPSQ to use HashPSQ.
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/DHT/Search.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Network/BitTorrent/DHT/Search.hs b/src/Network/BitTorrent/DHT/Search.hs index 356f6fd9..07240755 100644 --- a/src/Network/BitTorrent/DHT/Search.hs +++ b/src/Network/BitTorrent/DHT/Search.hs | |||
@@ -23,7 +23,7 @@ import System.IO | |||
23 | import qualified Data.MinMaxPSQ as MM | 23 | import qualified Data.MinMaxPSQ as MM |
24 | ;import Data.MinMaxPSQ (MinMaxPSQ) | 24 | ;import Data.MinMaxPSQ (MinMaxPSQ) |
25 | import qualified Data.Wrapper.PSQ as PSQ | 25 | import qualified Data.Wrapper.PSQ as PSQ |
26 | ;import Data.Wrapper.PSQ (pattern (:->), Binding, PSQ) | 26 | ;import Data.Wrapper.PSQ (pattern (:->), Binding, PSQ, PSQKey) |
27 | import Network.Address hiding (NodeId) | 27 | import Network.Address hiding (NodeId) |
28 | import Network.DatagramServer.Types | 28 | import Network.DatagramServer.Types |
29 | import Data.Bits | 29 | import Data.Bits |
@@ -39,7 +39,8 @@ data IterativeSearch dht u ip r = IterativeSearch | |||
39 | } | 39 | } |
40 | 40 | ||
41 | newSearch :: ( Eq ip | 41 | newSearch :: ( Eq ip |
42 | , Ord (NodeId dht) | 42 | , PSQKey (NodeId dht) |
43 | , PSQKey (NodeInfo dht ip u) | ||
43 | , FiniteBits (NodeId dht) | 44 | , FiniteBits (NodeId dht) |
44 | ) => (NodeInfo dht ip u -> IO ([NodeInfo dht ip u], [r])) | 45 | ) => (NodeInfo dht ip u -> IO ([NodeInfo dht ip u], [r])) |
45 | -> NodeId dht -> [NodeInfo dht ip u] -> IO (IterativeSearch dht u ip r) | 46 | -> NodeId dht -> [NodeInfo dht ip u] -> IO (IterativeSearch dht u ip r) |
@@ -60,7 +61,8 @@ searchK = 8 | |||
60 | sendQuery :: forall a ip dht u. | 61 | sendQuery :: forall a ip dht u. |
61 | ( Ord a | 62 | ( Ord a |
62 | , Ord ip | 63 | , Ord ip |
63 | , Ord (NodeId dht) | 64 | , PSQKey (NodeId dht) |
65 | , PSQKey (NodeInfo dht ip u) | ||
64 | , FiniteBits (NodeId dht) | 66 | , FiniteBits (NodeId dht) |
65 | ) => | 67 | ) => |
66 | IterativeSearch dht u ip a | 68 | IterativeSearch dht u ip a |
@@ -85,7 +87,8 @@ sendQuery IterativeSearch{..} (ni :-> d) = do | |||
85 | 87 | ||
86 | 88 | ||
87 | searchIsFinished :: ( Ord ip | 89 | searchIsFinished :: ( Ord ip |
88 | , Ord (NodeId dht) | 90 | , PSQKey (NodeId dht) |
91 | , PSQKey (NodeInfo dht ip u) | ||
89 | ) => IterativeSearch dht u ip r -> STM Bool | 92 | ) => IterativeSearch dht u ip r -> STM Bool |
90 | searchIsFinished IterativeSearch{..} = do | 93 | searchIsFinished IterativeSearch{..} = do |
91 | q <- readTVar searchQueued | 94 | q <- readTVar searchQueued |
@@ -98,7 +101,7 @@ searchIsFinished IterativeSearch{..} = do | |||
98 | <= PSQ.prio (fromJust $ MM.findMin q)))) | 101 | <= PSQ.prio (fromJust $ MM.findMin q)))) |
99 | 102 | ||
100 | search :: | 103 | search :: |
101 | (Ord r, Ord ip, Ord (NodeId dht), FiniteBits (NodeId dht)) => | 104 | (Ord r, Ord ip, PSQKey (NodeId dht), PSQKey (NodeInfo dht ip u), FiniteBits (NodeId dht)) => |
102 | IterativeSearch dht u ip r -> IO () | 105 | IterativeSearch dht u ip r -> IO () |
103 | search s@IterativeSearch{..} = withTaskGroup searchAlpha $ \g -> do | 106 | search s@IterativeSearch{..} = withTaskGroup searchAlpha $ \g -> do |
104 | fix $ \again -> do | 107 | fix $ \again -> do |