mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Remove imports and cleanups (#3590)
* Remove unused import and if else chain
This commit is contained in:
parent
45f74c396d
commit
725622da7a
22 changed files with 17 additions and 48 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ use grin_pool as pool;
|
|||
|
||||
use grin_util as util;
|
||||
|
||||
use failure;
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
#[macro_use]
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(_)) => {
|
||||
|
|
|
@ -20,7 +20,6 @@ use std::thread;
|
|||
use std::time::Duration;
|
||||
|
||||
use clap::ArgMatches;
|
||||
use ctrlc;
|
||||
|
||||
use crate::config::GlobalConfig;
|
||||
use crate::p2p::Seeding;
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
use failure;
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
#[macro_use]
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
//! Common storage-related types
|
||||
use memmap;
|
||||
use tempfile::tempfile;
|
||||
|
||||
use crate::core::ser::{
|
||||
|
|
Loading…
Reference in a new issue