crdt: Remove unused `Envelope` type

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-12-01 15:05:03 +01:00
parent d6467fe4f1
commit f6e8a18b15
No known key found for this signature in database
1 changed files with 1 additions and 29 deletions

View File

@ -1,6 +1,6 @@
use std::collections::BTreeMap;
use radicle_crypto::{PublicKey, Signature, Signer};
use radicle_crypto::{PublicKey, Signer};
use serde::{Deserialize, Serialize};
use crate::clock;
@ -53,15 +53,6 @@ impl<'de, A: Deserialize<'de>> Change<A> {
}
}
/// Change envelope. Carries signed changes.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Envelope {
/// Changes included in this envelope, serialized as JSON.
pub changes: Vec<u8>,
/// Signature over the change, by the change author.
pub signature: Signature,
}
/// An object that can be used to create and sign changes.
#[derive(Default)]
pub struct Actor<G, A> {
@ -116,23 +107,4 @@ impl<G: Signer, A: Clone + Serialize> Actor<G, A> {
change
}
pub fn sign(&self, changes: impl IntoIterator<Item = Change<A>>) -> Envelope {
let changes = changes.into_iter().collect::<Vec<_>>();
let json = serde_json::to_value(changes).unwrap();
let mut buffer = Vec::new();
let mut serializer = serde_json::Serializer::with_formatter(
&mut buffer,
olpc_cjson::CanonicalFormatter::new(),
);
json.serialize(&mut serializer).unwrap();
let signature = self.signer.sign(&buffer);
Envelope {
changes: buffer,
signature,
}
}
}