diff --git a/side-node/src/node.rs b/side-node/src/node.rs index 52c7092..aac03dd 100644 --- a/side-node/src/node.rs +++ b/side-node/src/node.rs @@ -46,7 +46,7 @@ impl SideNode { } match self.incoming_receiver.try_recv() { Ok(incoming) => { - self.handle_incoming(&incoming); + self.handle_incoming(incoming); } Err(_) => {} // ignore empty channel errors in this PoC } @@ -59,9 +59,9 @@ impl SideNode { self.handle.call(to_send).unwrap(); } - fn handle_incoming(&mut self, incoming: &SignedOp) { + fn handle_incoming(&mut self, incoming: SignedOp) { println!("WINNNINGINGINGINGINGIGNIGN"); - self.crdt.apply(incoming.clone()); + self.crdt.apply(incoming); } pub(crate) fn add_transaction_local( diff --git a/side-node/src/websocket.rs b/side-node/src/websocket.rs index eecafe0..f7d5caa 100644 --- a/side-node/src/websocket.rs +++ b/side-node/src/websocket.rs @@ -37,6 +37,8 @@ impl ezsockets::ClientExt for WebSocketClient { // match on it. type Call = String; + /// 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> { tracing::info!("received text: {text:?}"); let incoming: bft_json_crdt::json_crdt::SignedOp = serde_json::from_str(&text).unwrap(); @@ -44,11 +46,14 @@ impl ezsockets::ClientExt for WebSocketClient { Ok(()) } + /// When we receive a binary message, log the bytes. Currently unused. async fn on_binary(&mut self, bytes: Vec) -> Result<(), ezsockets::Error> { tracing::info!("received bytes: {bytes:?}"); Ok(()) } + /// Call this with the `Call` type to send application data to the websocket client + /// (and from there, to the server). async fn on_call(&mut self, call: Self::Call) -> Result<(), ezsockets::Error> { tracing::info!("sending signed op: {call:?}"); self.handle.text(call)?;