try all bootstrap nodes until successfully joined

This commit is contained in:
Trolli Schmittlauch 2020-05-26 20:54:02 +02:00
parent 702684b1a9
commit b1c5c5e5f4

View file

@ -17,12 +17,20 @@ main = do
print serverSock
-- currently no masking is necessary, as there is nothing to clean up
cacheWriterThread <- forkIO $ cacheWriter thisNode
-- idea: list of bootstrapping nodes, try joining within a timeout
joinedState <- fediChordBootstrapJoin thisNode $ head . confBootstrapNodes $ conf
-- try joining the DHT using one of the provided bootstrapping nodes
let
tryJoining (bn:bns) = do
j <- fediChordBootstrapJoin thisNode bn
case j of
Left _ -> tryJoining bns
Right joined -> pure $ Right joined
tryJoining [] = pure $ Left "Exhausted all bootstrap points for joining."
joinedState <- tryJoining $ confBootstrapNodes conf
-- stop main thread from terminating during development
getChar
pure ()
readConfig :: IO FediChordConf
readConfig = do
confDomainString : ipString : portString : bootstrapHost : bootstrapPortString : _ <- getArgs