state.height fix in remove_branch()
This commit is contained in:
@@ -158,7 +158,7 @@ class BlockState:
|
|||||||
def remove_branch(self, branch: Branch, *, remove_series_diffs=True):
|
def remove_branch(self, branch: Branch, *, remove_series_diffs=True):
|
||||||
if branch.height == self.height and len(self.branches_by_height[branch.height]) == 1:
|
if branch.height == self.height and len(self.branches_by_height[branch.height]) == 1:
|
||||||
# this is the only branch at this height: compute the new lower height
|
# this is the only branch at this height: compute the new lower height
|
||||||
self.height = max(b.height for b in self.branches_by_id.values()) if self.branches_by_id else 0
|
self.height = max(0, *[b.height for b in self.branches_by_id.values() if b is not branch])
|
||||||
del self.branches_by_id[branch.id]
|
del self.branches_by_id[branch.id]
|
||||||
by_height = self.branches_by_height.get(branch.height)
|
by_height = self.branches_by_height.get(branch.height)
|
||||||
if by_height is not None:
|
if by_height is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user