Minor tweaks suggested by clippy (#10673)

* Minor tweaks suggested by clippy

* Fix typo caused by last commit

* Apply review suggestions
This commit is contained in:
Nazar Mokrynskyi
2022-01-15 22:00:12 +02:00
committed by GitHub
parent a534274c6f
commit 0bca06a483
5 changed files with 27 additions and 35 deletions
+5 -5
View File
@@ -197,7 +197,7 @@ pub fn finalize_block() -> Header {
use sp_core::storage::StateVersion;
let extrinsic_index: u32 = storage::unhashed::take(well_known_keys::EXTRINSIC_INDEX).unwrap();
let txs: Vec<_> = (0..extrinsic_index).map(ExtrinsicData::take).collect();
let extrinsics_root = trie::blake2_256_ordered_root(txs, StateVersion::V0).into();
let extrinsics_root = trie::blake2_256_ordered_root(txs, StateVersion::V0);
let number = <Number>::take().expect("Number is set by `initialize_block`");
let parent_hash = <ParentHash>::take();
let mut digest = <StorageDigest>::take().expect("StorageDigest is set by `initialize_block`");
@@ -235,11 +235,11 @@ fn execute_transaction_backend(utx: &Extrinsic, extrinsic_index: u32) -> ApplyEx
Extrinsic::StorageChange(key, value) =>
execute_storage_change(key, value.as_ref().map(|v| &**v)),
Extrinsic::OffchainIndexSet(key, value) => {
sp_io::offchain_index::set(&key, &value);
sp_io::offchain_index::set(key, value);
Ok(Ok(()))
},
Extrinsic::OffchainIndexClear(key) => {
sp_io::offchain_index::clear(&key);
sp_io::offchain_index::clear(key);
Ok(Ok(()))
},
Extrinsic::Store(data) => execute_store(data.clone()),
@@ -250,7 +250,7 @@ fn execute_transfer_backend(tx: &Transfer) -> ApplyExtrinsicResult {
// check nonce
let nonce_key = tx.from.to_keyed_vec(NONCE_OF);
let expected_nonce: u64 = storage::hashed::get_or(&blake2_256, &nonce_key, 0);
if !(tx.nonce == expected_nonce) {
if tx.nonce != expected_nonce {
return Err(InvalidTransaction::Stale.into())
}
@@ -262,7 +262,7 @@ fn execute_transfer_backend(tx: &Transfer) -> ApplyExtrinsicResult {
let from_balance: u64 = storage::hashed::get_or(&blake2_256, &from_balance_key, 0);
// enact transfer
if !(tx.amount <= from_balance) {
if tx.amount > from_balance {
return Err(InvalidTransaction::Payment.into())
}
let to_balance_key = tx.to.to_keyed_vec(BALANCE_OF);