diff --git a/src/Hash2Pub/Main.hs b/src/Hash2Pub/Main.hs index f1e6b29..3fa5d47 100644 --- a/src/Hash2Pub/Main.hs +++ b/src/Hash2Pub/Main.hs @@ -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