summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Network/Kademlia/Search.hs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Network/Kademlia/Search.hs b/src/Network/Kademlia/Search.hs
index b7d07f7c..29a8fc61 100644
--- a/src/Network/Kademlia/Search.hs
+++ b/src/Network/Kademlia/Search.hs
@@ -101,16 +101,15 @@ stripValue (Binding ni _ nid) = (ni :-> nid)
101 101
102-- | Reset a 'SearchState' object to ready it for a repeated search. 102-- | Reset a 'SearchState' object to ready it for a repeated search.
103reset :: (Ord ni, Ord nid, Hashable ni, Hashable nid) => 103reset :: (Ord ni, Ord nid, Hashable ni, Hashable nid) =>
104 TVar (BucketList ni) 104 (nid -> STM [ni])
105 -> Search nid addr1 tok1 ni r1 105 -> Search nid addr1 tok1 ni r1
106 -> nid 106 -> nid
107 -> SearchState nid addr tok ni r 107 -> SearchState nid addr tok ni r
108 -> STM (SearchState nid addr tok ni r) 108 -> STM (SearchState nid addr tok ni r)
109reset bkts qsearch target st = do 109reset nearestNodes qsearch target st = do
110 searchIsFinished st >>= check -- Wait for a search to finish before resetting. 110 searchIsFinished st >>= check -- Wait for a search to finish before resetting.
111 bktNodes <- map (\ni -> ni :-> kademliaLocation (searchSpace qsearch) ni) 111 bktNodes <- map (\ni -> ni :-> kademliaLocation (searchSpace qsearch) ni)
112 . R.kclosest (searchSpace qsearch) searchK target 112 <$> nearestNodes target
113 <$> readTVar bkts
114 priorInformants <- map stripValue . MM.toList <$> readTVar (searchInformant st) 113 priorInformants <- map stripValue . MM.toList <$> readTVar (searchInformant st)
115 writeTVar (searchQueued st) $ MM.fromList $ priorInformants ++ bktNodes 114 writeTVar (searchQueued st) $ MM.fromList $ priorInformants ++ bktNodes
116 writeTVar (searchInformant st) MM.empty 115 writeTVar (searchInformant st) MM.empty