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) destAddr <- addrAddress <$> resolve (Just dest) (Just destPort)
sendSock <- socket AF_INET6 Datagram defaultProtocol sendSock <- socket AF_INET6 Datagram defaultProtocol
setSocketOption sendSock IPv6Only 1 setSocketOption sendSock IPv6Only 1
connect sendSock destAddr
pure sendSock pure sendSock

View file

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

View file

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

View file

@ -18,15 +18,17 @@ main = do
-- currently no masking is necessary, as there is nothing to clean up -- currently no masking is necessary, as there is nothing to clean up
cacheWriterThread <- forkIO $ cacheWriter thisNode cacheWriterThread <- forkIO $ cacheWriter thisNode
-- idea: list of bootstrapping nodes, try joining within a timeout -- idea: list of bootstrapping nodes, try joining within a timeout
joinedState <- fediChordJoin thisNode $ head . confBootstrapNodes $ conf
-- stop main thread from terminating during development -- stop main thread from terminating during development
getChar getChar
pure () pure ()
readConfig :: IO FediChordConf readConfig :: IO FediChordConf
readConfig = do readConfig = do
confDomainString : ipString : portString : _ <- getArgs confDomainString : ipString : portString : bootstrapHost : bootstrapPortString : _ <- getArgs
pure $ FediChordConf { pure $ FediChordConf {
confDomain = confDomainString confDomain = confDomainString
, confIP = toHostAddress6 . read $ ipString , confIP = toHostAddress6 . read $ ipString
, confDhtPort = read portString , confDhtPort = read portString
, confBootstrapNodes = [(bootstrapHost, read bootstrapPortString)]
} }