Add set-dead-slot command (#9008)
This commit is contained in:
parent
aa24181a53
commit
ff2c183ac1
|
@ -35,14 +35,15 @@ enum LedgerOutputMethod {
|
||||||
Json,
|
Json,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_slot(blockstore: &Blockstore, slot: Slot, method: &LedgerOutputMethod) {
|
fn output_slot(
|
||||||
|
blockstore: &Blockstore,
|
||||||
|
slot: Slot,
|
||||||
|
method: &LedgerOutputMethod,
|
||||||
|
) -> Result<(), String> {
|
||||||
println!("Slot Meta {:?}", blockstore.meta(slot));
|
println!("Slot Meta {:?}", blockstore.meta(slot));
|
||||||
let entries = blockstore
|
let entries = blockstore
|
||||||
.get_slot_entries(slot, 0, None)
|
.get_slot_entries(slot, 0, None)
|
||||||
.unwrap_or_else(|err| {
|
.map_err(|err| format!("Failed to load entries for slot {}: {}", slot, err))?;
|
||||||
eprintln!("Failed to load entries for slot {}: {:?}", slot, err);
|
|
||||||
exit(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (entry_index, entry) in entries.iter().enumerate() {
|
for (entry_index, entry) in entries.iter().enumerate() {
|
||||||
match method {
|
match method {
|
||||||
|
@ -115,6 +116,7 @@ fn output_slot(blockstore: &Blockstore, slot: Slot, method: &LedgerOutputMethod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_ledger(blockstore: Blockstore, starting_slot: Slot, method: LedgerOutputMethod) {
|
fn output_ledger(blockstore: Blockstore, starting_slot: Slot, method: LedgerOutputMethod) {
|
||||||
|
@ -140,7 +142,9 @@ fn output_ledger(blockstore: Blockstore, starting_slot: Slot, method: LedgerOutp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output_slot(&blockstore, slot, &method);
|
if let Err(err) = output_slot(&blockstore, slot, &method) {
|
||||||
|
eprintln!("{}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if method == LedgerOutputMethod::Json {
|
if method == LedgerOutputMethod::Json {
|
||||||
|
@ -616,7 +620,21 @@ fn main() {
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("List of slots to print"),
|
.help("Slots to print"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("set-dead-slot")
|
||||||
|
.about("Mark one or more slots dead")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("slots")
|
||||||
|
.index(1)
|
||||||
|
.value_name("SLOTS")
|
||||||
|
.validator(is_slot)
|
||||||
|
.takes_value(true)
|
||||||
|
.multiple(true)
|
||||||
|
.required(true)
|
||||||
|
.help("Slots to mark dead"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
|
@ -824,13 +842,12 @@ fn main() {
|
||||||
}
|
}
|
||||||
("slot", Some(arg_matches)) => {
|
("slot", Some(arg_matches)) => {
|
||||||
let slots = values_t_or_exit!(arg_matches, "slots", Slot);
|
let slots = values_t_or_exit!(arg_matches, "slots", Slot);
|
||||||
|
let blockstore = open_blockstore(&ledger_path);
|
||||||
for slot in slots {
|
for slot in slots {
|
||||||
println!("Slot {}", slot);
|
println!("Slot {}", slot);
|
||||||
output_slot(
|
if let Err(err) = output_slot(&blockstore, slot, &LedgerOutputMethod::Print) {
|
||||||
&open_blockstore(&ledger_path),
|
eprintln!("{}", err);
|
||||||
slot,
|
}
|
||||||
&LedgerOutputMethod::Print,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
("json", Some(arg_matches)) => {
|
("json", Some(arg_matches)) => {
|
||||||
|
@ -841,6 +858,16 @@ fn main() {
|
||||||
LedgerOutputMethod::Json,
|
LedgerOutputMethod::Json,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
("set-dead-slot", Some(arg_matches)) => {
|
||||||
|
let slots = values_t_or_exit!(arg_matches, "slots", Slot);
|
||||||
|
let blockstore = open_blockstore(&ledger_path);
|
||||||
|
for slot in slots {
|
||||||
|
match blockstore.set_dead_slot(slot) {
|
||||||
|
Ok(_) => println!("Slot {} dead", slot),
|
||||||
|
Err(err) => eprintln!("Failed to set slot {} dead slot: {}", slot, err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
("verify", Some(arg_matches)) => {
|
("verify", Some(arg_matches)) => {
|
||||||
let process_options = ProcessOptions {
|
let process_options = ProcessOptions {
|
||||||
dev_halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(),
|
dev_halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(),
|
||||||
|
|
Loading…
Reference in New Issue