Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Dec 17, 2024
1 parent 079c394 commit 12e940d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/protocol/src/protocol_transport/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub enum WsError {
Serialization(#[from] bincode::Error),
#[error("Received bad subscribe message")]
BadSubscribeMessage,
#[error("Node has started fresh and not yet successfully set up")]
#[error("Node has started fresh and is not yet successfully set up")]
NotReady,
}

Expand Down
10 changes: 0 additions & 10 deletions crates/threshold-signature-server/src/helpers/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ use crate::user::UserErr;
const KDF_SR25519: &[u8] = b"sr25519-threshold-account";
const KDF_X25519: &[u8] = b"X25519-keypair";

// Returns a PairSigner for this node's threshold server.
// The PairSigner is stored as an encrypted mnemonic in the kvdb and
// is used to sign encrypted messages and to submit extrinsics on chain.
// pub async fn get_signer(
// kv: &KvManager,
// ) -> Result<PairSigner<EntropyConfig, sr25519::Pair>, UserErr> {
// let hkdf = get_hkdf(kv).await?;
// get_signer_from_hkdf(&hkdf)
// }

/// Get the PairSigner as above, and also the x25519 encryption keypair for
/// this threshold server
pub fn get_signer_and_x25519_secret(
Expand Down
12 changes: 12 additions & 0 deletions crates/threshold-signature-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,24 @@ use crate::{

#[derive(Clone)]
pub struct AppState {
/// Tracks whether prerequisite checks have passed.
/// This means:
/// - Communication has been established with the chain node
/// - The TSS account is funded
/// - The TSS account is registered with the staking extension pallet
ready: Arc<RwLock<bool>>,
/// Tracks incoming protocol connections with other TSS nodes
listener_state: ListenerState,
/// Keypair for TSS account
pair: sr25519::Pair,
/// Secret encryption key
x25519_secret: StaticSecret,
pub configuration: Configuration,
pub kv_store: KvManager,
}

impl AppState {
/// Setup AppState, generating new keypairs unless a test validator name is passed
pub fn new(
configuration: Configuration,
kv_store: KvManager,
Expand All @@ -234,13 +243,16 @@ impl AppState {
}
}

/// Returns true if all prerequisite checks have passed.
/// Is is not possible to participate in the protocols before this is true.
pub fn is_ready(&self) -> bool {
match self.ready.read() {
Ok(r) => *r,
_ => false,
}
}

/// Mark the node as ready. This is called once when the prerequisite checks have passed.
pub fn make_ready(&self) {
let mut is_ready = self.ready.write().unwrap();
*is_ready = true;
Expand Down

0 comments on commit 12e940d

Please sign in to comment.