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
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