aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-06 16:47:32 +0100
committertv <tv@krebsco.de>2026-11-06 16:47:32 +0100
commitab8f5447680da56ce658abbc33c222219c3204ef (patch)
tree93ed572d120cf29b7e440c31194bafd021e8a5a6 /src/transport/mod.rs
parent7c0f90b327ad567c4e5e6a96cda433d774182dac (diff)
plumtree
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 743e713..52b544a 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -247,6 +247,10 @@ pub(crate) enum ParsedMessage {
Probe(ProbeRequest),
/// Answers a PROBE.
ProbeReply(ProbeReply),
+ /// Asks the recipient to leave a writer's changes to announcements (`swarm::plumtree`).
+ Prune(TreeLink),
+ /// Asks the recipient to send a writer's changes at once (`swarm::plumtree`).
+ Graft(TreeLink),
}
/// A node's proof that it holds the key of its node ID (`identity`), sending from its
@@ -391,6 +395,8 @@ pub(crate) enum MessageKind {
LinksReply,
Probe,
ProbeReply,
+ Prune,
+ Graft,
}
impl ParsedMessage {
@@ -410,6 +416,8 @@ impl ParsedMessage {
ParsedMessage::LinksReply(_) => MessageKind::LinksReply,
ParsedMessage::Probe(_) => MessageKind::Probe,
ParsedMessage::ProbeReply(_) => MessageKind::ProbeReply,
+ ParsedMessage::Prune(_) => MessageKind::Prune,
+ ParsedMessage::Graft(_) => MessageKind::Graft,
}
}
@@ -430,6 +438,9 @@ impl ParsedMessage {
ParsedMessage::LinksReply(reply) => Some((reply.epoch, reply.epoch_seq)),
ParsedMessage::Probe(request) => Some((request.epoch, request.epoch_seq)),
ParsedMessage::ProbeReply(reply) => Some((reply.epoch, reply.epoch_seq)),
+ ParsedMessage::Prune(link) | ParsedMessage::Graft(link) => {
+ Some((link.epoch, link.epoch_seq))
+ }
ParsedMessage::Who(_)
| ParsedMessage::Me(_)
| ParsedMessage::Ping(_)
@@ -438,6 +449,18 @@ impl ParsedMessage {
}
}
+/// PRUNE and GRAFT: a writer's changes left to announcements, or sent at once, between
+/// the sender and the recipient (`swarm::plumtree`).
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub(crate) struct TreeLink {
+ #[serde(with = "crate::transport::wire::codec::epoch")]
+ pub(crate) epoch: Epoch,
+ /// See `SyncEnvelope::epoch_seq`.
+ pub(crate) epoch_seq: u32,
+ /// The writer, by its pair key (`topology::pair_key`).
+ pub(crate) writer: u64,
+}
+
/// PROBE: whether the recipient reaches `member` (`swarm::working_links`), as SWIM
/// asks others before it suspects a member. Answered from what the recipient knows,
/// without contacting the member.