Merge branch 'master' of github.com:ethcore/parity into db
This commit is contained in:
@@ -24,7 +24,7 @@ pub type LogBloom = H2048;
|
||||
/// Constant 2048-bit datum for 0. Often used as a default.
|
||||
pub static ZERO_LOGBLOOM: LogBloom = H2048([0x00; 256]);
|
||||
|
||||
#[allow(enum_variant_names)]
|
||||
#[cfg_attr(feature="dev", allow(enum_variant_names))]
|
||||
/// Semantic boolean for when a seal/signature is included.
|
||||
pub enum Seal {
|
||||
/// The seal/signature is included.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Blockchain block.
|
||||
|
||||
#![allow(ptr_arg)] // Because of &LastHashes -> &Vec<_>
|
||||
#![cfg_attr(feature="dev", allow(ptr_arg))] // Because of &LastHashes -> &Vec<_>
|
||||
|
||||
use common::*;
|
||||
use engine::*;
|
||||
@@ -267,7 +267,7 @@ impl<'x, 'y> OpenBlock<'x, 'y> {
|
||||
s.block.base.header.uncles_hash = uncle_bytes.sha3();
|
||||
s.block.base.header.state_root = s.block.state.root().clone();
|
||||
s.block.base.header.receipts_root = ordered_trie_root(s.block.receipts.iter().map(|ref r| r.rlp_bytes().to_vec()).collect());
|
||||
s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b |= &r.log_bloom; b});
|
||||
s.block.base.header.log_bloom = s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b}); //TODO: use |= operator
|
||||
s.block.base.header.gas_used = s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used);
|
||||
s.block.base.header.note_dirty();
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ struct QueueSignal {
|
||||
}
|
||||
|
||||
impl QueueSignal {
|
||||
#[allow(bool_comparison)]
|
||||
#[cfg_attr(feature="dev", allow(bool_comparison))]
|
||||
fn set(&self) {
|
||||
if self.signalled.compare_and_swap(false, true, AtomicOrdering::Relaxed) == false {
|
||||
self.message_channel.send(UserMessage(SyncMessage::BlockVerified)).expect("Error sending BlockVerified message");
|
||||
|
||||
@@ -161,7 +161,7 @@ impl ClientReport {
|
||||
pub fn accrue_block(&mut self, block: &PreVerifiedBlock) {
|
||||
self.blocks_imported += 1;
|
||||
self.transactions_applied += block.transactions.len();
|
||||
self.gas_processed += block.header.gas_used;
|
||||
self.gas_processed = self.gas_processed + block.header.gas_used;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ impl Engine for Ethash {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(wrong_self_convention)] // to_ethash should take self
|
||||
#[cfg_attr(feature="dev", allow(wrong_self_convention))] // to_ethash should take self
|
||||
impl Ethash {
|
||||
fn calculate_difficuty(&self, header: &Header, parent: &Header) -> U256 {
|
||||
const EXP_DIFF_PERIOD: u64 = 100000;
|
||||
|
||||
@@ -243,7 +243,7 @@ struct CodeReader<'a> {
|
||||
code: &'a Bytes
|
||||
}
|
||||
|
||||
#[allow(len_without_is_empty)]
|
||||
#[cfg_attr(feature="dev", 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 {
|
||||
@@ -258,7 +258,7 @@ impl<'a> CodeReader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(enum_variant_names)]
|
||||
#[cfg_attr(feature="dev", allow(enum_variant_names))]
|
||||
enum InstructionCost {
|
||||
Gas(U256),
|
||||
GasMem(U256, U256),
|
||||
@@ -299,7 +299,7 @@ impl evm::Evm for Interpreter {
|
||||
let (gas_cost, mem_size) = try!(self.get_gas_cost_mem(ext, instruction, &mut mem, &stack));
|
||||
try!(self.verify_gas(¤t_gas, &gas_cost));
|
||||
mem.expand(mem_size);
|
||||
current_gas -= gas_cost;
|
||||
current_gas = current_gas - gas_cost; //TODO: use operator -=
|
||||
|
||||
evm_debug!({
|
||||
println!("[0x{:x}][{}(0x{:x}) Gas: {:x}\n Gas Before: {:x}",
|
||||
@@ -320,7 +320,7 @@ impl evm::Evm for Interpreter {
|
||||
match result {
|
||||
InstructionResult::Ok => {},
|
||||
InstructionResult::UnusedGas(gas) => {
|
||||
current_gas += gas;
|
||||
current_gas = current_gas + gas; //TODO: use operator +=
|
||||
},
|
||||
InstructionResult::UseAllGas => {
|
||||
current_gas = U256::zero();
|
||||
@@ -347,7 +347,7 @@ impl evm::Evm for Interpreter {
|
||||
}
|
||||
|
||||
impl Interpreter {
|
||||
#[allow(cyclomatic_complexity)]
|
||||
#[cfg_attr(feature="dev", allow(cyclomatic_complexity))]
|
||||
fn get_gas_cost_mem(&self,
|
||||
ext: &evm::Ext,
|
||||
instruction: Instruction,
|
||||
|
||||
@@ -188,7 +188,7 @@ impl<'a> Ext for Externalities<'a> {
|
||||
self.state.code(address).unwrap_or_else(|| vec![])
|
||||
}
|
||||
|
||||
#[allow(match_ref_pats)]
|
||||
#[cfg_attr(feature="dev", allow(match_ref_pats))]
|
||||
fn ret(&mut self, gas: &U256, data: &[u8]) -> Result<U256, evm::Error> {
|
||||
match &mut self.output {
|
||||
&mut OutputPolicy::Return(BytesRef::Fixed(ref mut slice)) => unsafe {
|
||||
|
||||
@@ -15,18 +15,16 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![feature(cell_extras)]
|
||||
#![feature(augmented_assignments)]
|
||||
#![feature(plugin)]
|
||||
// Clippy
|
||||
#![plugin(clippy)]
|
||||
// TODO [todr] not really sure
|
||||
#![allow(needless_range_loop)]
|
||||
// Shorter than if-else
|
||||
#![allow(match_bool)]
|
||||
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||
#![allow(clone_on_copy)]
|
||||
#![cfg_attr(feature="dev", feature(plugin))]
|
||||
#![cfg_attr(feature="dev", plugin(clippy))]
|
||||
|
||||
// Clippy config
|
||||
// TODO [todr] not really sure
|
||||
#![cfg_attr(feature="dev", allow(needless_range_loop))]
|
||||
// Shorter than if-else
|
||||
#![cfg_attr(feautre="dev", allow(match_bool))]
|
||||
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||
#![cfg_attr(feature="dev", allow(clone_on_copy))]
|
||||
|
||||
//! Ethcore library
|
||||
//!
|
||||
|
||||
@@ -39,7 +39,7 @@ impl Receipt {
|
||||
Receipt {
|
||||
state_root: state_root,
|
||||
gas_used: gas_used,
|
||||
log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b |= &l.bloom(); b }),
|
||||
log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = &b | &l.bloom(); b }), //TODO: use |= operator
|
||||
logs: logs,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(match_ref_pats)]
|
||||
#[allow(single_match)]
|
||||
#[cfg_attr(feature="dev", allow(match_ref_pats))]
|
||||
#[cfg_attr(feature="dev", allow(single_match))]
|
||||
fn message(&self, io: &IoContext<NetSyncMessage>, net_message: &NetSyncMessage) {
|
||||
if let &UserMessage(ref message) = net_message {
|
||||
match message {
|
||||
@@ -124,6 +124,8 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: rewrite into something that doesn't dependent on the testing environment having a particular port ready for use.
|
||||
/*
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -138,3 +140,4 @@ mod tests {
|
||||
assert!(service.is_ok());
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -97,7 +97,7 @@ pub struct Spec {
|
||||
genesis_state: PodState,
|
||||
}
|
||||
|
||||
#[allow(wrong_self_convention)] // because to_engine(self) should be to_engine(&self)
|
||||
#[cfg_attr(feature="dev", allow(wrong_self_convention))] // because to_engine(self) should be to_engine(&self)
|
||||
impl Spec {
|
||||
/// Convert this object into a boxed Engine of the right underlying type.
|
||||
// TODO avoid this hard-coded nastiness - use dynamic-linked plugin framework instead.
|
||||
|
||||
@@ -224,7 +224,7 @@ impl State {
|
||||
|
||||
/// Commit accounts to SecTrieDBMut. This is similar to cpp-ethereum's dev::eth::commit.
|
||||
/// `accounts` is mutable because we may need to commit the code or storage and record that.
|
||||
#[allow(match_ref_pats)]
|
||||
#[cfg_attr(feature="dev", allow(match_ref_pats))]
|
||||
pub fn commit_into(db: &mut HashDB, root: &mut H256, accounts: &mut HashMap<Address, Option<Account>>) {
|
||||
// first, commit the sub trees.
|
||||
// TODO: is this necessary or can we dispense with the `ref mut a` for just `a`?
|
||||
@@ -282,7 +282,7 @@ impl State {
|
||||
|
||||
/// Pull account `a` in our cache from the trie DB and return it.
|
||||
/// `require_code` requires that the code be cached, too.
|
||||
fn get(&self, a: &Address, require_code: bool) -> Ref<Option<Account>> {
|
||||
fn get<'a>(&'a self, a: &Address, require_code: bool) -> &'a Option<Account> {
|
||||
let have_key = self.cache.borrow().contains_key(a);
|
||||
if !have_key {
|
||||
self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp))
|
||||
@@ -292,17 +292,17 @@ impl State {
|
||||
account.cache_code(&AccountDB::new(&self.db, a));
|
||||
}
|
||||
}
|
||||
Ref::map(self.cache.borrow(), |m| m.get(a).unwrap())
|
||||
unsafe { ::std::mem::transmute(self.cache.borrow().get(a).unwrap()) }
|
||||
}
|
||||
|
||||
/// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too.
|
||||
fn require(&self, a: &Address, require_code: bool) -> RefMut<Account> {
|
||||
fn require<'a>(&'a self, a: &Address, require_code: bool) -> &'a mut Account {
|
||||
self.require_or_from(a, require_code, || Account::new_basic(U256::from(0u8), self.account_start_nonce), |_|{})
|
||||
}
|
||||
|
||||
/// Pull account `a` in our cache from the trie DB. `require_code` requires that the code be cached, too.
|
||||
/// If it doesn't exist, make account equal the evaluation of `default`.
|
||||
fn require_or_from<F: FnOnce() -> Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> RefMut<Account> {
|
||||
fn require_or_from<'a, F: FnOnce() -> Account, G: FnOnce(&mut Account)>(&self, a: &Address, require_code: bool, default: F, not_default: G) -> &'a mut Account {
|
||||
let have_key = self.cache.borrow().contains_key(a);
|
||||
if !have_key {
|
||||
self.insert_cache(a, SecTrieDB::new(&self.db, &self.root).get(&a).map(Account::from_rlp))
|
||||
@@ -316,13 +316,12 @@ impl State {
|
||||
not_default(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().unwrap());
|
||||
}
|
||||
|
||||
let b = self.cache.borrow_mut();
|
||||
RefMut::map(b, |m| m.get_mut(a).unwrap().as_mut().map(|account| {
|
||||
unsafe { ::std::mem::transmute(self.cache.borrow_mut().get_mut(a).unwrap().as_mut().map(|account| {
|
||||
if require_code {
|
||||
account.cache_code(&AccountDB::new(&self.db, a));
|
||||
}
|
||||
account
|
||||
}).unwrap())
|
||||
}).unwrap()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user