Make ledger-tool list-roots subcommand inclusive of start-root arg (#29265)
This commit is contained in:
parent
a44ea779bd
commit
0609dce36c
|
@ -4076,25 +4076,7 @@ fn main() {
|
||||||
.rooted_slot_iterator(start_root)
|
.rooted_slot_iterator(start_root)
|
||||||
.expect("Failed to get rooted slot");
|
.expect("Failed to get rooted slot");
|
||||||
|
|
||||||
let mut slot_hash = Vec::new();
|
let mut output: Box<dyn Write> =
|
||||||
for (i, slot) in iter.into_iter().enumerate() {
|
|
||||||
if i > num_roots {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if slot <= max_height as u64 {
|
|
||||||
let blockhash = blockstore
|
|
||||||
.get_slot_entries(slot, 0)
|
|
||||||
.unwrap()
|
|
||||||
.last()
|
|
||||||
.unwrap()
|
|
||||||
.hash;
|
|
||||||
slot_hash.push((slot, blockhash));
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut output_file: Box<dyn Write> =
|
|
||||||
if let Some(path) = arg_matches.value_of("slot_list") {
|
if let Some(path) = arg_matches.value_of("slot_list") {
|
||||||
match File::create(path) {
|
match File::create(path) {
|
||||||
Ok(file) => Box::new(file),
|
Ok(file) => Box::new(file),
|
||||||
|
@ -4104,16 +4086,20 @@ fn main() {
|
||||||
Box::new(stdout())
|
Box::new(stdout())
|
||||||
};
|
};
|
||||||
|
|
||||||
slot_hash
|
iter.take(num_roots)
|
||||||
|
.take_while(|slot| *slot <= max_height as u64)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.rev()
|
.rev()
|
||||||
.enumerate()
|
.for_each(|slot| {
|
||||||
.for_each(|(i, (slot, hash))| {
|
let blockhash = blockstore
|
||||||
if i < num_roots {
|
.get_slot_entries(slot, 0)
|
||||||
output_file
|
.unwrap()
|
||||||
.write_all(format!("{slot:?}: {hash:?}\n").as_bytes())
|
.last()
|
||||||
.expect("failed to write");
|
.unwrap()
|
||||||
}
|
.hash;
|
||||||
|
|
||||||
|
writeln!(output, "{}: {:?}", slot, blockhash).expect("failed to write");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
("latest-optimistic-slots", Some(arg_matches)) => {
|
("latest-optimistic-slots", Some(arg_matches)) => {
|
||||||
|
|
Loading…
Reference in New Issue