fix(call-to-play): compact expired snapshots
Expired call histories were removed on the next store insertion, so an otherwise idle peer could continue carrying stale payload through handshakes after the five-minute UI retention ended. Run the same inactive-call compaction before local and handshake snapshots. This makes the expiry boundary exact without trimming any event from an active call. Test Plan: - `just fmt` -- passed - `just clippy` -- passed - `just test` -- passed, 147 peer tests - `git diff --cached --check` -- passed
This commit is contained in:
3 files changed
+11
-8
No files matched your search
@@ -30,7 +30,12 @@ pub(crate) struct CallToPlayStore {
|
||||
}
|
||||
|
||||
impl CallToPlayStore {
|
||||
pub(crate) fn snapshot(&self) -> Vec<CallToPlayEvent> {
|
||||
pub(crate) fn snapshot(&mut self) -> Vec<CallToPlayEvent> {
|
||||
self.snapshot_at(now_ms())
|
||||
}
|
||||
|
||||
fn snapshot_at(&mut self, now: i64) -> Vec<CallToPlayEvent> {
|
||||
self.compact_inactive_calls(now);
|
||||
self.events.clone()
|
||||
}
|
||||
|
||||
@@ -434,8 +439,6 @@ mod tests {
|
||||
.insert(create_event("create"))
|
||||
.expect("active call should fit");
|
||||
|
||||
store.compact_inactive_calls(TEST_NOW + 5 * 60_000 + 60_001);
|
||||
|
||||
assert!(store.snapshot().is_empty());
|
||||
assert!(store.snapshot_at(TEST_NOW + 5 * 60_000 + 60_001).is_empty());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user