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/transport/mod.rs | |
| parent | 7c0c318dca3054be6c7bacf5a4b3f5a4e47cc949 (diff) | |
HyParView (slim)
Diffstat (limited to 'src/transport/mod.rs')
| -rw-r--r-- | src/transport/mod.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 52b544a..8cbf412 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -251,6 +251,12 @@ pub(crate) enum ParsedMessage { Prune(TreeLink), /// Asks the recipient to send a writer's changes at once (`swarm::plumtree`). Graft(TreeLink), + /// Asks the recipient to be neighbours (`swarm::hyparview`). + Neighbour(NeighbourRequest), + /// Answers a NEIGHBOUR. + NeighbourReply(NeighbourAnswer), + /// Tells the recipient we are neighbours no more (`swarm::hyparview`). + Disconnect(NeighbourAnswer), } /// A node's proof that it holds the key of its node ID (`identity`), sending from its @@ -397,6 +403,9 @@ pub(crate) enum MessageKind { ProbeReply, Prune, Graft, + Neighbour, + NeighbourReply, + Disconnect, } impl ParsedMessage { @@ -418,6 +427,9 @@ impl ParsedMessage { ParsedMessage::ProbeReply(_) => MessageKind::ProbeReply, ParsedMessage::Prune(_) => MessageKind::Prune, ParsedMessage::Graft(_) => MessageKind::Graft, + ParsedMessage::Neighbour(_) => MessageKind::Neighbour, + ParsedMessage::NeighbourReply(_) => MessageKind::NeighbourReply, + ParsedMessage::Disconnect(_) => MessageKind::Disconnect, } } @@ -441,6 +453,10 @@ impl ParsedMessage { ParsedMessage::Prune(link) | ParsedMessage::Graft(link) => { Some((link.epoch, link.epoch_seq)) } + ParsedMessage::Neighbour(request) => Some((request.epoch, request.epoch_seq)), + ParsedMessage::NeighbourReply(answer) | ParsedMessage::Disconnect(answer) => { + Some((answer.epoch, answer.epoch_seq)) + } ParsedMessage::Who(_) | ParsedMessage::Me(_) | ParsedMessage::Ping(_) @@ -461,6 +477,29 @@ pub(crate) struct TreeLink { pub(crate) writer: u64, } +/// NEIGHBOUR: the sender asks the recipient to be neighbours (`swarm::hyparview`), as +/// HyParView's NEIGHBOR; `high` when the sender has none (then the recipient makes room +/// if it must). +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct NeighbourRequest { + #[serde(with = "crate::transport::wire::codec::epoch")] + pub(crate) epoch: Epoch, + /// See `SyncEnvelope::epoch_seq`. + pub(crate) epoch_seq: u32, + pub(crate) high: bool, +} + +/// NEIGHBOUR_REPLY (whether the recipient of a NEIGHBOUR agreed) and DISCONNECT (never +/// agreed: neighbours no more) (`swarm::hyparview`). +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct NeighbourAnswer { + #[serde(with = "crate::transport::wire::codec::epoch")] + pub(crate) epoch: Epoch, + /// See `SyncEnvelope::epoch_seq`. + pub(crate) epoch_seq: u32, + pub(crate) agreed: bool, +} + /// 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. |
