Skip to content

Commit

Permalink
Remove imports and cleanups (#3590)
Browse files Browse the repository at this point in the history
* Remove unused import and if else chain
  • Loading branch information
quentinlesceller committed Mar 8, 2021
1 parent 45f74c3 commit 725622d
Show file tree
Hide file tree
Showing 22 changed files with 17 additions and 48 deletions.
2 changes: 0 additions & 2 deletions api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -890,6 +890,6 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response {
serde_json::to_string_pretty(&expected_response).unwrap()
);
}*/
}
}
};
}
3 changes: 1 addition & 2 deletions api/src/json_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//! JSON RPC Client functionality
use std::{error, fmt};

use hyper;
use serde::{Deserialize, Serialize};

/// Builds a request
Expand Down Expand Up @@ -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),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use grin_pool as pool;

use grin_util as util;

use failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
Expand Down
4 changes: 2 additions & 2 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -425,6 +425,6 @@ macro_rules! doctest_helper_json_rpc_owner_assert_response {
serde_json::to_string_pretty(&expected_response).unwrap()
);
}*/
}
}
};
}
1 change: 0 additions & 1 deletion api/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion api/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +29,7 @@ macro_rules! no_dup {
($field:ident) => {
if $field.is_some() {
return Err(serde::de::Error::duplicate_field("$field"));
}
}
};
}

Expand Down Expand Up @@ -644,7 +643,7 @@ impl BlockPrintable {
.map(|output| {
OutputPrintable::from_output(
output,
chain.clone(),
chain,
Some(&block.header),
include_proof,
include_merkle_proof,
Expand Down
1 change: 0 additions & 1 deletion api/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion chain/src/txhashset/txhashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 0 additions & 2 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

//! Configuration file management

use dirs;
use rand::distributions::{Alphanumeric, Distribution};
use rand::thread_rng;
use std::env;
Expand All @@ -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;
Expand Down
21 changes: 7 additions & 14 deletions core/src/core/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ impl TryFrom<u64> for FeeFields {
type Error = Error;

fn try_from(fee: u64) -> Result<Self, Self::Error> {
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))
Expand Down Expand Up @@ -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<Self, Error> {
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))
Expand Down Expand Up @@ -236,12 +230,11 @@ impl TryFrom<u16> for NRDRelativeHeight {
type Error = Error;

fn try_from(height: u16) -> Result<Self, Self::Error> {
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 {
Expand Down
2 changes: 0 additions & 2 deletions p2p/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions servers/src/mining/stratumserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/bin/cmd/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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(_)) => {
Expand Down
1 change: 0 additions & 1 deletion src/bin/cmd/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::thread;
use std::time::Duration;

use clap::ArgMatches;
use ctrlc;

use crate::config::GlobalConfig;
use crate::p2p::Seeding;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tui/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 0 additions & 4 deletions src/bin/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/tui/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#[macro_use]
extern crate log;
use failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
Expand Down
1 change: 0 additions & 1 deletion store/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.

//! Common storage-related types
use memmap;
use tempfile::tempfile;

use crate::core::ser::{
Expand Down

0 comments on commit 725622d

Please sign in to comment.