diff options
Diffstat (limited to 'src/transport/mod.rs')
| -rw-r--r-- | src/transport/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index a1fb9d5..e0359b0 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -254,6 +254,23 @@ pub(crate) enum ParsedMessage { Disconnect(NeighbourAnswer), /// Signatures of changes, sent on their own (`swarm::signatures`). Signatures(SignaturesMessage), + /// Changes the sender refused, of those the recipient brought (`swarm::refusals`). + Refusals(RefusalsMessage), +} + +/// REFUSALS: changes the sender refused by the swarm's rules (`access::screen`), of +/// those the recipient brought it: the recipient judges them itself, and rejoins if its +/// own rules refuse them too, as it took them under another policy (`swarm::refusals`). +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct RefusalsMessage { + #[serde(with = "crate::transport::wire::codec::epoch")] + pub(crate) epoch: Epoch, + /// See `SyncEnvelope::epoch_seq`. + pub(crate) epoch_seq: u32, + /// The changes that broke the rules (not those refused for building on them), at + /// most `swarm::refusals::MAX_LISTED`. + #[serde(with = "crate::transport::wire::codec::change_hashes")] + pub(crate) changes: Vec<crate::document::ChangeHash>, } /// SIGNATURES: signatures of changes no sync message took (`swarm::signatures`). @@ -413,6 +430,7 @@ pub(crate) enum MessageKind { NeighbourReply, Disconnect, Signatures, + Refusals, } impl ParsedMessage { @@ -436,6 +454,7 @@ impl ParsedMessage { ParsedMessage::NeighbourReply(_) => MessageKind::NeighbourReply, ParsedMessage::Disconnect(_) => MessageKind::Disconnect, ParsedMessage::Signatures(_) => MessageKind::Signatures, + ParsedMessage::Refusals(_) => MessageKind::Refusals, } } @@ -462,6 +481,7 @@ impl ParsedMessage { Some((answer.epoch, answer.epoch_seq)) } ParsedMessage::Signatures(message) => Some((message.epoch, message.epoch_seq)), + ParsedMessage::Refusals(message) => Some((message.epoch, message.epoch_seq)), ParsedMessage::Who(_) | ParsedMessage::Me(_) | ParsedMessage::Ping(_) |
