Cleanup imports (#1161)

Reorganize imports
This commit is contained in:
Quentin Le Sceller 2018-06-14 08:16:14 -04:00 committed by GitHub
parent 88616fd341
commit a30ee88236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 230 additions and 315 deletions

View file

@ -17,9 +17,8 @@ use std::sync::{Arc, RwLock, Weak};
use std::thread;
use failure::{Fail, ResultExt};
use iron::Handler;
use iron::prelude::*;
use iron::status;
use iron::prelude::{IronError, IronResult, Plugin, Request, Response};
use iron::{status, Handler};
use serde::Serialize;
use serde_json;
use urlencoded::UrlEncodedQuery;
@ -32,11 +31,10 @@ use p2p;
use p2p::types::ReasonForBan;
use pool;
use regex::Regex;
use rest::*;
use rest::{ApiServer, Error, ErrorKind};
use types::*;
use util;
use util::LOGGER;
use util::secp::pedersen::Commitment;
use util::{self, LOGGER};
// All handlers use `Weak` references instead of `Arc` to avoid cycles that
// can never be destroyed. These 2 functions are simple helpers to reduce the

View file

@ -25,7 +25,7 @@ use std::string::ToString;
use failure::{Backtrace, Context, Fail};
use iron::middleware::Handler;
use iron::prelude::*;
use iron::prelude::Iron;
use iron::Listening;
use mount::Mount;
use router::Router;

View file

@ -20,19 +20,19 @@ use std::fs::File;
use std::sync::{Arc, Mutex, RwLock};
use std::time::{Duration, Instant};
use core::core::Committed;
use core::core::hash::{Hash, Hashed};
use core::core::pmmr::MerkleProof;
use core::core::target::Difficulty;
use core::core::Committed;
use core::core::{Block, BlockHeader, Output, OutputIdentifier, Transaction, TxKernel};
use core::global;
use grin_store::Error::NotFoundErr;
use pipe;
use store;
use txhashset;
use types::*;
use util::LOGGER;
use types::{BlockMarker, BlockSums, ChainAdapter, ChainStore, Error, Options, Tip};
use util::secp::pedersen::{Commitment, RangeProof};
use util::LOGGER;
/// Orphan pool size is limited by MAX_ORPHAN_SIZE
pub const MAX_ORPHAN_SIZE: usize = 200;

View file

@ -26,7 +26,7 @@ use core::global;
use grin_store;
use store;
use txhashset;
use types::*;
use types::{BlockSums, ChainStore, Error, Options, Tip};
use util::LOGGER;
/// Contextual information required to process a new block and either reject or

View file

@ -24,8 +24,8 @@ use core::consensus::TargetError;
use core::core::hash::{Hash, Hashed};
use core::core::target::Difficulty;
use core::core::{Block, BlockHeader};
use grin_store::{self, option_to_not_found, to_key, Error, u64_to_key};
use types::*;
use grin_store::{self, option_to_not_found, to_key, u64_to_key, Error};
use types::{BlockMarker, BlockSums, ChainStore, Tip};
const STORE_SUBPATH: &'static str = "chain";

View file

@ -26,7 +26,6 @@ use core::core::target::Difficulty;
use core::core::{block, transaction, Block, BlockHeader};
use core::ser::{self, Readable, Reader, Writeable, Writer};
use grin_store as store;
use grin_store;
use keychain;
bitflags! {
@ -93,7 +92,7 @@ pub enum Error {
/// We've been provided a bad txhashset
InvalidTxHashSet(String),
/// Internal issue when trying to save or load data from store
StoreErr(grin_store::Error, String),
StoreErr(store::Error, String),
/// Internal issue when trying to save or load data from append only files
FileReadErr(String),
/// Error serializing or deserializing a type
@ -128,8 +127,8 @@ impl fmt::Display for Error {
}
}
impl From<grin_store::Error> for Error {
fn from(e: grin_store::Error) -> Error {
impl From<store::Error> for Error {
fn from(e: store::Error) -> Error {
Error::StoreErr(e, "wrapped".to_owned())
}
}

View file

@ -24,19 +24,16 @@ extern crate time;
use std::fs;
use std::sync::Arc;
use chain::types::{NoopAdapter, Tip};
use chain::Chain;
use chain::types::*;
use core::core::target::Difficulty;
use core::core::{Block, BlockHeader, Transaction};
use core::global;
use core::global::ChainTypes;
use core::global::{self, ChainTypes};
use core::pow;
use core::{consensus, genesis};
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::pow;
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);
}

View file

@ -24,19 +24,15 @@ extern crate time;
use std::fs;
use std::sync::Arc;
use chain::types::NoopAdapter;
use chain::Chain;
use chain::types::*;
use core::consensus;
use core::core::hash::Hashed;
use core::core::target::Difficulty;
use core::core::{Block, BlockHeader, OutputFeatures, OutputIdentifier, Transaction};
use core::global;
use core::global::ChainTypes;
use wallet::libtx::{self, build};
use core::{consensus, global, pow};
use keychain::{ExtKeychain, Keychain};
use core::pow;
use wallet::libtx::{self, build};
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -22,15 +22,12 @@ extern crate rand;
use std::fs;
use chain::{ChainStore, Tip};
use core::core::Block;
use core::core::BlockHeader;
use core::core::hash::Hashed;
use core::core::target::Difficulty;
use core::global;
use core::global::ChainTypes;
use core::core::{Block, BlockHeader};
use core::global::{self, ChainTypes};
use core::pow;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
fn clean_output_dir(dir_name: &str) {

View file

@ -23,19 +23,13 @@ extern crate time;
use std::fs;
use std::sync::Arc;
use chain::types::*;
use core::consensus;
use core::core::OutputIdentifier;
use chain::types::{Error, NoopAdapter};
use core::core::target::Difficulty;
use core::core::transaction;
use core::global;
use core::global::ChainTypes;
use wallet::libtx::build;
use core::core::{transaction, OutputIdentifier};
use core::global::{self, ChainTypes};
use core::{consensus, pow};
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::pow;
use wallet::libtx::{self, build};
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -20,11 +20,10 @@ extern crate grin_wallet as wallet;
use std::fs;
use std::sync::Arc;
use chain::ChainStore;
use chain::store::ChainKVStore;
use chain::txhashset;
use chain::txhashset::TxHashSet;
use chain::txhashset::{self, TxHashSet};
use chain::types::Tip;
use chain::ChainStore;
use core::core::pmmr::MerkleProof;
use core::core::target::Difficulty;
use core::core::{Block, BlockHeader};

View file

@ -15,14 +15,14 @@
//! Configuration file management
use std::env;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use std::fs::File;
use toml;
use servers::{ServerConfig, StratumServerConfig};
use util::LoggingConfig;
use types::{ConfigError, ConfigMembers, GlobalConfig};
use util::LoggingConfig;
use wallet::WalletConfig;
/// The default file name to use when trying to derive
@ -108,7 +108,7 @@ impl GlobalConfig {
let config_file = return_value.config_file_path.clone().unwrap();
if !config_file.exists() {
return Err(ConfigError::FileNotFoundError(String::from(
config_file.to_str().unwrap()
config_file.to_str().unwrap(),
)));
}

View file

@ -1,14 +1,13 @@
extern crate grin_core;
extern crate grin_keychain;
use std::path::Path;
use std::fs::{self, File};
use grin_core::ser;
use grin_core::core::{Block, BlockHeader, CompactBlock, Transaction};
use grin_core::core::target::Difficulty;
use grin_core::core::build::{input, output, transaction_with_offset, with_fee};
use grin_core::core::target::Difficulty;
use grin_core::core::{Block, BlockHeader, CompactBlock, Transaction};
use grin_core::ser;
use grin_keychain::keychain::Keychain;
use std::fs::{self, File};
use std::path::Path;
fn main() {
generate("transaction_read", &tx()).unwrap();

View file

@ -19,22 +19,17 @@ use std::collections::HashSet;
use std::iter::FromIterator;
use time;
use consensus;
use consensus::{exceeds_weight, reward, VerifySortOrder, REWARD};
use core::committed;
use core::committed::Committed;
use consensus::{self, exceeds_weight, reward, VerifySortOrder, REWARD};
use core::committed::{self, Committed};
use core::hash::{Hash, HashWriter, Hashed, ZERO_HASH};
use core::id::ShortIdentifiable;
use core::target::Difficulty;
use core::transaction;
use core::{Commitment, Input, KernelFeatures, Output, OutputFeatures, Proof, ShortId, Transaction,
TxKernel};
use core::{transaction, Commitment, Input, KernelFeatures, Output, OutputFeatures, Proof, ShortId,
Transaction, TxKernel};
use global;
use keychain;
use keychain::BlindingFactor;
use keychain::{self, BlindingFactor};
use ser::{self, read_and_verify_sorted, Readable, Reader, Writeable, WriteableSorted, Writer};
use util::LOGGER;
use util::{secp, static_secp_instance};
use util::{secp, static_secp_instance, LOGGER};
/// Errors thrown by Block validation
#[derive(Debug, Clone, PartialEq)]

View file

@ -17,7 +17,7 @@
use keychain;
use keychain::BlindingFactor;
use util::secp::pedersen::*;
use util::secp::pedersen::Commitment;
use util::{secp, secp_static, static_secp_instance};
/// Errors from summing and verifying kernel excesses via committed trait.

View file

@ -14,15 +14,14 @@
//! short ids for compact blocks
use std::cmp::Ordering;
use std::cmp::min;
use std::cmp::Ordering;
use byteorder::{ByteOrder, LittleEndian};
use siphasher::sip::SipHasher24;
use core::hash::{Hash, Hashed};
use ser;
use ser::{Readable, Reader, Writeable, Writer};
use ser::{self, Readable, Reader, Writeable, Writer};
use util;
/// The size of a short id used to identify inputs|outputs|kernels (6 bytes)

View file

@ -27,7 +27,7 @@ use rand::{thread_rng, Rng};
use std::num::ParseFloatError;
use std::{fmt, iter};
use util::secp::pedersen::*;
use util::secp::pedersen::Commitment;
pub use self::block::*;
pub use self::committed::Committed;

View file

@ -40,8 +40,7 @@ use ser::{self, PMMRIndexHashable, PMMRable, Readable, Reader, Writeable, Writer
use std::clone::Clone;
use std::marker;
use util;
use util::LOGGER;
use util::{self, LOGGER};
/// Storage backend for the MMR, just needs to be indexed by order of insertion.
/// The PMMR itself does not need the Backend to be accurate on the existence

View file

@ -14,8 +14,8 @@
//! Transactions
use std::cmp::Ordering;
use std::cmp::max;
use std::cmp::Ordering;
use std::collections::HashSet;
use std::io::Cursor;
use std::{error, fmt};
@ -24,16 +24,11 @@ use util::secp::pedersen::{Commitment, ProofMessage, RangeProof};
use util::secp::{self, Message, Signature};
use util::{kernel_sig_msg, static_secp_instance};
use consensus;
use consensus::VerifySortOrder;
use core::BlockHeader;
use core::Committed;
use core::committed;
use core::global;
use consensus::{self, VerifySortOrder};
use core::hash::{Hash, Hashed, ZERO_HASH};
use core::pmmr::MerkleProof;
use keychain;
use keychain::BlindingFactor;
use core::{committed, global, BlockHeader, Committed};
use keychain::{self, BlindingFactor};
use ser::{self, read_and_verify_sorted, ser_vec, PMMRable, Readable, Reader, Writeable,
WriteableSorted, Writer};
use util;
@ -505,7 +500,7 @@ pub fn aggregate(transactions: Vec<Transaction>) -> Result<Transaction, Error> {
let mut kernel_offsets: Vec<BlindingFactor> = vec![];
for mut transaction in transactions {
// we will summ these later to give a single aggregate offset
// we will sum these later to give a single aggregate offset
kernel_offsets.push(transaction.offset);
inputs.append(&mut transaction.inputs);

View file

@ -16,19 +16,15 @@
//! having to pass them all over the place, but aren't consensus values.
//! should be used sparingly.
use consensus::TargetError;
use consensus::{BLOCK_TIME_SEC, COINBASE_MATURITY, CUT_THROUGH_HORIZON, DEFAULT_SIZESHIFT,
DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY, MEDIAN_TIME_WINDOW, PROOFSIZE};
use core::target::Difficulty;
/// An enum collecting sets of parameters used throughout the
/// code wherever mining is needed. This should allow for
/// different sets of parameters for different purposes,
/// e.g. CI, User testing, production values
use std::sync::RwLock;
use consensus::PROOFSIZE;
use consensus::DEFAULT_SIZESHIFT;
use consensus::COINBASE_MATURITY;
use consensus::{BLOCK_TIME_SEC, CUT_THROUGH_HORIZON, DIFFICULTY_ADJUST_WINDOW, INITIAL_DIFFICULTY,
MEDIAN_TIME_WINDOW};
use core::target::Difficulty;
use consensus::TargetError;
/// Define these here, as they should be developer-set, not really tweakable
/// by users
@ -193,8 +189,9 @@ pub fn get_genesis_nonce() -> u64 {
}
}
/// Converts an iterator of block difficulty data to more a more mangeable vector and pads
/// if needed (which will) only be needed for the first few blocks after genesis
/// Converts an iterator of block difficulty data to more a more mangeable
/// vector and pads if needed (which will) only be needed for the first few
/// blocks after genesis
pub fn difficulty_data_to_vector<T>(cursor: T) -> Vec<Result<(u64, Difficulty), TargetError>>
where

View file

@ -20,17 +20,15 @@
//! `serialize` or `deserialize` functions on them as appropriate.
use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
use consensus;
use consensus::VerifySortOrder;
use consensus::{self, VerifySortOrder};
use core::hash::{Hash, Hashed};
use keychain::{BlindingFactor, Identifier, IDENTIFIER_SIZE};
use std::io::{self, Read, Write};
use std::{cmp, error, fmt, mem};
use util::secp::Signature;
use util::secp::constants::{AGG_SIGNATURE_SIZE, MAX_PROOF_SIZE, PEDERSEN_COMMITMENT_SIZE,
SECRET_KEY_SIZE};
use util::secp::pedersen::Commitment;
use util::secp::pedersen::RangeProof;
use util::secp::pedersen::{Commitment, RangeProof};
use util::secp::Signature;
/// Possible errors deriving from serializing or deserializing.
#[derive(Debug)]

View file

@ -21,18 +21,16 @@ pub mod common;
use common::{new_block, tx1i2o, tx2i1o, txspend1i1o};
use grin_core::consensus::{BLOCK_OUTPUT_WEIGHT, MAX_BLOCK_WEIGHT};
use grin_core::core::Committed;
use grin_core::core::block::Error;
use grin_core::core::hash::Hashed;
use grin_core::core::id::{ShortId, ShortIdentifiable};
use grin_core::core::Committed;
use grin_core::core::{Block, BlockHeader, CompactBlock, KernelFeatures, OutputFeatures};
use grin_core::global;
use grin_core::ser;
use grin_core::{global, ser};
use keychain::{ExtKeychain, Keychain};
use std::time::Instant;
use wallet::libtx::build::{self, input, output, with_fee};
use util::{secp, secp_static};
use wallet::libtx::build::{self, input, output, with_fee};
// Too slow for now #[test]
// TODO: make this fast enough or add similar but faster test?

View file

@ -16,9 +16,10 @@
extern crate grin_core as core;
extern crate time;
use core::consensus::{next_difficulty, valid_header_version, TargetError,
DIFFICULTY_ADJUST_WINDOW, MEDIAN_TIME_WINDOW};
use core::core::target::Difficulty;
use core::global;
use core::consensus::*;
// Builds an iterator for next difficulty calculation with the provided
// constant time interval, difficulty and total length.
@ -49,9 +50,10 @@ fn create_chain_sim(diff: u64) -> Vec<Result<(u64, Difficulty), TargetError>> {
time::get_time().sec,
Difficulty::from_num(diff)
);
vec![
Ok((time::get_time().sec as u64, Difficulty::from_num(diff))),
]
vec![Ok((
time::get_time().sec as u64,
Difficulty::from_num(diff),
))]
}
// Adds another 'block' to the iterator, so to speak, with difficulty calculated

View file

@ -20,17 +20,15 @@
//! forces us to go through some additional gymnastic to loop over the async
//! stream and make sure we get the right number of bytes out.
use std::cmp;
use std::fs::File;
use std::io::{self, Read, Write};
use std::net::TcpStream;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time;
use std::{cmp, thread, time};
use core::ser;
use msg::*;
use types::*;
use msg::{read_body, read_exact, read_header, write_all, write_to_buf, MsgHeader, Type};
use types::Error;
use util::LOGGER;
/// A trait to be implemented in order to receive messages from the

View file

@ -16,14 +16,14 @@ use std::collections::VecDeque;
use std::net::{SocketAddr, TcpStream};
use std::sync::{Arc, RwLock};
use rand::Rng;
use rand::os::OsRng;
use rand::Rng;
use core::core::hash::Hash;
use core::core::target::Difficulty;
use msg::*;
use msg::{read_message, write_message, Hand, Shake, SockAddr, Type, PROTOCOL_VERSION, USER_AGENT};
use peer::Peer;
use types::*;
use types::{Capabilities, Direction, Error, P2PConfig, PeerInfo};
use util::LOGGER;
const NONCES_CAP: usize = 100;

View file

@ -17,16 +17,15 @@
use num::FromPrimitive;
use std::io::{self, Read, Write};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, TcpStream};
use std::thread;
use std::time;
use std::{thread, time};
use core::consensus::{MAX_MSG_LEN, MAX_TX_INPUTS, MAX_TX_KERNELS, MAX_TX_OUTPUTS};
use core::core::BlockHeader;
use core::core::hash::Hash;
use core::core::target::Difficulty;
use core::core::BlockHeader;
use core::ser::{self, Readable, Reader, Writeable, Writer};
use types::*;
use types::{Capabilities, Error, ReasonForBan, MAX_BLOCK_HEADERS, MAX_LOCATORS, MAX_PEER_ADDRS};
use util::LOGGER;
/// Current latest version of the protocol

View file

@ -21,10 +21,10 @@ use core::core;
use core::core::hash::{Hash, Hashed};
use core::core::target::Difficulty;
use handshake::Handshake;
use msg;
use msg::*;
use msg::{self, BanReason, GetPeerAddrs, Locator, Ping, TxHashSetRequest};
use protocol::Protocol;
use types::*;
use types::{Capabilities, ChainAdapter, Error, NetAdapter, P2PConfig, PeerInfo, ReasonForBan,
TxHashSetRead};
use util::LOGGER;
const MAX_TRACK_SIZE: usize = 30;

View file

@ -27,7 +27,8 @@ use util::LOGGER;
use peer::Peer;
use store::{PeerData, PeerStore, State};
use types::*;
use types::{Capabilities, ChainAdapter, Direction, Error, NetAdapter, P2PConfig, ReasonForBan,
TxHashSetRead, MAX_PEER_ADDRS};
pub struct Peers {
pub adapter: Arc<ChainAdapter>,

View file

@ -17,13 +17,13 @@ use std::fs::File;
use std::net::SocketAddr;
use std::sync::Arc;
use conn::*;
use conn::{Message, MessageHandler, Response};
use core::core;
use core::core::hash::{Hash, Hashed};
use msg::*;
use rand;
use rand::Rng;
use types::*;
use msg::{BanReason, GetPeerAddrs, Headers, Locator, PeerAddrs, Ping, Pong, SockAddr,
TxHashSetArchive, TxHashSetRequest, Type};
use rand::{self, Rng};
use types::{Error, NetAdapter};
use util::LOGGER;
pub struct Protocol {

View file

@ -13,12 +13,11 @@
// limitations under the License.
use std::fs::File;
use std::io;
use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread;
use std::time::Duration;
use std::{io, thread};
use core::core;
use core::core::hash::Hash;
@ -27,7 +26,7 @@ use handshake::Handshake;
use peer::Peer;
use peers::Peers;
use store::PeerStore;
use types::*;
use types::{Capabilities, ChainAdapter, Error, NetAdapter, P2PConfig, TxHashSetRead};
use util::LOGGER;
/// P2P server implementation, handling bootstrapping to find and connect to

View file

@ -18,10 +18,9 @@ use std::io;
use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc;
use core::core;
use core::core::hash::Hash;
use core::core::target::Difficulty;
use core::ser;
use core::{core, ser};
use grin_store;
/// Maximum number of block headers a peer should ever send

View file

@ -17,10 +17,9 @@ extern crate grin_p2p as p2p;
extern crate grin_util as util;
use std::net::{SocketAddr, TcpListener, TcpStream};
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::thread;
use std::time;
use std::sync::Arc;
use std::{thread, time};
use core::core::hash::Hash;
use core::core::target::Difficulty;

View file

@ -22,7 +22,7 @@ use core::core::hash::Hashed;
use core::core::id::ShortIdentifiable;
use core::core::transaction;
use core::core::{Block, CompactBlock, Transaction, TxKernel};
use types::*;
use types::{BlockChain, PoolEntry, PoolEntryState, PoolError};
use util::LOGGER;
pub struct Pool<T> {

View file

@ -21,10 +21,9 @@ use std::sync::Arc;
use time;
use core::core::hash::Hashed;
use core::core::transaction;
use core::core::{Block, CompactBlock, Transaction};
use core::core::{transaction, Block, CompactBlock, Transaction};
use pool::Pool;
use types::*;
use types::{BlockChain, PoolAdapter, PoolConfig, PoolEntry, PoolEntryState, PoolError, TxSource};
use util::LOGGER;
/// Transaction pool implementation.

View file

@ -19,8 +19,7 @@ use std::{error, fmt};
use time::Timespec;
use core::consensus;
use core::core::transaction;
use core::core::transaction::Transaction;
use core::core::transaction::{self, Transaction};
/// Dandelion relay timer
const DANDELION_RELAY_SECS: u64 = 600;

View file

@ -29,9 +29,8 @@ use std::sync::{Arc, RwLock};
use core::core::{Block, BlockHeader};
use chain::ChainStore;
use chain::txhashset;
use chain::types::Tip;
use chain::{txhashset, ChainStore};
use core::core::target::Difficulty;
use keychain::{ExtKeychain, Keychain};

View file

@ -29,16 +29,14 @@ use std::sync::{Arc, RwLock};
use core::core::{Block, BlockHeader};
use chain::ChainStore;
use chain::txhashset;
use chain::types::Tip;
use chain::{txhashset, ChainStore};
use common::{clean_output_dir, test_setup, test_source, test_transaction,
test_transaction_spending_coinbase, ChainAdapter};
use core::core::target::Difficulty;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use common::*;
#[test]
fn test_transaction_pool_block_reconciliation() {
let keychain: ExtKeychain = Keychain::from_random_seed().unwrap();

View file

@ -27,13 +27,11 @@ pub mod common;
use std::sync::{Arc, RwLock};
use common::{test_source, test_transaction};
use core::core::Transaction;
use keychain::{ExtKeychain, Keychain};
use pool::types::{BlockChain, NoopAdapter, PoolConfig, PoolError};
use pool::TransactionPool;
use pool::types::*;
use common::*;
pub fn test_setup(
chain: &Arc<CoinbaseMaturityErrorChainAdapter>,

View file

@ -27,19 +27,15 @@ pub mod common;
use std::sync::{Arc, RwLock};
use core::core::{Block, BlockHeader};
use chain::ChainStore;
use chain::txhashset;
use chain::types::Tip;
use chain::{txhashset, ChainStore};
use common::{clean_output_dir, test_setup, test_source, test_transaction,
test_transaction_spending_coinbase, ChainAdapter};
use core::core::target::Difficulty;
use core::core::transaction;
use core::core::{transaction, Block, BlockHeader};
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use common::*;
/// Test we can add some txs to the pool (both stempool and txpool).
#[test]
fn test_the_transaction_pool() {

View file

@ -15,8 +15,7 @@
//! Adapters connecting new block, new transaction, and accepted transaction
//! events to consumers of those events.
use rand;
use rand::Rng;
use rand::{self, Rng};
use std::fs::File;
use std::net::SocketAddr;
use std::ops::Deref;
@ -35,8 +34,7 @@ use core::core::transaction::Transaction;
use p2p;
use pool;
use store;
use util::LOGGER;
use util::OneTime;
use util::{OneTime, LOGGER};
// All adapters use `Weak` references instead of `Arc` to avoid cycles that
// can never be destroyed. These 2 functions are simple helpers to reduce the

View file

@ -18,9 +18,8 @@ use std::convert::From;
use api;
use chain;
use core::core;
use core::global::ChainTypes;
use core::pow;
use core::{core, pow};
use p2p;
use pool;
use store;

View file

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use rand;
use rand::Rng;
use rand::{self, Rng};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread;
@ -22,8 +21,7 @@ use time::now_utc;
use core::core::hash::Hashed;
use core::core::transaction;
use pool::DandelionConfig;
use pool::{BlockChain, PoolEntryState, PoolError, TransactionPool, TxSource};
use pool::{BlockChain, DandelionConfig, PoolEntryState, PoolError, TransactionPool, TxSource};
use util::LOGGER;
/// A process to monitor transactions in the stempool.

View file

@ -17,8 +17,7 @@
//!
use std::io::Read;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::net::{SocketAddr, ToSocketAddrs};
use std::str;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{mpsc, Arc};

View file

@ -19,20 +19,18 @@
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread;
use std::time;
use std::{thread, time};
use api;
use chain;
use common::adapters::*;
use common::stats::*;
use common::types::*;
use common::adapters::{ChainToPoolAndNetAdapter, NetToChainAdapter, PoolToChainAdapter,
PoolToNetAdapter};
use common::stats::{DiffBlock, DiffStats, PeerStats, ServerStateInfo, ServerStats};
use common::types::{Error, Seeding, ServerConfig, StratumServerConfig};
use core::core::hash::Hashed;
use core::core::target::Difficulty;
use core::{consensus, genesis, global, pow};
use grin::dandelion_monitor;
use grin::seed;
use grin::sync;
use grin::{dandelion_monitor, seed, sync};
use mining::stratumserver;
use mining::test_miner::Miner;
use p2p;

View file

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use std::{cmp, thread};
use time;
@ -457,7 +457,7 @@ mod test {
assert_eq!(
get_locator_heights(10000),
vec![
10000, 9998, 9994, 9986, 9970, 9938, 9874, 9746, 9490, 8978, 7954, 5906, 1810, 0
10000, 9998, 9994, 9986, 9970, 9938, 9874, 9746, 9490, 8978, 7954, 5906, 1810, 0,
]
);
}

View file

@ -22,21 +22,16 @@ use std::thread;
use std::time::Duration;
use time;
use chain;
use chain::types::BlockSums;
use chain::{self, types::BlockSums};
use common::adapters::PoolToChainAdapter;
use common::types::Error;
use core::consensus;
use core::core;
use core::core::hash::Hashed;
use core::ser;
use core::ser::AsFixedBytes;
use core::ser::{self, AsFixedBytes};
use core::{consensus, core};
use keychain::{ExtKeychain, Identifier, Keychain};
use pool;
use util;
use util::LOGGER;
use wallet;
use wallet::BlockFees;
use util::{self, LOGGER};
use wallet::{self, BlockFees};
/// Serializer that outputs the pre-pow part of the header,
/// including the nonce (last 8 bytes) that can be sent off

View file

@ -15,25 +15,21 @@
//! Mining Stratum Server
use bufstream::BufStream;
use serde_json;
use std::cmp;
use std::error::Error;
use std::io::BufRead;
use std::io::{ErrorKind, Write};
use std::io::{BufRead, ErrorKind, Write};
use std::net::{TcpListener, TcpStream};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, RwLock};
use std::thread;
use std::time::Duration;
use std::time::SystemTime;
use std::time::{Duration, SystemTime};
use std::{cmp, thread};
use time;
use chain;
use common::adapters::PoolToChainAdapter;
use common::stats::{StratumStats, WorkerStats};
use common::types::StratumServerConfig;
use core::consensus;
use core::core::{Block, BlockHeader};
use core::pow;
use core::{consensus, pow};
use keychain;
use mining::mine_block;
use pool;

View file

@ -21,19 +21,16 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use time;
use chain;
use common::adapters::PoolToChainAdapter;
use common::types::StratumServerConfig;
use core::consensus;
use core::core::Proof;
use core::core::hash::{Hash, Hashed};
use core::core::{Block, BlockHeader};
use core::core::{Block, BlockHeader, Proof};
use core::pow::cuckoo;
use util::LOGGER;
use chain;
use core::global;
use core::{consensus, global};
use mining::mine_block;
use pool;
use util::LOGGER;
// Max number of transactions this miner will assemble in a block
const MAX_TX: u32 = 5000;

View file

@ -26,11 +26,10 @@ extern crate grin_wallet as wallet;
mod framework;
use std::{thread, time};
use std::sync::{Arc, Mutex};
use std::{thread, time};
use core::global;
use core::global::ChainTypes;
use core::global::{self, ChainTypes};
use framework::{LocalServerContainer, LocalServerContainerConfig};
use util::{init_test_logger, LOGGER};

View file

@ -24,10 +24,8 @@ extern crate grin_wallet as wallet;
extern crate blake2_rfc as blake2;
use std::default::Default;
use std::fs;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time;
use std::{fs, thread, time};
use wallet::{FileWallet, WalletConfig};

View file

@ -23,11 +23,9 @@ extern crate grin_wallet as wallet;
mod framework;
use std::default::Default;
use std::thread;
use std::time;
use std::{thread, time};
use core::global;
use core::global::ChainTypes;
use core::global::{self, ChainTypes};
use framework::{config, stratum_config, LocalServerContainerConfig, LocalServerContainerPool,
LocalServerContainerPoolConfig};

View file

@ -25,16 +25,14 @@ extern crate serde_json;
mod framework;
use std::io::prelude::*;
use std::net::TcpStream;
use bufstream::BufStream;
use serde_json::Value;
use std::io::prelude::{BufRead, Write};
use std::net::TcpStream;
use std::thread;
use std::time;
use std::{thread, time};
use core::global;
use core::global::ChainTypes;
use core::global::{self, ChainTypes};
use framework::{config, stratum_config};

View file

@ -14,15 +14,16 @@
//! Main Menu definition
use cursive::Cursive;
use cursive::view::View;
use cursive::align::HAlign;
use cursive::direction::Orientation;
use cursive::event::{EventResult, Key};
use cursive::view::Identifiable;
use cursive::view::View;
use cursive::views::{BoxView, LinearLayout, OnEventView, SelectView, StackView, TextView, ViewRef};
use cursive::direction::Orientation;
use cursive::Cursive;
use tui::constants::*;
use tui::constants::{MAIN_MENU, ROOT_STACK, SUBMENU_MINING_BUTTON, VIEW_BASIC_STATUS, VIEW_MINING,
VIEW_PEER_SYNC, VIEW_VERSION};
pub fn create() -> Box<View> {
let mut main_menu = SelectView::new().h_align(HAlign::Left).with_id(MAIN_MENU);

View file

@ -16,18 +16,19 @@
use std::cmp::Ordering;
use cursive::Cursive;
use cursive::direction::Orientation;
use cursive::event::Key;
use cursive::traits::{Boxable, Identifiable};
use cursive::view::View;
use cursive::views::{BoxView, Button, Dialog, LinearLayout, OnEventView, Panel, StackView,
TextView};
use cursive::direction::Orientation;
use cursive::traits::*;
use cursive::Cursive;
use std::time;
use tui::chrono::prelude::*;
use tui::chrono::prelude::{DateTime, NaiveDateTime, Utc};
use tui::constants::*;
use tui::types::*;
use tui::constants::{MAIN_MENU, SUBMENU_MINING_BUTTON, TABLE_MINING_DIFF_STATUS,
TABLE_MINING_STATUS, VIEW_MINING};
use tui::types::TUIStatusListener;
use servers::{DiffBlock, ServerStats, WorkerStats};
use tui::table::{TableView, TableViewItem};

View file

@ -18,15 +18,15 @@ use std::cmp::Ordering;
use servers::{PeerStats, ServerStats};
use cursive::Cursive;
use cursive::direction::Orientation;
use cursive::traits::{Boxable, Identifiable};
use cursive::view::View;
use cursive::views::{BoxView, Dialog, LinearLayout, TextView};
use cursive::direction::Orientation;
use cursive::traits::*;
use cursive::Cursive;
use tui::constants::{TABLE_PEER_STATUS, VIEW_PEER_SYNC};
use tui::table::{TableView, TableViewItem};
use tui::constants::*;
use tui::types::*;
use tui::types::TUIStatusListener;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
enum PeerColumn {

View file

@ -14,14 +14,14 @@
//! Basic status view definition
use cursive::Cursive;
use cursive::direction::Orientation;
use cursive::traits::Identifiable;
use cursive::view::View;
use cursive::views::{BoxView, LinearLayout, TextView};
use cursive::direction::Orientation;
use cursive::traits::*;
use cursive::Cursive;
use tui::constants::*;
use tui::types::*;
use tui::constants::VIEW_BASIC_STATUS;
use tui::types::TUIStatusListener;
use servers::ServerStats;

View file

@ -41,8 +41,10 @@
//! Adapted from https://github.com/behnam/rust-cursive-table-view
//! A basic table view implementation for [cursive](https://crates.io/crates/cursive).
#![deny(missing_docs, missing_copy_implementations, trivial_casts, trivial_numeric_casts,
unsafe_code, unused_import_braces, unused_qualifications)]
#![deny(
missing_docs, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unsafe_code,
unused_import_braces, unused_qualifications
)]
// Crate Dependencies ---------------------------------------------------------
extern crate cursive;
@ -54,14 +56,14 @@ use std::hash::Hash;
use std::rc::Rc;
// External Dependencies ------------------------------------------------------
use cursive::With;
use cursive::align::HAlign;
use cursive::direction::Direction;
use cursive::event::{Callback, Event, EventResult, Key};
use cursive::theme::ColorStyle;
use cursive::theme::PaletteColor::*;
use cursive::theme::PaletteColor::{Highlight, HighlightInactive, Primary};
use cursive::vec::Vec2;
use cursive::view::{ScrollBase, View};
use cursive::With;
use cursive::{Cursive, Printer};
/// A trait for displaying and sorting items inside a

View file

@ -14,8 +14,8 @@
//! Types specific to the UI module
use cursive::Cursive;
use cursive::view::View;
use cursive::Cursive;
use servers::ServerStats;
/// Main message struct to communicate between the UI and

View file

@ -18,21 +18,21 @@
use std::sync::{mpsc, Arc};
use time;
use cursive::Cursive;
use cursive::direction::Orientation;
use cursive::theme::BaseColor::{Black, Blue, Cyan, White};
use cursive::theme::Color::Dark;
use cursive::theme::PaletteColor::{Background, Highlight, HighlightInactive, Primary, Shadow, View};
use cursive::theme::{BaseColor, BorderStyle, Color, Theme};
use cursive::theme::PaletteColor::*;
use cursive::theme::Color::*;
use cursive::theme::BaseColor::*;
use cursive::traits::Identifiable;
use cursive::utils::markup::StyledString;
use cursive::views::{LinearLayout, Panel, StackView, TextView, ViewBox};
use cursive::direction::Orientation;
use cursive::traits::*;
use cursive::Cursive;
use servers::Server;
use tui::constants::ROOT_STACK;
use tui::types::{TUIStatusListener, UIMessage};
use tui::{menu, mining, peers, status, version};
use tui::types::*;
use tui::constants::*;
use built_info;

View file

@ -14,17 +14,17 @@
//! Version and build info
use cursive::Cursive;
use cursive::direction::Orientation;
use cursive::traits::Identifiable;
use cursive::view::View;
use cursive::views::{BoxView, LinearLayout, TextView};
use cursive::direction::Orientation;
use cursive::traits::*;
use cursive::Cursive;
use tui::constants::*;
use tui::types::*;
use tui::constants::VIEW_VERSION;
use tui::types::TUIStatusListener;
use servers::ServerStats;
use info_strings;
use servers::ServerStats;
pub struct TUIVersionView;

View file

@ -19,9 +19,8 @@ use std::marker;
use core::core::hash::Hash;
use core::core::pmmr::{self, family, Backend};
use core::ser;
use core::ser::PMMRable;
use types::*;
use core::ser::{self, PMMRable};
use types::{prune_noop, read_ordered_vec, write_vec, AppendOnlyFile, RemoveLog};
use util::LOGGER;
const PMMR_HASH_FILE: &'static str = "pmmr_hash.bin";

View file

@ -16,8 +16,7 @@ use memmap;
use std::cmp;
use std::fs::{self, File, OpenOptions};
use std::io::Read;
use std::io::{self, BufRead, BufReader, BufWriter, ErrorKind, Write};
use std::io::{self, BufRead, BufReader, BufWriter, ErrorKind, Read, Write};
use std::os::unix::io::AsRawFd;
use std::path::Path;

View file

@ -20,7 +20,7 @@ extern crate time;
use std::fs;
use core::core::pmmr::{Backend, PMMR};
use core::ser::*;
use core::ser::{Error, PMMRIndexHashable, PMMRable, Readable, Reader, Writeable, Writer};
use store::types::prune_noop;
#[test]

View file

@ -21,9 +21,8 @@ use std::collections::HashMap;
use std::io;
use futures::{Future, Stream};
use hyper;
use hyper::header::ContentType;
use hyper::{Method, Request};
use hyper::{self, Method, Request};
use serde_json;
use tokio_core::reactor;

View file

@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use core::core;
use core::core::amount_to_hr_string;
use libwallet::Error;
use core::core::{self, amount_to_hr_string};
use libwallet::types::{OutputData, WalletInfo};
use libwallet::Error;
use prettytable;
use std::io::prelude::*;
use std::io::prelude::Write;
use term;
/// Display outputs in a pretty way

View file

@ -18,27 +18,26 @@ use std::cmp::min;
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::{Read, Write};
use std::path::MAIN_SEPARATOR;
use std::path::Path;
use std::path::{Path, MAIN_SEPARATOR};
use serde_json;
use tokio_core::reactor;
use tokio_retry::Retry;
use tokio_retry::strategy::FibonacciBackoff;
use tokio_retry::Retry;
use failure::ResultExt;
use keychain::{self, Keychain};
use util;
use util::LOGGER;
use util::secp::pedersen;
use util::{self, LOGGER};
use error::{Error, ErrorKind};
use client;
use libtx::slate::Slate;
use libwallet;
use libwallet::types::*;
use libwallet::types::{BlockFees, BlockIdentifier, CbData, MerkleProofWrapper, OutputData,
TxWrapper, WalletBackend, WalletClient};
const DAT_FILE: &'static str = "wallet.dat";
const BCK_FILE: &'static str = "wallet.bck";
@ -189,7 +188,7 @@ impl<K> WalletBackend<K> for FileWallet<K>
where
K: Keychain,
{
/// Initialise with whatever stored credentials we have
/// Initialize with whatever stored credentials we have
fn open_with_credentials(&mut self) -> Result<(), libwallet::Error> {
let wallet_seed = WalletSeed::from_file(&self.config)
.context(libwallet::ErrorKind::CallbackImpl("Error opening wallet"))?;
@ -361,7 +360,7 @@ where
// The limit exists because by default, we always select as many inputs as
// possible in a transaction, to reduce both the Output set and the fees.
// But that only makes sense up to a point, hence the limit to avoid being too
// greedy. But if max_outputs(500) is actually not enought to cover the whole
// greedy. But if max_outputs(500) is actually not enough to cover the whole
// amount, the wallet should allow going over it to satisfy what the user
// wants to send. So the wallet considers max_outputs more of a soft limit.
if eligible.len() > max_outputs {
@ -436,7 +435,7 @@ impl<K> WalletClient for FileWallet<K> {
}
}
/// Posts a tranaction to a grin node
/// Posts a transaction to a grin node
fn post_tx(&self, dest: &str, tx: &TxWrapper, fluff: bool) -> Result<(), libwallet::Error> {
let res = client::post_tx(dest, tx, fluff).context(libwallet::ErrorKind::Node)?;
Ok(res)

View file

@ -16,8 +16,7 @@
use failure::{Backtrace, Context, Fail};
use std::fmt::{self, Display};
use core::core::committed;
use core::core::transaction;
use core::core::{committed, transaction};
use keychain;
use util::secp;

View file

@ -23,8 +23,8 @@ use keychain::{BlindSum, BlindingFactor, Keychain};
use libtx::error::{Error, ErrorKind};
use libtx::{aggsig, build, tx_fee};
use util::secp::Signature;
use util::secp::key::{PublicKey, SecretKey};
use util::secp::Signature;
use util::{secp, LOGGER};
/// Public data for each participant in the slate

View file

@ -19,14 +19,13 @@
use std::marker::PhantomData;
use core::ser;
use keychain::Keychain;
use libtx::slate::Slate;
use libwallet::Error;
use libwallet::internal::{tx, updater};
use libwallet::types::{BlockFees, CbData, OutputData, TxWrapper, WalletBackend, WalletClient,
WalletInfo};
use core::ser;
use keychain::Keychain;
use libwallet::Error;
use util::{self, LOGGER};
/// Wrapper around internal API functions, containing a reference to

View file

@ -20,10 +20,8 @@ use std::marker::PhantomData;
use std::sync::{Arc, Mutex};
use bodyparser;
use iron::Handler;
use iron::Headers;
use iron::prelude::*;
use iron::status;
use iron::prelude::{IronError, IronResult, Plugin, Request, Response};
use iron::{status, Handler, Headers};
use serde::Serialize;
use serde_json;
use urlencoded::UrlEncodedQuery;

View file

@ -48,8 +48,11 @@ pub enum ErrorKind {
},
/// Fee Exceeds amount
#[fail(display = "Fee exceeds amount: sender amount {}, recipient fee {}", sender_amount,
recipient_fee)]
#[fail(
display = "Fee exceeds amount: sender amount {}, recipient fee {}",
sender_amount,
recipient_fee
)]
FeeExceedsAmount {
/// sender amount
sender_amount: u64,

View file

@ -23,9 +23,8 @@ use failure::{Fail, ResultExt};
use keychain::{Identifier, Keychain};
use libtx::proof;
use libwallet::types::*;
use util;
use util::LOGGER;
use util::secp::pedersen;
use util::{self, LOGGER};
fn get_merkle_proof_for_commit(node_addr: &str, commit: &str) -> Result<MerkleProofWrapper, Error> {
let url = format!("{}/v1/txhashset/merkleproof?id={}", node_addr, commit);

View file

@ -15,7 +15,7 @@
//! Selection of inputs for building transactions
use keychain::{Identifier, Keychain};
use libtx::{build, tx_fee, slate::Slate};
use libtx::{build, slate::Slate, tx_fee};
use libwallet::error::{Error, ErrorKind};
use libwallet::internal::{keys, sigcontext};
use libwallet::types::*;

View file

@ -16,21 +16,20 @@
//! the wallet storage and update them.
use failure::ResultExt;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use core::consensus::reward;
use core::core::{Output, TxKernel};
use core::global;
use core::ser;
use core::{global, ser};
use keychain::{Identifier, Keychain};
use libtx::reward;
use libwallet::error::{Error, ErrorKind};
use libwallet::internal::keys;
use libwallet::types::*;
use util;
use util::LOGGER;
use libwallet::types::{BlockFees, CbData, OutputData, OutputStatus, WalletBackend, WalletClient,
WalletInfo};
use util::secp::pedersen;
use util::{self, LOGGER};
/// Retrieve all of the outputs (doesn't attempt to update from node)
pub fn retrieve_outputs<T, K>(wallet: &mut T, show_spent: bool) -> Result<Vec<OutputData>, Error>

View file

@ -24,7 +24,6 @@ use failure::ResultExt;
use core::core::hash::Hash;
use core::core::pmmr::MerkleProof;
use keychain::{Identifier, Keychain};
use libtx::slate::Slate;

View file

@ -13,8 +13,8 @@
// limitations under the License.
//! Common functions to facilitate wallet, walletlib and transaction testing
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
extern crate grin_api as api;
extern crate grin_chain as chain;
@ -28,9 +28,10 @@ use core::core::hash::Hashed;
use core::core::{Output, OutputFeatures, OutputIdentifier, Transaction, TxKernel};
use core::{consensus, global, pow};
use keychain::ExtKeychain;
use wallet::file_wallet::*;
use wallet::file_wallet::{FileWallet, WalletConfig};
use wallet::libwallet::internal::updater;
use wallet::libwallet::types::*;
use wallet::libwallet::types::{BlockFees, BlockIdentifier, MerkleProofWrapper, OutputStatus,
WalletBackend};
use wallet::libwallet::{Error, ErrorKind};
use util;

View file

@ -29,8 +29,8 @@ mod common;
use std::fs;
use std::sync::Arc;
use chain::types::NoopAdapter;
use chain::Chain;
use chain::types::*;
use core::global::ChainTypes;
use core::{global, pow};
use util::LOGGER;