Skip to content

Commit

Permalink
Rename --cache-listpools-ttl to --cache-listpools-refresh
Browse files Browse the repository at this point in the history
and clarify its function
  • Loading branch information
HeinrichApfelmus committed Jan 17, 2022
1 parent 4f9d278 commit 4307659
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/contributing/Testing.md
Expand Up @@ -51,7 +51,7 @@ integration tests and test cluster.
| `NO_POOLS` | bool | Don't start any stake pool nodes in the local test cluster. | Pool nodes are started |
| `TOKEN_METADATA_SERVER` | URL | Use this URL for querying asset metadata | Asset metadata fetching disabled |
| `NO_CACHE_LISTPOOLS` | bool | Do not cache pool listing retrieved from cardano-node. *Testing only. Use `--no-cache-listpools` command line for executable*. | Stake distribution is cached to improve responsiveness |
| `CACHE_LISTPOOLS_TTL` | number | Cache time to live (TTL) for pool listing. *Testing only. Use `--no-cache-listpools` command line for executable*. | 6 seconds for test builds |
| `CACHE_LISTPOOLS_REFRESH` | number | Time interval that indicates how often the cache for the stake-pools listing will be refreshed. *Testing only. Use `--cache-listpools-refresh` command line for executable*. | 6 seconds for test builds |


Here are the possible values of different types of environment variables:
Expand Down
5 changes: 3 additions & 2 deletions docs/user-guide/cli.md
Expand Up @@ -168,8 +168,9 @@ Serve API that listens for commands/actions. Before launching user should start
> you are fully trusting the operator of the metadata
> server to provide authentic token metadata.
> --no-cache-listpools Do not cache the stake-pools listing.
> --cache-listpools-ttl TTL
> Cache time to live (TTL) for stake-pools listing.
> --cache-listpools-refresh DURATION
> Time interval that indicates how often
> the cache for the stake-pools listing will be refreshed.
> Expressed in seconds with a trailing 's'.
> (default: 3600s)
> --log-level SEVERITY Global minimum severity for a message to be logged.
Expand Down
15 changes: 8 additions & 7 deletions lib/cli/src/Cardano/CLI.hs
Expand Up @@ -1408,15 +1408,16 @@ walletIdArgument :: Parser WalletId
walletIdArgument = argumentT $ mempty
<> metavar "WALLET_ID"

-- | [--no-cache-listpools|--cache-listpools-ttl DURATION]
-- | [--no-cache-listpools|--cache-listpools-refresh DURATION]
cacheListPoolsOption :: Parser CacheConfig
cacheListPoolsOption = no <|> fmap (CacheTTL . getQuantity) ttl
cacheListPoolsOption = no <|> fmap (CacheTTL . getQuantity) refresh
where
ttl :: Parser (Quantity "second" NominalDiffTime)
ttl = fmap Quantity $ optionT $ mempty
<> long "cache-listpools-ttl"
<> metavar "TTL"
<> help ( "Cache time to live (TTL) for stake-pools listing. "
refresh :: Parser (Quantity "second" NominalDiffTime)
refresh = fmap Quantity $ optionT $ mempty
<> long "cache-listpool-refresh"
<> metavar "DURATION"
<> help ( "Time interval that indicates how often "
<> "the cache for the stake-pools listing will be refreshed."
<> "Expressed in seconds with a trailing 's'. "
)
<> value 3600
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/test/unit/Cardano/CLISpec.hs
Expand Up @@ -299,9 +299,9 @@ spec = do
forM_ parseTimeTests $ \(desc, arg, tst) ->
it desc $ parse arg `shouldSatisfy` tst

describe "Cache listpools TTL option" $ do
describe "Cache listpools refresh option" $ do
let parse arg = execParserPure defaultPrefs
(info cacheListPoolsOption mempty) ["--cache-listpools-ttl", arg]
(info cacheListPoolsOption mempty) ["--cache-listpools-refresh", arg]
let toMaybe (CacheTTL x) = Just (Quantity x)
toMaybe (NoCache) = Nothing
forM_ parseTimeTests $ \(desc, arg, tst) ->
Expand Down
4 changes: 2 additions & 2 deletions lib/shelley/src/Cardano/Wallet/Shelley/Launch/Cluster.hs
Expand Up @@ -300,11 +300,11 @@ tokenMetadataServerFromEnv = envFromText "TOKEN_METADATA_SERVER" >>= \case
Just (Right s) -> pure (Just s)
Just (Left e) -> die $ show e

-- | Collect @--cache-listpools-ttl@ and @--no-cache-listpools@ options
-- | Collect @--cache-listpools-refresh@ and @--no-cache-listpools@ options
-- from environment variables.
listPoolsConfigFromEnv :: IO CacheConfig
listPoolsConfigFromEnv = do
ttl <- envFromText "CACHE_LISTPOOLS_TTL" >>= \case
ttl <- envFromText "CACHE_LISTPOOLS_REFRESH" >>= \case
Nothing -> pure $ CacheTTL 6 -- default value for testing
Just (Right s) -> pure $ CacheTTL s
Just (Left e) -> die $ show e
Expand Down

0 comments on commit 4307659

Please sign in to comment.