diff --git a/side-node/src/list_transaction_crdt.rs b/side-node/src/list_transaction_crdt.rs index 9192b02..6e4be79 100644 --- a/side-node/src/list_transaction_crdt.rs +++ b/side-node/src/list_transaction_crdt.rs @@ -35,14 +35,12 @@ pub(crate) fn new(side_dir: PathBuf) -> (BaseCrdt, Ed25519KeyPair) { (bft_crdt, keys) } -pub(crate) async fn send( - count: u32, +pub(crate) fn send( bft_crdt: &mut BaseCrdt, - // ws: &mut WebSocket, keys: &Ed25519KeyPair, -) { +) -> bft_json_crdt::json_crdt::SignedOp { // generate a placeholder transaction - let transaction = generate_transaction(count, keys.public().to_string()); + let transaction = generate_transaction(keys.public().to_string()); // next job is to keep adding to this guy let next = bft_crdt.doc.list.ops.len(); @@ -51,16 +49,13 @@ pub(crate) async fn send( .list .insert_idx(next - 1, transaction.clone()) .sign(&keys); - - // Ok(ws - // .send_text(serde_json::to_string(&signed_op).unwrap()) - // .await?) + signed_op } -fn generate_transaction(count: u32, pubkey: String) -> Value { +fn generate_transaction(pubkey: String) -> Value { json!({ "from": pubkey, "to": "Bob", - "amount": count + "amount": 1 }) } diff --git a/side-node/src/websocket/mod.rs b/side-node/src/websocket/mod.rs index 60c380d..d8ca37b 100644 --- a/side-node/src/websocket/mod.rs +++ b/side-node/src/websocket/mod.rs @@ -1,23 +1,8 @@ /* loop { - let _ = list_transaction_crdt::send(count, bft_crdt, &mut ws, &keys).await; - - let msg = ws.receive().await?; - - // deserialize the received websocket Frame into a string - let msg = msg.into_text().unwrap().0; - - // deserialize the message into a Transaction struct - let incoming_operation: SignedOp = serde_json::from_str(&msg).unwrap(); - let author = general_purpose::STANDARD.encode(&incoming_operation.author()); - println!("Received from {:?}", author); - bft_crdt.apply(incoming_operation.clone()); - - count = count + 1; - interval.tick().await; } */ @@ -28,7 +13,7 @@ use ezsockets::ClientConfig; use fastcrypto::ed25519::Ed25519KeyPair; use std::io::BufRead; -use crate::list_transaction_crdt::CrdtList; +use crate::list_transaction_crdt::{self, CrdtList}; struct Client {} @@ -63,7 +48,13 @@ pub(crate) async fn start(keys: Ed25519KeyPair, bft_crdt: &mut BaseCrdt