Now serializing a fake transaction instead sending a character
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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<char>, // switch to Transaction as soon as char is working
|
||||
list: ListCrdt<Transaction>, // 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<String> {
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user