From 8bd4e04bcd5736c5cd80010536c181a77024282c Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Wed, 7 Oct 2020 15:50:44 +0200 Subject: [PATCH] bootstrapQueryId doesn't need a STM'd node state --- src/Hash2Pub/FediChord.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Hash2Pub/FediChord.hs b/src/Hash2Pub/FediChord.hs index 4936e7c..8c13a0d 100644 --- a/src/Hash2Pub/FediChord.hs +++ b/src/Hash2Pub/FediChord.hs @@ -267,7 +267,7 @@ kChoicesVsJoin queryVsSTM bootstrapNode capacity activeVss nodeSTM remainingTarg -- if bootstrap node is provided, do initial lookup via that currentlyResponsible <- maybe (requestQueryID queryVs vsNid) - (\bs -> bootstrapQueryId queryVsSTM bs vsNid) + (\bs -> bootstrapQueryId queryVs bs vsNid) bootstrapNode segment <- requestQueryLoad queryVs vsNid currentlyResponsible pure $ Just (segment, vsId, currentlyResponsible) @@ -362,7 +362,7 @@ fediChordBootstrapJoin nsSTM bootstrapNode = do ns <- readTVarIO nsSTM runExceptT $ do -- 1. get routed to the currently responsible node - currentlyResponsible <- bootstrapQueryId nsSTM bootstrapNode $ getNid ns + currentlyResponsible <- bootstrapQueryId ns bootstrapNode $ getNid ns liftIO . putStrLn $ "Trying to join on " <> show (getNid currentlyResponsible) -- 2. then send a join to the currently responsible node liftIO $ putStrLn "send a bootstrap Join" @@ -384,7 +384,7 @@ convergenceSampleThread nodeSTM = forever $ do let bss = bootstrapNodes parentNode randIndex <- liftIO $ randomRIO (0, length bss - 1) chosenNode <- maybe (throwError "invalid bootstrapping node index") pure $ atMay bss randIndex - currentlyResponsible <- bootstrapQueryId nsSTM chosenNode (getNid nsSnap) + currentlyResponsible <- bootstrapQueryId nsSnap chosenNode (getNid nsSnap) if getNid currentlyResponsible /= getNid nsSnap -- if mismatch, stabilise on the result, else do nothing then do @@ -435,12 +435,11 @@ tryBootstrapJoining nodeSTM = do -- | Look up a key just based on the responses of a single bootstrapping node. bootstrapQueryId :: (MonadError String m, MonadIO m, Service s (RealNodeSTM s)) - => LocalNodeStateSTM s + => LocalNodeState s -> (String, PortNumber) -> NodeID -> m RemoteNodeState -bootstrapQueryId nsSTM (bootstrapHost, bootstrapPort) targetID = do - ns <- liftIO $ readTVarIO nsSTM +bootstrapQueryId ns (bootstrapHost, bootstrapPort) targetID = do nodeConf <- nodeConfig <$> liftIO (readTVarIO $ parentRealNode ns) let srcAddr = confIP nodeConf -- IP address needed for ID generation, so look it up