Skip to content

Commit 2fcc545

Browse files
committed
fix a delta issue
1 parent b29a23a commit 2fcc545

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

odorobo/src/actors/agent_actor.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,19 +387,25 @@ impl Message<GetAgentStatus> for AgentActor {
387387
};
388388
}
389389

390-
let mut added = Vec::with_capacity(self.status_history.len());
391-
let mut removed = Vec::with_capacity(self.status_history.len());
390+
let mut latest_changes = AHashMap::new();
392391
for change in self
393392
.status_history
394393
.iter()
395394
.filter(|change| change.revision > msg.since_revision)
396395
{
397-
if change.added {
398-
added.push(change.vmid);
396+
latest_changes.insert(change.vmid, change.added);
397+
}
398+
let mut added = Vec::with_capacity(latest_changes.len());
399+
let mut removed = Vec::with_capacity(latest_changes.len());
400+
for (vmid, added_change) in latest_changes {
401+
if added_change {
402+
added.push(vmid);
399403
} else {
400-
removed.push(change.vmid);
404+
removed.push(vmid);
401405
}
402406
}
407+
added.sort_unstable();
408+
removed.sort_unstable();
403409
AgentStatusUpdate::Delta {
404410
revision: self.membership_revision,
405411
added,

0 commit comments

Comments
 (0)