crdt: Remove unused `Envelope` type
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
d6467fe4f1
commit
f6e8a18b15
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use radicle_crypto::{PublicKey, Signature, Signer};
|
use radicle_crypto::{PublicKey, Signer};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::clock;
|
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.
|
/// An object that can be used to create and sign changes.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Actor<G, A> {
|
pub struct Actor<G, A> {
|
||||||
|
|
@ -116,23 +107,4 @@ impl<G: Signer, A: Clone + Serialize> Actor<G, A> {
|
||||||
|
|
||||||
change
|
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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue