Fixing clippy warnings (#1568)
* Fixing clippy warnings * Fixing more warnings
This commit is contained in:
parent
ae757afe15
commit
d7caae2241
@ -587,14 +587,14 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Notify us that the network has been started.
|
||||
pub fn network_started(&self, url: &String) {
|
||||
pub fn network_started(&self, url: &str) {
|
||||
let mut previous_enode = self.previous_enode.locked();
|
||||
if let Some(ref u) = *previous_enode {
|
||||
if u == url {
|
||||
return;
|
||||
}
|
||||
}
|
||||
*previous_enode = Some(url.clone());
|
||||
*previous_enode = Some(url.into());
|
||||
info!(target: "mode", "Public node URL: {}", url.apply(Colour::White.bold()));
|
||||
}
|
||||
}
|
||||
|
@ -93,11 +93,11 @@ impl Default for MinerOptions {
|
||||
pub struct GasPriceCalibratorOptions {
|
||||
/// Base transaction price to match against.
|
||||
pub usd_per_tx: f32,
|
||||
/// How frequently we should recalibrate.
|
||||
/// How frequently we should recalibrate.
|
||||
pub recalibration_period: Duration,
|
||||
}
|
||||
|
||||
/// The gas price validator variant for a GasPricer.
|
||||
/// The gas price validator variant for a `GasPricer`.
|
||||
pub struct GasPriceCalibrator {
|
||||
options: GasPriceCalibratorOptions,
|
||||
|
||||
|
@ -158,21 +158,19 @@ impl Configuration {
|
||||
die!("{}: Invalid duration given. See parity --help for more information.", s)
|
||||
};
|
||||
Duration::from_secs(match s {
|
||||
"daily" => 24 * 60 * 60,
|
||||
"twice-daily" => 12 * 60 * 60,
|
||||
"hourly" => 60 * 60,
|
||||
"half-hourly" => 30 * 60,
|
||||
"1second" | "1 second" | "second" => 1,
|
||||
"1minute" | "1 minute" | "minute" => 60,
|
||||
"1hour" | "1 hour" | "hour" => 60 * 60,
|
||||
"1day" | "1 day" | "day" => 24 * 60 * 60,
|
||||
"hourly" | "1hour" | "1 hour" | "hour" => 60 * 60,
|
||||
"daily" | "1day" | "1 day" | "day" => 24 * 60 * 60,
|
||||
x if x.ends_with("seconds") => FromStr::from_str(&x[0..x.len() - 7]).unwrap_or_else(bad),
|
||||
x if x.ends_with("minutes") => FromStr::from_str(&x[0..x.len() - 7]).unwrap_or_else(bad) * 60,
|
||||
x if x.ends_with("hours") => FromStr::from_str(&x[0..x.len() - 5]).unwrap_or_else(bad) * 60 * 60,
|
||||
x if x.ends_with("days") => FromStr::from_str(&x[0..x.len() - 4]).unwrap_or_else(bad) * 24 * 60 * 60,
|
||||
x => FromStr::from_str(x).unwrap_or_else(bad),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gas_pricer(&self) -> GasPricer {
|
||||
match self.args.flag_gasprice.as_ref() {
|
||||
|
@ -75,7 +75,6 @@ impl Informant {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature="dev", allow(match_bool))]
|
||||
pub fn tick<Message>(&self, client: &Client, maybe_sync: Option<(&EthSync, &NetworkService<Message>)>) where Message: Send + Sync + Clone + 'static {
|
||||
let elapsed = self.last_tick.unwrapped_read().elapsed();
|
||||
if elapsed < Duration::from_secs(5) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#![cfg_attr(feature="dev", feature(plugin))]
|
||||
#![cfg_attr(feature="dev", plugin(clippy))]
|
||||
#![cfg_attr(feature="dev", allow(useless_format))]
|
||||
#![cfg_attr(feature="dev", allow(match_bool))]
|
||||
|
||||
extern crate docopt;
|
||||
extern crate num_cpus;
|
||||
|
@ -21,7 +21,6 @@ use std::sync::{Arc, Weak, Mutex};
|
||||
use std::collections::HashSet;
|
||||
use jsonrpc_core::*;
|
||||
use util::Lockable;
|
||||
use util::numbers::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::filter::Filter as EthcoreFilter;
|
||||
use ethcore::client::{BlockChainClient, BlockID};
|
||||
|
@ -18,7 +18,7 @@ use std::str::FromStr;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::{Lockable, RwLockable};
|
||||
use util::RwLockable;
|
||||
use util::hash::{Address, H256, FixedHash};
|
||||
use util::numbers::{Uint, U256};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
@ -92,7 +92,7 @@ impl<T: SimpleMigration> Migration for T {
|
||||
}
|
||||
}
|
||||
|
||||
if batch.len() != 0 {
|
||||
if !batch.is_empty() {
|
||||
try!(commit_batch(dest, &batch));
|
||||
}
|
||||
|
||||
@ -189,12 +189,12 @@ impl Manager {
|
||||
|
||||
// start with the old db.
|
||||
let old_path_str = try!(old_path.to_str().ok_or(Error::MigrationImpossible));
|
||||
let mut cur_db = try!(Database::open(&db_config, old_path_str).map_err(|s| Error::Custom(s)));
|
||||
let mut cur_db = try!(Database::open(&db_config, old_path_str).map_err(Error::Custom));
|
||||
for migration in migrations {
|
||||
// open the target temporary database.
|
||||
temp_path = temp_idx.path(&db_root);
|
||||
let temp_path_str = try!(temp_path.to_str().ok_or(Error::MigrationImpossible));
|
||||
let mut new_db = try!(Database::open(&db_config, temp_path_str).map_err(|s| Error::Custom(s)));
|
||||
let mut new_db = try!(Database::open(&db_config, temp_path_str).map_err(Error::Custom));
|
||||
|
||||
// perform the migration from cur_db to new_db.
|
||||
try!(migration.migrate(&cur_db, &self.config, &mut new_db));
|
||||
|
@ -1,16 +1,33 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
//! An owning, nibble-oriented byte vector.
|
||||
|
||||
use ::NibbleSlice;
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
/// Owning, nibble-oriented byte vector. Counterpart to NibbleSlice.
|
||||
#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
/// Owning, nibble-oriented byte vector. Counterpart to `NibbleSlice`.
|
||||
pub struct NibbleVec {
|
||||
inner: Vec<u8>,
|
||||
len: usize,
|
||||
}
|
||||
|
||||
impl NibbleVec {
|
||||
/// Make a new NibbleVec
|
||||
/// Make a new `NibbleVec`
|
||||
pub fn new() -> Self {
|
||||
NibbleVec {
|
||||
inner: Vec::new(),
|
||||
@ -18,7 +35,7 @@ impl NibbleVec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Make a NibbleVec with capacity for `n` nibbles.
|
||||
/// Make a `NibbleVec` with capacity for `n` nibbles.
|
||||
pub fn with_capacity(n: usize) -> Self {
|
||||
NibbleVec {
|
||||
inner: Vec::with_capacity((n / 2) + (n % 2)),
|
||||
@ -26,10 +43,13 @@ impl NibbleVec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Length of the NibbleVec
|
||||
/// Length of the `NibbleVec`
|
||||
pub fn len(&self) -> usize { self.len }
|
||||
|
||||
/// Capacity of the NibbleVec.
|
||||
/// Retrurns true if `NibbleVec` has zero length
|
||||
pub fn is_empty(&self) -> bool { self.len == 0 }
|
||||
|
||||
/// Capacity of the `NibbleVec`.
|
||||
pub fn capacity(&self) -> usize { self.inner.capacity() * 2 }
|
||||
|
||||
/// Try to get the nibble at the given offset.
|
||||
@ -41,7 +61,7 @@ impl NibbleVec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Push a nibble onto the NibbleVec. Ignores the high 4 bits.
|
||||
/// Push a nibble onto the `NibbleVec`. Ignores the high 4 bits.
|
||||
pub fn push(&mut self, nibble: u8) {
|
||||
let nibble = nibble & 0x0F;
|
||||
|
||||
@ -54,9 +74,9 @@ impl NibbleVec {
|
||||
self.len += 1;
|
||||
}
|
||||
|
||||
/// Try to pop a nibble off the NibbleVec. Fails if len == 0.
|
||||
/// Try to pop a nibble off the `NibbleVec`. Fails if len == 0.
|
||||
pub fn pop(&mut self) -> Option<u8> {
|
||||
if self.len == 0 {
|
||||
if self.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -72,7 +92,7 @@ impl NibbleVec {
|
||||
Some(nibble)
|
||||
}
|
||||
|
||||
/// Try to treat this NibbleVec as a NibbleSlice. Works only if len is even.
|
||||
/// Try to treat this `NibbleVec` as a `NibbleSlice`. Works only if len is even.
|
||||
pub fn as_nibbleslice(&self) -> Option<NibbleSlice> {
|
||||
if self.len % 2 == 0 {
|
||||
Some(NibbleSlice::new(self.inner()))
|
||||
@ -127,4 +147,4 @@ mod tests {
|
||||
let v2: NibbleVec = v.as_nibbleslice().unwrap().into();
|
||||
assert_eq!(v, v2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user