mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +00:00
Run cargo fmt on the whole code base (#9394)
* Run cargo fmt on the whole code base * Second run * Add CI check * Fix compilation * More unnecessary braces * Handle weights * Use --all * Use correct attributes... * Fix UI tests * AHHHHHHHHH * 🤦 * Docs * Fix compilation * 🤷 * Please stop * 🤦 x 2 * More * make rustfmt.toml consistent with polkadot Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
@@ -17,9 +17,11 @@
|
||||
|
||||
//! Transaction validity interface.
|
||||
|
||||
use crate::{
|
||||
codec::{Decode, Encode},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
use crate::codec::{Encode, Decode};
|
||||
use crate::RuntimeDebug;
|
||||
|
||||
/// Priority for a transaction. Additive. Higher is better.
|
||||
pub type TransactionPriority = u64;
|
||||
@@ -98,8 +100,7 @@ impl From<InvalidTransaction> for &'static str {
|
||||
InvalidTransaction::Stale => "Transaction is outdated",
|
||||
InvalidTransaction::BadProof => "Transaction has a bad signature",
|
||||
InvalidTransaction::AncientBirthBlock => "Transaction has an ancient birth block",
|
||||
InvalidTransaction::ExhaustsResources =>
|
||||
"Transaction would exhaust the block limits",
|
||||
InvalidTransaction::ExhaustsResources => "Transaction would exhaust the block limits",
|
||||
InvalidTransaction::Payment =>
|
||||
"Inability to pay some fees (e.g. account balance too low)",
|
||||
InvalidTransaction::BadMandatory =>
|
||||
@@ -220,7 +221,9 @@ impl From<UnknownTransaction> for TransactionValidity {
|
||||
/// Depending on the source we might apply different validation schemes.
|
||||
/// For instance we can disallow specific kinds of transactions if they were not produced
|
||||
/// by our local node (for instance off-chain workers).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, parity_util_mem::MallocSizeOf)]
|
||||
#[derive(
|
||||
Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, parity_util_mem::MallocSizeOf,
|
||||
)]
|
||||
pub enum TransactionSource {
|
||||
/// Transaction is already included in block.
|
||||
///
|
||||
@@ -295,10 +298,7 @@ impl ValidTransaction {
|
||||
/// To avoid conflicts between different parts in runtime it's recommended to build `requires`
|
||||
/// and `provides` tags with a unique prefix.
|
||||
pub fn with_tag_prefix(prefix: &'static str) -> ValidTransactionBuilder {
|
||||
ValidTransactionBuilder {
|
||||
prefix: Some(prefix),
|
||||
validity: Default::default(),
|
||||
}
|
||||
ValidTransactionBuilder { prefix: Some(prefix), validity: Default::default() }
|
||||
}
|
||||
|
||||
/// Combine two instances into one, as a best effort. This will take the superset of each of the
|
||||
@@ -307,8 +307,14 @@ impl ValidTransaction {
|
||||
pub fn combine_with(mut self, mut other: ValidTransaction) -> Self {
|
||||
Self {
|
||||
priority: self.priority.saturating_add(other.priority),
|
||||
requires: { self.requires.append(&mut other.requires); self.requires },
|
||||
provides: { self.provides.append(&mut other.provides); self.provides },
|
||||
requires: {
|
||||
self.requires.append(&mut other.requires);
|
||||
self.requires
|
||||
},
|
||||
provides: {
|
||||
self.provides.append(&mut other.provides);
|
||||
self.provides
|
||||
},
|
||||
longevity: self.longevity.min(other.longevity),
|
||||
propagate: self.propagate && other.propagate,
|
||||
}
|
||||
@@ -412,7 +418,6 @@ impl From<ValidTransactionBuilder> for ValidTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -430,7 +435,10 @@ mod tests {
|
||||
let encoded = v.encode();
|
||||
assert_eq!(
|
||||
encoded,
|
||||
vec![0, 5, 0, 0, 0, 0, 0, 0, 0, 4, 16, 1, 2, 3, 4, 4, 12, 4, 5, 6, 42, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
vec![
|
||||
0, 5, 0, 0, 0, 0, 0, 0, 0, 4, 16, 1, 2, 3, 4, 4, 12, 4, 5, 6, 42, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// decode back
|
||||
@@ -450,12 +458,15 @@ mod tests {
|
||||
.priority(3)
|
||||
.priority(6)
|
||||
.into();
|
||||
assert_eq!(a, ValidTransaction {
|
||||
propagate: false,
|
||||
longevity: 5,
|
||||
priority: 6,
|
||||
requires: vec![(PREFIX, 1).encode(), (PREFIX, 2).encode()],
|
||||
provides: vec![(PREFIX, 3).encode(), (PREFIX, 4).encode()],
|
||||
});
|
||||
assert_eq!(
|
||||
a,
|
||||
ValidTransaction {
|
||||
propagate: false,
|
||||
longevity: 5,
|
||||
priority: 6,
|
||||
requires: vec![(PREFIX, 1).encode(), (PREFIX, 2).encode()],
|
||||
provides: vec![(PREFIX, 3).encode(), (PREFIX, 4).encode()],
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user