diff options
| author | tv <tv@krebsco.de> | 2026-11-06 19:54:09 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-06 19:54:09 +0100 |
| commit | 5994b49412c058079639585501a78e6458fdbb6f (patch) | |
| tree | ca78aa3cd7d0d6d2a48bfa42d61afcddb8efd6df /src/state | |
| parent | 7c0c318dca3054be6c7bacf5a4b3f5a4e47cc949 (diff) | |
HyParView (slim)
Diffstat (limited to 'src/state')
| -rw-r--r-- | src/state/mod.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs index d5c18b3..3dfc6b1 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -68,10 +68,17 @@ pub(crate) struct AppState { pub(crate) peer_states: Arc<RwLock<HashMap<String, Arc<Mutex<PeerState>>>>>, pub(crate) transport: Arc<dyn transport::Transport>, - /// How members' neighbours are chosen (`swarm::topology::Topology`). - pub(crate) topology: Arc<dyn crate::swarm::topology::Topology>, - /// How a change reaches every member (`swarm::dissemination::Dissemination`). - pub(crate) dissemination: Arc<dyn crate::swarm::dissemination::Dissemination>, + /// How members' neighbours are chosen (`swarm::topology::Topology`), and how a change + /// reaches every member (`swarm::dissemination::Dissemination`): as the swarm + /// records them (`swarm::topology::swarm_ways`), swapped when that changes; + /// `--topology` and `--dissemination` until then (`configured_ways`). + pub(crate) ways: Arc<std::sync::RwLock<crate::swarm::topology::Ways>>, + /// `--topology` and `--dissemination`: what a genesis node records, and what counts + /// where the swarm records nothing this node knows. + pub(crate) configured_ways: ( + crate::swarm::topology::Kind, + crate::swarm::dissemination::Kind, + ), pub(crate) firewall: Arc<Firewall>, /// Messages and bytes exchanged, per peer (`transport::traffic`). pub(crate) traffic: Arc<transport::traffic::Traffic>, @@ -253,6 +260,16 @@ impl AppState { .collect() } + /// How members' neighbours are chosen now (`ways`). + pub(crate) fn topology(&self) -> Arc<dyn crate::swarm::topology::Topology> { + Arc::clone(&self.ways.read_or_recover().topology) + } + + /// How a change reaches every member now (`ways`). + pub(crate) fn dissemination(&self) -> Arc<dyn crate::swarm::dissemination::Dissemination> { + Arc::clone(&self.ways.read_or_recover().dissemination) + } + pub(crate) fn lock_rtt(&self) -> std::sync::MutexGuard<'_, crate::swarm::rtt::RttTable> { self.rtt.lock_or_recover() } |
