Module quality_monitor

Module quality_monitor 

Source
Expand description

Network quality monitor — Ping and Proof-of-Storage challenge loops.

§What it does

The monitor runs as a background Tokio task spawned by the daemon.

Ping loop (every 60 s):

  1. Reads the live NetworkState to enumerate all known Pouch peers.
  2. Sends a NetworkCommand::Ping for each Pouch (fire-and-forget per peer).
  3. Each Ping waits up to 5 seconds for a Pong from the network loop.
  4. On success: records the RTT into QosRegistry via crate::network::qos::PeerQos::record_ping and crate::network::qos::PeerQos::record_challenge.
  5. On timeout: records a timeout via crate::network::qos::PeerQos::record_ping_timeout and a failed challenge.

Proof-of-Storage loop (every 300 s):

  1. For each Pouch peer that has entries in OutgoingAssignments: picks one random fragment ID assigned to that peer.
  2. Sends a NetworkCommand::ProofOfStorage challenge.
  3. Waits up to 10 s for a bool proof result.
  4. On success: calls crate::network::qos::PeerQos::record_pos_success.
  5. On failure/timeout: calls crate::network::qos::PeerQos::record_pos_failure — increments fault_score toward the degraded/suspected/blacklisted thresholds.

The QosRegistry populated here is consumed by PutFile in the control server to compute adaptive k/n coding parameters.

§Concurrency model

All per-peer tasks within a round are spawned concurrently so a slow or dead peer does not delay the others.

Functions§

run_quality_monitor
Run the quality monitor loop indefinitely.