Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Correctly handle borderline, but legit, case
  • Loading branch information
davxy committed Feb 7, 2023
commit 4c00660c6acb542e2af124fd3323f59e9dcceaa5
9 changes: 2 additions & 7 deletions utils/fork-tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,12 @@ where

// Curr now points to our direct ancestor, if necessary remove any node that is
// not a descendant of `hash`.
let mut is_first = true;
let children = std::mem::take(&mut curr.children);
for child in children {
if is_first &&
(child.number == *number && child.hash == *hash ||
*number < child.number && is_descendent_of(hash, &child.hash)?)
if child.number == *number && child.hash == *hash ||
*number < child.number && is_descendent_of(hash, &child.hash)?
{
curr.children.push(child);
// Assuming that the tree is well formed only one child should pass this
// requirement due to ancestry restrictions (i.e. they must be different forks).
is_first = false;
} else {
removed.push(child);
}
Expand Down