preliminary passing of bootstrap nodes in Main to fediChordJoin

This commit is contained in:
Trolli Schmittlauch 2020-05-26 09:38:38 +02:00
parent ad1465c5fe
commit 43eb04dfea
4 changed files with 9 additions and 4 deletions

View file

@ -334,4 +334,5 @@ mkSendSocket dest destPort = do
destAddr <- addrAddress <$> resolve (Just dest) (Just destPort)
sendSock <- socket AF_INET6 Datagram defaultProtocol
setSocketOption sendSock IPv6Only 1
connect sendSock destAddr
pure sendSock

View file

@ -37,6 +37,7 @@ module Hash2Pub.FediChord (
, bsAsIpAddr
, FediChordConf(..)
, fediChordInit
, fediChordJoin
, nodeStateInit
, mkServerSocket
, mkSendSocket

View file

@ -422,6 +422,7 @@ data FediChordConf = FediChordConf
{ confDomain :: String
, confIP :: HostAddress6
, confDhtPort :: Int
, confBootstrapNodes :: [(String, PortNumber)]
}
deriving (Show, Eq)

View file

@ -18,15 +18,17 @@ main = do
-- 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 <- fediChordJoin thisNode $ head . confBootstrapNodes $ conf
-- stop main thread from terminating during development
getChar
pure ()
readConfig :: IO FediChordConf
readConfig = do
confDomainString : ipString : portString : _ <- getArgs
confDomainString : ipString : portString : bootstrapHost : bootstrapPortString : _ <- getArgs
pure $ FediChordConf {
confDomain = confDomainString
, confIP = toHostAddress6 . read $ ipString
, confDhtPort = read portString
, confBootstrapNodes = [(bootstrapHost, read bootstrapPortString)]
}