summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-20 06:16:25 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-20 06:16:25 +0400
commit24e337832cb4e9fd102cba981d308759487335ea (patch)
treefc23acd8e4f7a0f9b44950ab402ef80f8a90a01e /src
parent0dc9a3a103189a99c60e8f8cad3ef3a8eb47e7db (diff)
Allow to pass infohash to findNodeQ
Diffstat (limited to 'src')
-rw-r--r--src/Network/BitTorrent/DHT/Query.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/DHT/Query.hs b/src/Network/BitTorrent/DHT/Query.hs
index 4ba88b46..48dfc15a 100644
--- a/src/Network/BitTorrent/DHT/Query.hs
+++ b/src/Network/BitTorrent/DHT/Query.hs
@@ -119,10 +119,12 @@ pingQ addr = do
119 (nid, Ping) <- queryNode addr Ping 119 (nid, Ping) <- queryNode addr Ping
120 return (NodeInfo nid addr) 120 return (NodeInfo nid addr)
121 121
122-- TODO match with expected node id 122-- TODO [robustness] match range of returned node ids with the
123findNodeQ :: Address ip => NodeId -> Iteration ip NodeInfo 123-- expected range and either filter bad nodes or discard response at
124findNodeQ nid NodeInfo {..} = do 124-- all throwing an exception
125 NodeFound closest <- FindNode nid <@> nodeAddr 125findNodeQ :: Address ip => TableKey key => key -> Iteration ip NodeInfo
126findNodeQ key NodeInfo {..} = do
127 NodeFound closest <- FindNode (toNodeId key) <@> nodeAddr
126 return $ Right closest 128 return $ Right closest
127 129
128isLeft :: Either a b -> Bool 130isLeft :: Either a b -> Bool