From a07980536ac3763c958f5491c6f83c5a4de2a441 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 30 Aug 2020 09:04:14 -0700 Subject: [PATCH] Add bank-hash subcommand --- ledger-tool/src/main.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index ff9db8ed4..9569881bd 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -971,6 +971,11 @@ fn main() { .arg(&hard_forks_arg) .arg(&max_genesis_archive_unpacked_size_arg) ) + .subcommand( + SubCommand::with_name("bank-hash") + .about("Prints the hash of the working bank after reading the ledger") + .arg(&max_genesis_archive_unpacked_size_arg) + ) .subcommand( SubCommand::with_name("bounds") .about("Print lowest and highest non-empty slots. Note that there may be empty slots within the bounds") @@ -1390,6 +1395,32 @@ fn main() { } } } + ("bank-hash", Some(arg_matches)) => { + let process_options = ProcessOptions { + dev_halt_at_slot: Some(0), + new_hard_forks: hardforks_of(arg_matches, "hard_forks"), + poh_verify: false, + ..ProcessOptions::default() + }; + let genesis_config = open_genesis_config_by(&ledger_path, arg_matches); + match load_bank_forks( + arg_matches, + &ledger_path, + &genesis_config, + process_options, + AccessType::TryPrimaryThenSecondary, + wal_recovery_mode, + snapshot_archive_path, + ) { + Ok((bank_forks, _leader_schedule_cache, _snapshot_hash)) => { + println!("{}", &bank_forks.working_bank().hash()); + } + Err(err) => { + eprintln!("Failed to load ledger: {:?}", err); + exit(1); + } + } + } ("slot", Some(arg_matches)) => { let slots = values_t_or_exit!(arg_matches, "slots", Slot); let allow_dead_slots = arg_matches.is_present("allow_dead_slots");