diff --git a/Cargo.lock b/Cargo.lock index 670da88..1cdc8f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,6 +296,7 @@ dependencies = [ "itertools 0.12.1", "rand 0.8.5", "random_color", + "serde", "serde_json", "sha2 0.10.8", ] @@ -1031,12 +1032,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "half" -version = "1.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" - [[package]] name = "hashbrown" version = "0.12.3" @@ -1953,16 +1948,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.203" @@ -2090,7 +2075,6 @@ dependencies = [ "bft-json-crdt", "clap", "serde", - "serde_cbor", "serde_json", "tokio", "websockets", diff --git a/side-node/Cargo.toml b/side-node/Cargo.toml index d1e0d5b..b54db7b 100644 --- a/side-node/Cargo.toml +++ b/side-node/Cargo.toml @@ -11,7 +11,7 @@ tokio = { version = "1.37.0", features = ["time"] } websockets = "0.3.0" bft-json-crdt = { path = "../../bft-json-crdt" } bft-crdt-derive = { path = "../../bft-json-crdt/bft-crdt-derive" } -serde_cbor = "0.11.2" +# serde_cbor = "0.11.2" # move to this once we need to pack things in CBOR serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.117" diff --git a/side-node/src/websocket/mod.rs b/side-node/src/websocket/mod.rs index b0bd14c..9c6de9f 100644 --- a/side-node/src/websocket/mod.rs +++ b/side-node/src/websocket/mod.rs @@ -1,7 +1,7 @@ use bft_crdt_derive::add_crdt_fields; use bft_json_crdt::{ json_crdt::{BaseCrdt, CrdtNode, IntoCrdtNode}, - keypair::make_keypair, + keypair::{make_keypair, ED25519_PUBLIC_KEY_LENGTH}, list_crdt::ListCrdt, op::ROOT_ID, }; @@ -42,24 +42,27 @@ fn every_two_seconds() -> time::Interval { } #[add_crdt_fields] -#[derive(Clone, CrdtNode)] +#[derive(Clone, CrdtNode, Serialize, Deserialize)] struct ListExample { - list: ListCrdt, // switch to Transaction as soon as char is working + list: ListCrdt, // switch to Transaction as soon as char is working } /// A fake Transaction struct we can use as a simulated payload -#[derive(Serialize, Deserialize)] +#[add_crdt_fields] +#[derive(Clone, CrdtNode, Serialize, Deserialize)] struct Transaction { from: String, to: String, - amount: u64, + amount: f64, } fn generate_transaction() -> serde_json::Result { let transaction = Transaction { from: "Alice".to_string(), to: "Bob".to_string(), - amount: 100, + amount: 100.0, + path: vec![], + id: [0; ED25519_PUBLIC_KEY_LENGTH], }; let json = serde_json::to_string(&transaction).unwrap();