From cadcfc38f15aa54b9785d690b72426bad7a9e264 Mon Sep 17 00:00:00 2001 From: Vladimir Krutkin Date: Thu, 2 Mar 2023 23:35:09 +0300 Subject: [PATCH] Refactoring --- hbs2-peer/app/PeerConfig.hs | 6 ++++-- hbs2-peer/app/PeerMain.hs | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hbs2-peer/app/PeerConfig.hs b/hbs2-peer/app/PeerConfig.hs index b7312810..9ca18af3 100644 --- a/hbs2-peer/app/PeerConfig.hs +++ b/hbs2-peer/app/PeerConfig.hs @@ -131,11 +131,13 @@ peerConfigRead mbfp = do debug $ pretty cfgPath - confData' <- liftIO $ readFile cfgPath <&> parseTop <&> either mempty id + let parseConf f = liftIO $ readFile f <&> parseTop <&> either mempty id + + confData' <- parseConf cfgPath knownPeersFiles <- mapM (liftIO . canonicalizePath . (dir )) (cfgValue @PeerKnownPeersFile $ PeerConfig confData') - knownPeersConfData <- concat <$> mapM (\file -> liftIO $ readFile file <&> parseTop <&> either mempty id) knownPeersFiles + knownPeersConfData <- concat <$> mapM parseConf knownPeersFiles let confData = confData' <> either mempty id (parseTop peerConfDef) <> knownPeersConfData diff --git a/hbs2-peer/app/PeerMain.hs b/hbs2-peer/app/PeerMain.hs index 148200e1..9233996c 100644 --- a/hbs2-peer/app/PeerMain.hs +++ b/hbs2-peer/app/PeerMain.hs @@ -116,7 +116,6 @@ instance HasCfgKey PeerBlackListKey (Set String) where instance HasCfgKey PeerAcceptAnnounceKey AcceptAnnounce where key = "accept-block-announce" - instance HasCfgValue PeerAcceptAnnounceKey AcceptAnnounce where cfgValue (PeerConfig syn) = fromMaybe (AcceptAnnounceFrom lst) fromAll where