From 4fc1435e5eb50bc171f40154ba8edb1999dd5b64 Mon Sep 17 00:00:00 2001 From: steviez Date: Mon, 6 May 2024 18:32:09 -0500 Subject: [PATCH] ledger-tool: Remove blockstore json command (#1206) This command is basically an exact duplicate of the print command, except print had OutputFormat::Display hard-coded whereas the json command had OutputFormat::Json hard-coded. Instead of hard-coded values, parse value of --output-format from CLI --- ledger-tool/src/blockstore.rs | 25 +++---------------------- ledger-tool/src/main.rs | 1 - 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/ledger-tool/src/blockstore.rs b/ledger-tool/src/blockstore.rs index f7aa2544ec36eb..6f2471ef117b5e 100644 --- a/ledger-tool/src/blockstore.rs +++ b/ledger-tool/src/blockstore.rs @@ -347,12 +347,6 @@ pub fn blockstore_subcommands<'a, 'b>(hidden: bool) -> Vec> { .about("Print all the duplicate slots in the ledger") .settings(&hidden) .arg(&starting_slot_arg), - SubCommand::with_name("json") - .about("Print the ledger in JSON format") - .settings(&hidden) - .arg(&starting_slot_arg) - .arg(&ending_slot_arg) - .arg(&allow_dead_slots_arg), SubCommand::with_name("latest-optimistic-slots") .about( "Output up to the most recent optimistic slots with their hashes \ @@ -717,21 +711,6 @@ fn do_blockstore_process_command(ledger_path: &Path, matches: &ArgMatches<'_>) - println!("{slot}"); } } - ("json", Some(arg_matches)) => { - let starting_slot = value_t_or_exit!(arg_matches, "starting_slot", Slot); - let ending_slot = value_t!(arg_matches, "ending_slot", Slot).unwrap_or(Slot::MAX); - let allow_dead_slots = arg_matches.is_present("allow_dead_slots"); - output_ledger( - crate::open_blockstore(&ledger_path, arg_matches, AccessType::Secondary), - starting_slot, - ending_slot, - allow_dead_slots, - OutputFormat::Json, - None, - std::u64::MAX, - true, - ); - } ("latest-optimistic-slots", Some(arg_matches)) => { let blockstore = crate::open_blockstore(&ledger_path, arg_matches, AccessType::Secondary); @@ -858,12 +837,14 @@ fn do_blockstore_process_command(ledger_path: &Path, matches: &ArgMatches<'_>) - let num_slots = value_t!(arg_matches, "num_slots", Slot).ok(); let allow_dead_slots = arg_matches.is_present("allow_dead_slots"); let only_rooted = arg_matches.is_present("only_rooted"); + let output_format = OutputFormat::from_matches(arg_matches, "output_format", false); + output_ledger( crate::open_blockstore(&ledger_path, arg_matches, AccessType::Secondary), starting_slot, ending_slot, allow_dead_slots, - OutputFormat::Display, + output_format, num_slots, verbose_level, only_rooted, diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 814c30a4f7b384..27fbf778a22e5c 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -1534,7 +1534,6 @@ fn main() { | ("copy", Some(_)) | ("dead-slots", Some(_)) | ("duplicate-slots", Some(_)) - | ("json", Some(_)) | ("latest-optimistic-slots", Some(_)) | ("list-roots", Some(_)) | ("parse_full_frozen", Some(_))