From 25fcecb3b5b62d14493d058bd67077e686acef19 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Wed, 14 Oct 2020 12:40:02 +1000 Subject: [PATCH 1/4] Revise help text for pool metadata source CLI option Noticed while reviewing input-output-hk/cardano-launcher#90. - Fix variable names to reflect the new option - Add more detail to CLI help text --- lib/cli/src/Cardano/CLI.hs | 17 +++++++++-------- lib/cli/test/unit/Cardano/CLISpec.hs | 7 ++++--- lib/shelley/exe/cardano-wallet.hs | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/cli/src/Cardano/CLI.hs b/lib/cli/src/Cardano/CLI.hs index 6f2f4aa205a..7b1bb711dc5 100644 --- a/lib/cli/src/Cardano/CLI.hs +++ b/lib/cli/src/Cardano/CLI.hs @@ -53,7 +53,7 @@ module Cardano.CLI , stateDirOption , syncToleranceOption , tlsOption - , smashURLOption + , poolMetadataSourceOption , metadataOption -- * Option parsers for configuring tracing @@ -1318,15 +1318,16 @@ tlsOption = TlsConfiguration <> metavar "FILE" <> help "The RSA Server key which signed the x.509 server certificate." -smashURLOption +poolMetadataSourceOption :: Parser PoolMetadataSource -smashURLOption = option (eitherReader reader) $ mempty +poolMetadataSourceOption = option (eitherReader reader) $ mempty <> long "pool-metadata-fetching" - <> metavar "STRATEGY" - <> help "Pool Metadata fetching strategy. This setting will persist across restarts. Possible values: \ - \ none, \ - \ direct, \ - \ ." + <> metavar "( none | direct | SMASH-URL )" + <> help ("Stake pool metadata fetching strategy. " + <> "Provide a URL to specify a SMASH metadata proxy server, " + <> "use \"direct\" to fetch directly from the registered pool URLs," + <> " or \"none\" to completely disable stake pool metadata. " + <> "This setting will persist across restarts.") where reader :: String -> Either String PoolMetadataSource reader = left (const err) . fromTextS @PoolMetadataSource diff --git a/lib/cli/test/unit/Cardano/CLISpec.hs b/lib/cli/test/unit/Cardano/CLISpec.hs index c5d4000217e..53edd730956 100644 --- a/lib/cli/test/unit/Cardano/CLISpec.hs +++ b/lib/cli/test/unit/Cardano/CLISpec.hs @@ -29,7 +29,7 @@ import Cardano.CLI , hGetLine , hGetSensitiveLine , metadataOption - , smashURLOption + , poolMetadataSourceOption ) import Cardano.Wallet.Api.Client ( addressClient @@ -648,9 +648,10 @@ spec = do , expectedResult = "pata14" :: Text } - describe "SMASH URL option" $ do + describe "Pool metadata fetching option" $ do let parse arg = execParserPure defaultPrefs - (info smashURLOption mempty) ["--pool-metadata-fetching", arg] + (info poolMetadataSourceOption mempty) + ["--pool-metadata-fetching", arg] let ok arg (Success url) = Right url == fromText @PoolMetadataSource (T.pack arg) ok _ _ = False diff --git a/lib/shelley/exe/cardano-wallet.hs b/lib/shelley/exe/cardano-wallet.hs index c8dd52bf6e8..8ae1c9247ca 100644 --- a/lib/shelley/exe/cardano-wallet.hs +++ b/lib/shelley/exe/cardano-wallet.hs @@ -51,10 +51,10 @@ import Cardano.CLI , loggingOptions , loggingSeverityOrOffReader , loggingTracers + , poolMetadataSourceOption , runCli , setupDirectory , shutdownHandlerFlag - , smashURLOption , syncToleranceOption , tlsOption , withLogging @@ -195,7 +195,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty <*> optional databaseOption <*> syncToleranceOption <*> shutdownHandlerFlag - <*> optional smashURLOption + <*> optional poolMetadataSourceOption <*> loggingOptions tracerSeveritiesOption exec :: ServeArgs -> IO () From add10eaa63f3c96d65907d903611ec6a901cd7c2 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Fri, 16 Oct 2020 15:36:48 +1000 Subject: [PATCH 2/4] Enhance wording of --pool-metadata-fetching help --- lib/cli/src/Cardano/CLI.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cli/src/Cardano/CLI.hs b/lib/cli/src/Cardano/CLI.hs index 7b1bb711dc5..48b6cc38f5d 100644 --- a/lib/cli/src/Cardano/CLI.hs +++ b/lib/cli/src/Cardano/CLI.hs @@ -1323,11 +1323,12 @@ poolMetadataSourceOption poolMetadataSourceOption = option (eitherReader reader) $ mempty <> long "pool-metadata-fetching" <> metavar "( none | direct | SMASH-URL )" - <> help ("Stake pool metadata fetching strategy. " + <> help ("Sets the stake pool metadata fetching strategy. " <> "Provide a URL to specify a SMASH metadata proxy server, " <> "use \"direct\" to fetch directly from the registered pool URLs," - <> " or \"none\" to completely disable stake pool metadata. " - <> "This setting will persist across restarts.") + <> " or \"none\" to completely disable stake pool" + <> " metadata. The initial setting is \"none\" and changes by" + <> " either this option or the API will persist across restarts.") where reader :: String -> Either String PoolMetadataSource reader = left (const err) . fromTextS @PoolMetadataSource From 25bfad7d169fd9864124c80a74d2b90799823688 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Fri, 16 Oct 2020 15:38:53 +1000 Subject: [PATCH 3/4] Rename more smashURL variables --- lib/shelley/exe/cardano-wallet.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/shelley/exe/cardano-wallet.hs b/lib/shelley/exe/cardano-wallet.hs index 8ae1c9247ca..6206f452993 100644 --- a/lib/shelley/exe/cardano-wallet.hs +++ b/lib/shelley/exe/cardano-wallet.hs @@ -175,7 +175,7 @@ data ServeArgs = ServeArgs , _database :: Maybe FilePath , _syncTolerance :: SyncTolerance , _enableShutdownHandler :: Bool - , _smashOpt :: Maybe PoolMetadataSource + , _poolMetadataSourceOpt :: Maybe PoolMetadataSource , _logging :: LoggingOptions TracerSeverities } deriving (Show) @@ -208,7 +208,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty databaseDir sTolerance enableShutdownHandler - smashURL + poolMetadataSource logOpt) = do withTracers logOpt $ \tr tracers -> do installSignalHandlers (logNotice tr MsgSigTerm) @@ -232,7 +232,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty host listen tlsConfig - (fmap Settings smashURL) + (fmap Settings poolMetadataSource) nodeSocket block0 (gp, vData) From ab496a58d63640762c13a8908eabd35822cf65d5 Mon Sep 17 00:00:00 2001 From: Rodney Lorrimar Date: Fri, 16 Oct 2020 22:45:40 +1000 Subject: [PATCH 4/4] Fix name shadowing warning --- lib/shelley/exe/cardano-wallet.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shelley/exe/cardano-wallet.hs b/lib/shelley/exe/cardano-wallet.hs index 6206f452993..85de90718b9 100644 --- a/lib/shelley/exe/cardano-wallet.hs +++ b/lib/shelley/exe/cardano-wallet.hs @@ -208,7 +208,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty databaseDir sTolerance enableShutdownHandler - poolMetadataSource + poolMetadataFetching logOpt) = do withTracers logOpt $ \tr tracers -> do installSignalHandlers (logNotice tr MsgSigTerm) @@ -232,7 +232,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty host listen tlsConfig - (fmap Settings poolMetadataSource) + (fmap Settings poolMetadataFetching) nodeSocket block0 (gp, vData)