summaryrefslogtreecommitdiff
path: root/src/Network/Kademlia/Search.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-18 04:58:15 -0400
committerjoe <joe@jerkface.net>2018-06-18 04:58:15 -0400
commit2dbb1e710d6d58fc00126d84763ec3597d92437d (patch)
treeac9b3a9d13c1bd7f093492ab057175fe2c74fc2c /src/Network/Kademlia/Search.hs
parentbbefd12b49de18f0608d2c2a0cbc52cab4266349 (diff)
Use combined IPv6/IPv4 announce item for announcing toxid.
Diffstat (limited to 'src/Network/Kademlia/Search.hs')
-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