diff --git a/src/dexorder/blockstate/state.py b/src/dexorder/blockstate/state.py index 9f1b2fa..414f3a5 100644 --- a/src/dexorder/blockstate/state.py +++ b/src/dexorder/blockstate/state.py @@ -158,7 +158,7 @@ class BlockState: def remove_branch(self, branch: Branch, *, remove_series_diffs=True): 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 - 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] by_height = self.branches_by_height.get(branch.height) if by_height is not None: