From 4ab1de695cb484f7859cb5d1794da5ce6510c0c2 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Thu, 28 Jun 2018 14:47:24 -0400 Subject: Move ready-route retry to happen earlier in OnionRouter STM. --- OnionRouter.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OnionRouter.hs b/OnionRouter.hs index 2391e13c..e3c32fbe 100644 --- a/OnionRouter.hs +++ b/OnionRouter.hs @@ -388,19 +388,19 @@ hookQueries :: OnionRouter -> (tid -> Nonce8) -> TransactionMethods d tid (OnionDestination RouteId) x hookQueries or t8 tmethods = TransactionMethods { dispatchRegister = \mvar od d -> {-# SCC "hookQ.dispatchRegister" #-} do -- :: MVar x -> d -> STM (tid, d) - (tid,d') <- dispatchRegister tmethods mvar od d - let Nonce8 w8 = t8 tid - ni = onionNodeInfo od + let ni = onionNodeInfo od rid@(RouteId ridn) = fromMaybe (routeId (nodeId ni)) $ onionRouteSpec od - od' = case od of - OnionDestination {} -> od { onionRouteSpec = Just rid } - OnionToOwner a b -> OnionToOwner a b -- Type cast. wanted <- {-# SCC "hookQ.wanted" #-} (readTVar (pendingRoutes or IntMap.! ridn)) mr <- {-# SCC "hookQ.mr_action" #-} (readArray (routeMap or) ridn) -- Block query until a route is ready. check $ fromMaybe False $ do RouteRecord{routeVersion=rv} <- {-# SCC "hookQ.mr" #-} mr return $ wanted <= rv + (tid,d') <- dispatchRegister tmethods mvar od d + let Nonce8 w8 = t8 tid + od' = case od of + OnionDestination {} -> od { onionRouteSpec = Just rid } + OnionToOwner a b -> OnionToOwner a b -- Type cast. let pq = PendingQuery { pendingDestination = od' , pendingVersion = maybe 0 routeVersion mr } -- cgit v1.2.3