mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Make keystore return None when a key doesn't exist (#8163)
* Make keystore return `None` when a key doesn't exist * Fixes * More fixes * Update comment * Update primitives/keystore/src/lib.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/keystore/src/local.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Address comments * Update client/keystore/src/local.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -255,8 +255,8 @@ where
|
||||
let expected_author = slot_author::<P>(slot, epoch_data);
|
||||
expected_author.and_then(|p| {
|
||||
if SyncCryptoStore::has_keys(
|
||||
&*self.keystore,
|
||||
&[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)],
|
||||
&*self.keystore,
|
||||
&[(p.to_raw_vec(), sp_application_crypto::key_types::AURA)],
|
||||
) {
|
||||
Some(p.clone())
|
||||
} else {
|
||||
@@ -299,6 +299,9 @@ where
|
||||
header_hash.as_ref()
|
||||
).map_err(|e| sp_consensus::Error::CannotSign(
|
||||
public.clone(), e.to_string(),
|
||||
))?
|
||||
.ok_or_else(|| sp_consensus::Error::CannotSign(
|
||||
public.clone(), "Could not find key in keystore.".into(),
|
||||
))?;
|
||||
let signature = signature.clone().try_into()
|
||||
.map_err(|_| sp_consensus::Error::InvalidSignature(
|
||||
|
||||
@@ -159,7 +159,7 @@ fn claim_secondary_slot(
|
||||
authority_id.as_ref(),
|
||||
transcript_data,
|
||||
);
|
||||
if let Ok(signature) = result {
|
||||
if let Ok(Some(signature)) = result {
|
||||
Some(PreDigest::SecondaryVRF(SecondaryVRFPreDigest {
|
||||
slot,
|
||||
vrf_output: VRFOutput(signature.output),
|
||||
@@ -265,7 +265,7 @@ fn claim_primary_slot(
|
||||
authority_id.as_ref(),
|
||||
transcript_data,
|
||||
);
|
||||
if let Ok(signature) = result {
|
||||
if let Ok(Some(signature)) = result {
|
||||
let public = PublicKey::from_bytes(&authority_id.to_raw_vec()).ok()?;
|
||||
let inout = match signature.output.attach_input_hash(&public, transcript) {
|
||||
Ok(inout) => inout,
|
||||
|
||||
@@ -649,6 +649,9 @@ where
|
||||
)
|
||||
.map_err(|e| sp_consensus::Error::CannotSign(
|
||||
public.clone(), e.to_string(),
|
||||
))?
|
||||
.ok_or_else(|| sp_consensus::Error::CannotSign(
|
||||
public.clone(), "Could not find key in keystore.".into(),
|
||||
))?;
|
||||
let signature: AuthoritySignature = signature.clone().try_into()
|
||||
.map_err(|_| sp_consensus::Error::InvalidSignature(
|
||||
|
||||
Reference in New Issue
Block a user