From 30c68204377742dbd7cda4bd5ac3114713de5cb1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 2 Mar 2016 00:52:18 +0100 Subject: [PATCH] Refactor and cleanup. --- ethcore/src/block.rs | 9 +++++---- ethcore/src/engine.rs | 3 +-- ethcore/src/ethereum/ethash.rs | 2 +- rpc/src/v1/impls/web3.rs | 2 +- util/src/misc.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 0ca6e88be..f5788baba 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -178,11 +178,12 @@ impl<'x> OpenBlock<'x> { last_hashes: last_hashes, }; - r.block.base.header.set_number(parent.number() + 1); - r.block.base.header.set_author(author); - r.block.base.header.set_extra_data(extra_data); + r.block.base.header.parent_hash = parent.hash(); + r.block.base.header.number = parent.number + 1; + r.block.base.header.author = author; r.block.base.header.set_timestamp_now(parent.timestamp()); - r.block.base.header.set_parent_hash(parent.hash()); + r.block.base.header.extra_data = extra_data; + r.block.base.header.note_dirty(); engine.populate_from_parent(&mut r.block.base.header, parent); engine.on_new_block(&mut r.block); diff --git a/ethcore/src/engine.rs b/ethcore/src/engine.rs index 6806fcce3..d607ce2e2 100644 --- a/ethcore/src/engine.rs +++ b/ethcore/src/engine.rs @@ -84,10 +84,9 @@ pub trait Engine : Sync + Send { /// Don't forget to call Super::populate_from_parent when subclassing & overriding. // TODO: consider including State in the params. fn populate_from_parent(&self, header: &mut Header, parent: &Header) { - header.parent_hash = parent.hash; header.difficulty = parent.difficulty; header.gas_limit = parent.gas_limit; - header.number = parent.number + 1; + header.note_dirty(); } // TODO: builtin contract routing - to do this properly, it will require removing the built-in configuration-reading logic diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index bf0c1d188..f9810b964 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -104,7 +104,7 @@ impl Engine for Ethash { max(gas_floor_target, gas_limit - gas_limit / bound_divisor + x!(1) + (header.gas_used * x!(6) / x!(5)) / bound_divisor) } }; - + header.note_dirty(); // info!("ethash: populate_from_parent #{}: difficulty={} and gas_limit={}", header.number, header.difficulty, header.gas_limit); } diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index 0a237d56b..4d31f73ae 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -31,7 +31,7 @@ impl Web3 for Web3Client { fn client_version(&self, params: Params) -> Result { match params { Params::None => { - Ok(Value::String(version())), + Ok(Value::String(version().to_owned().replace("Parity/", "Parity//"))), } _ => Err(Error::invalid_params()) } diff --git a/util/src/misc.rs b/util/src/misc.rs index 6cd506d02..39ccbf2da 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -70,7 +70,7 @@ pub fn contents(name: &str) -> Result { /// Get the standard version string for this software. pub fn version() -> String { - format!("Parity//v{}-{}-{}/{}-{}-{}/rustc{}", env!("CARGO_PKG_VERSION"), short_sha(), commit_date().replace("-", ""), Target::arch(), Target::os(), Target::env(), rustc_version::version()) + format!("Parity/v{}-{}-{}/{}-{}-{}/rustc{}", env!("CARGO_PKG_VERSION"), short_sha(), commit_date().replace("-", ""), Target::arch(), Target::os(), Target::env(), rustc_version::version()) } /// Get the standard version data for this software.