finished
This commit is contained in:
@@ -54,6 +54,7 @@ parity-updater = { path = "../updater" }
|
||||
rlp = { path = "../util/rlp" }
|
||||
stats = { path = "../util/stats" }
|
||||
vm = { path = "../ethcore/vm" }
|
||||
hash = { path = "../util/hash" }
|
||||
|
||||
clippy = { version = "0.0.103", optional = true}
|
||||
pretty_assertions = "0.1"
|
||||
|
||||
@@ -21,7 +21,8 @@ use std::{fs, time, mem};
|
||||
use itertools::Itertools;
|
||||
use rand::Rng;
|
||||
use rand::os::OsRng;
|
||||
use util::{H256, Hashable};
|
||||
use hash::keccak;
|
||||
use util::H256;
|
||||
|
||||
/// Providing current time in seconds
|
||||
pub trait TimeProvider {
|
||||
@@ -162,7 +163,7 @@ impl<T: TimeProvider> AuthCodes<T> {
|
||||
return false;
|
||||
}
|
||||
|
||||
let as_token = |code| format!("{}:{}", code, time).sha3();
|
||||
let as_token = |code| keccak(format!("{}:{}", code, time));
|
||||
|
||||
// Check if it's the initial token.
|
||||
if self.is_empty() {
|
||||
@@ -231,12 +232,13 @@ mod tests {
|
||||
use std::io::{Read, Write};
|
||||
use std::{time, fs};
|
||||
use std::cell::Cell;
|
||||
use hash::keccak;
|
||||
|
||||
use util::{H256, Hashable};
|
||||
use util::H256;
|
||||
use super::*;
|
||||
|
||||
fn generate_hash(val: &str, time: u64) -> H256 {
|
||||
format!("{}:{}", val, time).sha3()
|
||||
keccak(format!("{}:{}", val, time))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -60,6 +60,7 @@ extern crate parity_reactor;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate rlp;
|
||||
extern crate stats;
|
||||
extern crate hash;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
@@ -56,7 +56,7 @@ pub fn request(server: Server<ws::Server>, request: &str) -> http_client::Respon
|
||||
#[cfg(test)]
|
||||
mod testing {
|
||||
use std::time;
|
||||
use util::Hashable;
|
||||
use hash::keccak;
|
||||
use devtools::http_client;
|
||||
use super::{serve, request};
|
||||
|
||||
@@ -125,7 +125,7 @@ mod testing {
|
||||
{{}}
|
||||
",
|
||||
port,
|
||||
format!("{}:{}", code, timestamp).sha3(),
|
||||
keccak(format!("{}:{}", code, timestamp)),
|
||||
timestamp,
|
||||
)
|
||||
);
|
||||
@@ -155,7 +155,7 @@ mod testing {
|
||||
{{}}
|
||||
",
|
||||
port,
|
||||
format!("{}:{}", code, timestamp).sha3(),
|
||||
keccak(format!("{}:{}", code, timestamp)),
|
||||
timestamp,
|
||||
)
|
||||
);
|
||||
@@ -171,7 +171,7 @@ mod testing {
|
||||
{{}}
|
||||
",
|
||||
port,
|
||||
format!("{}:{}", code, timestamp).sha3(),
|
||||
keccak(format!("{}:{}", code, timestamp)),
|
||||
timestamp,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -26,8 +26,8 @@ use light::client::LightChainClient;
|
||||
use light::on_demand::{request, OnDemand};
|
||||
use light::TransactionQueue as LightTransactionQueue;
|
||||
use rlp;
|
||||
use hash::keccak;
|
||||
use util::{Address, H520, H256, U256, Bytes, Mutex, RwLock};
|
||||
use util::sha3::Hashable;
|
||||
use stats::Corpus;
|
||||
|
||||
use ethkey::Signature;
|
||||
@@ -226,7 +226,7 @@ pub fn eth_data_hash(mut data: Bytes) -> H256 {
|
||||
format!("\x19Ethereum Signed Message:\n{}", data.len())
|
||||
.into_bytes();
|
||||
message_data.append(&mut data);
|
||||
message_data.sha3()
|
||||
keccak(message_data)
|
||||
}
|
||||
|
||||
/// Dispatcher for light clients -- fetches default gas price, next nonce, etc. from network.
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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())))
|
||||
|
||||
@@ -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)
|
||||
}))
|
||||
|
||||
@@ -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)
|
||||
}))
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ use ethcore::miner::{MinerOptions, Banning, GasPricer, MinerService, ExternalMin
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethjson::blockchain::BlockChain;
|
||||
use io::IoChannel;
|
||||
use util::{U256, H256, Address, Hashable};
|
||||
use util::{U256, H256, Address};
|
||||
|
||||
use jsonrpc_core::IoHandler;
|
||||
use v1::impls::{EthClient, SigningUnsafeClient};
|
||||
@@ -431,7 +431,7 @@ fn verify_transaction_counts(name: String, chain: BlockChain) {
|
||||
for b in chain.blocks_rlp().iter().filter(|b| Block::is_good(b)).map(|b| BlockView::new(b)) {
|
||||
let count = b.transactions_count();
|
||||
|
||||
let hash = b.sha3();
|
||||
let hash = b.hash();
|
||||
let number = b.header_view().number();
|
||||
|
||||
let (req, res) = by_hash(hash, count, &mut id);
|
||||
|
||||
Reference in New Issue
Block a user