mirror of https://github.com/voidlizard/hbs2
Add `known-peers-file` config option
This commit is contained in:
parent
eaa4f38989
commit
02be353096
|
@ -46,6 +46,11 @@ data PeerDownloadLogKey
|
||||||
instance HasCfgKey PeerDownloadLogKey (Maybe String) where
|
instance HasCfgKey PeerDownloadLogKey (Maybe String) where
|
||||||
key = "download-log"
|
key = "download-log"
|
||||||
|
|
||||||
|
data PeerKnownPeersFile
|
||||||
|
|
||||||
|
instance HasCfgKey PeerKnownPeersFile [String] where
|
||||||
|
key = "known-peers-file"
|
||||||
|
|
||||||
cfgName :: FilePath
|
cfgName :: FilePath
|
||||||
cfgName = "config"
|
cfgName = "config"
|
||||||
|
|
||||||
|
@ -128,7 +133,11 @@ peerConfigRead mbfp = do
|
||||||
|
|
||||||
confData' <- liftIO $ readFile cfgPath <&> parseTop <&> either mempty id
|
confData' <- liftIO $ readFile cfgPath <&> parseTop <&> either mempty id
|
||||||
|
|
||||||
let confData = confData' <> either mempty id (parseTop peerConfDef)
|
knownPeersFiles <- mapM (liftIO . canonicalizePath . (dir </>)) (cfgValue @PeerKnownPeersFile $ PeerConfig confData')
|
||||||
|
|
||||||
|
knownPeersConfData <- concat <$> mapM (\file -> liftIO $ readFile file <&> parseTop <&> either mempty id) knownPeersFiles
|
||||||
|
|
||||||
|
let confData = confData' <> either mempty id (parseTop peerConfDef) <> knownPeersConfData
|
||||||
|
|
||||||
-- debug $ pretty confData
|
-- debug $ pretty confData
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue