diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-20 06:16:25 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-20 06:16:25 +0400 |
commit | 24e337832cb4e9fd102cba981d308759487335ea (patch) | |
tree | fc23acd8e4f7a0f9b44950ab402ef80f8a90a01e /src | |
parent | 0dc9a3a103189a99c60e8f8cad3ef3a8eb47e7db (diff) |
Allow to pass infohash to findNodeQ
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/DHT/Query.hs | 10 |
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 |
123 | findNodeQ :: Address ip => NodeId -> Iteration ip NodeInfo | 123 | -- expected range and either filter bad nodes or discard response at |
124 | findNodeQ nid NodeInfo {..} = do | 124 | -- all throwing an exception |
125 | NodeFound closest <- FindNode nid <@> nodeAddr | 125 | findNodeQ :: Address ip => TableKey key => key -> Iteration ip NodeInfo |
126 | findNodeQ key NodeInfo {..} = do | ||
127 | NodeFound closest <- FindNode (toNodeId key) <@> nodeAddr | ||
126 | return $ Right closest | 128 | return $ Right closest |
127 | 129 | ||
128 | isLeft :: Either a b -> Bool | 130 | isLeft :: Either a b -> Bool |