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
@@ -67,7 +67,7 @@ pub(super) async fn build_hello_ack(ctx: &PeerCtx) -> eyre::Result<HelloAck> {
|
||||
let library_guard = ctx.local_library.read().await;
|
||||
build_library_snapshot(&library_guard)
|
||||
};
|
||||
let call_to_play_events = ctx.call_to_play.read().await.snapshot();
|
||||
let call_to_play_events = ctx.call_to_play.write().await.snapshot();
|
||||
Ok(HelloAck {
|
||||
peer_id: ctx.peer_id.as_ref().clone(),
|
||||
proto_ver: PROTOCOL_VERSION,
|
||||
@@ -84,7 +84,7 @@ async fn build_hello_from_state(ctx: &HandshakeCtx) -> eyre::Result<Hello> {
|
||||
let library_guard = ctx.local_library.read().await;
|
||||
build_library_snapshot(&library_guard)
|
||||
};
|
||||
let call_to_play_events = ctx.call_to_play.read().await.snapshot();
|
||||
let call_to_play_events = ctx.call_to_play.write().await.snapshot();
|
||||
Ok(Hello {
|
||||
peer_id: ctx.peer_id.as_ref().clone(),
|
||||
proto_ver: PROTOCOL_VERSION,
|
||||
@@ -538,7 +538,7 @@ mod tests {
|
||||
.expect("current protocol hello should be accepted");
|
||||
|
||||
assert_eq!(
|
||||
ctx.call_to_play.read().await.snapshot(),
|
||||
ctx.call_to_play.write().await.snapshot(),
|
||||
[call_to_play_event()]
|
||||
);
|
||||
assert!(matches!(
|
||||
|
||||
Reference in new issue
Block a user