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

Commit

Permalink
Merge pull request #2460 from suchapalaver/fix/fix-compiler-and-clipp…
Browse files Browse the repository at this point in the history
…y-errors

Fix compiler and clippy errors
  • Loading branch information
vaporos authored Oct 11, 2023
2 parents 3004c63 + b62668d commit 9ccb01f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 43 deletions.
2 changes: 1 addition & 1 deletion families/battleship/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions perf/sawtooth_perf/src/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions perf/smallbank_workload/src/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion perf/smallbank_workload/src/smallbank_transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
19 changes: 7 additions & 12 deletions validator/src/journal/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,18 +653,13 @@ impl BlockManager {
}

fn block_contains_any_transaction(&self, block: &Block, ids: &[&String]) -> Option<String> {
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)
Expand Down
9 changes: 2 additions & 7 deletions validator/src/journal/block_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,16 @@ 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,
Missing = 3,
InValidation = 5,
}

impl Default for BlockStatus {
fn default() -> Self {
BlockStatus::Unknown
}
}

#[derive(Debug)]
pub struct BlockWrapper {
pub(super) py_block_wrapper: PyObject,
Expand Down
9 changes: 2 additions & 7 deletions validator/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ pub fn get_collector<S: AsRef<str>>(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 {
Expand Down
10 changes: 4 additions & 6 deletions validator/src/permissions/state_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
9 changes: 4 additions & 5 deletions validator/src/state/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
)];
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 9ccb01f

Please sign in to comment.