cleaning up hash reexports
This commit is contained in:
parent
573e775ef9
commit
e8c451ac82
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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)]
|
||||
|
@ -27,7 +27,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::panics::*;
|
||||
use util::io::*;
|
||||
use util::sha3::*;
|
||||
@ -256,7 +256,7 @@ impl Client {
|
||||
}
|
||||
}
|
||||
let mut last_hashes = LastHashes::new();
|
||||
last_hashes.resize(256, H256::new());
|
||||
last_hashes.resize(256, Default::default());
|
||||
last_hashes[0] = parent_hash;
|
||||
for i in 0..255 {
|
||||
match self.chain.block_details(&last_hashes[i]) {
|
||||
@ -648,7 +648,7 @@ impl BlockChainClient for Client {
|
||||
timestamp: view.timestamp(),
|
||||
difficulty: view.difficulty(),
|
||||
last_hashes: last_hashes,
|
||||
gas_used: U256::zero(),
|
||||
gas_used: Default::default(),
|
||||
gas_limit: U256::max_value(),
|
||||
};
|
||||
// that's just a copy of the state.
|
||||
@ -923,7 +923,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(Default::default),
|
||||
transaction_index: index,
|
||||
log_index: log_index + i
|
||||
})
|
||||
|
@ -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};
|
||||
|
@ -14,7 +14,8 @@
|
||||
// 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 util::{U256, Address, H256, Hashable};
|
||||
use header::BlockNumber;
|
||||
use ethjson;
|
||||
|
||||
@ -45,7 +46,7 @@ impl Default for EnvInfo {
|
||||
fn default() -> Self {
|
||||
EnvInfo {
|
||||
number: 0,
|
||||
author: Address::new(),
|
||||
author: Default::default(),
|
||||
timestamp: 0,
|
||||
difficulty: 0.into(),
|
||||
gas_limit: 0.into(),
|
||||
@ -65,7 +66,7 @@ impl From<ethjson::vm::Env> for EnvInfo {
|
||||
gas_limit: e.gas_limit.into(),
|
||||
timestamp: e.timestamp.into(),
|
||||
last_hashes: (1..cmp::min(number + 1, 257)).map(|i| format!("{}", number - i).as_bytes().sha3()).collect(),
|
||||
gas_used: U256::zero(),
|
||||
gas_used: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,10 +75,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]
|
||||
|
@ -372,7 +372,7 @@ 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".parse().unwrap();
|
||||
uncle.author = uncle_author.clone();
|
||||
b.push_uncle(uncle).unwrap();
|
||||
|
||||
|
@ -69,12 +69,12 @@ mod tests {
|
||||
let mut db = db_result.take();
|
||||
spec.ensure_db_good(db.as_hashdb_mut());
|
||||
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".parse().unwrap()), U256::from(1u64));
|
||||
assert_eq!(s.balance(&"0000000000000000000000000000000000000002".parse().unwrap()), U256::from(1u64));
|
||||
assert_eq!(s.balance(&"0000000000000000000000000000000000000003".parse().unwrap()), U256::from(1u64));
|
||||
assert_eq!(s.balance(&"0000000000000000000000000000000000000004".parse().unwrap()), U256::from(1u64));
|
||||
assert_eq!(s.balance(&"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c".parse().unwrap()), U256::from(1u64) << 200);
|
||||
assert_eq!(s.balance(&"0000000000000000000000000000000000000000".parse().unwrap()), U256::from(0u64));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -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;
|
||||
@ -85,8 +84,7 @@ use std::default::Default;
|
||||
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};
|
||||
|
@ -18,10 +18,7 @@
|
||||
|
||||
use account_db::{AccountDB, AccountDBMut};
|
||||
use error::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::{DecoderError, Rlp, RlpStream, Stream, UntrustedRlp, View};
|
||||
|
||||
// An alternate account structure from ::account::Account.
|
||||
@ -208,4 +205,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,8 +145,7 @@ mod tests {
|
||||
use super::AbridgedBlock;
|
||||
use types::transaction::{Action, Transaction};
|
||||
|
||||
use util::numbers::U256;
|
||||
use util::hash::{Address, H256, FixedHash};
|
||||
use util::{Address, H256, FixedHash, U256};
|
||||
use util::{Bytes, RlpStream, Stream};
|
||||
|
||||
fn encode_block(b: &Block) -> Bytes {
|
||||
@ -208,4 +207,4 @@ mod tests {
|
||||
let abridged = AbridgedBlock::from_block_view(&BlockView::new(&encoded[..]));
|
||||
assert_eq!(abridged.to_block(H256::new(), 0).unwrap(), b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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).
|
||||
|
@ -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(Debug, Binary)]
|
||||
|
@ -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;
|
||||
|
@ -16,18 +16,15 @@
|
||||
|
||||
//! Log entry type definition.
|
||||
|
||||
use util::numbers::*;
|
||||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::collections::VecDeque;
|
||||
use util::{H256, Address, Bytes, HeapSizeOf, FixedHash, Hashable};
|
||||
use util::rlp::*;
|
||||
use util::Bytes;
|
||||
use util::HeapSizeOf;
|
||||
use util::sha3::*;
|
||||
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)]
|
||||
|
@ -16,15 +16,15 @@
|
||||
|
||||
//! Receipt
|
||||
|
||||
use util::numbers::*;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
use util::{H256, U256, Address};
|
||||
use util::rlp::*;
|
||||
use util::HeapSizeOf;
|
||||
use basic_types::LogBloom;
|
||||
use header::BlockNumber;
|
||||
use log_entry::{LogEntry, LocalizedLogEntry};
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
/// Information describing execution of a transaction.
|
||||
#[derive(Default, Debug, Clone, Binary)]
|
||||
@ -45,7 +45,7 @@ impl Receipt {
|
||||
Receipt {
|
||||
state_root: state_root,
|
||||
gas_used: gas_used,
|
||||
log_bloom: logs.iter().fold(LogBloom::new(), |mut b, l| { b = &b | &l.bloom(); b }), //TODO: use |= operator
|
||||
log_bloom: logs.iter().fold(Default::default(), |mut b, l| { b = &b | &l.bloom(); b }), //TODO: use |= operator
|
||||
logs: logs,
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,12 @@
|
||||
|
||||
//! State diff module.
|
||||
|
||||
use util::numbers::*;
|
||||
use account_diff::*;
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::mem;
|
||||
use std::fmt;
|
||||
use std::{mem, fmt};
|
||||
use std::ops::*;
|
||||
use std::collections::{VecDeque, BTreeMap};
|
||||
use util::Address;
|
||||
use account_diff::*;
|
||||
use ipc::binary::BinaryConvertError;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Binary)]
|
||||
/// Expression for the delta between two system states. Encoded the
|
||||
|
@ -17,6 +17,8 @@
|
||||
//! Trace filters type definitions
|
||||
|
||||
use std::ops::Range;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
use bloomchain::{Filter as BloomFilter, Bloom, Number};
|
||||
use util::{Address, FixedHash};
|
||||
use util::sha3::Hashable;
|
||||
@ -24,8 +26,6 @@ use basic_types::LogBloom;
|
||||
use trace::flat::FlatTrace;
|
||||
use types::trace_types::trace::{Action, Res};
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
/// Addresses filter.
|
||||
///
|
||||
@ -55,7 +55,7 @@ impl AddressesFilter {
|
||||
/// Returns blooms of this addresses filter.
|
||||
pub fn blooms(&self) -> Vec<LogBloom> {
|
||||
match self.list.is_empty() {
|
||||
true => vec![LogBloom::new()],
|
||||
true => vec![Default::default()],
|
||||
false => self.list.iter()
|
||||
.map(|address| LogBloom::from_bloomed(&address.sha3()))
|
||||
.collect(),
|
||||
@ -142,7 +142,6 @@ mod tests {
|
||||
use trace::trace::{Action, Call, Res, Create, CreateResult, Suicide};
|
||||
use trace::flat::FlatTrace;
|
||||
use trace::{Filter, AddressesFilter};
|
||||
use basic_types::LogBloom;
|
||||
use types::executed::CallType;
|
||||
|
||||
#[test]
|
||||
@ -154,7 +153,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let blooms = filter.bloom_possibilities();
|
||||
assert_eq!(blooms, vec![LogBloom::new()]);
|
||||
assert_eq!(blooms, vec![Default::default()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -16,19 +16,20 @@
|
||||
|
||||
//! Transaction data structure.
|
||||
|
||||
use util::numbers::*;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
use util::{H256, Address, U256, H520};
|
||||
use std::ops::Deref;
|
||||
use util::rlp::*;
|
||||
use util::sha3::*;
|
||||
use util::{UtilError, CryptoError, Bytes, Signature, Secret, ec};
|
||||
use util::crypto::{signature_from_rsv, signature_to_rsv};
|
||||
use std::cell::*;
|
||||
use error::*;
|
||||
use evm::Schedule;
|
||||
use header::BlockNumber;
|
||||
use ethjson;
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Binary)]
|
||||
/// Transaction action type.
|
||||
@ -146,7 +147,7 @@ impl Transaction {
|
||||
|
||||
/// Signs the transaction with signature.
|
||||
pub fn with_signature(self, sig: H520) -> SignedTransaction {
|
||||
let (r, s, v) = sig.to_rsv();
|
||||
let (r, s, v) = signature_to_rsv(&sig);
|
||||
SignedTransaction {
|
||||
unsigned: self,
|
||||
r: r,
|
||||
@ -162,8 +163,8 @@ impl Transaction {
|
||||
pub fn invalid_sign(self) -> SignedTransaction {
|
||||
SignedTransaction {
|
||||
unsigned: self,
|
||||
r: U256::zero(),
|
||||
s: U256::zero(),
|
||||
r: Default::default(),
|
||||
s: Default::default(),
|
||||
v: 0,
|
||||
hash: Cell::new(None),
|
||||
sender: Cell::new(None),
|
||||
@ -174,8 +175,8 @@ impl Transaction {
|
||||
pub fn fake_sign(self, from: Address) -> SignedTransaction {
|
||||
SignedTransaction {
|
||||
unsigned: self,
|
||||
r: U256::zero(),
|
||||
s: U256::zero(),
|
||||
r: Default::default(),
|
||||
s: Default::default(),
|
||||
v: 0,
|
||||
hash: Cell::new(None),
|
||||
sender: Cell::new(Some(from)),
|
||||
@ -290,7 +291,7 @@ impl SignedTransaction {
|
||||
pub fn standard_v(&self) -> u8 { match self.v { 27 => 0, 28 => 1, _ => 4 } }
|
||||
|
||||
/// Construct a signature object from the sig.
|
||||
pub fn signature(&self) -> Signature { Signature::from_rsv(&From::from(&self.r), &From::from(&self.s), self.standard_v()) }
|
||||
pub fn signature(&self) -> Signature { signature_from_rsv(&From::from(&self.r), &From::from(&self.s), self.standard_v()) }
|
||||
|
||||
/// Checks whether the signature has a low 's' value.
|
||||
pub fn check_low_s(&self) -> Result<(), Error> {
|
||||
@ -360,10 +361,10 @@ fn sender_test() {
|
||||
assert_eq!(t.gas_price, U256::from(0x01u64));
|
||||
assert_eq!(t.nonce, U256::from(0x00u64));
|
||||
if let Action::Call(ref to) = t.action {
|
||||
assert_eq!(*to, address_from_hex("095e7baea6a6c7c4c2dfeb977efac326af552d87"));
|
||||
assert_eq!(*to, "095e7baea6a6c7c4c2dfeb977efac326af552d87".parse().unwrap());
|
||||
} else { panic!(); }
|
||||
assert_eq!(t.value, U256::from(0x0au64));
|
||||
assert_eq!(t.sender().unwrap(), address_from_hex("0f65fe9276bc9a24ae7083ae28e2660ef72df99e"));
|
||||
assert_eq!(t.sender().unwrap(), "0f65fe9276bc9a24ae7083ae28e2660ef72df99e".parse().unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -16,10 +16,10 @@
|
||||
|
||||
//! Tree route info type definition
|
||||
|
||||
use util::numbers::H256;
|
||||
use ipc::BinaryConvertError;
|
||||
use std::collections::VecDeque;
|
||||
use std::mem;
|
||||
use ipc::BinaryConvertError;
|
||||
use util::H256;
|
||||
|
||||
/// Represents a tree route between `from` block and `to` block:
|
||||
#[derive(Debug, Binary)]
|
||||
|
@ -17,7 +17,7 @@
|
||||
//! Binary representation of types
|
||||
|
||||
use util::bytes::Populatable;
|
||||
use util::numbers::{U256, U512, H256, H2048, Address};
|
||||
use util::{U256, U512, H256, H2048, Address};
|
||||
use std::mem;
|
||||
use std::collections::{VecDeque, BTreeMap};
|
||||
use std::ops::Range;
|
||||
|
@ -44,7 +44,7 @@ impl Account {
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::account::Account;
|
||||
use util::numbers::U256;
|
||||
use util::U256;
|
||||
use uint::Uint;
|
||||
use bytes::Bytes;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
use std::str::FromStr;
|
||||
use serde::{Deserialize, Deserializer, Error};
|
||||
use serde::de::Visitor;
|
||||
use util::numbers::{U256, Uint as U};
|
||||
use util::{U256, Uint as U};
|
||||
|
||||
/// Lenient uint json deserialization for test json files.
|
||||
#[derive(Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
||||
@ -88,7 +88,7 @@ impl Visitor for UintVisitor {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use serde_json;
|
||||
use util::numbers::U256;
|
||||
use util::U256;
|
||||
use uint::Uint;
|
||||
|
||||
#[test]
|
||||
|
@ -39,7 +39,7 @@ pub struct Call {
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use vm::Call;
|
||||
use util::numbers::U256;
|
||||
use util::U256;
|
||||
use uint::Uint;
|
||||
use util::hash::Address as Hash160;
|
||||
use hash::Address;
|
||||
|
@ -27,7 +27,7 @@ use std::ops::Deref;
|
||||
use ethsync::{SyncProvider, SyncState};
|
||||
use ethcore::miner::{MinerService, ExternalMinerService};
|
||||
use jsonrpc_core::*;
|
||||
use util::numbers::*;
|
||||
use util::{H256, Address, FixedHash, U256, H64, Uint};
|
||||
use util::sha3::*;
|
||||
use util::rlp::{encode, decode, UntrustedRlp, View};
|
||||
use util::{FromHex, Mutex};
|
||||
|
@ -60,7 +60,7 @@ use ethcore::miner::MinerService;
|
||||
use ethcore::client::MiningBlockChainClient;
|
||||
use ethcore::transaction::{Action, SignedTransaction, Transaction};
|
||||
use ethcore::account_provider::{AccountProvider, Error as AccountError};
|
||||
use util::numbers::*;
|
||||
use util::{U256, H256, Address};
|
||||
use util::rlp::encode;
|
||||
use util::bytes::ToPretty;
|
||||
use jsonrpc_core::{Error, ErrorCode, Value, to_value};
|
||||
@ -100,13 +100,13 @@ fn prepare_transaction<C, M>(client: &C, miner: &M, request: TransactionRequest)
|
||||
nonce: request.nonce
|
||||
.or_else(|| miner
|
||||
.last_nonce(&request.from)
|
||||
.map(|nonce| nonce + U256::one()))
|
||||
.map(|nonce| nonce + 1.into()))
|
||||
.unwrap_or_else(|| client.latest_nonce(&request.from)),
|
||||
|
||||
action: request.to.map_or(Action::Create, Action::Call),
|
||||
gas: request.gas.unwrap_or_else(|| miner.sensible_gas_limit()),
|
||||
gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(client, miner)),
|
||||
value: request.value.unwrap_or_else(U256::zero),
|
||||
value: request.value.unwrap_or_else(Default::default),
|
||||
data: request.data.map_or_else(Vec::new, |b| b.to_vec()),
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||
use std::time::{Instant, Duration};
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::hash::{Address, H256, FixedHash};
|
||||
use util::numbers::{Uint, U256};
|
||||
use util::{Uint, U256};
|
||||
use util::Mutex;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, TransactionID};
|
||||
|
@ -22,8 +22,7 @@ use v1::impls::EthSigningQueueClient;
|
||||
use v1::traits::EthSigning;
|
||||
use v1::helpers::{ConfirmationsQueue, SigningQueue};
|
||||
use v1::tests::helpers::TestMinerService;
|
||||
use util::{Address, FixedHash};
|
||||
use util::numbers::{Uint, U256, H256};
|
||||
use util::{Address, FixedHash, Uint, U256, H256};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::client::TestBlockChainClient;
|
||||
use ethcore::transaction::{Transaction, Action};
|
||||
|
@ -21,7 +21,7 @@ use v1::{EthcoreSet, EthcoreSetClient};
|
||||
use ethcore::miner::MinerService;
|
||||
use ethcore::client::TestBlockChainClient;
|
||||
use v1::tests::helpers::TestMinerService;
|
||||
use util::numbers::*;
|
||||
use util::{U256, Address};
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use super::manage_network::TestManageNetwork;
|
||||
use ethsync::ManageNetwork;
|
||||
|
@ -18,11 +18,10 @@ use std::sync::Arc;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use v1::{Net, NetClient};
|
||||
use v1::tests::helpers::{Config, TestSyncProvider};
|
||||
use util::numbers::*;
|
||||
|
||||
fn sync_provider() -> Arc<TestSyncProvider> {
|
||||
Arc::new(TestSyncProvider::new(Config {
|
||||
network_id: U256::from(3),
|
||||
network_id: 3.into(),
|
||||
num_peers: 120,
|
||||
}))
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::numbers::*;
|
||||
use util::{U256, Uint, Address};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use v1::{PersonalClient, Personal};
|
||||
use v1::tests::helpers::TestMinerService;
|
||||
|
@ -17,7 +17,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use jsonrpc_core::IoHandler;
|
||||
use util::numbers::*;
|
||||
use util::{U256, Uint, Address};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::client::TestBlockChainClient;
|
||||
use ethcore::transaction::{Transaction, Action};
|
||||
|
@ -28,7 +28,7 @@ extern crate ethcore_util;
|
||||
extern crate rand;
|
||||
|
||||
use test::{Bencher, black_box};
|
||||
use ethcore_util::numbers::*;
|
||||
use ethcore_util::U256;
|
||||
|
||||
#[bench]
|
||||
fn u256_add(b: &mut Bencher) {
|
||||
|
@ -28,7 +28,7 @@ extern crate ethcore_util;
|
||||
use test::Bencher;
|
||||
use std::str::FromStr;
|
||||
use ethcore_util::rlp::*;
|
||||
use ethcore_util::numbers::U256;
|
||||
use ethcore_util::U256;
|
||||
|
||||
#[bench]
|
||||
fn bench_stream_u64_value(b: &mut Bencher) {
|
||||
|
@ -36,21 +36,19 @@ lazy_static! {
|
||||
static ref SECP256K1: Secp256k1 = Secp256k1::new();
|
||||
}
|
||||
|
||||
impl Signature {
|
||||
/// Create a new signature from the R, S and V componenets.
|
||||
pub fn from_rsv(r: &H256, s: &H256, v: u8) -> Signature {
|
||||
let mut ret: Signature = Signature::new();
|
||||
(&mut ret[0..32]).copy_from_slice(r);
|
||||
(&mut ret[32..64]).copy_from_slice(s);
|
||||
/// Create a new signature from the R, S and V componenets.
|
||||
pub fn signature_from_rsv(r: &H256, s: &H256, v: u8) -> Signature {
|
||||
let mut ret: Signature = Signature::new();
|
||||
(&mut ret[0..32]).copy_from_slice(r);
|
||||
(&mut ret[32..64]).copy_from_slice(s);
|
||||
|
||||
ret[64] = v;
|
||||
ret
|
||||
}
|
||||
ret[64] = v;
|
||||
ret
|
||||
}
|
||||
|
||||
/// Convert transaction to R, S and V components.
|
||||
pub fn to_rsv(&self) -> (U256, U256, u8) {
|
||||
(U256::from(&self.as_slice()[0..32]), U256::from(&self.as_slice()[32..64]), self[64])
|
||||
}
|
||||
/// Convert transaction to R, S and V components.
|
||||
pub fn signature_to_rsv(s: &Signature) -> (U256, U256, u8) {
|
||||
(U256::from(&s.as_slice()[0..32]), U256::from(&s.as_slice()[32..64]), s[64])
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -206,10 +204,10 @@ pub mod ec {
|
||||
signature.clone_from_slice(&data);
|
||||
signature[64] = rec_id.to_i32() as u8;
|
||||
|
||||
let (_, s, v) = signature.to_rsv();
|
||||
let (_, s, v) = signature_to_rsv(&signature);
|
||||
let secp256k1n = U256::from_str("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141").unwrap();
|
||||
if !is_low_s(&s) {
|
||||
signature = super::Signature::from_rsv(&H256::from_slice(&signature[0..32]), &H256::from(secp256k1n - s), v ^ 1);
|
||||
signature = super::signature_from_rsv(&H256::from_slice(&signature[0..32]), &H256::from(secp256k1n - s), v ^ 1);
|
||||
}
|
||||
Ok(signature)
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Calculates heapsize of util types.
|
||||
|
||||
use hash::*;
|
||||
|
||||
|
@ -139,7 +139,6 @@ pub mod triehash;
|
||||
pub mod trie;
|
||||
pub mod nibbleslice;
|
||||
pub mod nibblevec;
|
||||
mod heapsizeof;
|
||||
pub mod semantic_version;
|
||||
pub mod io;
|
||||
pub mod network;
|
||||
@ -171,6 +170,7 @@ pub use timer::*;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use {U256, H256, Uint};
|
||||
|
||||
#[test]
|
||||
fn u256_multi_muls() {
|
||||
|
Loading…
Reference in New Issue
Block a user