Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
crdt: Remove unused `Envelope` type
Alexis Sellier committed 3 years ago
commit f6e8a18b15d0d934f0b9ed0b2cdcd437ac47e8fa
parent d6467fe4f19ecf3afa7ea8b0ab7b118317445bf2
1 file changed +1 -29
modified radicle-crdt/src/change.rs
@@ -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,
-
        }
-
    }
}