Skip to content

Commit

Permalink
[substrate-apply] humanode-peer: Keystore overhaul (final) (#13683)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylavrenov committed Jan 17, 2024
1 parent 6261649 commit d8f41d2
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions crates/humanode-peer/src/validator_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{fmt::Display, sync::Arc};

use bioauth_flow_rpc::Signer;
use sp_application_crypto::{AppPublic, CryptoTypePublicPair};
use sp_application_crypto::AppPublic;
use sp_keystore::Keystore;

/// The validator public key implementation using the app crypto public key.
Expand Down Expand Up @@ -53,7 +53,7 @@ where
let data = data.as_ref();
let outcome = self
.keystore
.sign_with(PK::ID, &self.public_key.0.to_public_crypto_pair(), data)
.sign_with(PK::ID, PK::CRYPTO_ID, self.public_key.0.as_slice(), data)
.map_err(SignerError::Keystore)?;

outcome.ok_or(SignerError::NoSignature)
Expand All @@ -78,18 +78,12 @@ where
keystore: &dyn Keystore,
) -> Result<impl Iterator<Item = Self>, sp_keystore::Error> {
let crypto_type_public_pairs = keystore.keys(T::ID)?;
let filtered = crypto_type_public_pairs.into_iter().filter_map(
|CryptoTypePublicPair(crypto_type, public_key)| {
if crypto_type == T::CRYPTO_ID {
match T::from_slice(&public_key) {
Ok(id) => Some(Self(id)),
Err(_) => None,
}
} else {
None
}
},
);
let filtered = crypto_type_public_pairs
.into_iter()
.filter_map(|public_key| match T::from_slice(&public_key) {
Ok(id) => Some(Self(id)),
Err(_) => None,
});
Ok(filtered)
}
}
Expand Down

0 comments on commit d8f41d2

Please sign in to comment.