From 663e055241d02fb44dcac6d8f93d709a4b427ef3 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 12 Apr 2024 21:00:30 -0400 Subject: [PATCH] state.height fix in remove_branch() --- src/dexorder/blockstate/state.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: