stop get_unrepaired_path at root slot (#30450)
This commit is contained in:
parent
1269011477
commit
5221049595
|
@ -111,6 +111,7 @@ fn get_unrepaired_path(
|
||||||
pub fn get_closest_completion(
|
pub fn get_closest_completion(
|
||||||
tree: &HeaviestSubtreeForkChoice,
|
tree: &HeaviestSubtreeForkChoice,
|
||||||
blockstore: &Blockstore,
|
blockstore: &Blockstore,
|
||||||
|
root_slot: Slot,
|
||||||
slot_meta_cache: &mut HashMap<Slot, Option<SlotMeta>>,
|
slot_meta_cache: &mut HashMap<Slot, Option<SlotMeta>>,
|
||||||
processed_slots: &mut HashSet<Slot>,
|
processed_slots: &mut HashSet<Slot>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
@ -169,7 +170,7 @@ pub fn get_closest_completion(
|
||||||
}
|
}
|
||||||
v.sort_by(|(_, d1), (_, d2)| d1.cmp(d2));
|
v.sort_by(|(_, d1), (_, d2)| d1.cmp(d2));
|
||||||
|
|
||||||
let mut visited = HashSet::new();
|
let mut visited = HashSet::from([root_slot]);
|
||||||
let mut repairs = Vec::new();
|
let mut repairs = Vec::new();
|
||||||
let mut total_processed_slots = 0;
|
let mut total_processed_slots = 0;
|
||||||
for (slot, _) in v {
|
for (slot, _) in v {
|
||||||
|
@ -237,6 +238,7 @@ pub mod test {
|
||||||
let (repairs, _) = get_closest_completion(
|
let (repairs, _) = get_closest_completion(
|
||||||
&heaviest_subtree_fork_choice,
|
&heaviest_subtree_fork_choice,
|
||||||
&blockstore,
|
&blockstore,
|
||||||
|
0, // root_slot
|
||||||
&mut slot_meta_cache,
|
&mut slot_meta_cache,
|
||||||
&mut processed_slots,
|
&mut processed_slots,
|
||||||
10,
|
10,
|
||||||
|
@ -261,14 +263,12 @@ pub mod test {
|
||||||
let (repairs, _) = get_closest_completion(
|
let (repairs, _) = get_closest_completion(
|
||||||
&heaviest_subtree_fork_choice,
|
&heaviest_subtree_fork_choice,
|
||||||
&blockstore,
|
&blockstore,
|
||||||
|
0, // root_slot
|
||||||
&mut slot_meta_cache,
|
&mut slot_meta_cache,
|
||||||
&mut processed_slots,
|
&mut processed_slots,
|
||||||
2,
|
1,
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
repairs,
|
|
||||||
[ShredRepairType::Shred(0, 3), ShredRepairType::Shred(1, 3)]
|
|
||||||
);
|
);
|
||||||
|
assert_eq!(repairs, [ShredRepairType::Shred(1, 3)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_tree_with_missing_shreds(
|
fn add_tree_with_missing_shreds(
|
||||||
|
|
|
@ -478,6 +478,7 @@ impl RepairWeight {
|
||||||
let (new_repairs, new_processed_slots) = get_closest_completion(
|
let (new_repairs, new_processed_slots) = get_closest_completion(
|
||||||
tree,
|
tree,
|
||||||
blockstore,
|
blockstore,
|
||||||
|
self.root,
|
||||||
slot_meta_cache,
|
slot_meta_cache,
|
||||||
processed_slots,
|
processed_slots,
|
||||||
max_new_repairs - repairs.len(),
|
max_new_repairs - repairs.len(),
|
||||||
|
|
Loading…
Reference in New Issue