state-res: fix tiebreaking comparisons

`node` needs to be swapped with `parent` here, otherwise the
`power_level` and `age` in a `TieBreaker` inserted on the following line
are always equal, because both sides are the values for `node` rather
than a different value of `parent` on each iteration, and so the only
thing that could possibly be different is the `event_id` because that's
correctly set to `parent`. This is why I was observing tiebreaks always
being sorted by `event_id` and experiencing incorrectly resolved states.
This commit is contained in:
Charles Hall 2024-11-07 18:42:10 -05:00 committed by strawberry
parent 8ce5d8eb87
commit 35e459d86e

View File

@ -340,7 +340,7 @@ where
// Only push on the heap once older events have been cleared // Only push on the heap once older events have been cleared
out.remove(node.borrow()); out.remove(node.borrow());
if out.is_empty() { if out.is_empty() {
let (power_level, age) = key_fn(node.clone()).await?; let (power_level, age) = key_fn(parent.clone()).await?;
heap.push(Reverse(TieBreaker { heap.push(Reverse(TieBreaker {
inv_power_level: -power_level, inv_power_level: -power_level,
age, age,