summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-02-01 15:27:34 -0500
committerjoe <joe@jerkface.net>2017-02-01 15:27:34 -0500
commit713cee07450697e40811e74059739da02dd604c7 (patch)
treec30014b323d207f2b9aaf07ca819dc1ad7e31f30 /src
parent38c23ccf93a7715babc2f99b2b98acd695159aca (diff)
Show peers as soon as they're found.
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index 39ef9604..5345f8b1 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -209,13 +209,17 @@ ioFindNode ih = do
209isearch :: (Ord r, Ord ip) => 209isearch :: (Ord r, Ord ip) =>
210 (InfoHash -> DHT ip (NodeInfo ip -> IO ([NodeInfo ip], [r]))) 210 (InfoHash -> DHT ip (NodeInfo ip -> IO ([NodeInfo ip], [r])))
211 -> InfoHash 211 -> InfoHash
212 -> DHT ip (Set r) 212 -> DHT ip (ThreadId, Search.IterativeSearch ip r)
213isearch f ih = do 213isearch f ih = do
214 qry <- f ih 214 qry <- f ih
215 ns <- kclosest 8 ih <$> getTable 215 ns <- kclosest 8 ih <$> getTable
216 liftIO $ do s <- Search.newSearch qry (toNodeId ih) ns 216 liftIO $ do s <- Search.newSearch qry (toNodeId ih) ns
217 Search.search s 217 a <- fork $ do
218 atomically $ readTVar (Search.searchResults s) 218 tid <- myThreadId
219 labelThread tid ("search."++show ih)
220 Search.search s
221 -- atomically $ readTVar (Search.searchResults s)
222 return (a, s)
219 223
220 224
221type Search ip o = Conduit [NodeInfo ip] (DHT ip) [o ip] 225type Search ip o = Conduit [NodeInfo ip] (DHT ip) [o ip]