From b1c5c5e5f4360801e667923347a19b9d5c7dac85 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Tue, 26 May 2020 20:54:02 +0200 Subject: [PATCH] try all bootstrap nodes until successfully joined --- src/Hash2Pub/Main.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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