Fix typos and unused imports (#1466)

* Fix typos and unused imports
This commit is contained in:
Quentin Le Sceller 2018-09-03 13:09:28 +02:00 committed by GitHub
parent eae0ab6b2a
commit 544a296f77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 58 additions and 62 deletions

View file

@ -865,7 +865,7 @@ pub fn start_rest_apis(
ROUTER.with(|router| {
*router.borrow_mut() =
Some(build_router(chain, tx_pool, peers).expect("unbale to build API router"));
Some(build_router(chain, tx_pool, peers).expect("unable to build API router"));
info!(LOGGER, "Starting HTTP API server at {}.", addr);
let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");

View file

@ -577,7 +577,7 @@ impl<'a> Extension<'a> {
let cutoff_header = self.commit_index.get_header_by_height(cutoff_height)?;
let cutoff_pos = cutoff_header.output_mmr_size;
// If any output pos exceeed the cutoff_pos
// If any output pos exceed the cutoff_pos
// we know they have not yet sufficiently matured.
if pos > cutoff_pos {
return Err(ErrorKind::ImmatureCoinbase.into());

View file

@ -15,7 +15,7 @@
//! Comments for configuration + injection into output .toml
use std::collections::HashMap;
/// maps entries to Comments that should preceed them
/// maps entries to Comments that should precede them
fn comments() -> HashMap<String, String> {
let mut retval = HashMap::new();
retval.insert(

View file

@ -89,7 +89,7 @@ pub const BLOCK_KERNEL_WEIGHT: usize = 2;
///
/// Given that a block needs to have at least one kernel for the coinbase,
/// and one kernel for the transaction, practical maximum size is 2_831_440,
/// (ignoring the edge case of a miner producting a block with all coinbase
/// (ignoring the edge case of a miner producing a block with all coinbase
/// outputs and a single kernel).
///
/// A more "standard" block, filled with transactions of 2 inputs, 2 outputs

View file

@ -82,7 +82,7 @@ impl MerkleProof {
util::to_hex(vec)
}
/// Convert hex string represenation back to a Merkle proof instance
/// Convert hex string representation back to a Merkle proof instance
pub fn from_hex(hex: &str) -> Result<MerkleProof, String> {
let bytes = util::from_hex(hex.to_string()).unwrap();
let res = ser::deserialize(&mut &bytes[..])
@ -106,7 +106,7 @@ impl MerkleProof {
}
/// Consumes the Merkle proof while verifying it.
/// The proof can no longer beused by the caller after dong this.
/// The proof can no longer be used by the caller after dong this.
/// Caller must clone() the proof first.
fn verify_consume(
&mut self,

View file

@ -285,7 +285,7 @@ where
/// "undo".
pub fn rewind(&mut self, position: u64, rewind_rm_pos: &Bitmap) -> Result<(), String> {
// Identify which actual position we should rewind to as the provided
// position is a leaf. We traverse the MMR to inclue any parent(s) that
// position is a leaf. We traverse the MMR to include any parent(s) that
// need to be included for the MMR to be valid.
let mut pos = position;
while bintree_postorder_height(pos + 1) > 0 {

View file

@ -42,7 +42,7 @@ impl Difficulty {
Difficulty { num: 0 }
}
/// Difficulty of one, which is the minumum difficulty
/// Difficulty of one, which is the minimum difficulty
/// (when the hash equals the max target)
pub fn one() -> Difficulty {
Difficulty { num: 1 }

View file

@ -203,7 +203,7 @@ pub fn get_genesis_nonce() -> u64 {
}
}
/// Converts an iterator of block difficulty data to more a more mangeable
/// Converts an iterator of block difficulty data to more a more manageable
/// vector and pads if needed (which will) only be needed for the first few
/// blocks after genesis

View file

@ -16,13 +16,14 @@
extern crate grin_core as core;
extern crate chrono;
use core::consensus::{next_difficulty, valid_header_version, TargetError,
DIFFICULTY_ADJUST_WINDOW, MEDIAN_TIME_WINDOW,
UPPER_TIME_BOUND, BLOCK_TIME_WINDOW, DAMP_FACTOR, MEDIAN_TIME_INDEX};
use chrono::prelude::Utc;
use core::consensus::{
next_difficulty, valid_header_version, TargetError, BLOCK_TIME_WINDOW, DAMP_FACTOR,
DIFFICULTY_ADJUST_WINDOW, MEDIAN_TIME_INDEX, MEDIAN_TIME_WINDOW, UPPER_TIME_BOUND,
};
use core::core::target::Difficulty;
use std::fmt::{self, Display};
use chrono::prelude::{Utc};
use core::global;
use std::fmt::{self, Display};
/// Last n blocks for difficulty calculation purposes
/// (copied from stats in server crate)
@ -58,11 +59,10 @@ pub struct DiffStats {
pub block_diff_sum: u64,
/// latest ts
pub latest_ts: u64,
/// earlist ts
/// earliest ts
pub earliest_ts: u64,
/// ts delta
pub ts_delta: u64,
}
impl Display for DiffBlock {
@ -98,20 +98,21 @@ fn repeat(
}
// Creates a new chain with a genesis at a simulated difficulty
fn create_chain_sim(diff: u64)
-> Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)> {
fn create_chain_sim(diff: u64) -> Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)> {
println!(
"adding create: {}, {}",
Utc::now().timestamp(),
Difficulty::from_num(diff)
);
let return_vec = vec![
Ok((Utc::now().timestamp() as u64, Difficulty::from_num(diff))),
];
let return_vec = vec![Ok((
Utc::now().timestamp() as u64,
Difficulty::from_num(diff),
))];
let diff_stats = get_diff_stats(&return_vec);
vec![
(Ok((Utc::now().timestamp() as u64, Difficulty::from_num(diff))), diff_stats),
]
vec![(
Ok((Utc::now().timestamp() as u64, Difficulty::from_num(diff))),
diff_stats,
)]
}
fn get_diff_stats(chain_sim: &Vec<Result<(u64, Difficulty), TargetError>>) -> DiffStats {
@ -126,7 +127,8 @@ fn get_diff_stats(chain_sim: &Vec<Result<(u64, Difficulty), TargetError>>) -> Di
// Obtain the median window for the earlier time period
// the first MEDIAN_TIME_WINDOW elements
let mut window_earliest: Vec<u64> = last_blocks.clone()
let mut window_earliest: Vec<u64> = last_blocks
.clone()
.iter()
.take(MEDIAN_TIME_WINDOW as usize)
.map(|n| n.clone().unwrap().0)
@ -137,7 +139,8 @@ fn get_diff_stats(chain_sim: &Vec<Result<(u64, Difficulty), TargetError>>) -> Di
// Obtain the median window for the latest time period
// i.e. the last MEDIAN_TIME_WINDOW elements
let mut window_latest: Vec<u64> = last_blocks.clone()
let mut window_latest: Vec<u64> = last_blocks
.clone()
.iter()
.skip(DIFFICULTY_ADJUST_WINDOW as usize)
.map(|n| n.clone().unwrap().0)
@ -147,13 +150,13 @@ fn get_diff_stats(chain_sim: &Vec<Result<(u64, Difficulty), TargetError>>) -> Di
let latest_ts = window_latest[MEDIAN_TIME_INDEX as usize];
let mut i = 1;
let sum_blocks: Vec<Result<(u64, Difficulty), TargetError>> =
global::difficulty_data_to_vector(diff_iter)
.into_iter()
.skip(MEDIAN_TIME_WINDOW as usize)
.take(DIFFICULTY_ADJUST_WINDOW as usize)
.collect();
let sum_blocks: Vec<Result<(u64, Difficulty), TargetError>> = global::difficulty_data_to_vector(
diff_iter,
).into_iter()
.skip(MEDIAN_TIME_WINDOW as usize)
.take(DIFFICULTY_ADJUST_WINDOW as usize)
.collect();
let sum_entries: Vec<DiffBlock> = sum_blocks
.iter()
@ -207,7 +210,7 @@ fn get_diff_stats(chain_sim: &Vec<Result<(u64, Difficulty), TargetError>>) -> Di
block_diff_sum: block_diff_sum,
latest_ts: latest_ts,
earliest_ts: earliest_ts,
ts_delta: latest_ts-earliest_ts,
ts_delta: latest_ts - earliest_ts,
}
}
@ -218,9 +221,8 @@ fn add_block(
chain_sim: Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)>,
) -> Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)> {
let mut ret_chain_sim = chain_sim.clone();
let mut return_chain: Vec<(Result<(u64, Difficulty), TargetError>)> = chain_sim.clone().iter()
.map(|e| e.0.clone())
.collect();
let mut return_chain: Vec<(Result<(u64, Difficulty), TargetError>)> =
chain_sim.clone().iter().map(|e| e.0.clone()).collect();
// get last interval
let diff = next_difficulty(return_chain.clone()).unwrap();
let last_elem = chain_sim.first().as_ref().unwrap().0.as_ref().unwrap();
@ -258,9 +260,7 @@ fn add_block_repeated(
// Prints the contents of the iterator and its difficulties.. useful for
// tweaking
fn print_chain_sim(
chain_sim: Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)>
){
fn print_chain_sim(chain_sim: Vec<((Result<(u64, Difficulty), TargetError>), DiffStats)>) {
let mut chain_sim = chain_sim.clone();
chain_sim.reverse();
let mut last_time = 0;
@ -307,13 +307,12 @@ fn repeat_offs(
diff: u64,
len: u64,
) -> Vec<Result<(u64, Difficulty), TargetError>> {
map_vec!(
repeat(interval, diff, len, Some(from)),
|e| match e.clone() {
map_vec!(repeat(interval, diff, len, Some(from)), |e| {
match e.clone() {
Err(e) => Err(e),
Ok((t, d)) => Ok((t, d)),
}
)
})
}
/// Checks different next_target adjustments and difficulty boundaries

View file

@ -419,7 +419,7 @@ fn pmmr_prune() {
assert_eq!(ba.elems.len(), 16);
assert_eq!(ba.remove_list.len(), 4);
// TODO - no longeer true (leaves only now) - pruning all leaves under level >1
// TODO - no longer true (leaves only now) - pruning all leaves under level >1
// removes all subtree
{
let mut pmmr: PMMR<TestElem, _> = PMMR::at(&mut ba, sz);

View file

@ -54,7 +54,7 @@ can be used to construct a variety of contracts using "simple" arithmetic.
## (Absolute) Timelocked Transactions
Analogus to Bitcoin [nLockTime](https://en.bitcoin.it/wiki/Timelock#nLockTime).
Analogous to Bitcoin [nLockTime](https://en.bitcoin.it/wiki/Timelock#nLockTime).
A transaction can be time-locked with a few simple modifications:
@ -250,7 +250,7 @@ can compute `sr' - sr` to get `x`.
### Notes on the Bitcoin setup
Prior to completing the atomic swap, Bob needs to know Alice's public key. Bob
would then create an outpout on the Bitcoin blockchain with a 2-of-2 multisig
would then create an output on the Bitcoin blockchain with a 2-of-2 multisig
similar to `alice_pubkey secret_pubkey 2 OP_CHECKMULTISIG`. This should be
wrapped in an `OP_IF` so Bob can get his money back after an agreed-upon time
and all of this can even be wrapped in a P2SH. Here `secret_pubkey` is `x*G`

View file

@ -428,7 +428,6 @@ only by adding or removing an output. Doing so would cause the summation of all
blinding factors in the transaction kernels to differ from the summation of blinding
factors in the outputs.
## Conclusion
In this document we covered the basic principles that underlie a MimbleWimble

View file

@ -26,7 +26,7 @@ further technical details.
There is also a [podcast with Mike from Monero Monitor](https://moneromonitor.com/episodes/2017-09-26-Episode-014.html)
in which John Tromp talks at length about Cuckoo Cycle; recommended listening for anyone wanting
more background on Cuckoo Cycle, including more technical detail, the history of the algorihm's development
more background on Cuckoo Cycle, including more technical detail, the history of the algorithm's development
and some of the motivations behind it.
## Cycles in a Graph

View file

@ -57,7 +57,7 @@ spend any generated outputs. The password is specified with `-p`
## Basic Wallet Commands
`grin wallet --help` will display usage info and all flags.
`grin wallet help [command]` will deplay flags specific to the command, e.g `grin wallet help listen`
`grin wallet help [command]` will display flags specific to the command, e.g `grin wallet help listen`
### init

View file

@ -355,7 +355,7 @@ fn headers_streaming_body(
msg_len: u64, // (i) length of whole 'Headers'
headers_num: u64, // (i) how many BlockHeader(s) do you want to read
total_read: &mut u64, // (i/o) how many bytes already read on this 'Headers' message
reserved: &mut Vec<u8>, // (i/o) reserved part of previous read, which's not a whole header
reserved: &mut Vec<u8>, // (i/o) reserved part of previous read, which is not a whole header
max_header_size: u64, // (i) maximum possible size of single BlockHeader
) -> Result<Headers, Error> {
if headers_num == 0 || msg_len < *total_read || *total_read < 2 {

View file

@ -138,7 +138,7 @@ pub struct PeerStats {
pub addr: String,
/// version running
pub version: u32,
/// difficulty repored by peer
/// difficulty reported by peer
pub total_difficulty: u64,
/// height reported by peer on ping
pub height: u64,

View file

@ -131,9 +131,9 @@ fn simple_server_wallet() {
assert!(last_10_rangeproofs.is_ok());
let last_5_rangeproofs = get_txhashset_lastrangeproofs(&base_addr, api_server_port, 5);
assert!(last_5_rangeproofs.is_ok());
let last_10_kernels = gettxhashset_lastkernels(&base_addr, api_server_port, 0);
let last_10_kernels = get_txhashset_lastkernels(&base_addr, api_server_port, 0);
assert!(last_10_kernels.is_ok());
let last_5_kernels = gettxhashset_lastkernels(&base_addr, api_server_port, 5);
let last_5_kernels = get_txhashset_lastkernels(&base_addr, api_server_port, 5);
assert!(last_5_kernels.is_ok());
//let some more mining happen, make sure nothing pukes
@ -392,7 +392,7 @@ fn get_txhashset_lastrangeproofs(
api::client::get::<Vec<api::TxHashSetNode>>(url.as_str()).map_err(|e| Error::API(e))
}
fn gettxhashset_lastkernels(
fn get_txhashset_lastkernels(
base_addr: &String,
api_server_port: u16,
n: u64,

View file

@ -70,7 +70,7 @@ pub struct LocalServerContainerConfig {
// Whether we're going to mine
pub start_miner: bool,
// time in millis by which to artifically slow down the mining loop
// time in millis by which to artificially slow down the mining loop
// in this container
pub miner_slowdown_in_millis: u64,
@ -265,7 +265,7 @@ impl LocalServerContainer {
let client = HTTPWalletClient::new(&self.wallet_config.check_node_api_http_addr);
if let Err(e) = r {
//panic!("Error initting wallet seed: {}", e);
//panic!("Error initializing wallet seed: {}", e);
}
let wallet: FileWallet<HTTPWalletClient, keychain::ExtKeychain> =

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
/// Grin configuation file output command
/// Grin configuration file output command
use config::{GlobalConfig, GlobalWalletConfig};
use std::env;

View file

@ -24,10 +24,8 @@ use clap::ArgMatches;
use ctrlc;
use daemonize::Daemonize;
use cmd::wallet;
use config::GlobalConfig;
use core::global;
use grin_wallet::controller;
use p2p::Seeding;
use servers;
use tui::ui;

View file

@ -92,7 +92,7 @@ where
res
}
/// Attempt to update outputs and retrieve tranasactions
/// Attempt to update outputs and retrieve transactions
/// Return (whether the outputs were validated against a node, OutputData)
pub fn retrieve_txs(
&self,

View file

@ -283,7 +283,7 @@ where
pub struct LocalWalletClient {
/// wallet identifier for the proxy queue
pub id: String,
/// proxy's tx queue (receive messsages from other wallets or node
/// proxy's tx queue (receive messages from other wallets or node
pub proxy_tx: Arc<Mutex<Sender<WalletProxyMessage>>>,
/// my rx queue
pub rx: Arc<Mutex<Receiver<WalletProxyMessage>>>,