Files
lanspread/crates/lanspread-peer/src/config.rs
T
ddidderr 6c8a2bb9f0 feat(peer): add transactional local game operations
Implement the peer-owned state model from PLAN.md. A root-level version.ini
is now the download completion sentinel, local/ as a directory is the install
predicate, and exact root-level version.ini detection prevents nested files
from becoming sentinels by accident.

Add the peer operation table that gates downloads, installs, updates, and
uninstalls by game ID. Serving paths now reject non-catalog games, active
operations, missing sentinels, and any request that points under local/.
Remote aggregation treats LocalOnly peers as non-downloadable so they do not
contribute peer counts, candidate source selection, or latest-version checks.

Move install-side filesystem mutation into lanspread-peer::install. The new
module writes atomic .lanspread.json intents, uses .local.installing and
.local.backup with .lanspread_owned markers, and performs startup recovery
from recorded intent plus filesystem state. Downloads now buffer version.ini
chunks in memory and commit the sentinel last through .version.ini.tmp.

Replace the fixed 15-second monitor with notify-backed non-recursive watches,
per-ID rescan gating, and a 300-second fallback scan. The optimized rescan
path updates one cached library-index entry and active operation IDs preserve
their previous summary during scans.

Test Plan:
- just fmt
- just clippy
- just test
- just build

Refs: PLAN.md
2026-05-15 18:18:55 +02:00

34 lines
1.1 KiB
Rust

//! Configuration constants for the peer system.
use std::time::Duration;
/// Interval between peer ping checks (seconds).
pub const PEER_PING_INTERVAL_SECS: u64 = 20;
/// Minimum idle time before pinging a peer (seconds).
pub const PEER_PING_IDLE_SECS: u64 = 30;
/// Timeout after which a peer is considered stale (seconds).
pub const PEER_STALE_TIMEOUT_SECS: u64 = 90;
/// Size of each download chunk (32 MB).
pub const CHUNK_SIZE: u64 = 32 * 1024 * 1024;
/// Maximum number of retry attempts for failed chunk downloads.
pub const MAX_RETRY_COUNT: usize = 3;
/// Fallback interval for reconciling missed filesystem watcher events (seconds).
pub const LOCAL_GAME_FALLBACK_SCAN_SECS: u64 = 300;
/// TLS certificate for QUIC connections.
pub static CERT_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../cert.pem"));
/// TLS private key for QUIC connections.
pub static KEY_PEM: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../key.pem"));
/// Returns the peer stale timeout as a Duration.
#[must_use]
pub fn peer_stale_timeout() -> Duration {
Duration::from_secs(PEER_STALE_TIMEOUT_SECS)
}