Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/cli/src/Cardano/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Cardano.CLI
, stateDirOption
, syncToleranceOption
, tlsOption
, smashURLOption
, poolMetadataSourceOption
, metadataOption

-- * Option parsers for configuring tracing
Expand Down Expand Up @@ -1318,15 +1318,17 @@ 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, \
\ <SMASH-URL>."
<> metavar "( none | direct | SMASH-URL )"
<> 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. 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
Expand Down
7 changes: 4 additions & 3 deletions lib/cli/test/unit/Cardano/CLISpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Cardano.CLI
, hGetLine
, hGetSensitiveLine
, metadataOption
, smashURLOption
, poolMetadataSourceOption
)
import Cardano.Wallet.Api.Client
( addressClient
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/shelley/exe/cardano-wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import Cardano.CLI
, loggingOptions
, loggingSeverityOrOffReader
, loggingTracers
, poolMetadataSourceOption
, runCli
, setupDirectory
, shutdownHandlerFlag
, smashURLOption
, syncToleranceOption
, tlsOption
, withLogging
Expand Down Expand Up @@ -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)

Expand All @@ -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 ()
Expand All @@ -208,7 +208,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty
databaseDir
sTolerance
enableShutdownHandler
smashURL
poolMetadataFetching
logOpt) = do
withTracers logOpt $ \tr tracers -> do
installSignalHandlers (logNotice tr MsgSigTerm)
Expand All @@ -232,7 +232,7 @@ cmdServe = command "serve" $ info (helper <*> helper' <*> cmd) $ mempty
host
listen
tlsConfig
(fmap Settings smashURL)
(fmap Settings poolMetadataFetching)
nodeSocket
block0
(gp, vData)
Expand Down