From de34187db089a1c0ecec7347b2921858dd9d13db Mon Sep 17 00:00:00 2001 From: sakridge Date: Sun, 8 Mar 2020 12:40:56 -0700 Subject: [PATCH] Add purge function to ledger-tool (#8719) --- ledger-tool/src/main.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 5993198bb..3f465c6d1 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -718,6 +718,24 @@ fn main() { .required(true) .help("The location of the YAML file with a list of rollback slot heights and hashes"), ) + ).subcommand( + SubCommand::with_name("purge") + .about("Purge the ledger at the block height") + .arg( + Arg::with_name("start_slot") + .index(1) + .value_name("SLOT") + .takes_value(true) + .required(true) + .help("Start slot to purge from."), + ) + .arg( + Arg::with_name("end_slot") + .index(2) + .value_name("SLOT") + .takes_value(true) + .help("Optional ending slot to stop purging."), + ) ) .subcommand( SubCommand::with_name("list-roots") @@ -998,6 +1016,13 @@ fn main() { } } } + ("purge", Some(arg_matches)) => { + let start_slot = value_t_or_exit!(arg_matches, "start_slot", Slot); + let end_slot = value_t!(arg_matches, "end_slot", Slot); + let end_slot = end_slot.map_or(None, Some); + let blockstore = open_blockstore(&ledger_path); + blockstore.purge_slots(start_slot, end_slot); + } ("prune", Some(arg_matches)) => { if let Some(prune_file_path) = arg_matches.value_of("slot_list") { let blockstore = open_blockstore(&ledger_path);