bootstrapQueryId doesn't need a STM'd node state

This commit is contained in:
Trolli Schmittlauch 2020-10-07 15:50:44 +02:00
parent 0cb4b6815c
commit 8bd4e04bcd

View file

@ -267,7 +267,7 @@ kChoicesVsJoin queryVsSTM bootstrapNode capacity activeVss nodeSTM remainingTarg
-- if bootstrap node is provided, do initial lookup via that -- if bootstrap node is provided, do initial lookup via that
currentlyResponsible <- maybe currentlyResponsible <- maybe
(requestQueryID queryVs vsNid) (requestQueryID queryVs vsNid)
(\bs -> bootstrapQueryId queryVsSTM bs vsNid) (\bs -> bootstrapQueryId queryVs bs vsNid)
bootstrapNode bootstrapNode
segment <- requestQueryLoad queryVs vsNid currentlyResponsible segment <- requestQueryLoad queryVs vsNid currentlyResponsible
pure $ Just (segment, vsId, currentlyResponsible) pure $ Just (segment, vsId, currentlyResponsible)
@ -362,7 +362,7 @@ fediChordBootstrapJoin nsSTM bootstrapNode = do
ns <- readTVarIO nsSTM ns <- readTVarIO nsSTM
runExceptT $ do runExceptT $ do
-- 1. get routed to the currently responsible node -- 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) liftIO . putStrLn $ "Trying to join on " <> show (getNid currentlyResponsible)
-- 2. then send a join to the currently responsible node -- 2. then send a join to the currently responsible node
liftIO $ putStrLn "send a bootstrap Join" liftIO $ putStrLn "send a bootstrap Join"
@ -384,7 +384,7 @@ convergenceSampleThread nodeSTM = forever $ do
let bss = bootstrapNodes parentNode let bss = bootstrapNodes parentNode
randIndex <- liftIO $ randomRIO (0, length bss - 1) randIndex <- liftIO $ randomRIO (0, length bss - 1)
chosenNode <- maybe (throwError "invalid bootstrapping node index") pure $ atMay bss randIndex 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 getNid currentlyResponsible /= getNid nsSnap
-- if mismatch, stabilise on the result, else do nothing -- if mismatch, stabilise on the result, else do nothing
then do then do
@ -435,12 +435,11 @@ tryBootstrapJoining nodeSTM = do
-- | Look up a key just based on the responses of a single bootstrapping node. -- | Look up a key just based on the responses of a single bootstrapping node.
bootstrapQueryId :: (MonadError String m, MonadIO m, Service s (RealNodeSTM s)) bootstrapQueryId :: (MonadError String m, MonadIO m, Service s (RealNodeSTM s))
=> LocalNodeStateSTM s => LocalNodeState s
-> (String, PortNumber) -> (String, PortNumber)
-> NodeID -> NodeID
-> m RemoteNodeState -> m RemoteNodeState
bootstrapQueryId nsSTM (bootstrapHost, bootstrapPort) targetID = do bootstrapQueryId ns (bootstrapHost, bootstrapPort) targetID = do
ns <- liftIO $ readTVarIO nsSTM
nodeConf <- nodeConfig <$> liftIO (readTVarIO $ parentRealNode ns) nodeConf <- nodeConfig <$> liftIO (readTVarIO $ parentRealNode ns)
let srcAddr = confIP nodeConf let srcAddr = confIP nodeConf
-- IP address needed for ID generation, so look it up -- IP address needed for ID generation, so look it up