Remove imports and cleanups (#3590)

* Remove unused import and if else chain
This commit is contained in:
Quentin Le Sceller 2021-03-08 11:09:41 -05:00 committed by GitHub
parent 45f74c396d
commit 725622da7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 17 additions and 48 deletions

View file

@ -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;

View file

@ -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),
}
}
}

View file

@ -19,7 +19,6 @@ use grin_pool as pool;
use grin_util as util;
use failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]

View file

@ -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};

View file

@ -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;

View file

@ -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;
@ -644,7 +643,7 @@ impl BlockPrintable {
.map(|output| {
OutputPrintable::from_output(
output,
chain.clone(),
chain,
Some(&block.header),
include_proof,
include_merkle_proof,

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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;

View file

@ -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))
@ -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))
@ -236,9 +230,8 @@ 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
if height == 0
|| height
> NRDRelativeHeight::MAX
.try_into()
.expect("WEEK_HEIGHT const should fit in u16")

View file

@ -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;

View file

@ -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;

View file

@ -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(_)) => {

View file

@ -20,7 +20,6 @@ use std::thread;
use std::time::Duration;
use clap::ArgMatches;
use ctrlc;
use crate::config::GlobalConfig;
use crate::p2p::Seeding;

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -22,7 +22,6 @@
#[macro_use]
extern crate log;
use failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]

View file

@ -12,7 +12,6 @@
// limitations under the License.
//! Common storage-related types
use memmap;
use tempfile::tempfile;
use crate::core::ser::{