Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit 9ccb01f

Browse files
authored
Merge pull request #2460 from suchapalaver/fix/fix-compiler-and-clippy-errors
Fix compiler and clippy errors
2 parents 3004c63 + b62668d commit 9ccb01f

File tree

9 files changed

+22
-43
lines changed

9 files changed

+22
-43
lines changed

families/battleship/src/game.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn get_battleship_name_hash(name: &str) -> String {
4141

4242
/// Get a state address for a given game of battleship
4343
pub fn get_battleship_address(name: &str) -> String {
44-
vec![get_battleship_prefix(), get_battleship_name_hash(name)].join("")
44+
[get_battleship_prefix(), get_battleship_name_hash(name)].join("")
4545
}
4646

4747
/// Hash the value and nonce for a revealed space

perf/sawtooth_perf/src/workload.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::sync::atomic::{AtomicUsize, Ordering};
2727
use std::time;
2828
use std::vec::IntoIter;
2929

30-
use chrono;
3130
use futures::Future;
3231
use hyper::client::{Client, HttpConnector, Request, Response};
3332
use hyper::error::UriError;
@@ -36,7 +35,6 @@ use hyper::Error as HyperError;
3635
use hyper::Method;
3736
use hyper::StatusCode;
3837
use hyper::Uri;
39-
use protobuf;
4038
use protobuf::Message;
4139
use tokio_core::reactor::Handle;
4240

perf/smallbank_workload/src/playlist.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use crate::protos::smallbank;
4040
use crate::protos::smallbank::SmallbankTransactionPayload;
4141
use crate::protos::smallbank::SmallbankTransactionPayload_PayloadType as SBPayloadType;
4242

43-
use protobuf;
4443
use protobuf::Message;
4544

4645
use sawtooth_sdk::messages::transaction::Transaction;
@@ -614,7 +613,7 @@ impl<'a> FmtWriter<'a> {
614613
impl<'a> fmt::Write for FmtWriter<'a> {
615614
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
616615
let w = &mut *self.writer;
617-
w.write_all(s.as_bytes()).map_err(|_| fmt::Error::default())
616+
w.write_all(s.as_bytes()).map_err(|_| fmt::Error)
618617
}
619618
}
620619

perf/smallbank_workload/src/smallbank_transformer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::time::Instant;
2323

2424
use crypto::digest::Digest;
2525
use crypto::sha2::Sha512;
26-
use protobuf;
26+
2727
use protobuf::Message;
2828

2929
use sawtooth_sdk::messages::transaction::{Transaction, TransactionHeader};

validator/src/journal/block_manager.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -653,18 +653,13 @@ impl BlockManager {
653653
}
654654

655655
fn block_contains_any_transaction(&self, block: &Block, ids: &[&String]) -> Option<String> {
656-
let transaction_ids: HashSet<&String> = HashSet::from_iter(
657-
block
658-
.batches
659-
.iter()
660-
.fold(vec![], |mut arr, b| {
661-
for transaction in &b.transactions {
662-
arr.push(&transaction.header_signature)
663-
}
664-
arr
665-
})
666-
.into_iter(),
667-
);
656+
let transaction_ids: HashSet<&String> =
657+
HashSet::from_iter(block.batches.iter().fold(vec![], |mut arr, b| {
658+
for transaction in &b.transactions {
659+
arr.push(&transaction.header_signature)
660+
}
661+
arr
662+
}));
668663
let comparison_transaction_ids: HashSet<&String> = HashSet::from_iter(ids.iter().cloned());
669664
transaction_ids
670665
.intersection(&comparison_transaction_ids)

validator/src/journal/block_wrapper.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,16 @@ use std::fmt;
2121

2222
use cpython::{self, ObjectProtocol, PyClone, PyObject};
2323

24-
#[derive(Debug, Clone, PartialEq, Eq)]
24+
#[derive(Debug, Default, Clone, PartialEq, Eq)]
2525
pub enum BlockStatus {
26+
#[default]
2627
Unknown = 0,
2728
Invalid = 1,
2829
Valid = 2,
2930
Missing = 3,
3031
InValidation = 5,
3132
}
3233

33-
impl Default for BlockStatus {
34-
fn default() -> Self {
35-
BlockStatus::Unknown
36-
}
37-
}
38-
3934
#[derive(Debug)]
4035
pub struct BlockWrapper {
4136
pub(super) py_block_wrapper: PyObject,

validator/src/metrics/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ pub fn get_collector<S: AsRef<str>>(name: S) -> MetricsCollectorHandle {
3232
}
3333
}
3434

35-
#[derive(Copy, Clone)]
35+
#[derive(Copy, Clone, Default)]
3636
pub enum Level {
37+
#[default]
3738
Info,
3839
}
3940

40-
impl Default for Level {
41-
fn default() -> Self {
42-
Level::Info
43-
}
44-
}
45-
4641
fn into_level_str(level: Level) -> &'static str {
4742
use self::Level::*;
4843
match level {

validator/src/permissions/state_source.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ impl IdentitySource for IdentityView {
4141
.map(|mut entry| match entry.get_field_type() {
4242
Policy_EntryType::PERMIT_KEY => Ok(Permission::PermitKey(entry.take_key())),
4343
Policy_EntryType::DENY_KEY => Ok(Permission::DenyKey(entry.take_key())),
44-
Policy_EntryType::ENTRY_TYPE_UNSET => {
45-
return Err(IdentityError::ReadError(format!(
46-
"policy {} is contains invalid type",
47-
entry.get_key()
48-
)))
49-
}
44+
Policy_EntryType::ENTRY_TYPE_UNSET => Err(IdentityError::ReadError(format!(
45+
"policy {} is contains invalid type",
46+
entry.get_key()
47+
))),
5048
})
5149
.collect();
5250

validator/src/state/merkle.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,7 @@ mod tests {
10411041
run_test(|merkle_path| {
10421042
let mut merkle_db = make_db(merkle_path);
10431043
let init_root = merkle_db.get_merkle_root();
1044-
let key_hashes = vec![
1045-
// matching prefix e55420
1044+
let key_hashes = [
10461045
(
10471046
"asdfg",
10481047
"e5542002d3e2892516fa461cde69e05880609fbad3d38ab69435a189e126de672b620c",
@@ -1133,7 +1132,7 @@ mod tests {
11331132
run_test(|merkle_path| {
11341133
let mut merkle_db = make_db(merkle_path);
11351134
let init_root = merkle_db.get_merkle_root();
1136-
let key_hashes = vec![
1135+
let key_hashes = [
11371136
(
11381137
"qwert",
11391138
"c946ee72d38b8c51328f1a5f31eb5bd3300362ad0ca69dab54eff996775c7069216bda",
@@ -1165,7 +1164,7 @@ mod tests {
11651164
assert_ne!(init_root, merkle_db.get_merkle_root());
11661165

11671166
// matching prefix e55420, however this will be newly added and not set already in trie
1168-
let key_hash_to_be_inserted = vec![(
1167+
let key_hash_to_be_inserted = [(
11691168
"asdfg",
11701169
"e5542002d3e2892516fa461cde69e05880609fbad3d38ab69435a189e126de672b620c",
11711170
)];
@@ -1517,7 +1516,7 @@ mod tests {
15171516
);
15181517
}
15191518

1520-
let addresses = vec!["ab0000", "aba001", "abff02"];
1519+
let addresses = ["ab0000", "aba001", "abff02"];
15211520
for (i, key) in addresses.iter().enumerate() {
15221521
let new_root = merkle_db
15231522
.set(key, format!("{:04x}", i * 10).as_bytes())

0 commit comments

Comments
 (0)