From 4d87725f32099355d4ece79e7aabde9b8486c0b3 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Sun, 29 Oct 2023 22:13:59 +0800 Subject: [PATCH] chore: rm needless package --- Cargo.lock | 106 +----------------------- crates/loro-e2ee/Cargo.toml | 16 ---- crates/loro-e2ee/README.md | 10 --- crates/loro-e2ee/src/encoding/decode.rs | 0 crates/loro-e2ee/src/encoding/encode.rs | 0 crates/loro-e2ee/src/encoding/mod.rs | 0 crates/loro-e2ee/src/lib.rs | 5 -- crates/loro-e2ee/src/loro.rs | 9 -- crates/loro-e2ee/src/raw_change.rs | 61 -------------- crates/loro-e2ee/src/raw_store.rs | 95 --------------------- crates/loro/Cargo.toml | 9 -- crates/loro/src/lib.rs | 1 - crates/loro/tests/test.rs | 1 - 13 files changed, 1 insertion(+), 312 deletions(-) delete mode 100644 crates/loro-e2ee/Cargo.toml delete mode 100644 crates/loro-e2ee/README.md delete mode 100644 crates/loro-e2ee/src/encoding/decode.rs delete mode 100644 crates/loro-e2ee/src/encoding/encode.rs delete mode 100644 crates/loro-e2ee/src/encoding/mod.rs delete mode 100644 crates/loro-e2ee/src/lib.rs delete mode 100644 crates/loro-e2ee/src/loro.rs delete mode 100644 crates/loro-e2ee/src/raw_change.rs delete mode 100644 crates/loro-e2ee/src/raw_store.rs delete mode 100644 crates/loro/Cargo.toml delete mode 100644 crates/loro/src/lib.rs delete mode 100644 crates/loro/tests/test.rs diff --git a/Cargo.lock b/Cargo.lock index a94986af..f616dd0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,15 +168,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - [[package]] name = "bumpalo" version = "3.11.1" @@ -360,15 +351,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - [[package]] name = "crc32fast" version = "1.3.2" @@ -500,16 +482,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "ctor" version = "0.1.26" @@ -598,16 +570,6 @@ dependencies = [ "thousands", ] -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "either" version = "1.8.0" @@ -705,16 +667,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "generic-btree" version = "0.8.0" @@ -778,7 +730,7 @@ dependencies = [ "hash32", "rustc_version", "serde", - "spin 0.9.4", + "spin", "stable_deref_trait", ] @@ -964,13 +916,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "loro" -version = "0.1.0" -dependencies = [ - "loro-internal", -] - [[package]] name = "loro-common" version = "0.1.0" @@ -995,17 +940,6 @@ dependencies = [ "loro-internal", ] -[[package]] -name = "loro-framework" -version = "0.1.0" -dependencies = [ - "fxhash", - "loro-internal", - "ring", - "rle", - "sha2", -] - [[package]] name = "loro-internal" version = "0.1.0" @@ -1720,21 +1654,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted", - "web-sys", - "winapi", -] - [[package]] name = "rle" version = "0.1.0" @@ -1899,17 +1818,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -1946,12 +1854,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.4" @@ -2241,12 +2143,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "version_check" version = "0.9.4" diff --git a/crates/loro-e2ee/Cargo.toml b/crates/loro-e2ee/Cargo.toml deleted file mode 100644 index 4803a8e7..00000000 --- a/crates/loro-e2ee/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "loro-framework" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -fxhash = "0.2.1" -loro-internal = { path = "../loro-internal" } -ring = "0.16.20" -rle = { path = "../rle" } -sha2 = "0.10.2" - -[lib] -doctest = false diff --git a/crates/loro-e2ee/README.md b/crates/loro-e2ee/README.md deleted file mode 100644 index 6b8afb2c..00000000 --- a/crates/loro-e2ee/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Loro Framework - -The layers of loro: - -- Loro Framework(this crate): It is agnostic to the op content. Thus intermediary nodes can work on this layer. It can handle apply updates, encode updates, hash and authentication. - - The change content is byte stream in this layer (may be encrypted). - - If it's encrypted, the public key is accessible for the intermediary nodes -- Encoding & Decoding layer(this crate). This layer also handle encryption and decryption -- CRDT Framework(loro-internal crate): It is agnostic to the specific CRDT algorithms. We can register different CRDT algorithm upon it. -- Specific CRDT Algorithm(loro-text, loro-array crate). diff --git a/crates/loro-e2ee/src/encoding/decode.rs b/crates/loro-e2ee/src/encoding/decode.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/crates/loro-e2ee/src/encoding/encode.rs b/crates/loro-e2ee/src/encoding/encode.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/crates/loro-e2ee/src/encoding/mod.rs b/crates/loro-e2ee/src/encoding/mod.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/crates/loro-e2ee/src/lib.rs b/crates/loro-e2ee/src/lib.rs deleted file mode 100644 index ac3f02f0..00000000 --- a/crates/loro-e2ee/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(unused)] -mod encoding; -mod loro; -mod raw_change; -mod raw_store; diff --git a/crates/loro-e2ee/src/loro.rs b/crates/loro-e2ee/src/loro.rs deleted file mode 100644 index bf14f744..00000000 --- a/crates/loro-e2ee/src/loro.rs +++ /dev/null @@ -1,9 +0,0 @@ -use loro_internal::{id::PeerID, LoroDoc}; - -use crate::raw_store::RawStore; - -pub struct Loro { - pub this_client_id: PeerID, - pub raw_store: Option, - pub log_store: Option, -} diff --git a/crates/loro-e2ee/src/raw_change.rs b/crates/loro-e2ee/src/raw_change.rs deleted file mode 100644 index 0a4dd668..00000000 --- a/crates/loro-e2ee/src/raw_change.rs +++ /dev/null @@ -1,61 +0,0 @@ -use rle::{HasLength, Mergable}; -use sha2::{Digest, Sha256}; - -pub(crate) type ChangeHash = [u8; 32]; - -pub struct ChangeData { - pub counter: usize, - pub len: usize, - pub data: Vec, - pub hash: Option, -} - -impl ChangeData { - pub fn update_hash(&mut self, prev_hash: Option) { - self.hash = Some(self.calc_hash(prev_hash)); - } - - pub fn calc_hash(&mut self, prev_hash: Option) -> ChangeHash { - let mut hasher = Sha256::new(); - hasher.update(&self.data); - if let Some(prev) = prev_hash { - hasher.update(prev); - } - - hasher.finalize()[..].try_into().unwrap() - } - - pub fn match_hash(&self, prev_hash: Option) -> bool { - if let Some(hash) = self.hash { - if let Some(prev) = prev_hash { - hash == prev - } else { - false - } - } else { - false - } - } -} - -impl HasLength for ChangeData { - fn content_len(&self) -> usize { - self.len - } -} - -impl Mergable for ChangeData { - fn is_mergable(&self, _other: &Self, _conf: &()) -> bool - where - Self: Sized, - { - false - } - - fn merge(&mut self, _other: &Self, _conf: &()) - where - Self: Sized, - { - unreachable!() - } -} diff --git a/crates/loro-e2ee/src/raw_store.rs b/crates/loro-e2ee/src/raw_store.rs deleted file mode 100644 index 43b629ea..00000000 --- a/crates/loro-e2ee/src/raw_store.rs +++ /dev/null @@ -1,95 +0,0 @@ -use fxhash::FxHashMap; -use loro_internal::{ - id::{Counter, PeerID}, - version::VersionVector, -}; -use rle::{HasLength, RleVecWithIndex}; - -use crate::raw_change::{ChangeData, ChangeHash}; - -pub type Mac = [u8; 32]; - -pub struct RawStore { - changes: FxHashMap>, - macs: Option>, -} - -impl RawStore { - pub fn new() -> Self { - Self { - changes: FxHashMap::default(), - macs: None, - } - } - - pub fn maced(&self) -> bool { - self.macs.is_some() - } - - pub fn encode_update(&self, _from: Option<&VersionVector>) -> Vec { - unimplemented!() - } - - pub fn verify(&mut self, _pub_key: &[u8; 32]) -> bool { - if !self.maced() { - return true; - } - - if self.macs.as_ref().unwrap().len() < self.changes.len() { - return false; - } - - self.calc_hash(); - for (_client_id, _mac) in self.macs.as_ref().unwrap().iter() { - todo!("pending"); - } - - true - } - - pub fn get_final_hash(&self, client_id: PeerID) -> ChangeHash { - let changes = self.changes.get(&client_id).unwrap(); - let last = changes.vec().last().unwrap(); - last.hash.unwrap() - } - - fn calc_hash(&mut self) { - for (_client_id, changes) in &mut self.changes.iter_mut() { - let changes = changes.vec_mut(); - let mut start_index = 0; - for i in (0..changes.len()).rev() { - if changes[i].hash.is_some() { - start_index = i + 1; - break; - } - } - for index in start_index..changes.len() { - let (prev, cur) = changes.split_at_mut(index); - cur[0].update_hash(if index == 0 { - None - } else { - Some(prev.last().unwrap().hash.unwrap()) - }); - } - } - } - - pub fn version_vector(&self) -> VersionVector { - let mut version_vector = VersionVector::new(); - for (client_id, changes) in &self.changes { - version_vector.insert(*client_id, changes.atom_len() as Counter); - } - - version_vector - } - - pub fn sign(&self, _pub_key: ()) { - unimplemented!() - } -} - -impl Default for RawStore { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/loro/Cargo.toml b/crates/loro/Cargo.toml deleted file mode 100644 index f8787fa3..00000000 --- a/crates/loro/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "loro" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -loro-internal = { path = "../loro-internal" } diff --git a/crates/loro/src/lib.rs b/crates/loro/src/lib.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/loro/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/crates/loro/tests/test.rs b/crates/loro/tests/test.rs deleted file mode 100644 index 8b137891..00000000 --- a/crates/loro/tests/test.rs +++ /dev/null @@ -1 +0,0 @@ -