Files
bft-crdt-experiment/side-node/src/main.rs

32 lines
856 B
Rust
Raw Normal View History

2024-06-05 19:42:41 +01:00
use bft_json_crdt::keypair::Ed25519KeyPair;
use bft_json_crdt::{json_crdt::BaseCrdt, keypair::make_keypair};
use cli::{parse_args, Commands};
2024-06-05 19:42:41 +01:00
use types::ListExample;
2024-05-29 12:44:52 +01:00
2024-05-29 13:17:16 +01:00
pub(crate) mod cli;
2024-05-29 16:47:35 +01:00
pub(crate) mod init;
2024-06-05 19:42:41 +01:00
pub(crate) mod types;
pub(crate) mod websocket;
2024-05-29 13:17:16 +01:00
2024-05-29 12:44:52 +01:00
#[tokio::main]
async fn main() {
let args = parse_args();
2024-05-29 12:44:52 +01:00
match &args.command {
Some(Commands::Init {}) => {
2024-05-29 16:47:35 +01:00
init::init();
}
Some(Commands::Run {}) => {
2024-06-05 19:42:41 +01:00
let (mut bft_crdt, keys) = setup_crdt();
websocket::start(keys, &mut bft_crdt).await.unwrap();
}
2024-05-29 16:47:35 +01:00
None => println!("No command provided. Exiting. See --help for more information."),
2024-05-29 12:44:52 +01:00
}
2024-05-29 08:32:40 +01:00
}
2024-06-05 19:42:41 +01:00
fn setup_crdt() -> (BaseCrdt<ListExample>, Ed25519KeyPair) {
let keys = make_keypair();
let bft_crdt = BaseCrdt::<ListExample>::new(&keys);
(bft_crdt, keys)
}