diff options
| author | tv <tv@krebsco.de> | 2026-11-29 04:00:43 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-29 04:00:43 +0000 |
| commit | 2ae7562083f5f96490f90e9398762cf6a024d51e (patch) | |
| tree | 5e23c6bda5682e39413fe557348023cc4204d487 /src/swarm/plumtree.rs | |
| parent | f497cf6ef14de8204bc1edec078116593d791b97 (diff) | |
document: a unit's name, which the swarm passes on by
document::UnitId: the name of a unit of a document as its kind has it,
an Automerge change's hash. What the swarm announces, forwards along
trees, tells a peer it refused and drops is named so (the
dissemination, relay, refusals, AppState::drop_taken), and the session
is told so what a peer gets from another; a change's hash it is where
the document is asked, and on the wire.
Diffstat (limited to 'src/swarm/plumtree.rs')
| -rw-r--r-- | src/swarm/plumtree.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/swarm/plumtree.rs b/src/swarm/plumtree.rs index 9560b9f..340fa68 100644 --- a/src/swarm/plumtree.rs +++ b/src/swarm/plumtree.rs @@ -45,7 +45,7 @@ use async_trait::async_trait; use tokio::time::Instant; use tracing::debug; -use crate::document::ChangeHash; +use crate::document::UnitId; use crate::locks::MutexExt; use crate::state::AppState; use crate::swarm::dissemination::{Dissemination, pass_on}; @@ -99,7 +99,7 @@ const SETTLE_UNKNOWN: Duration = Duration::from_secs(2); #[derive(Default)] pub(crate) struct PlumTree { lazy: Mutex<HashSet<String>>, - announced: Mutex<HashMap<ChangeHash, (String, Instant)>>, + announced: Mutex<HashMap<UnitId, (String, Instant)>>, ahead_times: Mutex<HashMap<String, u32>>, /// When we last grafted each link (`settling`). grafted: Mutex<HashMap<String, Instant>>, @@ -124,7 +124,7 @@ impl PlumTree { /// pushes in a row: its link is the faster, by at least an announcement's delay /// (`relay::ANNOUNCE_DELAY`), which a push over it doesn't wait. The changes are /// forgotten as announced. - fn ahead(&self, peer: &str, authors: &[(String, Vec<ChangeHash>)]) -> Option<String> { + fn ahead(&self, peer: &str, authors: &[(String, Vec<UnitId>)]) -> Option<String> { let now = Instant::now(); let told: Vec<(String, Instant)> = { let mut announced = self.announced.lock_or_recover(); @@ -186,7 +186,7 @@ impl PlumTree { } /// The changes, come another way, are forgotten as announced. - fn forget_announced(&self, authors: &[(String, Vec<ChangeHash>)]) { + fn forget_announced(&self, authors: &[(String, Vec<UnitId>)]) { let mut announced = self.announced.lock_or_recover(); for change in authors.iter().flat_map(|(_, changes)| changes) { announced.remove(change); @@ -241,7 +241,7 @@ impl Dissemination for PlumTree { state: &AppState, writer: u64, from: &str, - changes: &[ChangeHash], + changes: &[UnitId], ) -> Option<Plan> { let plan = self.plan(state, writer).await?; Some(pass_on(state, writer, from, changes, plan).await) @@ -262,7 +262,7 @@ impl Dissemination for PlumTree { peer: &str, writer: Option<u64>, carried: bool, - authors: &[(String, Vec<ChangeHash>)], + authors: &[(String, Vec<UnitId>)], ) { match writer { Some(writer) if carried && authors.is_empty() => { @@ -304,7 +304,7 @@ impl Dissemination for PlumTree { } /// The first to tell us of each head is the one noticed. - fn announced(&self, peer: &str, heads: &[ChangeHash]) { + fn announced(&self, peer: &str, heads: &[UnitId]) { let mut announced = self.announced.lock_or_recover(); if announced.len() + heads.len() > MAX_ANNOUNCED { announced.clear(); |
