diff options
author | Joe Crayne <joe@jerkface.net> | 2018-12-17 00:47:42 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-12-17 00:47:42 -0500 |
commit | 37eb345d1ffb40e814766b6df8134ca21e6987a7 (patch) | |
tree | b915748ce6806af9a88ce1115cedcdb7bdaa22ba /OnionRouter.hs | |
parent | 7dcd6ce16ce480791e4207e2c6d554a76fe75d6e (diff) |
tcp: this seems to work.
Diffstat (limited to 'OnionRouter.hs')
-rw-r--r-- | OnionRouter.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/OnionRouter.hs b/OnionRouter.hs index 018a6314..0bbcd20d 100644 --- a/OnionRouter.hs +++ b/OnionRouter.hs | |||
@@ -79,7 +79,7 @@ data OnionRouter = OnionRouter | |||
79 | -- discarded and replaced with a fresh one. | 79 | -- discarded and replaced with a fresh one. |
80 | , pendingRoutes :: TArray Int Int | 80 | , pendingRoutes :: TArray Int Int |
81 | -- | Parameters used to implement Kademlia for TCP relays. | 81 | -- | Parameters used to implement Kademlia for TCP relays. |
82 | , tcpKademliaClient :: TCP.TCPClient String () Nonce8 | 82 | , tcpKademliaClient :: TCP.TCPClient String Nonce8 |
83 | -- | This thread maintains the TCP relay table. | 83 | -- | This thread maintains the TCP relay table. |
84 | , tcpKademliaThread :: ThreadId | 84 | , tcpKademliaThread :: ThreadId |
85 | , tcpProber :: TCP.TCPProber | 85 | , tcpProber :: TCP.TCPProber |
@@ -275,7 +275,7 @@ updateTCP or addr x = | |||
275 | selectGateway :: TVar (R.BucketList TCP.NodeInfo) -> NodeInfo -> STM (Maybe TCP.NodeInfo) | 275 | selectGateway :: TVar (R.BucketList TCP.NodeInfo) -> NodeInfo -> STM (Maybe TCP.NodeInfo) |
276 | selectGateway tbl ni = do | 276 | selectGateway tbl ni = do |
277 | ns <- kclosest TCP.tcpSpace 2 (nodeId ni) <$> readTVar tbl | 277 | ns <- kclosest TCP.tcpSpace 2 (nodeId ni) <$> readTVar tbl |
278 | return $ listToMaybe $ dropWhile (\n -> TCP.nodeId n == nodeId ni) ns | 278 | return $ listToMaybe ns -- $ dropWhile (\n -> TCP.nodeId n == nodeId ni) ns |
279 | 279 | ||
280 | quitRouteBuilder :: OnionRouter -> IO () | 280 | quitRouteBuilder :: OnionRouter -> IO () |
281 | quitRouteBuilder or = do | 281 | quitRouteBuilder or = do |
@@ -473,7 +473,7 @@ handleEvent getnodes or e@(BuildRoute (RouteId rid)) = do | |||
473 | forkIO $ sendq csel cq 2 >>= atomically . writeTVar cv . Just | 473 | forkIO $ sendq csel cq 2 >>= atomically . writeTVar cv . Just |
474 | -- This timeout should be unnecessary... But I'm paranoid. | 474 | -- This timeout should be unnecessary... But I'm paranoid. |
475 | -- Note: 10 seconds should be sufficient for typical get-nodes queries. | 475 | -- Note: 10 seconds should be sufficient for typical get-nodes queries. |
476 | tm <- timeout 20000000 $ atomically $ do -- Wait for all 3 results. | 476 | tm <- timeout 30000000 $ atomically $ do -- Wait for all 3 results. |
477 | rs <- catMaybes <$> sequence [readTVar av,readTVar bv,readTVar cv] | 477 | rs <- catMaybes <$> sequence [readTVar av,readTVar bv,readTVar cv] |
478 | case rs of [_,_,_] -> do | 478 | case rs of [_,_,_] -> do |
479 | return $ catMaybes $ rs | 479 | return $ catMaybes $ rs |