Renamed sha operations to sound less crazy
This commit is contained in:
@@ -39,10 +39,10 @@ impl ezsockets::ClientExt for Client {
|
|||||||
/// When we receive a text message, apply the bft-crdt operation contained in it to our
|
/// When we receive a text message, apply the bft-crdt operation contained in it to our
|
||||||
/// local bft-crdt.
|
/// local bft-crdt.
|
||||||
async fn on_text(&mut self, text: String) -> Result<(), ezsockets::Error> {
|
async fn on_text(&mut self, text: String) -> Result<(), ezsockets::Error> {
|
||||||
let string_sha = utils::shassy(text.clone());
|
let string_sha = utils::sha_string(text.clone());
|
||||||
println!("received text, sha: {string_sha}");
|
println!("received text, sha: {string_sha}");
|
||||||
let incoming: bft_json_crdt::json_crdt::SignedOp = serde_json::from_str(&text).unwrap();
|
let incoming: bft_json_crdt::json_crdt::SignedOp = serde_json::from_str(&text).unwrap();
|
||||||
let object_sha = utils::shappy(incoming.clone());
|
let object_sha = utils::sha_op(incoming.clone());
|
||||||
println!("deserialized: {}", object_sha);
|
println!("deserialized: {}", object_sha);
|
||||||
if string_sha != object_sha {
|
if string_sha != object_sha {
|
||||||
panic!("sha mismatch: {string_sha} != {object_sha}, bft-bft-crdt has failed");
|
panic!("sha mismatch: {string_sha} != {object_sha}, bft-bft-crdt has failed");
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ impl SideNode {
|
|||||||
let transaction = utils::fake_generic_transaction_json(stdin);
|
let transaction = utils::fake_generic_transaction_json(stdin);
|
||||||
let json = serde_json::to_value(transaction).unwrap();
|
let json = serde_json::to_value(transaction).unwrap();
|
||||||
let signed_op = self.add_transaction_local(json);
|
let signed_op = self.add_transaction_local(json);
|
||||||
println!("STDIN: {}", utils::shappy(signed_op.clone()));
|
println!("STDIN: {}", utils::sha_op(signed_op.clone()));
|
||||||
self.send_to_network(signed_op).await;
|
self.send_to_network(signed_op).await;
|
||||||
}
|
}
|
||||||
Err(_) => {} // ignore empty channel errors in this PoC
|
Err(_) => {} // ignore empty channel errors in this PoC
|
||||||
}
|
}
|
||||||
match self.incoming_receiver.try_recv() {
|
match self.incoming_receiver.try_recv() {
|
||||||
Ok(incoming) => {
|
Ok(incoming) => {
|
||||||
println!("INCOMING: {}", utils::shappy(incoming.clone()));
|
println!("INCOMING: {}", utils::sha_op(incoming.clone()));
|
||||||
self.handle_incoming(incoming);
|
self.handle_incoming(incoming);
|
||||||
}
|
}
|
||||||
Err(_) => {} // ignore empty channel errors in this PoC
|
Err(_) => {} // ignore empty channel errors in this PoC
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ pub fn fake_generic_transaction_json(from: String) -> Value {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shappy(op: SignedOp) -> String {
|
pub fn sha_op(op: SignedOp) -> String {
|
||||||
let b = serde_json::to_string(&op).unwrap().into_bytes();
|
let b = serde_json::to_string(&op).unwrap().into_bytes();
|
||||||
sha256::digest(b).to_string()
|
sha256::digest(b).to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shassy(text: String) -> String {
|
pub fn sha_string(text: String) -> String {
|
||||||
let b = text.into_bytes();
|
let b = text.into_bytes();
|
||||||
sha256::digest(b).to_string()
|
sha256::digest(b).to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user