diff --git a/api/src/client.rs b/api/src/client.rs index de314d632..7ed935654 100644 --- a/api/src/client.rs +++ b/api/src/client.rs @@ -20,10 +20,8 @@ use failure::{Fail, ResultExt}; use hyper::body; use hyper::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, USER_AGENT}; use hyper::{Body, Client, Request}; -use hyper_rustls; use hyper_timeout::TimeoutConnector; use serde::{Deserialize, Serialize}; -use serde_json; use std::time::Duration; use tokio::runtime::Builder; diff --git a/api/src/foreign_rpc.rs b/api/src/foreign_rpc.rs index bd0b1938b..85673404c 100644 --- a/api/src/foreign_rpc.rs +++ b/api/src/foreign_rpc.rs @@ -856,7 +856,7 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response { // create temporary grin server, run jsonrpc request on node api, delete server, return // json response. - { + { /*use grin_servers::test_framework::framework::run_doctest; use grin_util as util; use serde_json; @@ -890,6 +890,6 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response { serde_json::to_string_pretty(&expected_response).unwrap() ); }*/ - } + } }; } diff --git a/api/src/json_rpc.rs b/api/src/json_rpc.rs index fb6a8e434..5978fc4a8 100644 --- a/api/src/json_rpc.rs +++ b/api/src/json_rpc.rs @@ -16,7 +16,6 @@ //! JSON RPC Client functionality use std::{error, fmt}; -use hyper; use serde::{Deserialize, Serialize}; /// Builds a request @@ -143,7 +142,7 @@ impl fmt::Display for Error { write!(f, "duplicate RPC batch response ID: {}", v) } Error::_WrongBatchResponseId(ref v) => write!(f, "wrong RPC batch response ID: {}", v), - _ => f.write_str(&self.to_string()), + _ => write!(f, "{}", self), } } } diff --git a/api/src/lib.rs b/api/src/lib.rs index 0b3f788f1..54620bc29 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -19,7 +19,6 @@ use grin_pool as pool; use grin_util as util; -use failure; #[macro_use] extern crate failure_derive; #[macro_use] diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index e68a31174..f8c3cdc48 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -391,7 +391,7 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response { // create temporary grin server, run jsonrpc request on node api, delete server, return // json response. - { + { /*use grin_servers::test_framework::framework::run_doctest; use grin_util as util; use serde_json; @@ -425,6 +425,6 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response { serde_json::to_string_pretty(&expected_response).unwrap() ); }*/ - } + } }; } diff --git a/api/src/rest.rs b/api/src/rest.rs index c94c73a91..01d10544f 100644 --- a/api/src/rest.rs +++ b/api/src/rest.rs @@ -26,7 +26,6 @@ use futures::TryStreamExt; use hyper::server::accept; use hyper::service::make_service_fn; use hyper::{Body, Request, Server, StatusCode}; -use rustls; use rustls::internal::pemfile; use std::convert::Infallible; use std::fmt::{self, Display}; diff --git a/api/src/router.rs b/api/src/router.rs index 04dd3024d..1c1bf0145 100644 --- a/api/src/router.rs +++ b/api/src/router.rs @@ -13,7 +13,6 @@ // limitations under the License. use futures::future::{self, Future}; -use hyper; use hyper::service::Service; use hyper::{Body, Method, Request, Response, StatusCode}; use std::collections::hash_map::DefaultHasher; diff --git a/api/src/types.rs b/api/src/types.rs index 422a90e37..3945341de 100644 --- a/api/src/types.rs +++ b/api/src/types.rs @@ -21,7 +21,6 @@ use crate::core::{core, ser}; use crate::p2p; use crate::util::secp::pedersen; use crate::util::{self, ToHex}; -use serde; use serde::de::MapAccess; use serde::ser::SerializeStruct; use std::fmt; @@ -30,7 +29,7 @@ macro_rules! no_dup { ($field:ident) => { if $field.is_some() { return Err(serde::de::Error::duplicate_field("$field")); - } + } }; } @@ -644,7 +643,7 @@ impl BlockPrintable { .map(|output| { OutputPrintable::from_output( output, - chain.clone(), + chain, Some(&block.header), include_proof, include_merkle_proof, diff --git a/api/src/web.rs b/api/src/web.rs index 5212349a3..fd5bc440d 100644 --- a/api/src/web.rs +++ b/api/src/web.rs @@ -5,7 +5,6 @@ use futures::future::ok; use hyper::body; use hyper::{Body, Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; -use serde_json; use std::collections::HashMap; use std::fmt::Debug; use url::form_urlencoded; diff --git a/chain/src/lib.rs b/chain/src/lib.rs index 092b88038..157275239 100644 --- a/chain/src/lib.rs +++ b/chain/src/lib.rs @@ -31,7 +31,6 @@ extern crate serde_derive; #[macro_use] extern crate log; -use failure; use grin_core as core; use grin_keychain as keychain; use grin_util as util; diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index c0ec9d394..3ea6eab0f 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -34,7 +34,6 @@ use crate::types::{CommitPos, OutputRoots, Tip, TxHashSetRoots, TxHashsetWriteSt use crate::util::secp::pedersen::{Commitment, RangeProof}; use crate::util::{file, secp_static, zip}; use croaring::Bitmap; -use grin_store; use grin_store::pmmr::{clean_files_by_prefix, PMMRBackend}; use std::fs::{self, File}; use std::path::{Path, PathBuf}; diff --git a/config/src/config.rs b/config/src/config.rs index 1723e3d14..5a71a20af 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -14,7 +14,6 @@ //! Configuration file management -use dirs; use rand::distributions::{Alphanumeric, Distribution}; use rand::thread_rng; use std::env; @@ -23,7 +22,6 @@ use std::io::prelude::*; use std::io::BufReader; use std::io::Read; use std::path::PathBuf; -use toml; use crate::comments::insert_comments; use crate::core::global; diff --git a/core/src/core/transaction.rs b/core/src/core/transaction.rs index d963e1854..58874c2d8 100644 --- a/core/src/core/transaction.rs +++ b/core/src/core/transaction.rs @@ -115,9 +115,7 @@ impl TryFrom for FeeFields { type Error = Error; fn try_from(fee: u64) -> Result { - if fee == 0 { - Err(Error::InvalidFeeFields) - } else if fee > FeeFields::FEE_MASK { + if fee == 0 || fee > FeeFields::FEE_MASK { Err(Error::InvalidFeeFields) } else { Ok(Self(fee)) @@ -158,11 +156,7 @@ impl FeeFields { /// Create a new FeeFields from the provided shift and fee /// Checks both are valid (in range) pub fn new(fee_shift: u64, fee: u64) -> Result { - if fee == 0 { - Err(Error::InvalidFeeFields) - } else if fee > FeeFields::FEE_MASK { - Err(Error::InvalidFeeFields) - } else if fee_shift > FeeFields::FEE_SHIFT_MASK { + if fee == 0 || fee > FeeFields::FEE_MASK || fee_shift > FeeFields::FEE_SHIFT_MASK { Err(Error::InvalidFeeFields) } else { Ok(Self((fee_shift << FeeFields::FEE_BITS) | fee)) @@ -236,12 +230,11 @@ impl TryFrom for NRDRelativeHeight { type Error = Error; fn try_from(height: u16) -> Result { - if height == 0 { - Err(Error::InvalidNRDRelativeHeight) - } else if height - > NRDRelativeHeight::MAX - .try_into() - .expect("WEEK_HEIGHT const should fit in u16") + if height == 0 + || height + > NRDRelativeHeight::MAX + .try_into() + .expect("WEEK_HEIGHT const should fit in u16") { Err(Error::InvalidNRDRelativeHeight) } else { diff --git a/p2p/src/types.rs b/p2p/src/types.rs index 2a89846bf..6ca114137 100644 --- a/p2p/src/types.rs +++ b/p2p/src/types.rs @@ -25,8 +25,6 @@ use chrono::prelude::*; use serde::de::{SeqAccess, Visitor}; use serde::{Deserialize, Deserializer}; -use grin_store; - use crate::chain; use crate::chain::txhashset::BitmapChunk; use crate::core::core; diff --git a/servers/src/mining/stratumserver.rs b/servers/src/mining/stratumserver.rs index c49838c5c..74e1a8955 100644 --- a/servers/src/mining/stratumserver.rs +++ b/servers/src/mining/stratumserver.rs @@ -23,8 +23,6 @@ use tokio_util::codec::{Framed, LinesCodec}; use crate::util::RwLock; use chrono::prelude::Utc; -use serde; -use serde_json; use serde_json::Value; use std::collections::HashMap; use std::net::SocketAddr; diff --git a/src/bin/cmd/client.rs b/src/bin/cmd/client.rs index dcb2f1417..92e25c728 100644 --- a/src/bin/cmd/client.rs +++ b/src/bin/cmd/client.rs @@ -24,7 +24,6 @@ use crate::config::GlobalConfig; use crate::p2p::types::PeerInfoDisplay; use crate::util::file::get_first_line; use serde_json::json; -use term; const ENDPOINT: &str = "/v2/owner"; @@ -155,7 +154,7 @@ pub fn client_command(client_args: &ArgMatches<'_>, global_config: GlobalConfig) // just get defaults from the global config let server_config = global_config.members.unwrap().server; let api_secret = get_first_line(server_config.api_secret_path.clone()); - let node_client = HTTPNodeClient::new(&server_config.api_http_addr, api_secret.clone()); + let node_client = HTTPNodeClient::new(&server_config.api_http_addr, api_secret); match client_args.subcommand() { ("status", Some(_)) => { diff --git a/src/bin/cmd/server.rs b/src/bin/cmd/server.rs index eb17181cc..b0c9d5a76 100644 --- a/src/bin/cmd/server.rs +++ b/src/bin/cmd/server.rs @@ -20,7 +20,6 @@ use std::thread; use std::time::Duration; use clap::ArgMatches; -use ctrlc; use crate::config::GlobalConfig; use crate::p2p::Seeding; diff --git a/src/bin/tui/mining.rs b/src/bin/tui/mining.rs index 5cd814537..7fabb6f99 100644 --- a/src/bin/tui/mining.rs +++ b/src/bin/tui/mining.rs @@ -16,7 +16,7 @@ use std::cmp::Ordering; -use crate::tui::chrono::prelude::{DateTime, NaiveDateTime, Utc}; +use chrono::prelude::{DateTime, NaiveDateTime, Utc}; use cursive::direction::Orientation; use cursive::event::Key; use cursive::traits::{Boxable, Identifiable}; diff --git a/src/bin/tui/mod.rs b/src/bin/tui/mod.rs index 8a2f98575..a1d3b7040 100644 --- a/src/bin/tui/mod.rs +++ b/src/bin/tui/mod.rs @@ -12,10 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Grin TUI -use chrono; -use humansize; -// mod constants; mod logs; mod menu; diff --git a/src/bin/tui/peers.rs b/src/bin/tui/peers.rs index 9848985e8..2a133227c 100644 --- a/src/bin/tui/peers.rs +++ b/src/bin/tui/peers.rs @@ -18,8 +18,8 @@ use std::cmp::Ordering; use crate::servers::{PeerStats, ServerStats}; -use crate::tui::humansize::{file_size_opts::CONVENTIONAL, FileSize}; use chrono::prelude::*; +use humansize::{file_size_opts::CONVENTIONAL, FileSize}; use cursive::direction::Orientation; use cursive::event::Key; diff --git a/store/src/lib.rs b/store/src/lib.rs index ac2e0800a..8fc27278d 100644 --- a/store/src/lib.rs +++ b/store/src/lib.rs @@ -22,7 +22,6 @@ #[macro_use] extern crate log; -use failure; #[macro_use] extern crate failure_derive; #[macro_use] diff --git a/store/src/types.rs b/store/src/types.rs index 4fd8105be..3c3d94aca 100644 --- a/store/src/types.rs +++ b/store/src/types.rs @@ -12,7 +12,6 @@ // limitations under the License. //! Common storage-related types -use memmap; use tempfile::tempfile; use crate::core::ser::{