Starting to modify things into container structs

This commit is contained in:
Dave Hrycyszyn
2024-06-07 17:03:05 +01:00
parent b1f5d2b75a
commit a81d1f913a
5 changed files with 100 additions and 55 deletions

31
side-node/src/node.rs Normal file
View File

@@ -0,0 +1,31 @@
use bft_json_crdt::json_crdt::BaseCrdt;
use fastcrypto::ed25519::Ed25519KeyPair;
use crate::{keys, list_transaction_crdt::TransactionList, utils, websocket::WebSocketClient};
pub(crate) struct SideNode {
crdt: BaseCrdt<TransactionList>,
keys: Ed25519KeyPair,
websocket_client: WebSocketClient,
}
impl SideNode {
pub(crate) fn new(
websocket_client: WebSocketClient,
crdt: BaseCrdt<TransactionList>,
name: String,
) -> Self {
let side_dir = utils::home(&name);
let keys = keys::load_from_file(side_dir);
Self {
crdt,
keys,
websocket_client,
}
}
pub(crate) async fn start(&mut self) {
self.websocket_client.start().await;
}
}