mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Improve overall performance (#6699)
* Improve overall performance * Clean up code Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove needless :: Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove needless :: Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -180,7 +180,7 @@ impl DeriveJunction {
|
||||
impl<T: AsRef<str>> From<T> for DeriveJunction {
|
||||
fn from(j: T) -> DeriveJunction {
|
||||
let j = j.as_ref();
|
||||
let (code, hard) = if j.starts_with("/") {
|
||||
let (code, hard) = if j.starts_with('/') {
|
||||
(&j[1..], true)
|
||||
} else {
|
||||
(j, false)
|
||||
|
||||
@@ -359,7 +359,7 @@ impl offchain::Externalities for TestOffchainExt {
|
||||
if let Some(req) = state.requests.get_mut(&request_id) {
|
||||
let response = req.response
|
||||
.as_mut()
|
||||
.expect(&format!("No response provided for request: {:?}", request_id));
|
||||
.unwrap_or_else(|| panic!("No response provided for request: {:?}", request_id));
|
||||
|
||||
if req.read >= response.len() {
|
||||
// Remove the pending request as per spec.
|
||||
|
||||
@@ -90,7 +90,7 @@ impl crate::traits::BareCryptoStore for KeyStore {
|
||||
v
|
||||
}))
|
||||
})
|
||||
.unwrap_or(Ok(vec![]))
|
||||
.unwrap_or_else(|| Ok(vec![]))
|
||||
}
|
||||
|
||||
fn sr25519_public_keys(&self, id: KeyTypeId) -> Vec<sr25519::Public> {
|
||||
@@ -222,19 +222,19 @@ impl crate::traits::BareCryptoStore for KeyStore {
|
||||
ed25519::CRYPTO_ID => {
|
||||
let key_pair: ed25519::Pair = self
|
||||
.ed25519_key_pair(id, &ed25519::Public::from_slice(key.1.as_slice()))
|
||||
.ok_or(Error::PairNotFound("ed25519".to_owned()))?;
|
||||
.ok_or_else(|| Error::PairNotFound("ed25519".to_owned()))?;
|
||||
return Ok(key_pair.sign(msg).encode());
|
||||
}
|
||||
sr25519::CRYPTO_ID => {
|
||||
let key_pair: sr25519::Pair = self
|
||||
.sr25519_key_pair(id, &sr25519::Public::from_slice(key.1.as_slice()))
|
||||
.ok_or(Error::PairNotFound("sr25519".to_owned()))?;
|
||||
.ok_or_else(|| Error::PairNotFound("sr25519".to_owned()))?;
|
||||
return Ok(key_pair.sign(msg).encode());
|
||||
}
|
||||
ecdsa::CRYPTO_ID => {
|
||||
let key_pair: ecdsa::Pair = self
|
||||
.ecdsa_key_pair(id, &ecdsa::Public::from_slice(key.1.as_slice()))
|
||||
.ok_or(Error::PairNotFound("ecdsa".to_owned()))?;
|
||||
.ok_or_else(|| Error::PairNotFound("ecdsa".to_owned()))?;
|
||||
return Ok(key_pair.sign(msg).encode());
|
||||
}
|
||||
_ => Err(Error::KeyNotSupported(id))
|
||||
@@ -249,7 +249,7 @@ impl crate::traits::BareCryptoStore for KeyStore {
|
||||
) -> Result<VRFSignature, Error> {
|
||||
let transcript = make_transcript(transcript_data);
|
||||
let pair = self.sr25519_key_pair(key_type, public)
|
||||
.ok_or(Error::PairNotFound("Not found".to_owned()))?;
|
||||
.ok_or_else(|| Error::PairNotFound("Not found".to_owned()))?;
|
||||
|
||||
let (inout, proof, _) = pair.as_ref().vrf_sign(transcript);
|
||||
Ok(VRFSignature {
|
||||
|
||||
Reference in New Issue
Block a user