From eb11b14cab840ad823477b68009e8c5bac67623d Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Thu, 20 Jul 2017 14:22:40 +0000 Subject: [PATCH] Minor warning cleanup in core Remove some unused import and add missing docs. --- core/src/consensus.rs | 9 +++++---- core/src/genesis.rs | 1 - core/src/pow/cuckoo.rs | 1 - core/src/pow/mod.rs | 14 +++++--------- grin/tests/simulnet.rs | 1 - store/Cargo.toml | 1 - 6 files changed, 10 insertions(+), 17 deletions(-) diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 4450de8e0..0f57be851 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -19,11 +19,8 @@ //! enough, consensus-relevant constants and short functions should be kept //! here. -use std::cmp; use std::fmt; -use bigint::{BigInt, Sign}; - use core::target::Difficulty; /// The block subsidy amount @@ -64,17 +61,21 @@ pub const CUT_THROUGH_HORIZON: u32 = 48 * 3600 / (BLOCK_TIME_SEC as u32); pub const MAX_MSG_LEN: u64 = 20_000_000; /// The minimum mining difficulty we'll allow - pub const MINIMUM_DIFFICULTY: u32 = 10; +/// Time window in blocks to calculate block time median pub const MEDIAN_TIME_WINDOW: u32 = 11; +/// Number of blocks used to calculate difficulty adjustments pub const DIFFICULTY_ADJUST_WINDOW: u32 = 23; +/// Average time span of the difficulty adjustment window pub const BLOCK_TIME_WINDOW: i64 = (DIFFICULTY_ADJUST_WINDOW as i64) * BLOCK_TIME_SEC; +/// Maximum size time window used for difficutly adjustments pub const UPPER_TIME_BOUND: i64 = BLOCK_TIME_WINDOW * 4 / 3; +/// Minimum size time window used for difficutly adjustments pub const LOWER_TIME_BOUND: i64 = BLOCK_TIME_WINDOW * 5 / 6; /// Error when computing the next difficulty adjustment. diff --git a/core/src/genesis.rs b/core/src/genesis.rs index cd693507f..d7425cd93 100644 --- a/core/src/genesis.rs +++ b/core/src/genesis.rs @@ -17,7 +17,6 @@ use time; use core; -use consensus::DEFAULT_SIZESHIFT; use consensus::MINIMUM_DIFFICULTY; use core::hash::Hashed; use core::target::Difficulty; diff --git a/core/src/pow/cuckoo.rs b/core/src/pow/cuckoo.rs index b39207e56..f73ad3770 100644 --- a/core/src/pow/cuckoo.rs +++ b/core/src/pow/cuckoo.rs @@ -18,7 +18,6 @@ //! miner will be much faster in almost every environment. use std::collections::HashSet; -use std::collections::HashMap; use std::cmp; use crypto::digest::Digest; diff --git a/core/src/pow/mod.rs b/core/src/pow/mod.rs index b9693a885..375ee0eee 100644 --- a/core/src/pow/mod.rs +++ b/core/src/pow/mod.rs @@ -24,17 +24,15 @@ mod siphash; pub mod cuckoo; -use std::collections::HashMap; use time; use consensus::EASINESS; -use consensus::MINIMUM_DIFFICULTY; use core::BlockHeader; use core::hash::Hashed; use core::Proof; use core::target::Difficulty; -use pow::cuckoo::{Cuckoo, Miner, Error}; +use pow::cuckoo::{Cuckoo, Error}; /// Should be implemented by anything providing mining services @@ -42,12 +40,11 @@ use pow::cuckoo::{Cuckoo, Miner, Error}; pub trait MiningWorker { - //This only sets parameters and does initialisation work now - fn new(ease: u32, - sizeshift: u32) -> Self; + /// This only sets parameters and does initialisation work now + fn new(ease: u32, sizeshift: u32) -> Self; - //Actually perform a mining attempt on the given input and - //return a proof if found + /// Actually perform a mining attempt on the given input and + /// return a proof if found fn mine(&mut self, header: &[u8]) -> Result; } @@ -71,7 +68,6 @@ pub fn pow20(miner:&mut T, bh: &mut BlockHeader, diff: Difficul /// Runs a proof of work computation over the provided block using the provided Mining Worker, /// until the required difficulty target is reached. May take a while for a low target... - pub fn pow_size(miner:&mut T, bh: &mut BlockHeader, diff: Difficulty, sizeshift: u32) -> Result<(), Error> { let start_nonce = bh.nonce; diff --git a/grin/tests/simulnet.rs b/grin/tests/simulnet.rs index 84f12f405..a43f88f8c 100644 --- a/grin/tests/simulnet.rs +++ b/grin/tests/simulnet.rs @@ -19,7 +19,6 @@ extern crate grin_chain as chain; extern crate grin_api as api; extern crate grin_wallet as wallet; extern crate secp256k1zkp as secp; -extern crate tiny_keccak; extern crate env_logger; extern crate futures; diff --git a/store/Cargo.toml b/store/Cargo.toml index e3a303fb2..00024f34b 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -14,6 +14,5 @@ rocksdb = "^0.6.0" ## https://github.com/facebook/rocksdb/commit/816c1e30ca73615c75fc208ddcc4b05012b30951 ## And swap the dependency for the one below #rocksdb = { path = "../../rust-rocksdb" } -tiny-keccak = "1.1" grin_core = { path = "../core" }