Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1827 from ethcore/move_hash
Browse files Browse the repository at this point in the history
moved hash.rs to bigint library
  • Loading branch information
debris authored Aug 9, 2016
2 parents 505a054 + 974d537 commit 3b6bc97
Show file tree
Hide file tree
Showing 58 changed files with 315 additions and 358 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ethcore/src/blockchain/best_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::bytes::Bytes;
use util::numbers::{U256,H256};
use util::{Bytes, U256, H256};
use header::BlockNumber;

/// Best block info.
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/block_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::numbers::{U256,H256};
use util::{U256,H256};
use header::BlockNumber;

/// Brief info about inserted block.
Expand Down
4 changes: 1 addition & 3 deletions ethcore/src/blockchain/generator/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::hash::H2048;
use util::numbers::U256;
use util::bytes::Bytes;
use util::{U256, H2048, Bytes};
use header::BlockNumber;
use super::fork::Fork;
use super::bloom::Bloom;
Expand Down
5 changes: 2 additions & 3 deletions ethcore/src/blockchain/import_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Import route.

use util::hash::H256;
use util::H256;
use blockchain::block_info::{BlockInfo, BlockLocation};

/// Import route for newly inserted block.
Expand Down Expand Up @@ -67,8 +67,7 @@ impl From<BlockInfo> for ImportRoute {

#[cfg(test)]
mod tests {
use util::hash::H256;
use util::numbers::U256;
use util::{U256, H256};
use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use blockchain::ImportRoute;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/blockchain/update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use util::numbers::H256;
use util::H256;
use header::BlockNumber;
use blockchain::block_info::BlockInfo;
use blooms::BloomGroup;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn new_builtin_exec(name: &str) -> Box<Fn(&[u8], &mut [u8])> {
let mut it: InType = InType { hash: H256::new(), v: H256::new(), r: H256::new(), s: H256::new() };
it.copy_raw(input);
if it.v == H256::from(&U256::from(27)) || it.v == H256::from(&U256::from(28)) {
let s = Signature::from_rsv(&it.r, &it.s, it.v[31] - 27);
let s = signature_from_rsv(&it.r, &it.s, it.v[31] - 27);
if ec::is_valid(&s) {
if let Ok(p) = ec::recover(&s, &it.hash) {
let r = p.as_slice().sha3();
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/client/chain_notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::numbers::*;
use ipc::{IpcConfig, BinaryConvertError};
use std::collections::VecDeque;
use std::mem;
use ipc::{IpcConfig, BinaryConvertError};
use util::H256;

/// Represents what has to be handled by actor listening to chain events
#[derive(Ipc)]
Expand Down
8 changes: 4 additions & 4 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use time::precise_time_ns;
use util::{journaldb, rlp, Bytes, View, PerfTimer, Itertools, Mutex, RwLock};
use util::journaldb::JournalDB;
use util::rlp::{UntrustedRlp};
use util::numbers::*;
use util::{U256, H256, Address, H2048, Uint};
use util::sha3::*;
use util::kvdb::*;

Expand Down Expand Up @@ -255,7 +255,7 @@ impl Client {
}
}
let mut last_hashes = LastHashes::new();
last_hashes.resize(256, H256::new());
last_hashes.resize(256, H256::default());
last_hashes[0] = parent_hash;
for i in 0..255 {
match self.chain.block_details(&last_hashes[i]) {
Expand Down Expand Up @@ -727,7 +727,7 @@ impl BlockChainClient for Client {
timestamp: view.timestamp(),
difficulty: view.difficulty(),
last_hashes: last_hashes,
gas_used: U256::zero(),
gas_used: U256::default(),
gas_limit: view.gas_limit(),
};
for t in txs.iter().take(address.index) {
Expand Down Expand Up @@ -953,7 +953,7 @@ impl BlockChainClient for Client {
entry: log,
block_hash: hash.clone(),
block_number: number,
transaction_hash: hashes.get(index).cloned().unwrap_or_else(H256::new),
transaction_hash: hashes.get(index).cloned().unwrap_or_else(H256::default),
transaction_index: index,
log_index: log_index + i
})
Expand Down
5 changes: 1 addition & 4 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::bytes::Bytes;
use util::hash::{Address, H256, H2048};
use util::numbers::U256;
use util::Itertools;
use util::{U256, Address, H256, H2048, Bytes, Itertools};
use blockchain::TreeRoute;
use block_queue::BlockQueueInfo;
use block::{OpenBlock, SealedBlock};
Expand Down
13 changes: 7 additions & 6 deletions ethcore/src/env_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::*;
use std::cmp;
use std::sync::Arc;
use util::{U256, Address, H256, Hashable};
use header::BlockNumber;
use ethjson;

Expand Down Expand Up @@ -45,7 +47,7 @@ impl Default for EnvInfo {
fn default() -> Self {
EnvInfo {
number: 0,
author: Address::new(),
author: Address::default(),
timestamp: 0,
difficulty: 0.into(),
gas_limit: 0.into(),
Expand All @@ -65,7 +67,7 @@ impl From<ethjson::vm::Env> for EnvInfo {
gas_limit: e.gas_limit.into(),
timestamp: e.timestamp.into(),
last_hashes: Arc::new((1..cmp::min(number + 1, 257)).map(|i| format!("{}", number - i).as_bytes().sha3()).collect()),
gas_used: U256::zero(),
gas_used: U256::default(),
}
}
}
Expand All @@ -74,10 +76,9 @@ impl From<ethjson::vm::Env> for EnvInfo {
mod tests {
extern crate rustc_serialize;

use super::*;
use util::hash::*;
use util::numbers::U256;
use std::str::FromStr;
use super::*;
use util::{U256, Address};
use ethjson;

#[test]
Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,13 @@ mod tests {
let vm_factory = Default::default();
let mut b = OpenBlock::new(engine.deref(), &vm_factory, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut uncle = Header::new();
let uncle_author = address_from_hex("ef2d6d194084c2de36e0dabfce45d046b37d1106");
let uncle_author: Address = "ef2d6d194084c2de36e0dabfce45d046b37d1106".into();
uncle.author = uncle_author.clone();
b.push_uncle(uncle).unwrap();

let b = b.close();
assert_eq!(b.state().balance(&Address::zero()), U256::from_str("478eae0e571ba000").unwrap());
assert_eq!(b.state().balance(&uncle_author), U256::from_str("3cb71f51fc558000").unwrap());
assert_eq!(b.state().balance(&Address::zero()), "478eae0e571ba000".into());
assert_eq!(b.state().balance(&uncle_author), "3cb71f51fc558000".into());
}

#[test]
Expand Down
20 changes: 10 additions & 10 deletions ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ mod tests {
let mut db = db_result.take();
spec.ensure_db_good(db.as_hashdb_mut()).unwrap();
let s = State::from_existing(db, genesis_header.state_root.clone(), engine.account_start_nonce(), Default::default()).unwrap();
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000001")), U256::from(1u64));
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000002")), U256::from(1u64));
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000003")), U256::from(1u64));
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000004")), U256::from(1u64));
assert_eq!(s.balance(&address_from_hex("102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c")), U256::from(1u64) << 200);
assert_eq!(s.balance(&address_from_hex("0000000000000000000000000000000000000000")), U256::from(0u64));
assert_eq!(s.balance(&"0000000000000000000000000000000000000001".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000002".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000003".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000004".into()), 1u64.into());
assert_eq!(s.balance(&"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c".into()), U256::from(1u64) << 200);
assert_eq!(s.balance(&"0000000000000000000000000000000000000000".into()), 0u64.into());
}

#[test]
fn morden() {
let morden = new_morden();

assert_eq!(morden.state_root(), H256::from_str("f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9").unwrap());
assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into());
let genesis = morden.genesis_block();
assert_eq!(BlockView::new(&genesis).header_view().sha3(), H256::from_str("0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303").unwrap());
assert_eq!(BlockView::new(&genesis).header_view().sha3(), "0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303".into());

let _ = morden.engine;
}
Expand All @@ -92,9 +92,9 @@ mod tests {
fn frontier() {
let frontier = new_frontier();

assert_eq!(frontier.state_root(), H256::from_str("d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544").unwrap());
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
let genesis = frontier.genesis_block();
assert_eq!(BlockView::new(&genesis).header_view().sha3(), H256::from_str("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3").unwrap());
assert_eq!(BlockView::new(&genesis).header_view().sha3(), "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3".into());

let _ = frontier.engine;
}
Expand Down
9 changes: 3 additions & 6 deletions ethcore/src/miner/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
//! extern crate rustc_serialize;
//!
//! use util::crypto::KeyPair;
//! use util::hash::Address;
//! use util::numbers::{Uint, U256};
//! use util::{Uint, U256, Address};
//! use ethcore::miner::{TransactionQueue, AccountDetails, TransactionOrigin};
//! use ethcore::transaction::*;
//! use rustc_serialize::hex::FromHex;
Expand Down Expand Up @@ -81,12 +80,10 @@
//! - It removes all transactions (either from `current` or `future`) with nonce < client nonce
//! - It moves matching `future` transactions to `current`

use std::default::Default;
use std::cmp::{Ordering};
use std::cmp::Ordering;
use std::cmp;
use std::collections::{HashMap, BTreeSet};
use util::numbers::{Uint, U256};
use util::hash::{Address, H256};
use util::{Address, H256, Uint, U256};
use util::table::Table;
use transaction::*;
use error::{Error, TransactionError};
Expand Down
9 changes: 3 additions & 6 deletions ethcore/src/snapshot/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
//! Account state encoding and decoding

use account_db::{AccountDB, AccountDBMut};
use snapshot::Error;

use util::{Bytes, HashDB, SHA3_EMPTY, TrieDB};
use util::hash::{FixedHash, H256};
use util::numbers::U256;
use util::{U256, FixedHash, H256, Bytes, HashDB, SHA3_EMPTY, TrieDB};
use util::rlp::{Rlp, RlpStream, Stream, UntrustedRlp, View};
use snapshot::Error;

// An alternate account structure from ::account::Account.
#[derive(PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -198,4 +195,4 @@ mod tests {
let fat_rlp = UntrustedRlp::new(&fat_rlp);
assert_eq!(Account::from_fat_rlp(&mut AccountDBMut::new(db.as_hashdb_mut(), &addr), fat_rlp).unwrap(), account);
}
}
}
6 changes: 2 additions & 4 deletions ethcore/src/snapshot/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ mod tests {
use super::AbridgedBlock;
use types::transaction::{Action, Transaction};

use util::numbers::U256;
use util::hash::{Address, H256, FixedHash};
use util::Bytes;
use util::{Address, H256, FixedHash, U256, Bytes};

fn encode_block(b: &Block) -> Bytes {
b.rlp_bytes(::basic_types::Seal::With)
Expand Down Expand Up @@ -190,4 +188,4 @@ mod tests {
let abridged = AbridgedBlock::from_block_view(&BlockView::new(&encoded[..]));
assert_eq!(abridged.to_block(H256::new(), 0).unwrap(), b);
}
}
}
3 changes: 1 addition & 2 deletions ethcore/src/spec/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use util::rlp::*;
use util::numbers::{Uint, U256};
use util::hash::{Address, H256};
use util::{Address, H256, Uint, U256};
use ethjson;
use super::seal::Seal;

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ fn alter_balance() {
let mut state_result = get_temp_state();
let mut state = state_result.reference_mut();
let a = Address::zero();
let b = address_from_u64(1u64);
let b = 1u64.into();
state.add_balance(&a, &U256::from(69u64));
assert_eq!(state.balance(&a), U256::from(69u64));
state.commit().unwrap();
Expand Down
8 changes: 3 additions & 5 deletions ethcore/src/types/account_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

//! Diff between two accounts.

use util::numbers::*;
use std::cmp::*;
use std::fmt;
use ipc::binary::{BinaryConvertError, BinaryConvertable};
use util::Bytes;
use std::{fmt, mem};
use std::collections::{VecDeque, BTreeMap};
use std::mem;
use util::{U256, H256, Uint, Bytes};
use ipc::binary::{BinaryConvertError, BinaryConvertable};

#[derive(Debug, PartialEq, Eq, Clone, Binary)]
/// Diff type for specifying a change (or not).
Expand Down
6 changes: 3 additions & 3 deletions ethcore/src/types/blockchain_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

//! Blockhain info type definition

use util::numbers::*;
use header::BlockNumber;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;
use util::{U256, H256};
use ipc::binary::BinaryConvertError;
use header::BlockNumber;

/// Information about the blockchain gathered together.
#[derive(Clone, Debug, Binary)]
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/types/executed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

//! Transaction execution format module.

use util::numbers::*;
use util::Bytes;
use util::{Bytes, U256, Address, U512};
use util::rlp::*;
use trace::{VMTrace, FlatTrace};
use types::log_entry::LogEntry;
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/types/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use util::hash::*;
use util::sha3::*;
use util::bloom::Bloomable;
use client::BlockID;
use log_entry::LogEntry;
use ipc::binary::BinaryConvertError;
Expand Down
12 changes: 5 additions & 7 deletions ethcore/src/types/log_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@

//! Log entry type definition.

use util::numbers::*;
use std::mem;
use std::ops::Deref;
use std::collections::VecDeque;
use util::{H256, Address, Bytes, HeapSizeOf, Hashable};
use util::rlp::*;
use util::Bytes;
use util::HeapSizeOf;
use util::sha3::*;
use util::bloom::Bloomable;
use ipc::binary::BinaryConvertError;
use basic_types::LogBloom;
use header::BlockNumber;
use ethjson;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;

/// A record of execution for a `LOG` operation.
#[derive(Default, Debug, Clone, PartialEq, Eq, Binary)]
Expand Down
Loading

0 comments on commit 3b6bc97

Please sign in to comment.