cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
This commit is contained in:
Shawn Tabrizi
2021-08-02 12:47:33 +02:00
committed by GitHub
parent 30e3012270
commit ff5d56fb76
350 changed files with 20617 additions and 21266 deletions
+20 -23
View File
@@ -19,18 +19,17 @@ use std::convert::TryInto;
use parity_scale_codec::{Decode, Encode};
use sp_application_crypto::AppKey;
use sp_keystore::{CryptoStore, SyncCryptoStorePtr, Error as KeystoreError};
use sp_keystore::{CryptoStore, Error as KeystoreError, SyncCryptoStorePtr};
use super::{Statement, UncheckedSignedFullStatement};
use polkadot_primitives::v1::{
CandidateHash, CandidateReceipt, DisputeStatement, InvalidDisputeStatementKind,
SessionIndex, ValidDisputeStatementKind, ValidatorId, ValidatorIndex,
ValidatorSignature, SigningContext,
CandidateHash, CandidateReceipt, DisputeStatement, InvalidDisputeStatementKind, SessionIndex,
SigningContext, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature,
};
use super::{UncheckedSignedFullStatement, Statement};
/// `DisputeMessage` and related types.
mod message;
pub use message::{DisputeMessage, UncheckedDisputeMessage, Error as DisputeMessageCheckError};
pub use message::{DisputeMessage, Error as DisputeMessageCheckError, UncheckedDisputeMessage};
/// A checked dispute statement from an associated validator.
#[derive(Debug, Clone)]
@@ -56,9 +55,8 @@ pub struct CandidateVotes {
impl CandidateVotes {
/// Get the set of all validators who have votes in the set, ascending.
pub fn voted_indices(&self) -> Vec<ValidatorIndex> {
let mut v: Vec<_> = self.valid.iter().map(|x| x.1).chain(
self.invalid.iter().map(|x| x.1)
).collect();
let mut v: Vec<_> =
self.valid.iter().map(|x| x.1).chain(self.invalid.iter().map(|x| x.1)).collect();
v.sort();
v.dedup();
@@ -76,18 +74,15 @@ impl SignedDisputeStatement {
validator_public: ValidatorId,
validator_signature: ValidatorSignature,
) -> Result<Self, ()> {
dispute_statement.check_signature(
&validator_public,
candidate_hash,
session_index,
&validator_signature,
).map(|_| SignedDisputeStatement {
dispute_statement,
candidate_hash,
validator_public,
validator_signature,
session_index,
})
dispute_statement
.check_signature(&validator_public, candidate_hash, session_index, &validator_signature)
.map(|_| SignedDisputeStatement {
dispute_statement,
candidate_hash,
validator_public,
validator_signature,
session_index,
})
}
/// Sign this statement with the given keystore and key. Pass `valid = true` to
@@ -111,10 +106,12 @@ impl SignedDisputeStatement {
ValidatorId::ID,
&validator_public.clone().into(),
&data,
).await?;
)
.await?;
let signature = match signature {
Some(sig) => sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?,
Some(sig) =>
sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?,
None => return Ok(None),
};