summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/DHT/Session.hs14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs
index 6c43c732..4e6a6825 100644
--- a/src/Network/BitTorrent/DHT/Session.hs
+++ b/src/Network/BitTorrent/DHT/Session.hs
@@ -333,23 +333,13 @@ queryNode :: forall a b ip. Address ip => KRPC (Query a) (Response b)
333 => NodeAddr ip -> a -> DHT ip b 333 => NodeAddr ip -> a -> DHT ip b
334queryNode addr q = do 334queryNode addr q = do
335 nid <- getNodeId 335 nid <- getNodeId
336 336 -- TODO remove timeout: KRPC already keep track timeouts
337 let Method name = method :: Method (Query a) (Response b)
338 let signature = T.decodeUtf8 name <> " @ " <> T.pack (render (pretty addr))
339 $(logDebugS) "queryNode" $ "Query sent | " <> signature
340
341 interval <- asks (optTimeout . options) 337 interval <- asks (optTimeout . options)
342 result <- timeout (microseconds interval) $ do 338 result <- timeout (microseconds interval) $ do
343 query (toSockAddr addr) (Query nid q) 339 query (toSockAddr addr) (Query nid q)
344 case result of 340 case result of
345 Nothing -> do 341 Nothing -> ioError $ userError "timeout expired"
346 $(logWarnS) "queryNode" $ "not responding @ "
347 <> T.pack (show (pretty addr)) <> " for "
348 <> T.pack (show interval)
349 ioError $ userError "timeout expired"
350
351 Just (Response remoteId r) -> do 342 Just (Response remoteId r) -> do
352 $(logDebugS) "queryNode" $ "Query recv | " <> signature
353 insertNode (NodeInfo remoteId addr) 343 insertNode (NodeInfo remoteId addr)
354 return r 344 return r
355 345