huskies: merge 977
This commit is contained in:
@@ -10,9 +10,7 @@ use std::path::Path;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use bft_json_crdt::json_crdt::{BaseCrdt, CrdtNode, JsonValue, SignedOp};
|
||||
use bft_json_crdt::keypair::make_keypair;
|
||||
use fastcrypto::ed25519::Ed25519KeyPair;
|
||||
use fastcrypto::traits::ToFromBytes;
|
||||
use bft_json_crdt::keypair::{Ed25519KeyPair, make_keypair};
|
||||
use sqlx::SqlitePool;
|
||||
use sqlx::sqlite::SqliteConnectOptions;
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
@@ -192,14 +190,14 @@ async fn load_or_create_keypair(pool: &SqlitePool) -> Result<Ed25519KeyPair, sql
|
||||
|
||||
if let Some((seed,)) = row {
|
||||
// Reconstruct from stored seed. The seed is the 32-byte private key.
|
||||
if let Ok(kp) = Ed25519KeyPair::from_bytes(&seed) {
|
||||
return Ok(kp);
|
||||
if let Ok(arr) = TryInto::<[u8; 32]>::try_into(seed) {
|
||||
return Ok(Ed25519KeyPair::from_bytes(&arr));
|
||||
}
|
||||
slog!("[crdt] Stored keypair invalid, regenerating");
|
||||
}
|
||||
|
||||
let kp = make_keypair();
|
||||
let seed = kp.as_bytes().to_vec();
|
||||
let seed = kp.to_bytes().to_vec();
|
||||
sqlx::query("INSERT INTO crdt_node_identity (id, seed) VALUES (1, ?1) ON CONFLICT(id) DO UPDATE SET seed = excluded.seed")
|
||||
.bind(&seed)
|
||||
.execute(pool)
|
||||
|
||||
@@ -10,8 +10,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
use bft_json_crdt::json_crdt::{BaseCrdt, SignedOp};
|
||||
use bft_json_crdt::keypair::make_keypair;
|
||||
use fastcrypto::ed25519::Ed25519KeyPair;
|
||||
use bft_json_crdt::keypair::{Ed25519KeyPair, make_keypair};
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
|
||||
use super::VectorClock;
|
||||
|
||||
Reference in New Issue
Block a user