Fixing all obvious warnings
This commit is contained in:
parent
db6e6a3e58
commit
f169951d4e
@ -66,7 +66,7 @@ impl AccountDiff {
|
||||
post.storage.get(&k).cloned().unwrap_or(H256::new())
|
||||
))).collect(),
|
||||
};
|
||||
if r.balance.is_same() && r.nonce.is_same() && r.code.is_same() && r.storage.len() == 0 {
|
||||
if r.balance.is_same() && r.nonce.is_same() && r.code.is_same() && r.storage.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(r)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![allow(ptr_arg)] // Because of &LastHashes -> &Vec<_>
|
||||
|
||||
use common::*;
|
||||
use engine::*;
|
||||
use state::*;
|
||||
@ -169,7 +171,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> {
|
||||
timestamp: self.block.header.timestamp,
|
||||
difficulty: self.block.header.difficulty.clone(),
|
||||
last_hashes: self.last_hashes.clone(), // TODO: should be a reference.
|
||||
gas_used: self.block.archive.last().map(|t| t.receipt.gas_used).unwrap_or(U256::from(0)),
|
||||
gas_used: self.block.archive.last().map_or(U256::zero(), |t| t.receipt.gas_used),
|
||||
gas_limit: self.block.header.gas_limit.clone(),
|
||||
}
|
||||
}
|
||||
@ -200,7 +202,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> {
|
||||
s.block.header.state_root = s.block.state.root().clone();
|
||||
s.block.header.receipts_root = ordered_trie_root(s.block.archive.iter().map(|ref e| e.receipt.rlp_bytes()).collect());
|
||||
s.block.header.log_bloom = s.block.archive.iter().fold(LogBloom::zero(), |mut b, e| {b |= &e.receipt.log_bloom; b});
|
||||
s.block.header.gas_used = s.block.archive.last().map(|t| t.receipt.gas_used).unwrap_or(U256::from(0));
|
||||
s.block.header.gas_used = s.block.archive.last().map_or(U256::zero(), |t| t.receipt.gas_used);
|
||||
s.block.header.note_dirty();
|
||||
|
||||
ClosedBlock::new(s, uncle_bytes)
|
||||
@ -251,7 +253,7 @@ impl SealedBlock {
|
||||
let mut block_rlp = RlpStream::new_list(3);
|
||||
self.block.header.stream_rlp(&mut block_rlp, Seal::With);
|
||||
block_rlp.append_list(self.block.archive.len());
|
||||
for e in self.block.archive.iter() { e.transaction.rlp_append(&mut block_rlp); }
|
||||
for e in &self.block.archive { e.transaction.rlp_append(&mut block_rlp); }
|
||||
block_rlp.append_raw(&self.uncle_bytes, 1);
|
||||
block_rlp.out()
|
||||
}
|
||||
|
@ -490,9 +490,8 @@ impl BlockChain {
|
||||
K: ExtrasSliceConvertable + Eq + Hash + Clone {
|
||||
{
|
||||
let read = cache.read().unwrap();
|
||||
match read.get(hash) {
|
||||
Some(v) => return Some(v.clone()),
|
||||
None => ()
|
||||
if let Some(v) = read.get(hash) {
|
||||
return Some(v.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,13 @@ impl Ethash {
|
||||
}
|
||||
|
||||
fn u64_param(&self, name: &str) -> u64 {
|
||||
*self.u64_params.write().unwrap().entry(name.to_string()).or_insert_with(||
|
||||
self.spec().engine_params.get(name).map(|a| decode(&a)).unwrap_or(0u64))
|
||||
*self.u64_params.write().unwrap().entry(name.to_owned()).or_insert_with(||
|
||||
self.spec().engine_params.get(name).map_or(0u64, |a| decode(&a)))
|
||||
}
|
||||
|
||||
fn u256_param(&self, name: &str) -> U256 {
|
||||
*self.u256_params.write().unwrap().entry(name.to_string()).or_insert_with(||
|
||||
self.spec().engine_params.get(name).map(|a| decode(&a)).unwrap_or(x!(0)))
|
||||
*self.u256_params.write().unwrap().entry(name.to_owned()).or_insert_with(||
|
||||
self.spec().engine_params.get(name).map_or(x!(0), |a| decode(&a)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ impl Engine for Ethash {
|
||||
/// Apply the block reward on finalisation of the block.
|
||||
/// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current).
|
||||
fn on_close_block(&self, block: &mut Block) {
|
||||
let reward = self.spec().engine_params.get("blockReward").map(|a| decode(&a)).unwrap_or(U256::from(0u64));
|
||||
let reward = self.spec().engine_params.get("blockReward").map_or(U256::from(0u64), |a| decode(&a));
|
||||
let fields = block.fields();
|
||||
|
||||
// Bestow block reward
|
||||
|
@ -65,10 +65,11 @@ impl Factory {
|
||||
fn jit() -> Box<Evm> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
}
|
||||
impl Default for Factory {
|
||||
/// Returns jitvm factory
|
||||
#[cfg(feature = "jit")]
|
||||
pub fn default() -> Factory {
|
||||
fn default() -> Factory {
|
||||
Factory {
|
||||
evm: VMType::Jit
|
||||
}
|
||||
@ -76,7 +77,7 @@ impl Factory {
|
||||
|
||||
/// Returns native rust evm factory
|
||||
#[cfg(not(feature = "jit"))]
|
||||
pub fn default() -> Factory {
|
||||
fn default() -> Factory {
|
||||
Factory {
|
||||
evm: VMType::Interpreter
|
||||
}
|
||||
|
@ -229,6 +229,7 @@ struct CodeReader<'a> {
|
||||
code: &'a Bytes
|
||||
}
|
||||
|
||||
#[allow(len_without_is_empty)]
|
||||
impl<'a> CodeReader<'a> {
|
||||
/// Get `no_of_bytes` from code and convert to U256. Move PC
|
||||
fn read(&mut self, no_of_bytes: usize) -> U256 {
|
||||
@ -331,6 +332,7 @@ impl evm::Evm for Interpreter {
|
||||
}
|
||||
|
||||
impl Interpreter {
|
||||
#[allow(cyclomatic_complexity)]
|
||||
fn get_gas_cost_mem(&self,
|
||||
ext: &evm::Ext,
|
||||
instruction: Instruction,
|
||||
|
@ -3,6 +3,8 @@
|
||||
#![feature(wrapping)]
|
||||
//#![feature(plugin)]
|
||||
//#![plugin(interpolate_idents)]
|
||||
#![allow(match_bool, needless_range_loop, match_ref_pats)]
|
||||
|
||||
//! Ethcore's ethereum implementation
|
||||
//!
|
||||
//! ### Rust version
|
||||
@ -86,7 +88,6 @@ extern crate num_cpus;
|
||||
#[cfg(feature = "jit" )]
|
||||
extern crate evmjit;
|
||||
#[macro_use]
|
||||
#[allow(match_bool)]
|
||||
extern crate ethcore_util as util;
|
||||
|
||||
pub mod common;
|
||||
|
@ -200,7 +200,7 @@ impl FromJson for Spec {
|
||||
|
||||
|
||||
Spec {
|
||||
name: json.find("name").map(|j| j.as_string().unwrap()).unwrap_or("unknown").to_owned(),
|
||||
name: json.find("name").map_or("unknown", |j| j.as_string().unwrap()).to_owned(),
|
||||
engine_name: json["engineName"].as_string().unwrap().to_owned(),
|
||||
engine_params: json_to_rlp_map(&json["params"]),
|
||||
builtins: builtins,
|
||||
|
@ -268,6 +268,7 @@ impl ChainSync {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(cyclomatic_complexity)]
|
||||
/// Called by peer once it has new block headers during sync
|
||||
fn on_peer_block_headers(&mut self, io: &mut SyncIo, peer_id: PeerId, r: &UntrustedRlp) -> Result<(), PacketDecodeError> {
|
||||
self.reset_peer_asking(peer_id, PeerAsking::BlockHeaders);
|
||||
@ -865,13 +866,10 @@ impl ChainSync {
|
||||
let mut added = 0usize;
|
||||
let mut data = Bytes::new();
|
||||
for i in 0..count {
|
||||
match io.chain().block_body(&try!(r.val_at::<H256>(i))) {
|
||||
Some(mut hdr) => {
|
||||
if let Some(mut hdr) = io.chain().block_body(&try!(r.val_at::<H256>(i))) {
|
||||
data.append(&mut hdr);
|
||||
added += 1;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
let mut rlp = RlpStream::new_list(added);
|
||||
rlp.append_raw(&data, added);
|
||||
@ -892,13 +890,10 @@ impl ChainSync {
|
||||
let mut added = 0usize;
|
||||
let mut data = Bytes::new();
|
||||
for i in 0..count {
|
||||
match io.chain().state_data(&try!(r.val_at::<H256>(i))) {
|
||||
Some(mut hdr) => {
|
||||
if let Some(mut hdr) = io.chain().state_data(&try!(r.val_at::<H256>(i))) {
|
||||
data.append(&mut hdr);
|
||||
added += 1;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
let mut rlp = RlpStream::new_list(added);
|
||||
rlp.append_raw(&data, added);
|
||||
@ -918,13 +913,10 @@ impl ChainSync {
|
||||
let mut added = 0usize;
|
||||
let mut data = Bytes::new();
|
||||
for i in 0..count {
|
||||
match io.chain().block_receipts(&try!(r.val_at::<H256>(i))) {
|
||||
Some(mut hdr) => {
|
||||
if let Some(mut hdr) = io.chain().block_receipts(&try!(r.val_at::<H256>(i))) {
|
||||
data.append(&mut hdr);
|
||||
added += 1;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
let mut rlp = RlpStream::new_list(added);
|
||||
rlp.append_raw(&data, added);
|
||||
|
@ -14,7 +14,7 @@ pub trait SyncIo {
|
||||
/// Send a packet to a peer.
|
||||
fn send(&mut self, peer_id: PeerId, packet_id: PacketId, data: Vec<u8>) -> Result<(), UtilError>;
|
||||
/// Get the blockchain
|
||||
fn chain<'s>(&'s mut self) -> &'s mut BlockChainClient;
|
||||
fn chain(&mut self) -> &mut BlockChainClient;
|
||||
/// Returns peer client identifier string
|
||||
fn peer_info(&self, peer_id: PeerId) -> String {
|
||||
peer_id.to_string()
|
||||
@ -50,7 +50,7 @@ impl<'s, 'h, 'op> SyncIo for NetSyncIo<'s, 'h, 'op> {
|
||||
self.network.send(peer_id, packet_id, data)
|
||||
}
|
||||
|
||||
fn chain<'a>(&'a mut self) -> &'a mut BlockChainClient {
|
||||
fn chain(&mut self) -> &mut BlockChainClient {
|
||||
self.chain
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub trait RangeCollection<K, V> {
|
||||
/// Remove all elements >= `tail`
|
||||
fn insert_item(&mut self, key: K, value: V);
|
||||
/// Get an iterator over ranges
|
||||
fn range_iter<'c>(&'c self) -> RangeIterator<'c, K, V>;
|
||||
fn range_iter(& self) -> RangeIterator<K, V>;
|
||||
}
|
||||
|
||||
/// Range iterator. For each range yelds a key for the first element of the range and a vector of values.
|
||||
@ -60,7 +60,7 @@ impl<'c, K:'c, V:'c> Iterator for RangeIterator<'c, K, V> where K: Add<Output =
|
||||
}
|
||||
|
||||
impl<K, V> RangeCollection<K, V> for Vec<(K, Vec<V>)> where K: Ord + PartialEq + Add<Output = K> + Sub<Output = K> + Copy + FromUsize + ToUsize {
|
||||
fn range_iter<'c>(&'c self) -> RangeIterator<'c, K, V> {
|
||||
fn range_iter(&self) -> RangeIterator<K, V> {
|
||||
RangeIterator {
|
||||
range: self.len(),
|
||||
collection: self
|
||||
|
@ -156,7 +156,7 @@ impl<'a> BlockView<'a> {
|
||||
|
||||
/// Return List of transactions in given block.
|
||||
pub fn uncle_views(&self) -> Vec<HeaderView> {
|
||||
self.rlp.at(2).iter().map(|rlp| HeaderView::new_from_rlp(rlp)).collect()
|
||||
self.rlp.at(2).iter().map(HeaderView::new_from_rlp).collect()
|
||||
}
|
||||
|
||||
/// Return list of uncle hashes of given block.
|
||||
|
Loading…
Reference in New Issue
Block a user