diff --git a/ethcore/light/src/net/status.rs b/ethcore/light/src/net/status.rs index 3e32f660943..3a09be3c218 100644 --- a/ethcore/light/src/net/status.rs +++ b/ethcore/light/src/net/status.rs @@ -373,7 +373,7 @@ pub fn write_announcement(announcement: &Announcement) -> Vec { mod tests { use super::*; use super::super::request_credits::FlowParams; - use util::{U256, H256, FixedHash}; + use util::{U256, H256}; use rlp::{RlpStream, Stream ,UntrustedRlp, View}; #[test] diff --git a/ethcore/light/src/on_demand/request.rs b/ethcore/light/src/on_demand/request.rs index 3a72db51d9c..01792543c51 100644 --- a/ethcore/light/src/on_demand/request.rs +++ b/ethcore/light/src/on_demand/request.rs @@ -267,7 +267,7 @@ impl TransactionProof { #[cfg(test)] mod tests { use super::*; - use util::{MemoryDB, Address, H256, FixedHash}; + use util::{MemoryDB, Address, H256}; use util::trie::{Trie, TrieMut, SecTrieDB, SecTrieDBMut}; use util::trie::recorder::Recorder; diff --git a/ethcore/src/account_provider/mod.rs b/ethcore/src/account_provider/mod.rs index 5bb183d0bf7..f9b7727db69 100755 --- a/ethcore/src/account_provider/mod.rs +++ b/ethcore/src/account_provider/mod.rs @@ -23,7 +23,7 @@ use self::stores::{AddressBook, DappsSettingsStore, NewDappsPolicy}; use std::fmt; use std::collections::{HashMap, HashSet}; use std::time::{Instant, Duration}; -use util::{FixedHash, RwLock}; +use util::{RwLock}; use ethstore::{SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore, random_string, SecretVaultRef, StoreAccountRef}; use ethstore::dir::MemoryDirectory; diff --git a/ethcore/src/action_params.rs b/ethcore/src/action_params.rs index cba8d7c6a1a..ef9c0052331 100644 --- a/ethcore/src/action_params.rs +++ b/ethcore/src/action_params.rs @@ -16,7 +16,7 @@ //! Evm input params. use util::{Address, Bytes, Uint, U256}; -use util::hash::{H256, FixedHash}; +use util::hash::{H256}; use util::sha3::{Hashable, SHA3_EMPTY}; use ethjson; use types::executed::CallType; diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 3626fdd3a62..67425ca862a 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use std::collections::HashSet; use rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, Decoder, DecoderError, View, Stream}; -use util::{Bytes, Address, Uint, FixedHash, Hashable, U256, H256, ordered_trie_root, SHA3_NULL_RLP}; +use util::{Bytes, Address, Uint, Hashable, U256, H256, ordered_trie_root, SHA3_NULL_RLP}; use util::error::{Mismatch, OutOfBounds}; use basic_types::{LogBloom, Seal}; @@ -618,7 +618,6 @@ mod tests { use state_db::StateDB; use views::BlockView; use util::Address; - use util::hash::FixedHash; use std::sync::Arc; use transaction::SignedTransaction; diff --git a/ethcore/src/builtin.rs b/ethcore/src/builtin.rs index 89b9ff2fd3f..ca3b13181e5 100644 --- a/ethcore/src/builtin.rs +++ b/ethcore/src/builtin.rs @@ -18,7 +18,7 @@ use crypto::sha2::Sha256 as Sha256Digest; use crypto::ripemd160::Ripemd160 as Ripemd160Digest; use crypto::digest::Digest; use std::cmp::min; -use util::{U256, H256, Hashable, FixedHash, BytesRef}; +use util::{U256, H256, Hashable, BytesRef}; use ethkey::{Signature, recover as ec_recover}; use ethjson; diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index edd585551c7..e7e2d439d55 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -25,7 +25,7 @@ use time::precise_time_ns; // util use util::{Bytes, PerfTimer, Itertools, Mutex, RwLock, MutexGuard, Hashable}; use util::{journaldb, DBValue, TrieFactory, Trie}; -use util::{U256, H256, Address, H2048, Uint, FixedHash}; +use util::{U256, H256, Address, H2048, Uint}; use util::trie::TrieSpec; use util::kvdb::*; diff --git a/ethcore/src/client/registry.rs b/ethcore/src/client/registry.rs index c8f750576fd..fb74ec36b99 100644 --- a/ethcore/src/client/registry.rs +++ b/ethcore/src/client/registry.rs @@ -5,7 +5,7 @@ use std::string::String; use std::result::Result; use std::fmt; use {util, ethabi}; -use util::{FixedHash, Uint}; +use util::{Uint}; pub struct Registry { contract: ethabi::Contract, @@ -22,7 +22,7 @@ impl Registry { } } fn as_string(e: T) -> String { format!("{:?}", e) } - + /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_data","type":"address"}],"name":"canReverse","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn can_reverse(&self, _data: &util::Address) -> Result @@ -45,7 +45,7 @@ impl Registry { vec![ethabi::Token::Address(_new.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } @@ -318,7 +318,7 @@ impl Registry { vec![] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } diff --git a/ethcore/src/engines/tendermint/params.rs b/ethcore/src/engines/tendermint/params.rs index e380131888a..3dbdf4041a0 100644 --- a/ethcore/src/engines/tendermint/params.rs +++ b/ethcore/src/engines/tendermint/params.rs @@ -17,7 +17,7 @@ //! Tendermint specific parameters. use ethjson; -use util::{U256, Uint, Address, FixedHash}; +use util::{U256, Uint, Address}; use time::Duration; use super::super::transition::Timeouts; use super::Step; diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/src/engines/validator_set/contract.rs index 91fbf5fab8b..adfdd1225c0 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/src/engines/validator_set/contract.rs @@ -92,7 +92,7 @@ mod provider { use std::result::Result; use std::fmt; use {util, ethabi}; - use util::{FixedHash, Uint}; + use util::{Uint}; pub struct Contract { contract: ethabi::Contract, @@ -108,7 +108,7 @@ mod provider { } } fn as_string(e: T) -> String { format!("{:?}", e) } - + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"validator","type":"address"}],"name":"reportMalicious","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn report_malicious(&self, validator: &util::Address) -> Result<(), String> { @@ -117,7 +117,7 @@ mod provider { vec![ethabi::Token::Address(validator.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } @@ -129,7 +129,7 @@ mod provider { vec![ethabi::Token::Address(validator.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } } @@ -159,7 +159,7 @@ mod tests { assert!(vc.contains(&last_hash, &Address::from_str("7d577a597b2742b498cb5cf0c26cdcd726d39e6e").unwrap())); assert!(vc.contains(&last_hash, &Address::from_str("82a978b3f5962a5b0957d9ee9eef472ee55b42f1").unwrap())); } - + #[test] fn reports_validators() { let tap = Arc::new(AccountProvider::transient_provider()); @@ -173,12 +173,12 @@ mod tests { client.miner().set_engine_signer(v1, "".into()).unwrap(); let mut header = Header::default(); - let seal = vec![encode(&5u8).to_vec(), encode(&(&H520::default() as &[u8])).to_vec()]; + let seal = vec![encode(&5u8).to_vec(), encode(&(&H520::default() as &[u8])).to_vec()]; header.set_seal(seal); header.set_author(v1); header.set_number(2); header.set_parent_hash(client.chain_info().best_block_hash); - + // `reportBenign` when the designated proposer releases block from the future (bad clock). assert!(client.engine().verify_block_family(&header, &header, None).is_err()); // Seal a block. diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index d9f1b74132e..924f3353cb1 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -509,7 +509,7 @@ mod tests { use std::sync::Arc; use ethkey::{Generator, Random}; use super::*; - use util::{H256, U256, U512, Address, Uint, FixedHash, FromHex, FromStr}; + use util::{H256, U256, U512, Address, Uint, FromHex, FromStr}; use util::bytes::BytesRef; use action_params::{ActionParams, ActionValue}; use env_info::EnvInfo; diff --git a/ethcore/src/migrations/state/v7.rs b/ethcore/src/migrations/state/v7.rs index ea065550855..bcfaf8c5d4d 100644 --- a/ethcore/src/migrations/state/v7.rs +++ b/ethcore/src/migrations/state/v7.rs @@ -20,7 +20,7 @@ use std::collections::HashMap; use util::Bytes; -use util::{Address, FixedHash, H256}; +use util::{Address, H256}; use util::kvdb::Database; use util::migration::{Batch, Config, Error, Migration, SimpleMigration, Progress}; use util::sha3::Hashable; diff --git a/ethcore/src/migrations/v10.rs b/ethcore/src/migrations/v10.rs index a152657780a..45fc457bd59 100644 --- a/ethcore/src/migrations/v10.rs +++ b/ethcore/src/migrations/v10.rs @@ -24,7 +24,7 @@ use views::HeaderView; use bloom_journal::Bloom; use util::migration::{Error, Migration, Progress, Batch, Config}; use util::journaldb; -use util::{H256, FixedHash, Trie}; +use util::{H256, Trie}; use util::{Database, DBTransaction}; /// Account bloom upgrade routine. If bloom already present, does nothing. diff --git a/ethcore/src/miner/service_transaction_checker.rs b/ethcore/src/miner/service_transaction_checker.rs index 5a7ab04e920..8a97ed9dc45 100644 --- a/ethcore/src/miner/service_transaction_checker.rs +++ b/ethcore/src/miner/service_transaction_checker.rs @@ -62,12 +62,12 @@ mod provider { use std::result::Result; use std::fmt; use {util, ethabi}; - use util::{FixedHash, Uint}; + use util::{Uint}; pub struct Contract { contract: ethabi::Contract, address: util::Address, - + } impl Contract { pub fn new(address: util::Address) -> Self @@ -75,11 +75,11 @@ mod provider { Contract { contract: ethabi::Contract::new(ethabi::Interface::load(b"[{\"constant\":false,\"inputs\":[{\"name\":\"_new\",\"type\":\"address\"}],\"name\":\"setOwner\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"}],\"name\":\"certify\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"},{\"name\":\"_field\",\"type\":\"string\"}],\"name\":\"getAddress\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"}],\"name\":\"revoke\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"delegate\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"},{\"name\":\"_field\",\"type\":\"string\"}],\"name\":\"getUint\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_new\",\"type\":\"address\"}],\"name\":\"setDelegate\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"}],\"name\":\"certified\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_who\",\"type\":\"address\"},{\"name\":\"_field\",\"type\":\"string\"}],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"payable\":false,\"type\":\"function\"}]").expect("JSON is autogenerated; qed")), address: address, - + } } fn as_string(e: T) -> String { format!("{:?}", e) } - + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] pub fn set_owner(&self, do_call: &F, _new: &util::Address) -> Result<(), String> @@ -89,7 +89,7 @@ mod provider { vec![ethabi::Token::Address(_new.clone().0)] ).map_err(Self::as_string)?; call.decode_output((do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } @@ -102,7 +102,7 @@ mod provider { vec![ethabi::Token::Address(_who.clone().0)] ).map_err(Self::as_string)?; call.decode_output((do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } @@ -128,7 +128,7 @@ mod provider { vec![ethabi::Token::Address(_who.clone().0)] ).map_err(Self::as_string)?; call.decode_output((do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } @@ -180,7 +180,7 @@ mod provider { vec![ethabi::Token::Address(_new.clone().0)] ).map_err(Self::as_string)?; call.decode_output((do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - + Ok(()) } diff --git a/ethcore/src/miner/stratum.rs b/ethcore/src/miner/stratum.rs index d887f1afadb..e67cbb5e139 100644 --- a/ethcore/src/miner/stratum.rs +++ b/ethcore/src/miner/stratum.rs @@ -25,7 +25,7 @@ use std::sync::{Arc, Weak}; use std::net::{SocketAddr, AddrParseError}; use std::fmt; -use util::{H256, U256, FixedHash, H64, clean_0x}; +use util::{H256, U256, H64, clean_0x}; use ethereum::ethash::Ethash; use ethash::SeedHashCompute; use util::Mutex; diff --git a/ethcore/src/snapshot/account.rs b/ethcore/src/snapshot/account.rs index c417a79a111..44c8093b7be 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/src/snapshot/account.rs @@ -20,7 +20,7 @@ use account_db::{AccountDB, AccountDBMut}; use basic_account::BasicAccount; use snapshot::Error; -use util::{U256, FixedHash, H256, Bytes, HashDB, SHA3_EMPTY, SHA3_NULL_RLP}; +use util::{U256, H256, Bytes, HashDB, SHA3_EMPTY, SHA3_NULL_RLP}; use util::trie::{TrieDB, Trie}; use rlp::{RlpStream, Stream, UntrustedRlp, View}; @@ -179,7 +179,7 @@ mod tests { use snapshot::tests::helpers::fill_storage; use util::sha3::{SHA3_EMPTY, SHA3_NULL_RLP}; - use util::{Address, FixedHash, H256, HashDB, DBValue}; + use util::{Address, H256, HashDB, DBValue}; use rlp::{UntrustedRlp, View}; use std::collections::HashSet; diff --git a/ethcore/src/snapshot/block.rs b/ethcore/src/snapshot/block.rs index 03feb94558f..048724ec910 100644 --- a/ethcore/src/snapshot/block.rs +++ b/ethcore/src/snapshot/block.rs @@ -134,7 +134,7 @@ mod tests { use super::AbridgedBlock; use types::transaction::{Action, Transaction}; - use util::{Address, H256, FixedHash, U256, Bytes}; + use util::{Address, H256, U256, Bytes}; fn encode_block(b: &Block) -> Bytes { b.rlp_bytes(::basic_types::Seal::With) diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 53aa428b621..e8001e54b61 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -32,7 +32,7 @@ use views::BlockView; use util::{Bytes, Hashable, HashDB, DBValue, snappy, U256, Uint}; use util::Mutex; -use util::hash::{FixedHash, H256}; +use util::hash::{H256}; use util::journaldb::{self, Algorithm, JournalDB}; use util::kvdb::Database; use util::trie::{TrieDB, TrieDBMut, Trie, TrieMut}; diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index 02ca268ec95..ed356346bce 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -22,7 +22,7 @@ use account_db::AccountDBMut; use rand::Rng; use util::DBValue; -use util::hash::{FixedHash, H256}; +use util::hash::H256; use util::hashdb::HashDB; use util::trie::{Alphabet, StandardMap, SecTrieDBMut, TrieMut, ValueMode}; use util::trie::{TrieDB, TrieDBMut, Trie}; diff --git a/ethcore/src/snapshot/tests/state.rs b/ethcore/src/snapshot/tests/state.rs index 90c9e990fac..809e9fe216a 100644 --- a/ethcore/src/snapshot/tests/state.rs +++ b/ethcore/src/snapshot/tests/state.rs @@ -96,7 +96,7 @@ fn snap_and_restore() { fn get_code_from_prev_chunk() { use std::collections::HashSet; use rlp::{RlpStream, Stream}; - use util::{HashDB, H256, FixedHash, U256, Hashable}; + use util::{HashDB, H256, U256, Hashable}; use account_db::{AccountDBMut, AccountDB}; diff --git a/ethcore/src/spec/genesis.rs b/ethcore/src/spec/genesis.rs index 072fb3f0fff..bf5ec46c127 100644 --- a/ethcore/src/spec/genesis.rs +++ b/ethcore/src/spec/genesis.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -use util::{Address, H256, Uint, U256, FixedHash}; +use util::{Address, H256, Uint, U256}; use util::sha3::SHA3_NULL_RLP; use ethjson; use super::seal::Seal; diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index 3c5a3bc09a8..c34f4304137 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -940,7 +940,7 @@ mod tests { use rustc_serialize::hex::FromHex; use super::*; use ethkey::Secret; - use util::{U256, H256, FixedHash, Address, Hashable}; + use util::{U256, H256, Address, Hashable}; use tests::helpers::*; use devtools::*; use env_info::EnvInfo; diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 85d40109903..bfd1068cad4 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -454,7 +454,7 @@ impl state::Backend for StateDB { #[cfg(test)] mod tests { - use util::{U256, H256, FixedHash, Address, DBTransaction}; + use util::{U256, H256, Address, DBTransaction}; use tests::helpers::*; use state::{Account, Backend}; use util::log::init_log; diff --git a/ethcore/src/types/filter.rs b/ethcore/src/types/filter.rs index 5749c34151f..1b6043129db 100644 --- a/ethcore/src/types/filter.rs +++ b/ethcore/src/types/filter.rs @@ -113,7 +113,6 @@ impl Filter { #[cfg(test)] mod tests { - use util::FixedHash; use filter::Filter; use client::BlockId; use log_entry::LogEntry; diff --git a/ethcrypto/src/lib.rs b/ethcrypto/src/lib.rs index 07c821752a9..a4d426b54b8 100644 --- a/ethcrypto/src/lib.rs +++ b/ethcrypto/src/lib.rs @@ -195,7 +195,7 @@ pub mod ecies { use rcrypto::sha2::Sha256; use rcrypto::hmac::Hmac; use rcrypto::mac::Mac; - use bigint::hash::{FixedHash, H128}; + use bigint::hash::H128; use ethkey::{Random, Generator, Public, Secret}; use {Error, ecdh, aes, Keccak256}; diff --git a/ethkey/src/extended.rs b/ethkey/src/extended.rs index c8f057a4ba6..490014db9d8 100644 --- a/ethkey/src/extended.rs +++ b/ethkey/src/extended.rs @@ -18,7 +18,7 @@ use secret::Secret; use Public; -use bigint::hash::{H256, FixedHash}; +use bigint::hash::H256; pub use self::derivation::Error as DerivationError; /// Represents label that can be stored as a part of key derivation @@ -212,7 +212,7 @@ mod derivation { use rcrypto::hmac::Hmac; use rcrypto::mac::Mac; use rcrypto::sha2::Sha512; - use bigint::hash::{H512, H256, FixedHash}; + use bigint::hash::{H512, H256}; use bigint::prelude::{U256, U512, Uint}; use secp256k1; use secp256k1::key::{SecretKey, PublicKey}; diff --git a/ethkey/src/signature.rs b/ethkey/src/signature.rs index 63f6854e293..34722228714 100644 --- a/ethkey/src/signature.rs +++ b/ethkey/src/signature.rs @@ -22,7 +22,7 @@ use std::hash::{Hash, Hasher}; use secp256k1::{Message as SecpMessage, RecoverableSignature, RecoveryId, Error as SecpError}; use secp256k1::key::{SecretKey, PublicKey}; use rustc_serialize::hex::{ToHex, FromHex}; -use bigint::hash::{H520, H256, FixedHash}; +use bigint::hash::{H520, H256}; use {Secret, Public, SECP256K1, Error, Message, public_to_address, Address}; #[repr(C)] diff --git a/ethstore/src/dir/memory.rs b/ethstore/src/dir/memory.rs index 87d12794eb9..955afc5b0e5 100644 --- a/ethstore/src/dir/memory.rs +++ b/ethstore/src/dir/memory.rs @@ -67,7 +67,7 @@ impl KeyDirectory for MemoryDirectory { fn unique_repr(&self) -> Result { let mut val = 0u64; let accounts = self.accounts.read(); - for acc in accounts.keys() { val = val ^ ::util::FixedHash::low_u64(acc) } + for acc in accounts.keys() { val = val ^ acc.low_u64() } Ok(val) } } diff --git a/evmbin/src/ext.rs b/evmbin/src/ext.rs index bcce9adc142..a293ccc8047 100644 --- a/evmbin/src/ext.rs +++ b/evmbin/src/ext.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use std::collections::HashMap; -use util::{U256, H256, Address, Bytes, FixedHash, trie}; +use util::{U256, H256, Address, Bytes, trie}; use ethcore::client::EnvInfo; use ethcore::evm::{self, Ext, ContractCreateResult, MessageCallResult, Schedule, CallType}; diff --git a/hw/src/ledger.rs b/hw/src/ledger.rs index 255fa851546..fca1d0c3af6 100644 --- a/hw/src/ledger.rs +++ b/hw/src/ledger.rs @@ -24,7 +24,7 @@ use std::str::FromStr; use std::time::Duration; use super::WalletInfo; use ethkey::{Address, Signature}; -use ethcore_bigint::hash::{H256, FixedHash}; +use ethcore_bigint::hash::H256; const LEDGER_VID: u16 = 0x2c97; const LEDGER_PIDS: [u16; 2] = [0x0000, 0x0001]; // Nano S and Blue @@ -260,12 +260,12 @@ impl Manager { { let mut chunk = &mut hid_chunk[HID_PREFIX_ZERO..]; &mut chunk[0..5].copy_from_slice(&[0x01, 0x01, APDU_TAG, (chunk_index >> 8) as u8, (chunk_index & 0xff) as u8 ]); - + if chunk_index == 0 { let data_len = data.len() + 5; &mut chunk[5..12].copy_from_slice(&[ (data_len >> 8) as u8, (data_len & 0xff) as u8, APDU_CLA, command, p1, p2, data.len() as u8 ]); } - + &mut chunk[chunk_size..chunk_size + size].copy_from_slice(&data[offset..offset + size]); offset += size; chunk_size += size; diff --git a/ipc-common-types/src/types/version_info.rs b/ipc-common-types/src/types/version_info.rs index e36e40aefff..1f0e5845209 100644 --- a/ipc-common-types/src/types/version_info.rs +++ b/ipc-common-types/src/types/version_info.rs @@ -19,7 +19,7 @@ use std::fmt; use std::str::FromStr; use semver::{Version}; -use util::{H160, FixedHash}; +use util::H160; use util::misc::raw_package_info; use release_track::ReleaseTrack; diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 8da7063f4b3..341ab13d8a7 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -23,7 +23,7 @@ use std::sync::{Arc, Weak}; use futures::{self, future, BoxFuture, Future}; use rlp::{self, UntrustedRlp, View}; use time::get_time; -use util::{H160, H256, Address, FixedHash, U256, H64, Uint}; +use util::{H160, H256, Address, U256, H64, Uint}; use util::sha3::Hashable; use util::Mutex; diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 9b0c92e9cc0..1c3d8fffd56 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -38,7 +38,7 @@ use ethcore::transaction::{Action, SignedTransaction, Transaction as EthTransact use ethsync::LightSync; use rlp::{UntrustedRlp, View}; use util::sha3::{SHA3_NULL_RLP, SHA3_EMPTY_LIST_RLP}; -use util::{RwLock, Mutex, FixedHash, Uint, U256}; +use util::{RwLock, Mutex, Uint, U256}; use futures::{future, Future, BoxFuture, IntoFuture}; use futures::sync::oneshot; diff --git a/rpc/src/v1/tests/helpers/miner_service.rs b/rpc/src/v1/tests/helpers/miner_service.rs index c667e408bc6..f84431e6e9f 100644 --- a/rpc/src/v1/tests/helpers/miner_service.rs +++ b/rpc/src/v1/tests/helpers/miner_service.rs @@ -17,7 +17,7 @@ //! Test implementation of miner service. use std::collections::hash_map::Entry; -use util::{Address, H256, Bytes, U256, FixedHash, Uint}; +use util::{Address, H256, Bytes, U256, Uint}; use util::standard::*; use ethcore::error::{Error, CallError}; use ethcore::client::{MiningBlockChainClient, Executed, CallAnalytics}; diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 6603bd7220b..146444c21f9 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -22,7 +22,7 @@ use rustc_serialize::hex::{FromHex, ToHex}; use time::get_time; use rlp; -use util::{Uint, U256, Address, H256, FixedHash, Mutex}; +use util::{Uint, U256, Address, H256, Mutex}; use ethkey::Secret; use ethcore::account_provider::AccountProvider; use ethcore::client::{TestBlockChainClient, EachBlockWith, Executed, TransactionId}; diff --git a/rpc/src/v1/tests/mocked/signing.rs b/rpc/src/v1/tests/mocked/signing.rs index 10611f13913..e5b068b52d3 100644 --- a/rpc/src/v1/tests/mocked/signing.rs +++ b/rpc/src/v1/tests/mocked/signing.rs @@ -28,7 +28,7 @@ use v1::types::ConfirmationResponse; use v1::tests::helpers::TestMinerService; use v1::tests::mocked::parity; -use util::{Address, FixedHash, Uint, U256, ToPretty}; +use util::{Address, Uint, U256, ToPretty}; use ethkey::Secret; use ethcore::account_provider::AccountProvider; use ethcore::client::TestBlockChainClient; diff --git a/scripts/contractABI.js b/scripts/contractABI.js index 4db0fe3a199..98081123a26 100644 --- a/scripts/contractABI.js +++ b/scripts/contractABI.js @@ -32,7 +32,7 @@ use std::string::String; use std::result::Result; use std::fmt; use {util, ethabi}; -use util::{FixedHash, Uint}; +use util::Uint; ${convertContract(name, json, prefs)} `; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index ef35f064007..2212876d1b3 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -2175,7 +2175,7 @@ mod tests { use tests::snapshot::TestSnapshotService; use util::{Uint, U256, Address, RwLock}; use util::sha3::Hashable; - use util::hash::{H256, FixedHash}; + use util::hash::H256; use util::bytes::Bytes; use rlp::{Rlp, RlpStream, UntrustedRlp, View, Stream}; use super::*; diff --git a/updater/src/operations.rs b/updater/src/operations.rs index c67abcc75cc..71112d3e743 100644 --- a/updater/src/operations.rs +++ b/updater/src/operations.rs @@ -4,7 +4,7 @@ use std::string::String; use std::result::Result; use std::fmt; use ethabi; -use util::{self, FixedHash, Uint}; +use util::{self, Uint}; pub struct Operations { contract: ethabi::Contract, @@ -20,340 +20,340 @@ impl Operations { } } fn as_string(e: T) -> String { format!("{:?}", e) } - + /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"resetClientOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn reset_client_owner(&self, _client: &str, _new_owner: &util::Address) -> Result<(), String> { + pub fn reset_client_owner(&self, _client: &str, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("resetClientOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Address(_new_owner.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"isLatest","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn is_latest(&self, _client: &str, _release: &util::H256) -> Result { + pub fn is_latest(&self, _client: &str, _release: &util::H256) -> Result { let call = self.contract.function("isLatest".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"rejectTransaction","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn reject_transaction(&self, _txid: &util::H256) -> Result<(), String> { + pub fn reject_transaction(&self, _txid: &util::H256) -> Result<(), String> { let call = self.contract.function("rejectTransaction".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned())] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn set_owner(&self, _new_owner: &util::Address) -> Result<(), String> { + pub fn set_owner(&self, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("setOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::Address(_new_owner.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_number","type":"uint32"},{"name":"_name","type":"bytes32"},{"name":"_hard","type":"bool"},{"name":"_spec","type":"bytes32"}],"name":"proposeFork","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn propose_fork(&self, _number: u32, _name: &util::H256, _hard: bool, _spec: &util::H256) -> Result<(), String> { + pub fn propose_fork(&self, _number: u32, _name: &util::H256, _hard: bool, _spec: &util::H256) -> Result<(), String> { let call = self.contract.function("proposeFork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_number as u64).to_big_endian(&mut r); r }), ethabi::Token::FixedBytes(_name.as_ref().to_owned()), ethabi::Token::Bool(_hard), ethabi::Token::FixedBytes(_spec.as_ref().to_owned())] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"}],"name":"removeClient","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn remove_client(&self, _client: &str) -> Result<(), String> { + pub fn remove_client(&self, _client: &str) -> Result<(), String> { let call = self.contract.function("removeClient".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned())] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"release","outputs":[{"name":"o_forkBlock","type":"uint32"},{"name":"o_track","type":"uint8"},{"name":"o_semver","type":"uint24"},{"name":"o_critical","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn release(&self, _client: &str, _release: &util::H256) -> Result<(u32, u8, u32, bool), String> { + pub fn release(&self, _client: &str, _release: &util::H256) -> Result<(u32, u8, u32, bool), String> { let call = self.contract.function("release".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u8 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u8 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"build","outputs":[{"name":"o_release","type":"bytes32"},{"name":"o_platform","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn build(&self, _client: &str, _checksum: &util::H256) -> Result<(util::H256, util::H256), String> { + pub fn build(&self, _client: &str, _checksum: &util::H256) -> Result<(util::H256, util::H256), String> { let call = self.contract.function("build".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) } /// Auto-generated from: `{"constant":false,"inputs":[],"name":"rejectFork","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn reject_fork(&self) -> Result<(), String> { + pub fn reject_fork(&self) -> Result<(), String> { let call = self.contract.function("rejectFork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"client","outputs":[{"name":"owner","type":"address"},{"name":"required","type":"bool"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn client(&self, _1: &util::H256) -> Result<(util::Address, bool), String> { + pub fn client(&self, _1: &util::H256) -> Result<(util::Address, bool), String> { let call = self.contract.function("client".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"setClientOwner","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn set_client_owner(&self, _new_owner: &util::Address) -> Result<(), String> { + pub fn set_client_owner(&self, _new_owner: &util::Address) -> Result<(), String> { let call = self.contract.function("setClientOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::Address(_new_owner.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"uint32"}],"name":"fork","outputs":[{"name":"name","type":"bytes32"},{"name":"spec","type":"bytes32"},{"name":"hard","type":"bool"},{"name":"ratified","type":"bool"},{"name":"requiredCount","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn fork(&self, _1: u32) -> Result<(util::H256, util::H256, bool, bool, util::U256), String> { + pub fn fork(&self, _1: u32) -> Result<(util::H256, util::H256, bool, bool, util::U256), String> { let call = self.contract.function("fork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_1 as u64).to_big_endian(&mut r); r })] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"},{"name":"_checksum","type":"bytes32"}],"name":"addChecksum","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn add_checksum(&self, _release: &util::H256, _platform: &str, _checksum: &util::H256) -> Result<(), String> { + pub fn add_checksum(&self, _release: &util::H256, _platform: &str, _checksum: &util::H256) -> Result<(), String> { let call = self.contract.function("addChecksum".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned()), ethabi::Token::FixedBytes(_checksum.as_ref().to_owned())] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"confirmTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn confirm_transaction(&self, _txid: &util::H256) -> Result { + pub fn confirm_transaction(&self, _txid: &util::H256) -> Result { let call = self.contract.function("confirmTransaction".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proxy","outputs":[{"name":"requiredCount","type":"uint256"},{"name":"to","type":"address"},{"name":"data","type":"bytes"},{"name":"value","type":"uint256"},{"name":"gas","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn proxy(&self, _1: &util::H256) -> Result<(util::U256, util::Address, Vec, util::U256, util::U256), String> { + pub fn proxy(&self, _1: &util::H256) -> Result<(util::U256, util::Address, Vec, util::U256, util::U256), String> { let call = self.contract.function("proxy".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_1.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bytes().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bytes().ok_or("Invalid type returned")?; r }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) }, { let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_owner","type":"address"}],"name":"addClient","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn add_client(&self, _client: &str, _owner: &util::Address) -> Result<(), String> { + pub fn add_client(&self, _client: &str, _owner: &util::Address) -> Result<(), String> { let call = self.contract.function("addClient".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Address(_owner.clone().0)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"clientOwner","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn client_owner(&self, _1: &util::Address) -> Result { + pub fn client_owner(&self, _1: &util::Address) -> Result { let call = self.contract.function("clientOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::Address(_1.clone().0)] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"},{"name":"_value","type":"uint256"},{"name":"_gas","type":"uint256"}],"name":"proposeTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn propose_transaction(&self, _txid: &util::H256, _to: &util::Address, _data: &[u8], _value: util::U256, _gas: util::U256) -> Result { + pub fn propose_transaction(&self, _txid: &util::H256, _to: &util::Address, _data: &[u8], _value: util::U256, _gas: util::U256) -> Result { let call = self.contract.function("proposeTransaction".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_txid.as_ref().to_owned()), ethabi::Token::Address(_to.clone().0), ethabi::Token::Bytes(_data.to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; _value.to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; _gas.to_big_endian(&mut r); r })] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()) })) } /// Auto-generated from: `{"constant":true,"inputs":[],"name":"grandOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn grand_owner(&self) -> Result { + pub fn grand_owner(&self) -> Result { let call = self.contract.function("grandOwner".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; util::Address::from(r) })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_forkBlock","type":"uint32"},{"name":"_track","type":"uint8"},{"name":"_semver","type":"uint24"},{"name":"_critical","type":"bool"}],"name":"addRelease","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn add_release(&self, _release: &util::H256, _fork_block: u32, _track: u8, _semver: u32, _critical: bool) -> Result<(), String> { + pub fn add_release(&self, _release: &util::H256, _fork_block: u32, _track: u8, _semver: u32, _critical: bool) -> Result<(), String> { let call = self.contract.function("addRelease".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_fork_block as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_track as u64).to_big_endian(&mut r); r }), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_semver as u64).to_big_endian(&mut r); r }), ethabi::Token::Bool(_critical)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":false,"inputs":[],"name":"acceptFork","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn accept_fork(&self) -> Result<(), String> { + pub fn accept_fork(&self) -> Result<(), String> { let call = self.contract.function("acceptFork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[],"name":"clientsRequired","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn clients_required(&self) -> Result { + pub fn clients_required(&self) -> Result { let call = self.contract.function("clientsRequired".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"track","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn track(&self, _client: &str, _release: &util::H256) -> Result { + pub fn track(&self, _client: &str, _release: &util::H256) -> Result { let call = self.contract.function("track".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u8 })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u8 })) } /// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_r","type":"bool"}],"name":"setClientRequired","outputs":[],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn set_client_required(&self, _client: &str, _r: bool) -> Result<(), String> { + pub fn set_client_required(&self, _client: &str, _r: bool) -> Result<(), String> { let call = self.contract.function("setClientRequired".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Bool(_r)] ).map_err(Self::as_string)?; call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; - - Ok(()) + + Ok(()) } /// Auto-generated from: `{"constant":true,"inputs":[],"name":"latestFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn latest_fork(&self) -> Result { + pub fn latest_fork(&self) -> Result { let call = self.contract.function("latestFork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_track","type":"uint8"}],"name":"latestInTrack","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn latest_in_track(&self, _client: &str, _track: u8) -> Result { + pub fn latest_in_track(&self, _client: &str, _track: u8) -> Result { let call = self.contract.function("latestInTrack".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::Uint({ let mut r = [0u8; 32]; util::U256::from(_track as u64).to_big_endian(&mut r); r })] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) } /// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"}],"name":"checksum","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn checksum(&self, _client: &str, _release: &util::H256, _platform: &str) -> Result { + pub fn checksum(&self, _client: &str, _release: &util::H256, _platform: &str) -> Result { let call = self.contract.function("checksum".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![ethabi::Token::FixedBytes(_client.as_bytes().to_owned()), ethabi::Token::FixedBytes(_release.as_ref().to_owned()), ethabi::Token::FixedBytes(_platform.as_bytes().to_owned())] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; util::H256::from_slice(r.as_ref()) })) } /// Auto-generated from: `{"constant":true,"inputs":[],"name":"proposedFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}` #[allow(dead_code)] - pub fn proposed_fork(&self) -> Result { + pub fn proposed_fork(&self) -> Result { let call = self.contract.function("proposedFork".into()).map_err(Self::as_string)?; let data = call.encode_call( vec![] ).map_err(Self::as_string)?; let output = call.decode_output((self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?; let mut result = output.into_iter().rev().collect::>(); - Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) + Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; util::U256::from(r.as_ref()).as_u64() as u32 })) } -} \ No newline at end of file +} diff --git a/updater/src/updater.rs b/updater/src/updater.rs index a6c374e10ed..c2bc98273e8 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -22,7 +22,7 @@ use target_info::Target; use util::misc; use ipc_common_types::{VersionInfo, ReleaseTrack}; use util::path::restrict_permissions_owner; -use util::{Address, H160, H256, FixedHash, Mutex, Bytes}; +use util::{Address, H160, H256, Mutex, Bytes}; use ethsync::{SyncProvider}; use ethcore::client::{BlockId, BlockChainClient, ChainNotify}; use hash_fetch::{self as fetch, HashFetch}; diff --git a/util/bigint/src/hash.rs b/util/bigint/src/hash.rs index cf74ea0cbe8..51407033bdc 100644 --- a/util/bigint/src/hash.rs +++ b/util/bigint/src/hash.rs @@ -28,32 +28,6 @@ use rustc_serialize::hex::{FromHex, FromHexError}; use bigint::{Uint, U256}; use libc::{c_void, memcmp}; -/// Trait for a fixed-size byte array to be used as the output of hash functions. -pub trait FixedHash: Sized { - /// Create a new, zero-initialised, instance. - fn new() -> Self; - /// Synonym for `new()`. Prefer to new as it's more readable. - fn zero() -> Self; - /// Create a new, cryptographically random, instance. - fn random() -> Self; - /// Assign self have a cryptographically random value. - fn randomize(&mut self); - /// Get the size of this object in bytes. - fn len() -> usize; - /// Convert a slice of bytes of length `len()` to an instance of this type. - fn from_slice(src: &[u8]) -> Self; - /// Assign self to be of the same value as a slice of bytes of length `len()`. - fn clone_from_slice(&mut self, src: &[u8]) -> usize; - /// Copy the data of this object into some mutable slice of length `len()`. - fn copy_to(&self, dest: &mut [u8]); - /// Returns `true` if all bits set in `b` are also set in `self`. - fn contains<'a>(&'a self, b: &'a Self) -> bool; - /// Returns `true` if no bits are set. - fn is_zero(&self) -> bool; - /// Returns the lowest 8 bytes interpreted as a BigEndian integer. - fn low_u64(&self) -> u64; -} - /// Return `s` without the `0x` at the beginning of it, if any. pub fn clean_0x(s: &str) -> &str { if s.starts_with("0x") { @@ -105,57 +79,68 @@ macro_rules! impl_hash { } } - impl FixedHash for $from { - fn new() -> $from { + impl $from { + /// Create a new, zero-initialised, instance. + pub fn new() -> $from { $from([0; $size]) } - fn zero() -> $from { + /// Synonym for `new()`. Prefer to new as it's more readable. + pub fn zero() -> $from { $from([0; $size]) } - fn random() -> $from { + /// Create a new, cryptographically random, instance. + pub fn random() -> $from { let mut hash = $from::new(); hash.randomize(); hash } - fn randomize(&mut self) { + /// Assign self have a cryptographically random value. + pub fn randomize(&mut self) { let mut rng = OsRng::new().unwrap(); rng.fill_bytes(&mut self.0); } - fn len() -> usize { + /// Get the size of this object in bytes. + pub fn len() -> usize { $size } #[inline] - fn clone_from_slice(&mut self, src: &[u8]) -> usize { + /// Assign self to be of the same value as a slice of bytes of length `len()`. + pub fn clone_from_slice(&mut self, src: &[u8]) -> usize { let min = cmp::min($size, src.len()); self.0[..min].copy_from_slice(&src[..min]); min } - fn from_slice(src: &[u8]) -> Self { + /// Convert a slice of bytes of length `len()` to an instance of this type. + pub fn from_slice(src: &[u8]) -> Self { let mut r = Self::new(); r.clone_from_slice(src); r } - fn copy_to(&self, dest: &mut[u8]) { + /// Copy the data of this object into some mutable slice of length `len()`. + pub fn copy_to(&self, dest: &mut[u8]) { let min = cmp::min($size, dest.len()); dest[..min].copy_from_slice(&self.0[..min]); } - fn contains<'a>(&'a self, b: &'a Self) -> bool { + /// Returns `true` if all bits set in `b` are also set in `self`. + pub fn contains<'a>(&'a self, b: &'a Self) -> bool { &(b & self) == b } - fn is_zero(&self) -> bool { + /// Returns `true` if no bits are set. + pub fn is_zero(&self) -> bool { self.eq(&Self::new()) } - fn low_u64(&self) -> u64 { + /// Returns the lowest 8 bytes interpreted as a BigEndian integer. + pub fn low_u64(&self) -> u64 { let mut ret = 0u64; for i in 0..min($size, 8) { ret |= (self.0[$size - 1 - i] as u64) << (i * 8); diff --git a/util/network/src/discovery.rs b/util/network/src/discovery.rs index 04ad0b7ce42..f3a8aa523ac 100644 --- a/util/network/src/discovery.rs +++ b/util/network/src/discovery.rs @@ -556,7 +556,6 @@ impl Discovery { mod tests { use super::*; use std::net::{SocketAddr}; - use util::FixedHash; use node_table::{Node, NodeId, NodeEndpoint}; use std::str::FromStr; diff --git a/util/network/src/handshake.rs b/util/network/src/handshake.rs index 6ae775f97ce..9f6474c39de 100644 --- a/util/network/src/handshake.rs +++ b/util/network/src/handshake.rs @@ -333,7 +333,7 @@ mod test { use std::sync::Arc; use rustc_serialize::hex::FromHex; use super::*; - use util::hash::{H256, FixedHash}; + use util::hash::H256; use io::*; use mio::tcp::TcpStream; use stats::NetworkStats; diff --git a/util/src/bloom.rs b/util/src/bloom.rs index a54e8073c0b..c39921f5d55 100644 --- a/util/src/bloom.rs +++ b/util/src/bloom.rs @@ -18,7 +18,7 @@ use std::mem; use std::ops::DerefMut; -use {H64, H160, H256, H512, H520, H2048, FixedHash}; +use {H64, H160, H256, H512, H520, H2048}; /// Returns log2. pub fn log2(x: usize) -> u32 { diff --git a/util/src/sha3.rs b/util/src/sha3.rs index 45d6a34d500..8adcfbfeec9 100644 --- a/util/src/sha3.rs +++ b/util/src/sha3.rs @@ -19,7 +19,7 @@ extern crate sha3 as sha3_ext; use std::io; use tiny_keccak::Keccak; -use hash::{H256, FixedHash}; +use hash::H256; use self::sha3_ext::*; /// Get the SHA3 (i.e. Keccak) hash of the empty bytes string.