Skip to content

Commit

Permalink
Make function return single arg instead of slice
Browse files Browse the repository at this point in the history
  • Loading branch information
steviez committed Jun 18, 2024
1 parent c7c1b38 commit 2f9e1f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
7 changes: 3 additions & 4 deletions ledger-tool/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ pub fn accounts_db_args<'a, 'b>() -> Box<[Arg<'a, 'b>]> {
const MAX_GENESIS_ARCHIVE_UNPACKED_SIZE_STR: &str = "10485760";

/// Returns the arguments that configure loading genesis
pub fn load_genesis_args<'a, 'b>() -> Box<[Arg<'a, 'b>]> {
vec![Arg::with_name("max_genesis_archive_unpacked_size")
pub fn load_genesis_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("max_genesis_archive_unpacked_size")
.long("max-genesis-archive-unpacked-size")
.value_name("NUMBER")
.takes_value(true)
.default_value(MAX_GENESIS_ARCHIVE_UNPACKED_SIZE_STR)
.help("maximum total uncompressed size of unpacked genesis archive")]
.into_boxed_slice()
.help("maximum total uncompressed size of unpacked genesis archive")
}

/// Returns the arguments that configure snapshot loading
Expand Down
22 changes: 11 additions & 11 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ fn main() {

solana_logger::setup_with_default_filter();

let load_genesis_config_args = load_genesis_args();
let load_genesis_config_arg = load_genesis_arg();
let accounts_db_config_args = accounts_db_args();
let snapshot_config_args = snapshot_args();

Expand Down Expand Up @@ -762,7 +762,7 @@ fn main() {
.subcommand(
SubCommand::with_name("genesis")
.about("Prints the ledger's genesis config")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.arg(
Arg::with_name("accounts")
.long("accounts")
Expand All @@ -781,12 +781,12 @@ fn main() {
.subcommand(
SubCommand::with_name("genesis-hash")
.about("Prints the ledger's genesis hash")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
)
.subcommand(
SubCommand::with_name("modify-genesis")
.about("Modifies genesis parameters")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.arg(&hashes_per_tick)
.arg(
Arg::with_name("cluster_type")
Expand All @@ -806,23 +806,23 @@ fn main() {
.subcommand(
SubCommand::with_name("shred-version")
.about("Prints the ledger's shred hash")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&hard_forks_arg)
)
.subcommand(
SubCommand::with_name("bank-hash")
.about("Prints the hash of the working bank after reading the ledger")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&halt_at_slot_arg)
)
.subcommand(
SubCommand::with_name("verify")
.about("Verify the ledger")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&halt_at_slot_arg)
Expand Down Expand Up @@ -958,7 +958,7 @@ fn main() {
.subcommand(
SubCommand::with_name("graph")
.about("Create a Graphviz rendering of the ledger")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&halt_at_slot_arg)
Expand Down Expand Up @@ -991,7 +991,7 @@ fn main() {
.subcommand(
SubCommand::with_name("create-snapshot")
.about("Create a new ledger snapshot")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&hard_forks_arg)
Expand Down Expand Up @@ -1197,7 +1197,7 @@ fn main() {
.subcommand(
SubCommand::with_name("accounts")
.about("Print account stats and contents after processing the ledger")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&halt_at_slot_arg)
Expand Down Expand Up @@ -1251,7 +1251,7 @@ fn main() {
.subcommand(
SubCommand::with_name("capitalization")
.about("Print capitalization (aka, total supply) while checksumming it")
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&accounts_db_config_args)
.args(&snapshot_config_args)
.arg(&halt_at_slot_arg)
Expand Down
4 changes: 2 additions & 2 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl ProgramSubCommand for App<'_, '_> {
.required(true)
.index(1);

let load_genesis_config_args = load_genesis_args();
let load_genesis_config_arg = load_genesis_arg();
let snapshot_config_args = snapshot_args();

self.subcommand(
Expand Down Expand Up @@ -157,7 +157,7 @@ and the following fields are required
.takes_value(true)
.default_value("0"),
)
.args(&load_genesis_config_args)
.arg(&load_genesis_config_arg)
.args(&snapshot_config_args)
.arg(
Arg::with_name("memory")
Expand Down

0 comments on commit 2f9e1f7

Please sign in to comment.