diff options
| author | tv <tv@krebsco.de> | 2026-11-06 16:35:02 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-06 16:35:02 +0100 |
| commit | 8a134df62167a85fa083ccf480a939fd654e2419 (patch) | |
| tree | d571d3ff39f013c4d0e3a9cb4b377c8f267e9853 /src/swarm/tree.rs | |
| parent | b18c75f20f937229c9b12bf3f07901090bd35317 (diff) | |
dissemination trait
Diffstat (limited to 'src/swarm/tree.rs')
| -rw-r--r-- | src/swarm/tree.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/swarm/tree.rs b/src/swarm/tree.rs index 064f5b9..de865de 100644 --- a/src/swarm/tree.rs +++ b/src/swarm/tree.rs @@ -707,6 +707,42 @@ pub(crate) async fn forward( Some(plan) } +/// Writers' trees as the way changes reach every member +/// (`swarm::dissemination::Dissemination`): `plan`, `forward` and `note_arrival` above. +pub(crate) struct WritersTrees; + +#[async_trait::async_trait] +impl crate::swarm::dissemination::Dissemination for WritersTrees { + fn name(&self) -> &'static str { + "writers-trees" + } + + async fn plan(&self, state: &AppState, writer: u64) -> Option<Plan> { + plan(state, writer).await + } + + async fn forward( + &self, + state: &AppState, + writer: u64, + from: &str, + changes: &[crate::document::ChangeHash], + ) -> Option<Plan> { + forward(state, writer, from, changes).await + } + + async fn note_arrival( + &self, + state: &AppState, + peer: &str, + writer: Option<u64>, + carried: bool, + authors: &[(String, Vec<crate::document::ChangeHash>)], + ) { + note_arrival(state, peer, writer, carried, authors).await; + } +} + #[cfg(test)] mod tests { use super::*; |
