Renamed ListExample

This commit is contained in:
Dave Hrycyszyn
2024-06-05 19:52:37 +01:00
parent b30203b91e
commit b8e9d71429
2 changed files with 6 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ use websockets::WebSocket;
#[add_crdt_fields] #[add_crdt_fields]
#[derive(Clone, CrdtNode, Serialize, Deserialize)] #[derive(Clone, CrdtNode, Serialize, Deserialize)]
pub(crate) struct ListExample { pub(crate) struct CrdtList {
pub(crate) list: ListCrdt<Transaction>, // switch to Transaction as soon as char is working pub(crate) list: ListCrdt<Transaction>, // switch to Transaction as soon as char is working
} }
@@ -25,15 +25,15 @@ pub(crate) struct Transaction {
amount: f64, amount: f64,
} }
pub(crate) fn new() -> (BaseCrdt<ListExample>, Ed25519KeyPair) { pub(crate) fn new() -> (BaseCrdt<CrdtList>, Ed25519KeyPair) {
let keys = make_keypair(); let keys = make_keypair();
let bft_crdt = BaseCrdt::<ListExample>::new(&keys); let bft_crdt = BaseCrdt::<CrdtList>::new(&keys);
(bft_crdt, keys) (bft_crdt, keys)
} }
pub(crate) async fn send( pub(crate) async fn send(
count: u32, count: u32,
bft_crdt: &mut BaseCrdt<ListExample>, bft_crdt: &mut BaseCrdt<CrdtList>,
ws: &mut WebSocket, ws: &mut WebSocket,
keys: &Ed25519KeyPair, keys: &Ed25519KeyPair,
) -> Result<(), websockets::WebSocketError> { ) -> Result<(), websockets::WebSocketError> {

View File

@@ -1,4 +1,4 @@
use crate::list_transaction_crdt::{self, ListExample}; use crate::list_transaction_crdt::{self, CrdtList};
use bft_json_crdt::json_crdt::SignedOp; use bft_json_crdt::json_crdt::SignedOp;
use bft_json_crdt::json_crdt::{BaseCrdt, CrdtNode}; use bft_json_crdt::json_crdt::{BaseCrdt, CrdtNode};
use bft_json_crdt::keypair::Ed25519KeyPair; use bft_json_crdt::keypair::Ed25519KeyPair;
@@ -8,7 +8,7 @@ use websockets::WebSocket;
/// Starts a websocket and periodically sends a BFT-CRDT message to the websocket server /// Starts a websocket and periodically sends a BFT-CRDT message to the websocket server
pub(crate) async fn start( pub(crate) async fn start(
keys: Ed25519KeyPair, keys: Ed25519KeyPair,
bft_crdt: &mut BaseCrdt<ListExample>, bft_crdt: &mut BaseCrdt<CrdtList>,
) -> Result<(), websockets::WebSocketError> { ) -> Result<(), websockets::WebSocketError> {
println!("connecting to websocket at ws://127.0.0.1:8080/"); println!("connecting to websocket at ws://127.0.0.1:8080/");
let mut ws = WebSocket::connect("ws://127.0.0.1:8080/").await?; let mut ws = WebSocket::connect("ws://127.0.0.1:8080/").await?;