fix(peer): settle current-protocol local state cleanup
The follow-up backlog had drifted into three settled peer/runtime issues: the legacy game-list fallback contradicted the one-wire-version policy, the Tauri shell still re-derived local install state from disk after peer snapshots, and `Availability::Downloading` existed even though active operations are already reported through a separate operation table. Remove the legacy `AnnounceGames` request and fallback service. Discovery now ignores peers that do not advertise the current protocol and a peer id, and library changes are sent through the current delta path only. This keeps the runtime aligned with the documented current-build-only interoperability model. Make peer `LocalGamesUpdated` snapshots authoritative for local fields in the Tauri database. The GUI-side catalog still owns static metadata such as names, sizes, and descriptions, but downloaded, installed, local version, and availability now come from the peer runtime instead of a second whole-library filesystem scan. Snapshot reconciliation also pins the missing-begin and missing-finish lifecycle cases in tests. Collapse availability back to the settled `Ready` and `LocalOnly` states. Aggregation now counts only `Ready` peers as download sources, and the frontend no longer carries a dead `Downloading` enum value. The core peer also exposes the small non-GUI hooks needed by scripted callers: startup options for state and mDNS, a local-ready event, direct connection, peer snapshots, and an explicit post-download install policy. Those hooks reuse the same current protocol path and do not add compatibility shims. Test Plan: - `git diff --check` - `just fmt` - `just clippy` - `just test` Refs: BACKLOG.md, FINDINGS.md, IMPL_DECISIONS.md
This commit is contained in:
@@ -35,12 +35,30 @@ pub async fn run_server_component(
|
||||
let server_addr = server.local_addr()?;
|
||||
log::info!("Peer server listening on {server_addr}");
|
||||
|
||||
let mdns_advertiser = start_mdns_advertiser(&ctx, server_addr).await?;
|
||||
let mdns_monitor = mdns_advertiser.monitor.clone();
|
||||
let mdns_shutdown = ctx.shutdown.clone();
|
||||
ctx.task_tracker.spawn(async move {
|
||||
monitor_mdns_events(mdns_monitor, mdns_shutdown).await;
|
||||
});
|
||||
let (ready_addr, _mdns_advertiser) = if ctx.enable_mdns {
|
||||
let mdns_advertiser = start_mdns_advertiser(&ctx, server_addr).await?;
|
||||
let mdns_monitor = mdns_advertiser.monitor.clone();
|
||||
let mdns_shutdown = ctx.shutdown.clone();
|
||||
ctx.task_tracker.spawn(async move {
|
||||
monitor_mdns_events(mdns_monitor, mdns_shutdown).await;
|
||||
});
|
||||
let ready_addr =
|
||||
(*ctx.local_peer_addr.read().await).unwrap_or_else(|| direct_connect_addr(server_addr));
|
||||
(ready_addr, Some(mdns_advertiser))
|
||||
} else {
|
||||
let addr = direct_connect_addr(server_addr);
|
||||
*ctx.local_peer_addr.write().await = Some(addr);
|
||||
log::info!("mDNS disabled; direct peer address is {addr}");
|
||||
(addr, None)
|
||||
};
|
||||
|
||||
events::send(
|
||||
&tx_notify_ui,
|
||||
PeerEvent::LocalPeerReady {
|
||||
peer_id: ctx.peer_id.as_ref().clone(),
|
||||
addr: ready_addr,
|
||||
},
|
||||
);
|
||||
|
||||
loop {
|
||||
let connection = tokio::select! {
|
||||
@@ -64,6 +82,13 @@ pub async fn run_server_component(
|
||||
}
|
||||
}
|
||||
|
||||
fn direct_connect_addr(server_addr: SocketAddr) -> SocketAddr {
|
||||
if server_addr.ip().is_unspecified() {
|
||||
return SocketAddr::from(([127, 0, 0, 1], server_addr.port()));
|
||||
}
|
||||
server_addr
|
||||
}
|
||||
|
||||
async fn handle_peer_connection(
|
||||
mut connection: Connection,
|
||||
ctx: PeerCtx,
|
||||
|
||||
Reference in New Issue
Block a user