From a6b9327cd04c9b776a2744cfa64bd40433f12a68 Mon Sep 17 00:00:00 2001 From: carllin Date: Thu, 25 Feb 2021 15:52:16 -0800 Subject: [PATCH] Fix root scan in ledger tool (#15532) --- ledger-tool/src/main.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index ad2aa5b3e0..10945c9eff 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -1285,7 +1285,7 @@ fn main() { ) .subcommand( SubCommand::with_name("list-roots") - .about("Output upto last root hashes and their heights starting at the given block height") + .about("Output up to last root hashes and their heights starting at the given block height") .arg( Arg::with_name("max_height") .long("max-height") @@ -1293,6 +1293,13 @@ fn main() { .takes_value(true) .help("Maximum block height") ) + .arg( + Arg::with_name("start_root") + .long("start-root") + .value_name("NUM") + .takes_value(true) + .help("First root to start searching from") + ) .arg( Arg::with_name("slot_list") .long("slot-list") @@ -2698,6 +2705,11 @@ fn main() { } else { usize::MAX }; + let start_root = if let Some(height) = arg_matches.value_of("start_root") { + Slot::from_str(height).expect("Starting root must be a number") + } else { + 0 + }; let num_roots = if let Some(roots) = arg_matches.value_of("num_roots") { usize::from_str(roots).expect("Number of roots must be a number") } else { @@ -2705,7 +2717,7 @@ fn main() { }; let iter = blockstore - .rooted_slot_iterator(0) + .rooted_slot_iterator(start_root) .expect("Failed to get rooted slot"); let mut slot_hash = Vec::new();