preliminary passing of bootstrap nodes in Main to fediChordJoin
This commit is contained in:
parent
ad1465c5fe
commit
43eb04dfea
|
@ -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
|
||||||
|
|
|
@ -37,6 +37,7 @@ module Hash2Pub.FediChord (
|
||||||
, bsAsIpAddr
|
, bsAsIpAddr
|
||||||
, FediChordConf(..)
|
, FediChordConf(..)
|
||||||
, fediChordInit
|
, fediChordInit
|
||||||
|
, fediChordJoin
|
||||||
, nodeStateInit
|
, nodeStateInit
|
||||||
, mkServerSocket
|
, mkServerSocket
|
||||||
, mkSendSocket
|
, mkSendSocket
|
||||||
|
|
|
@ -419,9 +419,10 @@ byteStringToUInteger bs = sum $ parsedBytes 0 bs
|
||||||
|
|
||||||
-- | configuration values used for initialising the FediChord DHT
|
-- | configuration values used for initialising the FediChord DHT
|
||||||
data FediChordConf = FediChordConf
|
data FediChordConf = FediChordConf
|
||||||
{ confDomain :: String
|
{ confDomain :: String
|
||||||
, confIP :: HostAddress6
|
, confIP :: HostAddress6
|
||||||
, confDhtPort :: Int
|
, confDhtPort :: Int
|
||||||
|
, confBootstrapNodes :: [(String, PortNumber)]
|
||||||
}
|
}
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
|
|
@ -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)]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue