Add a way to re-hash the bank (#10765)
This commit is contained in:
parent
4de0713aa3
commit
1269e348fb
|
@ -949,7 +949,13 @@ fn main() {
|
||||||
.help("After loading the snapshot slot warp the ledger to WARP_SLOT, \
|
.help("After loading the snapshot slot warp the ledger to WARP_SLOT, \
|
||||||
which could be a slot in a galaxy far far away"),
|
which could be a slot in a galaxy far far away"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("rehash")
|
||||||
|
.required(false)
|
||||||
|
.long("rehash")
|
||||||
|
.takes_value(false)
|
||||||
|
.help("Re-calculate the bank hash and overwrite the original bank hash."),
|
||||||
|
)
|
||||||
).subcommand(
|
).subcommand(
|
||||||
SubCommand::with_name("accounts")
|
SubCommand::with_name("accounts")
|
||||||
.about("Print account contents after processing in the ledger")
|
.about("Print account contents after processing in the ledger")
|
||||||
|
@ -1289,6 +1295,7 @@ fn main() {
|
||||||
let snapshot_slot = value_t_or_exit!(arg_matches, "snapshot_slot", Slot);
|
let snapshot_slot = value_t_or_exit!(arg_matches, "snapshot_slot", Slot);
|
||||||
let output_directory = value_t_or_exit!(arg_matches, "output_directory", String);
|
let output_directory = value_t_or_exit!(arg_matches, "output_directory", String);
|
||||||
let warp_slot = value_t!(arg_matches, "warp_slot", Slot).ok();
|
let warp_slot = value_t!(arg_matches, "warp_slot", Slot).ok();
|
||||||
|
let rehash = arg_matches.is_present("rehash");
|
||||||
let snapshot_version =
|
let snapshot_version =
|
||||||
arg_matches
|
arg_matches
|
||||||
.value_of("snapshot_version")
|
.value_of("snapshot_version")
|
||||||
|
@ -1340,6 +1347,9 @@ fn main() {
|
||||||
bank.squash();
|
bank.squash();
|
||||||
bank.clean_accounts();
|
bank.clean_accounts();
|
||||||
bank.update_accounts_hash();
|
bank.update_accounts_hash();
|
||||||
|
if rehash {
|
||||||
|
bank.rehash();
|
||||||
|
}
|
||||||
|
|
||||||
let temp_dir = tempfile::tempdir_in(ledger_path).unwrap_or_else(|err| {
|
let temp_dir = tempfile::tempdir_in(ledger_path).unwrap_or_else(|err| {
|
||||||
eprintln!("Unable to create temporary directory: {}", err);
|
eprintln!("Unable to create temporary directory: {}", err);
|
||||||
|
|
|
@ -817,6 +817,15 @@ impl Bank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn rehash(&self) {
|
||||||
|
let mut hash = self.hash.write().unwrap();
|
||||||
|
let new = self.hash_internal_state();
|
||||||
|
if new != *hash {
|
||||||
|
warn!("Updating bank hash to {}", new);
|
||||||
|
*hash = new;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn freeze(&self) {
|
pub fn freeze(&self) {
|
||||||
let mut hash = self.hash.write().unwrap();
|
let mut hash = self.hash.write().unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue