This commit is contained in:
Dave Hrycyszyn
2024-06-06 19:00:05 +01:00
parent da29d681d8
commit bc2307f085

View File

@@ -19,31 +19,23 @@ pub(crate) async fn start(
let _ = list_transaction_crdt::send(count, bft_crdt, &mut ws, &keys).await; let _ = list_transaction_crdt::send(count, bft_crdt, &mut ws, &keys).await;
let msg = ws.receive().await?; let msg = ws.receive().await?;
// println!("Received: {:?}", msg);
// deserialize the received websocket Frame into a string // deserialize the received websocket Frame into a string
let msg = msg.into_text().unwrap().0; let msg = msg.into_text().unwrap().0;
// deserialize the message into a Transaction struct // deserialize the message into a Transaction struct
let incoming_operation: SignedOp = serde_json::from_str(&msg).unwrap(); let incoming_operation: SignedOp = serde_json::from_str(&msg).unwrap();
// let hash = sha256::digest(incoming_operation.inner.hash());
// let hash = incoming_operation.inner.hash();
let author = general_purpose::STANDARD.encode(&incoming_operation.author()); let author = general_purpose::STANDARD.encode(&incoming_operation.author());
println!("Received from {:?}", author); println!("Received from {:?}", author);
bft_crdt.apply(incoming_operation.clone()); bft_crdt.apply(incoming_operation.clone());
// println!("New crdt state is: {}", bft_crdt.doc.view());
count = count + 1; count = count + 1;
interval.tick().await; interval.tick().await;
} }
} }
// fn every_two_seconds() -> time::Interval {
// time::interval(time::Duration::from_secs(2))
// }
fn every_ten_seconds() -> time::Interval { fn every_ten_seconds() -> time::Interval {
time::interval(time::Duration::from_secs(10)) time::interval(time::Duration::from_secs(10))
} }