ledger-tool: Allow compute-slot-cost to operate on dead slots (#213)
Make this command accept the --allow-dead-slots arg as well
This commit is contained in:
parent
33f941d473
commit
5ed30beb2a
|
@ -445,14 +445,14 @@ fn graph_forks(bank_forks: &BankForks, config: &GraphConfig) -> String {
|
||||||
dot.join("\n")
|
dot.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String> {
|
fn compute_slot_cost(
|
||||||
if blockstore.is_dead(slot) {
|
blockstore: &Blockstore,
|
||||||
return Err("Dead slot".to_string());
|
slot: Slot,
|
||||||
}
|
allow_dead_slots: bool,
|
||||||
|
) -> Result<(), String> {
|
||||||
let (entries, _num_shreds, _is_full) = blockstore
|
let (entries, _num_shreds, _is_full) = blockstore
|
||||||
.get_slot_entries_with_shred_info(slot, 0, false)
|
.get_slot_entries_with_shred_info(slot, 0, allow_dead_slots)
|
||||||
.map_err(|err| format!(" Slot: {slot}, Failed to load entries, err {err:?}"))?;
|
.map_err(|err| format!("Slot: {slot}, Failed to load entries, err {err:?}"))?;
|
||||||
|
|
||||||
let num_entries = entries.len();
|
let num_entries = entries.len();
|
||||||
let mut num_transactions = 0;
|
let mut num_transactions = 0;
|
||||||
|
@ -1482,7 +1482,8 @@ fn main() {
|
||||||
"Slots that their blocks are computed for cost, default to all slots \
|
"Slots that their blocks are computed for cost, default to all slots \
|
||||||
in ledger",
|
in ledger",
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
.arg(&allow_dead_slots_arg),
|
||||||
)
|
)
|
||||||
.program_subcommand()
|
.program_subcommand()
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
@ -2947,9 +2948,10 @@ fn main() {
|
||||||
} else {
|
} else {
|
||||||
slots = values_t_or_exit!(arg_matches, "slots", Slot);
|
slots = values_t_or_exit!(arg_matches, "slots", Slot);
|
||||||
}
|
}
|
||||||
|
let allow_dead_slots = arg_matches.is_present("allow_dead_slots");
|
||||||
|
|
||||||
for slot in slots {
|
for slot in slots {
|
||||||
if let Err(err) = compute_slot_cost(&blockstore, slot) {
|
if let Err(err) = compute_slot_cost(&blockstore, slot, allow_dead_slots) {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue