From 86d333d4dcaa04f285431970195c58ce9811828d Mon Sep 17 00:00:00 2001 From: Mollusk Date: Mon, 22 Jun 2026 02:31:45 -0400 Subject: [PATCH] chore(gossip): log the game field in peer_state_for_log Add the new PeerState.game field to the presence log formatter so gossip Announces show whether a peer is broadcasting a game. The line previously printed name/muted/addr_id/addrs/sharing only, making the game-presence broadcast invisible in logs (verified solely via UI during the 2026-06-22 2-machine field test). Log-only: no wire, protocol, or GOSSIP_PROTO change. Adds the first unit test for the formatter (Some and None cases). Implemented by Codex (gpt-5.5) on branch codex-log-game-field; reviewed and gates re-run by the senior (397 lib tests, clippy --all-targets, release build all green). Co-Authored-By: Claude Opus 4.8 --- src/network/gossip.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/network/gossip.rs b/src/network/gossip.rs index c2428d8..c017a8a 100644 --- a/src/network/gossip.rs +++ b/src/network/gossip.rs @@ -133,12 +133,13 @@ fn admit_state_mutation( fn peer_state_for_log(state: &PeerState) -> String { format!( - "name={:?}, muted={}, addr_id={}, addrs={}, sharing={}", + "name={:?}, muted={}, addr_id={}, addrs={}, sharing={}, game={:?}", state.name, state.is_muted, crate::short_id(&state.addr.id.to_string()), state.addr.addrs.len(), - state.sharing.is_some() + state.sharing.is_some(), + state.game ) } @@ -717,6 +718,16 @@ mod tests { EndpointAddr::from(id) } + #[test] + fn peer_state_log_includes_game() { + let mut state = sample_peer_state_for(fresh_id()); + state.game = Some("Half-Life 2".to_string()); + assert!(peer_state_for_log(&state).contains("game=Some(\"Half-Life 2\")")); + + state.game = None; + assert!(peer_state_for_log(&state).contains("game=None")); + } + #[test] fn bootstrap_client_dials_host() { // A non-host (client) with no retained peers dials just the ticket host.