This commit is contained in:
debris
2017-08-31 11:35:41 +02:00
parent f0e8abb07b
commit 7849fff41e
43 changed files with 130 additions and 95 deletions

View File

@@ -24,7 +24,6 @@ use futures::{self, future, BoxFuture, Future};
use rlp::{self, UntrustedRlp};
use time::get_time;
use util::{H160, H256, Address, U256, H64};
use util::sha3::Hashable;
use util::Mutex;
use ethash::SeedHashCompute;
@@ -149,7 +148,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> EthClient<C, SN, S, M, EM> where
let view = block.header_view();
Ok(Some(RichBlock {
inner: Block {
hash: Some(view.sha3().into()),
hash: Some(view.hash().into()),
size: Some(block.rlp().as_raw().len().into()),
parent_hash: view.parent_hash().into(),
uncles_hash: view.uncles_hash().into(),

View File

@@ -38,7 +38,7 @@ use ethcore::filter::Filter as EthcoreFilter;
use ethcore::transaction::{Action, SignedTransaction, Transaction as EthTransaction};
use ethsync::LightSync;
use rlp::UntrustedRlp;
use util::sha3::{SHA3_NULL_RLP, SHA3_EMPTY_LIST_RLP};
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP};
use util::{RwLock, Mutex, U256};
use futures::{future, Future, BoxFuture, IntoFuture};
@@ -295,7 +295,7 @@ impl Eth for EthClient {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
if hdr.transactions_root() == SHA3_NULL_RLP {
if hdr.transactions_root() == KECCAK_NULL_RLP {
future::ok(Some(U256::from(0).into())).boxed()
} else {
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
@@ -311,7 +311,7 @@ impl Eth for EthClient {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
self.fetcher().header(num.into()).and_then(move |hdr| {
if hdr.transactions_root() == SHA3_NULL_RLP {
if hdr.transactions_root() == KECCAK_NULL_RLP {
future::ok(Some(U256::from(0).into())).boxed()
} else {
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
@@ -327,7 +327,7 @@ impl Eth for EthClient {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
self.fetcher().header(BlockId::Hash(hash.into())).and_then(move |hdr| {
if hdr.uncles_hash() == SHA3_EMPTY_LIST_RLP {
if hdr.uncles_hash() == KECCAK_EMPTY_LIST_RLP {
future::ok(Some(U256::from(0).into())).boxed()
} else {
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))
@@ -343,7 +343,7 @@ impl Eth for EthClient {
let (sync, on_demand) = (self.sync.clone(), self.on_demand.clone());
self.fetcher().header(num.into()).and_then(move |hdr| {
if hdr.uncles_hash() == SHA3_EMPTY_LIST_RLP {
if hdr.uncles_hash() == KECCAK_EMPTY_LIST_RLP {
future::ok(Some(U256::from(0).into())).boxed()
} else {
sync.with_context(|ctx| on_demand.request(ctx, request::Body(hdr.into())))

View File

@@ -23,7 +23,7 @@ use std::sync::Arc;
use ethsync::ManageNetwork;
use fetch::Fetch;
use futures::{BoxFuture, Future};
use util::sha3;
use hash::keccak_buffer;
use jsonrpc_core::Error;
use v1::helpers::dapps::DappsService;
@@ -129,7 +129,7 @@ impl<F: Fetch> ParitySet for ParitySetClient<F> {
result
.map_err(errors::fetch)
.and_then(|response| {
sha3(&mut io::BufReader::new(response)).map_err(errors::fetch)
keccak_buffer(&mut io::BufReader::new(response)).map_err(errors::fetch)
})
.map(Into::into)
}))

View File

@@ -24,7 +24,7 @@ use ethcore::mode::Mode;
use ethsync::ManageNetwork;
use fetch::{self, Fetch};
use futures::{BoxFuture, Future};
use util::sha3;
use hash::keccak_buffer;
use updater::{Service as UpdateService};
use jsonrpc_core::Error;
@@ -170,7 +170,7 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
result
.map_err(errors::fetch)
.and_then(|response| {
sha3(&mut io::BufReader::new(response)).map_err(errors::fetch)
keccak_buffer(&mut io::BufReader::new(response)).map_err(errors::fetch)
})
.map(Into::into)
}))

View File

@@ -15,11 +15,11 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Web3 rpc implementation.
use hash::keccak;
use jsonrpc_core::*;
use util::version;
use v1::traits::Web3;
use v1::types::{H256, Bytes};
use util::sha3::Hashable;
/// Web3 rpc implementation.
pub struct Web3Client;
@@ -35,6 +35,6 @@ impl Web3 for Web3Client {
}
fn sha3(&self, data: Bytes) -> Result<H256, Error> {
Ok(data.0.sha3().into())
Ok(keccak(&data.0).into())
}
}