Skip to content

Commit

Permalink
fix(dot/state): fix a bug in IsDescendantOf (#3125)
Browse files Browse the repository at this point in the history
  • Loading branch information
kishansagathiya committed Feb 27, 2023
1 parent 2f5deb3 commit 4fd4a89
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dot/state/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,14 @@ func (bs *BlockState) IsDescendantOf(ancestor, descendant common.Hash) (bool, er
return false, fmt.Errorf("getting header: %w", err2)
}

for current := descendantHeader; descendantHeader.Number < ancestorHeader.Number; {
for current := descendantHeader; current.Number > ancestorHeader.Number; {
if current.ParentHash == ancestor {
return true, nil
}
current, err2 = bs.GetHeader(current.ParentHash)
if err2 != nil {
return false, fmt.Errorf("getting header: %w", err2)
}
}

return false, nil
Expand Down

0 comments on commit 4fd4a89

Please sign in to comment.