Key generation, saving and loading works.

This commit is contained in:
Dave Hrycyszyn
2024-06-06 18:52:39 +01:00
parent 6d6c544dd5
commit cda6dd2901
9 changed files with 67 additions and 58 deletions

View File

@@ -1,3 +1,5 @@
use std::path::PathBuf;
use bft_crdt_derive::add_crdt_fields;
use bft_json_crdt::{
@@ -10,6 +12,8 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use websockets::WebSocket;
use crate::keys;
#[add_crdt_fields]
#[derive(Clone, CrdtNode, Serialize, Deserialize)]
pub(crate) struct CrdtList {
@@ -25,8 +29,9 @@ pub(crate) struct Transaction {
amount: f64,
}
pub(crate) fn new() -> (BaseCrdt<CrdtList>, Ed25519KeyPair) {
let keys = make_keypair();
pub(crate) fn new(side_dir: PathBuf) -> (BaseCrdt<CrdtList>, Ed25519KeyPair) {
let keys = keys::load_from_file(side_dir);
// let keys = make_keypair();
let bft_crdt = BaseCrdt::<CrdtList>::new(&keys);
println!("Author is {}", keys.public().to_string());
(bft_crdt, keys)