Fixed serializiation determinacy problems.
This commit is contained in:
@@ -3,6 +3,8 @@ use bft_json_crdt::json_crdt::SignedOp;
|
||||
use ezsockets::ClientConfig;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::utils;
|
||||
|
||||
pub struct WebSocketClient {
|
||||
incoming_sender: mpsc::Sender<SignedOp>,
|
||||
handle: ezsockets::Client<WebSocketClient>,
|
||||
@@ -39,7 +41,16 @@ impl ezsockets::ClientExt for WebSocketClient {
|
||||
/// When we receive a text message, apply the crdt operation contained in it to our
|
||||
/// local crdt.
|
||||
async fn on_text(&mut self, text: String) -> Result<(), ezsockets::Error> {
|
||||
let string_sha = utils::shassy(text.clone());
|
||||
println!("received text, sha: {string_sha}");
|
||||
let incoming: bft_json_crdt::json_crdt::SignedOp = serde_json::from_str(&text).unwrap();
|
||||
let object_sha = utils::shappy(incoming.clone());
|
||||
println!("deserialized: {}", object_sha);
|
||||
if string_sha != object_sha {
|
||||
println!("SHA mismatch: {string_sha} != {object_sha}");
|
||||
println!("text: {text}");
|
||||
println!("incoming: {incoming:?}");
|
||||
}
|
||||
self.incoming_sender.send(incoming).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user