diff --git a/families/battleship/src/game.rs b/families/battleship/src/game.rs index d7ef8a3d1f..3bd50d9f09 100644 --- a/families/battleship/src/game.rs +++ b/families/battleship/src/game.rs @@ -41,7 +41,7 @@ pub fn get_battleship_name_hash(name: &str) -> String { /// Get a state address for a given game of battleship pub fn get_battleship_address(name: &str) -> String { - vec![get_battleship_prefix(), get_battleship_name_hash(name)].join("") + [get_battleship_prefix(), get_battleship_name_hash(name)].join("") } /// Hash the value and nonce for a revealed space diff --git a/perf/sawtooth_perf/src/workload.rs b/perf/sawtooth_perf/src/workload.rs index 3a20f32f3f..12a8a89505 100644 --- a/perf/sawtooth_perf/src/workload.rs +++ b/perf/sawtooth_perf/src/workload.rs @@ -27,7 +27,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::time; use std::vec::IntoIter; -use chrono; use futures::Future; use hyper::client::{Client, HttpConnector, Request, Response}; use hyper::error::UriError; @@ -36,7 +35,6 @@ use hyper::Error as HyperError; use hyper::Method; use hyper::StatusCode; use hyper::Uri; -use protobuf; use protobuf::Message; use tokio_core::reactor::Handle; diff --git a/perf/smallbank_workload/src/playlist.rs b/perf/smallbank_workload/src/playlist.rs index ab2fe9cbd8..d1468c70b0 100644 --- a/perf/smallbank_workload/src/playlist.rs +++ b/perf/smallbank_workload/src/playlist.rs @@ -40,7 +40,6 @@ use crate::protos::smallbank; use crate::protos::smallbank::SmallbankTransactionPayload; use crate::protos::smallbank::SmallbankTransactionPayload_PayloadType as SBPayloadType; -use protobuf; use protobuf::Message; use sawtooth_sdk::messages::transaction::Transaction; @@ -614,7 +613,7 @@ impl<'a> FmtWriter<'a> { impl<'a> fmt::Write for FmtWriter<'a> { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { let w = &mut *self.writer; - w.write_all(s.as_bytes()).map_err(|_| fmt::Error::default()) + w.write_all(s.as_bytes()).map_err(|_| fmt::Error) } } diff --git a/perf/smallbank_workload/src/smallbank_transformer.rs b/perf/smallbank_workload/src/smallbank_transformer.rs index b54768b666..13647fb9c7 100644 --- a/perf/smallbank_workload/src/smallbank_transformer.rs +++ b/perf/smallbank_workload/src/smallbank_transformer.rs @@ -23,7 +23,7 @@ use std::time::Instant; use crypto::digest::Digest; use crypto::sha2::Sha512; -use protobuf; + use protobuf::Message; use sawtooth_sdk::messages::transaction::{Transaction, TransactionHeader}; diff --git a/validator/src/journal/block_manager.rs b/validator/src/journal/block_manager.rs index 713ad089f4..8b046d9157 100644 --- a/validator/src/journal/block_manager.rs +++ b/validator/src/journal/block_manager.rs @@ -653,18 +653,13 @@ impl BlockManager { } fn block_contains_any_transaction(&self, block: &Block, ids: &[&String]) -> Option { - let transaction_ids: HashSet<&String> = HashSet::from_iter( - block - .batches - .iter() - .fold(vec![], |mut arr, b| { - for transaction in &b.transactions { - arr.push(&transaction.header_signature) - } - arr - }) - .into_iter(), - ); + let transaction_ids: HashSet<&String> = + HashSet::from_iter(block.batches.iter().fold(vec![], |mut arr, b| { + for transaction in &b.transactions { + arr.push(&transaction.header_signature) + } + arr + })); let comparison_transaction_ids: HashSet<&String> = HashSet::from_iter(ids.iter().cloned()); transaction_ids .intersection(&comparison_transaction_ids) diff --git a/validator/src/journal/block_wrapper.rs b/validator/src/journal/block_wrapper.rs index e2911de315..55269b7eb5 100644 --- a/validator/src/journal/block_wrapper.rs +++ b/validator/src/journal/block_wrapper.rs @@ -21,8 +21,9 @@ use std::fmt; use cpython::{self, ObjectProtocol, PyClone, PyObject}; -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub enum BlockStatus { + #[default] Unknown = 0, Invalid = 1, Valid = 2, @@ -30,12 +31,6 @@ pub enum BlockStatus { InValidation = 5, } -impl Default for BlockStatus { - fn default() -> Self { - BlockStatus::Unknown - } -} - #[derive(Debug)] pub struct BlockWrapper { pub(super) py_block_wrapper: PyObject, diff --git a/validator/src/metrics/mod.rs b/validator/src/metrics/mod.rs index f212a61338..b3913ae522 100644 --- a/validator/src/metrics/mod.rs +++ b/validator/src/metrics/mod.rs @@ -32,17 +32,12 @@ pub fn get_collector>(name: S) -> MetricsCollectorHandle { } } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Default)] pub enum Level { + #[default] Info, } -impl Default for Level { - fn default() -> Self { - Level::Info - } -} - fn into_level_str(level: Level) -> &'static str { use self::Level::*; match level { diff --git a/validator/src/permissions/state_source.rs b/validator/src/permissions/state_source.rs index de670b616e..81aedb91d0 100644 --- a/validator/src/permissions/state_source.rs +++ b/validator/src/permissions/state_source.rs @@ -41,12 +41,10 @@ impl IdentitySource for IdentityView { .map(|mut entry| match entry.get_field_type() { Policy_EntryType::PERMIT_KEY => Ok(Permission::PermitKey(entry.take_key())), Policy_EntryType::DENY_KEY => Ok(Permission::DenyKey(entry.take_key())), - Policy_EntryType::ENTRY_TYPE_UNSET => { - return Err(IdentityError::ReadError(format!( - "policy {} is contains invalid type", - entry.get_key() - ))) - } + Policy_EntryType::ENTRY_TYPE_UNSET => Err(IdentityError::ReadError(format!( + "policy {} is contains invalid type", + entry.get_key() + ))), }) .collect(); diff --git a/validator/src/state/merkle.rs b/validator/src/state/merkle.rs index 76f00bc476..c8ef6b57ba 100644 --- a/validator/src/state/merkle.rs +++ b/validator/src/state/merkle.rs @@ -1041,8 +1041,7 @@ mod tests { run_test(|merkle_path| { let mut merkle_db = make_db(merkle_path); let init_root = merkle_db.get_merkle_root(); - let key_hashes = vec![ - // matching prefix e55420 + let key_hashes = [ ( "asdfg", "e5542002d3e2892516fa461cde69e05880609fbad3d38ab69435a189e126de672b620c", @@ -1133,7 +1132,7 @@ mod tests { run_test(|merkle_path| { let mut merkle_db = make_db(merkle_path); let init_root = merkle_db.get_merkle_root(); - let key_hashes = vec![ + let key_hashes = [ ( "qwert", "c946ee72d38b8c51328f1a5f31eb5bd3300362ad0ca69dab54eff996775c7069216bda", @@ -1165,7 +1164,7 @@ mod tests { assert_ne!(init_root, merkle_db.get_merkle_root()); // matching prefix e55420, however this will be newly added and not set already in trie - let key_hash_to_be_inserted = vec![( + let key_hash_to_be_inserted = [( "asdfg", "e5542002d3e2892516fa461cde69e05880609fbad3d38ab69435a189e126de672b620c", )]; @@ -1517,7 +1516,7 @@ mod tests { ); } - let addresses = vec!["ab0000", "aba001", "abff02"]; + let addresses = ["ab0000", "aba001", "abff02"]; for (i, key) in addresses.iter().enumerate() { let new_root = merkle_db .set(key, format!("{:04x}", i * 10).as_bytes())