port ethcore

This commit is contained in:
Robert Habermeier 2016-09-01 14:29:59 +02:00
parent eb7b62a61c
commit 5dd56aa070
47 changed files with 113 additions and 77 deletions

View File

@ -16,7 +16,7 @@
//! DB backend wrapper for Account trie
use util::*;
use util::sha3::SHA3_NULL_RLP;
use rlp::NULL_RLP;
static NULL_RLP_STATIC: [u8; 1] = [0x80; 1];

View File

@ -22,6 +22,7 @@ use state::*;
use verification::PreverifiedBlock;
use trace::FlatTrace;
use factory::Factories;
use rlp::*;
/// A block, encoded as it is on the block chain.
#[derive(Default, Debug, Clone, PartialEq)]

View File

@ -18,6 +18,7 @@
use bloomchain as bc;
use util::*;
use rlp::*;
use header::*;
use super::extras::*;
use transaction::*;

View File

@ -18,6 +18,7 @@
use bloomchain;
use util::*;
use rlp::*;
use header::BlockNumber;
use receipt::Receipt;
use db::Key;

View File

@ -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::rlp::*;
use rlp::*;
use util::{H256, H2048};
use util::bytes::Bytes;
use header::Header;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use bloomchain as bc;
use util::rlp::*;
use rlp::*;
use util::HeapSizeOf;
use basic_types::LogBloom;

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use bloomchain::group as bc;
use util::rlp::*;
use rlp::*;
use util::HeapSizeOf;
use super::Bloom;

View File

@ -22,11 +22,11 @@ use std::time::{Instant};
use time::precise_time_ns;
// util
use util::{journaldb, rlp, Bytes, View, PerfTimer, Itertools, Mutex, RwLock};
use util::journaldb::JournalDB;
use util::rlp::{UntrustedRlp};
use util::{Bytes, PerfTimer, Itertools, Mutex, RwLock};
use util::journaldb::{self, JournalDB};
use util::{U256, H256, Address, H2048, Uint};
use util::sha3::*;
use util::TrieFactory;
use util::kvdb::*;
// other
@ -63,9 +63,10 @@ use trace;
use trace::FlatTransactionTraces;
use evm::Factory as EvmFactory;
use miner::{Miner, MinerService};
use util::TrieFactory;
use snapshot::{self, io as snapshot_io};
use factory::Factories;
use rlp::{View, UntrustedRlp};
// re-export
pub use types::blockchain_info::BlockChainInfo;
@ -877,7 +878,7 @@ impl BlockChainClient for Client {
}
fn block_receipts(&self, hash: &H256) -> Option<Bytes> {
self.chain.block_receipts(hash).map(|receipts| rlp::encode(&receipts).to_vec())
self.chain.block_receipts(hash).map(|receipts| ::rlp::encode(&receipts).to_vec())
}
fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError> {

View File

@ -18,6 +18,7 @@
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrder};
use util::*;
use rlp::*;
use ethkey::{Generator, Random};
use devtools::*;
use transaction::{Transaction, LocalizedTransaction, SignedTransaction, Action};
@ -204,7 +205,7 @@ impl TestBlockChainClient {
txs.append(&signed_tx);
txs.out()
},
_ => rlp::EMPTY_LIST_RLP.to_vec()
_ => ::rlp::EMPTY_LIST_RLP.to_vec()
};
let mut rlp = RlpStream::new_list(3);
@ -222,8 +223,8 @@ impl TestBlockChainClient {
header.set_extra_data(b"This extra data is way too long to be considered valid".to_vec());
let mut rlp = RlpStream::new_list(3);
rlp.append(&header);
rlp.append_raw(&rlp::NULL_RLP, 1);
rlp.append_raw(&rlp::NULL_RLP, 1);
rlp.append_raw(&::rlp::NULL_RLP, 1);
rlp.append_raw(&::rlp::NULL_RLP, 1);
self.blocks.write().insert(hash, rlp.out());
}
@ -234,8 +235,8 @@ impl TestBlockChainClient {
header.set_parent_hash(H256::from(42));
let mut rlp = RlpStream::new_list(3);
rlp.append(&header);
rlp.append_raw(&rlp::NULL_RLP, 1);
rlp.append_raw(&rlp::NULL_RLP, 1);
rlp.append_raw(&::rlp::NULL_RLP, 1);
rlp.append_raw(&::rlp::NULL_RLP, 1);
self.blocks.write().insert(hash, rlp.out());
}

View File

@ -20,7 +20,8 @@ use std::ops::Deref;
use std::hash::Hash;
use std::collections::HashMap;
use util::{DBTransaction, Database, RwLock};
use util::rlp::{encode, Encodable, decode, Decodable};
use rlp;
// database columns
/// Column for State
@ -83,12 +84,12 @@ pub trait Key<T> {
/// Should be used to write value into database.
pub trait Writable {
/// Writes the value into the database.
fn write<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>, value: &T) where T: Encodable, R: Deref<Target = [u8]>;
fn write<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>, value: &T) where T: rlp::Encodable, R: Deref<Target = [u8]>;
/// Writes the value into the database and updates the cache.
fn write_with_cache<K, T, R>(&mut self, col: Option<u32>, cache: &mut Cache<K, T>, key: K, value: T, policy: CacheUpdatePolicy) where
K: Key<T, Target = R> + Hash + Eq,
T: Encodable,
T: rlp::Encodable,
R: Deref<Target = [u8]> {
self.write(col, &key, &value);
match policy {
@ -104,7 +105,7 @@ pub trait Writable {
/// Writes the values into the database and updates the cache.
fn extend_with_cache<K, T, R>(&mut self, col: Option<u32>, cache: &mut Cache<K, T>, values: HashMap<K, T>, policy: CacheUpdatePolicy) where
K: Key<T, Target = R> + Hash + Eq,
T: Encodable,
T: rlp::Encodable,
R: Deref<Target = [u8]> {
match policy {
CacheUpdatePolicy::Overwrite => {
@ -127,13 +128,13 @@ pub trait Writable {
pub trait Readable {
/// Returns value for given key.
fn read<T, R>(&self, col: Option<u32>, key: &Key<T, Target = R>) -> Option<T> where
T: Decodable,
T: rlp::Decodable,
R: Deref<Target = [u8]>;
/// Returns value for given key either in cache or in database.
fn read_with_cache<K, T, C>(&self, col: Option<u32>, cache: &RwLock<C>, key: &K) -> Option<T> where
K: Key<T> + Eq + Hash + Clone,
T: Clone + Decodable,
T: Clone + rlp::Decodable,
C: Cache<K, T> {
{
let read = cache.read();
@ -169,17 +170,17 @@ pub trait Readable {
}
impl Writable for DBTransaction {
fn write<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>, value: &T) where T: Encodable, R: Deref<Target = [u8]> {
self.put(col, &key.key(), &encode(value));
fn write<T, R>(&mut self, col: Option<u32>, key: &Key<T, Target = R>, value: &T) where T: rlp::Encodable, R: Deref<Target = [u8]> {
self.put(col, &key.key(), &rlp::encode(value));
}
}
impl Readable for Database {
fn read<T, R>(&self, col: Option<u32>, key: &Key<T, Target = R>) -> Option<T> where T: Decodable, R: Deref<Target = [u8]> {
fn read<T, R>(&self, col: Option<u32>, key: &Key<T, Target = R>) -> Option<T> where T: rlp::Decodable, R: Deref<Target = [u8]> {
let result = self.get(col, &key.key());
match result {
Ok(option) => option.map(|v| decode(&v)),
Ok(option) => option.map(|v| rlp::decode(&v)),
Err(err) => {
panic!("db get failed, key: {:?}, err: {:?}", &key.key() as &[u8], err);
}

View File

@ -109,7 +109,7 @@ impl Engine for BasicAuthority {
let message = header.bare_hash();
// account should be pernamently unlocked, otherwise sealing will fail
if let Ok(signature) = ap.sign(*block.header().author(), message) {
return Some(vec![encode(&(&*signature as &[u8])).to_vec()]);
return Some(vec![::rlp::encode(&(&*signature as &[u8])).to_vec()]);
} else {
trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable");
}
@ -131,6 +131,8 @@ impl Engine for BasicAuthority {
}
fn verify_block_unordered(&self, header: &Header, _block: Option<&[u8]>) -> result::Result<(), Error> {
use rlp::{UntrustedRlp, View};
// check the signature is legit.
let sig = try!(UntrustedRlp::new(&header.seal()[0]).as_val::<H520>());
let signer = public_to_address(&try!(recover(&sig.into(), &header.bare_hash())));
@ -172,7 +174,7 @@ impl Engine for BasicAuthority {
impl Header {
/// Get the none field of the header.
pub fn signature(&self) -> H520 {
decode(&self.seal()[0])
::rlp::decode(&self.seal()[0])
}
}
@ -228,7 +230,7 @@ mod tests {
fn can_do_signature_verification_fail() {
let engine = new_test_authority().engine;
let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H520::default()).to_vec()]);
header.set_seal(vec![::rlp::encode(&H520::default()).to_vec()]);
let verify_result = engine.verify_block_unordered(&header, None);
assert!(verify_result.is_err());

View File

@ -100,7 +100,7 @@ mod tests {
assert!(engine.verify_block_basic(&header, None).is_ok());
header.set_seal(vec![rlp::encode(&H520::default()).to_vec()]);
header.set_seal(vec![::rlp::encode(&H520::default()).to_vec()]);
assert!(engine.verify_block_unordered(&header, None).is_ok());
}

View File

@ -302,8 +302,8 @@ impl From<ExecutionError> for Error {
}
}
impl From<DecoderError> for Error {
fn from(err: DecoderError) -> Error {
impl From<::rlp::DecoderError> for Error {
fn from(err: ::rlp::DecoderError) -> Error {
Error::Util(UtilError::Decoder(err))
}
}

View File

@ -21,6 +21,7 @@ use spec::CommonParams;
use engines::Engine;
use evm::Schedule;
use ethjson;
use rlp::{self, UntrustedRlp, View};
/// Ethash params.
#[derive(Debug, PartialEq)]
@ -328,17 +329,17 @@ impl Ethash {
impl Header {
/// Get the none field of the header.
pub fn nonce(&self) -> H64 {
decode(&self.seal()[1])
rlp::decode(&self.seal()[1])
}
/// Get the mix hash field of the header.
pub fn mix_hash(&self) -> H256 {
decode(&self.seal()[0])
rlp::decode(&self.seal()[0])
}
/// Set the nonce and mix hash fields of the header.
pub fn set_nonce_and_mix_hash(&mut self, nonce: &H64, mix_hash: &H256) {
self.set_seal(vec![encode(mix_hash).to_vec(), encode(nonce).to_vec()]);
self.set_seal(vec![rlp::encode(mix_hash).to_vec(), rlp::encode(nonce).to_vec()]);
}
}
@ -349,6 +350,7 @@ mod tests {
use tests::helpers::*;
use super::super::new_morden;
use super::Ethash;
use rlp;
#[test]
fn on_close_block() {

View File

@ -32,6 +32,8 @@ const MAX_VM_DEPTH_FOR_THREAD: usize = 64;
/// Returns new address created from address and given nonce.
pub fn contract_address(address: &Address, nonce: &U256) -> Address {
use rlp::{RlpStream, Stream};
let mut stream = RlpStream::new_list(2);
stream.append(address);
stream.append(nonce);

View File

@ -19,6 +19,7 @@
use util::*;
use basic_types::*;
use time::get_time;
use rlp::*;
use std::cell::RefCell;
@ -297,7 +298,7 @@ impl Encodable for Header {
#[cfg(test)]
mod tests {
use rustc_serialize::hex::FromHex;
use util::rlp::{decode, encode};
use rlp;
use super::Header;
#[test]
@ -307,7 +308,7 @@ mod tests {
let mix_hash = "a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd".from_hex().unwrap();
let nonce = "88ab4e252a7e8c2a23".from_hex().unwrap();
let header: Header = decode(&header_rlp);
let header: Header = rlp::decode(&header_rlp);
let seal_fields = header.seal;
assert_eq!(seal_fields.len(), 2);
assert_eq!(seal_fields[0], mix_hash);
@ -319,8 +320,8 @@ mod tests {
// that's rlp of block header created with ethash engine.
let header_rlp = "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23".from_hex().unwrap();
let header: Header = decode(&header_rlp);
let encoded_header = encode(&header).to_vec();
let header: Header = rlp::decode(&header_rlp);
let encoded_header = rlp::encode(&header).to_vec();
assert_eq!(header_rlp, encoded_header);
}

View File

@ -17,6 +17,7 @@
use super::test_common::*;
use evm;
use ethjson;
use rlp::{UntrustedRlp, View};
fn do_json_test(json_data: &[u8]) -> Vec<String> {
let tests = ethjson::transaction::Test::load(json_data).unwrap();

View File

@ -17,7 +17,7 @@
//! This migration compresses the state db.
use util::migration::{SimpleMigration, Progress};
use util::rlp::{Compressible, UntrustedRlp, View, RlpType};
use rlp::{Compressible, UntrustedRlp, View, RlpType};
/// Compressing migration.
#[derive(Default)]

View File

@ -23,9 +23,11 @@ use util::Bytes;
use util::{Address, FixedHash, H256};
use util::kvdb::Database;
use util::migration::{Batch, Config, Error, Migration, SimpleMigration, Progress};
use util::rlp::{decode, Rlp, RlpStream, Stream, View};
use util::sha3::Hashable;
use rlp::{decode, Rlp, RlpStream, Stream, View};
// attempt to migrate a key, value pair. None if migration not possible.
fn attempt_migrate(mut key_h: H256, val: &[u8]) -> Option<H256> {
let val_hash = val.sha3();

View File

@ -17,7 +17,7 @@
//! This migration consolidates all databases into single one using Column Families.
use util::{Rlp, RlpStream, View, Stream};
use rlp::{Rlp, RlpStream, View, Stream};
use util::kvdb::Database;
use util::migration::{Batch, Config, Error, Migration, Progress};

View File

@ -1229,6 +1229,8 @@ mod test {
#[test]
fn should_reject_incorectly_signed_transaction() {
use rlp::{self, RlpStream, Stream};
// given
let mut txq = TransactionQueue::new();
let tx = new_unsigned_tx(123.into(), 1.into());
@ -1243,7 +1245,7 @@ mod test {
s.append(&0u64); // v
s.append(&U256::zero()); // r
s.append(&U256::zero()); // s
decode(s.as_raw())
rlp::decode(s.as_raw())
};
// when
let res = txq.add(stx, &default_account_details, TransactionOrigin::External);

View File

@ -19,6 +19,7 @@ use state::Account;
use account_db::AccountDBMut;
use ethjson;
use types::account_diff::*;
use rlp::{self, RlpStream, Stream};
#[derive(Debug, Clone, PartialEq, Eq)]
/// An account, expressed as Plain-Old-Data (hence the name).
@ -57,7 +58,7 @@ impl PodAccount {
let mut stream = RlpStream::new_list(4);
stream.append(&self.nonce);
stream.append(&self.balance);
stream.append(&sec_trie_root(self.storage.iter().map(|(k, v)| (k.to_vec(), encode(&U256::from(v.as_slice())).to_vec())).collect()));
stream.append(&sec_trie_root(self.storage.iter().map(|(k, v)| (k.to_vec(), rlp::encode(&U256::from(v.as_slice())).to_vec())).collect()));
stream.append(&self.code.as_ref().unwrap_or(&vec![]).sha3());
stream.out()
}
@ -71,7 +72,7 @@ impl PodAccount {
let mut r = H256::new();
let mut t = SecTrieDBMut::new(db, &mut r);
for (k, v) in &self.storage {
if let Err(e) = t.insert(k, &encode(&U256::from(v.as_slice()))) {
if let Err(e) = t.insert(k, &rlp::encode(&U256::from(v.as_slice()))) {
warn!("Encountered potential DB corruption: {}", e);
}
}

View File

@ -17,11 +17,12 @@
//! Account state encoding and decoding
use account_db::{AccountDB, AccountDBMut};
use util::{U256, FixedHash, H256, Bytes, HashDB, SHA3_EMPTY};
use util::rlp::{Rlp, RlpStream, Stream, UntrustedRlp, View};
use util::trie::{TrieDB, Trie};
use snapshot::Error;
use util::{U256, FixedHash, H256, Bytes, HashDB, SHA3_EMPTY};
use util::trie::{TrieDB, Trie};
use rlp::{Rlp, RlpStream, Stream, UntrustedRlp, View};
use std::collections::{HashMap, HashSet};
// whether an encoded account has code and how it is referred to.
@ -206,9 +207,9 @@ mod tests {
use tests::helpers::get_temp_journal_db;
use snapshot::tests::helpers::fill_storage;
use util::{SHA3_NULL_RLP, SHA3_EMPTY};
use util::sha3::{SHA3_EMPTY, SHA3_NULL_RLP};
use util::{Address, FixedHash, H256, HashDB};
use util::rlp::{UntrustedRlp, View};
use rlp::{UntrustedRlp, View};
use std::collections::{HashSet, HashMap};

View File

@ -20,8 +20,8 @@ use block::Block;
use header::Header;
use views::BlockView;
use util::rlp::{DecoderError, RlpStream, Stream, UntrustedRlp, View};
use util::rlp::{Compressible, RlpType};
use rlp::{DecoderError, RlpStream, Stream, UntrustedRlp, View};
use rlp::{Compressible, RlpType};
use util::{Bytes, Hashable, H256};
const HEADER_FIELDS: usize = 10;

View File

@ -22,7 +22,7 @@ use ids::BlockID;
use util::H256;
use util::trie::TrieError;
use util::rlp::DecoderError;
use rlp::DecoderError;
/// Snapshot-related errors.
#[derive(Debug)]

View File

@ -27,7 +27,7 @@ use std::path::{Path, PathBuf};
use util::Bytes;
use util::hash::H256;
use util::rlp::{self, Encodable, RlpStream, UntrustedRlp, Stream, View};
use rlp::{self, Encodable, RlpStream, UntrustedRlp, Stream, View};
use super::ManifestData;

View File

@ -32,9 +32,9 @@ use util::Mutex;
use util::hash::{FixedHash, H256};
use util::journaldb::{self, Algorithm, JournalDB};
use util::kvdb::Database;
use util::rlp::{DecoderError, RlpStream, Stream, UntrustedRlp, View, Compressible, RlpType};
use util::rlp::SHA3_NULL_RLP;
use util::sha3::SHA3_NULL_RLP;
use util::trie::{TrieDB, TrieDBMut, Trie, TrieMut};
use rlp::{DecoderError, RlpStream, Stream, UntrustedRlp, View, Compressible, RlpType};
use self::account::Account;
use self::block::AbridgedBlock;

View File

@ -25,7 +25,7 @@ use util::hash::{FixedHash, H256};
use util::hashdb::HashDB;
use util::trie::{Alphabet, StandardMap, SecTrieDBMut, TrieMut, ValueMode};
use util::trie::{TrieDB, TrieDBMut, Trie};
use util::rlp::SHA3_NULL_RLP;
use util::sha3::SHA3_NULL_RLP;
// the proportion of accounts we will alter each tick.
const ACCOUNT_CHURN: f32 = 0.01;

View File

@ -14,8 +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::rlp::*;
use util::{Address, H256, Uint, U256};
use util::sha3::SHA3_NULL_RLP;
use ethjson;
use super::seal::Seal;

View File

@ -16,7 +16,7 @@
//! Spec seal.
use util::rlp::*;
use rlp::*;
use util::hash::{H64, H256};
use ethjson;

View File

@ -24,6 +24,7 @@ use super::genesis::Genesis;
use super::seal::Generic as GenericSeal;
use ethereum;
use ethjson;
use rlp::{Rlp, RlpStream, View, Stream};
/// Parameters common to all engines.
#[derive(Debug, PartialEq, Clone)]

View File

@ -19,6 +19,7 @@
use std::collections::hash_map::Entry;
use util::*;
use pod_account::*;
use rlp::*;
use std::cell::{Ref, RefCell, Cell};
@ -333,6 +334,7 @@ mod tests {
use util::*;
use super::*;
use account_db::*;
use rlp::*;
#[test]
fn account_compress() {

View File

@ -22,6 +22,7 @@ use tests::helpers::*;
use common::*;
use devtools::*;
use miner::Miner;
use rlp::{Rlp, View};
#[test]
fn imports_from_empty() {

View File

@ -27,6 +27,7 @@ use engines::Engine;
use ethereum;
use devtools::*;
use miner::Miner;
use rlp::{self, RlpStream, Stream};
#[cfg(feature = "json-tests")]
pub enum ChainEra {
@ -116,7 +117,7 @@ pub fn create_test_block_with_data(header: &Header, transactions: &[SignedTransa
rlp.append(header);
rlp.begin_list(transactions.len());
for t in transactions {
rlp.append_raw(&encode::<SignedTransaction>(t).to_vec(), 1);
rlp.append_raw(&rlp::encode::<SignedTransaction>(t).to_vec(), 1);
}
rlp.append(&uncles);
rlp.out()

View File

@ -1,6 +1,6 @@
use bloomchain::Bloom;
use bloomchain::group::{BloomGroup, GroupPosition};
use util::rlp::*;
use rlp::*;
use basic_types::LogBloom;
/// Helper structure representing bloom of the trace.

View File

@ -17,7 +17,7 @@
//! Transaction execution format module.
use util::{Bytes, U256, Address, U512};
use util::rlp::*;
use rlp::*;
use trace::{VMTrace, FlatTrace};
use types::log_entry::LogEntry;
use types::state_diff::StateDiff;
@ -203,7 +203,8 @@ pub type ExecutionResult = Result<Executed, ExecutionError>;
#[test]
fn should_encode_and_decode_call_type() {
use util::rlp;
use rlp;
let original = CallType::Call;
let encoded = rlp::encode(&original);
let decoded = rlp::decode(&encoded);

View File

@ -18,8 +18,9 @@
use std::ops::Deref;
use util::{H256, Address, Bytes, HeapSizeOf, Hashable};
use util::rlp::*;
use util::bloom::Bloomable;
use rlp::*;
use basic_types::LogBloom;
use header::BlockNumber;
use ethjson;

View File

@ -17,8 +17,9 @@
//! Receipt
use util::{H256, U256, Address};
use util::rlp::*;
use util::HeapSizeOf;
use rlp::*;
use basic_types::LogBloom;
use header::BlockNumber;
use log_entry::{LogEntry, LocalizedLogEntry};

View File

@ -17,7 +17,7 @@
//! Flat trace module
use std::collections::VecDeque;
use util::rlp::*;
use rlp::*;
use util::HeapSizeOf;
use basic_types::LogBloom;
use super::trace::{Action, Res};
@ -167,7 +167,6 @@ mod tests {
#[test]
fn test_trace_serialization() {
use util::rlp;
// block #51921
let flat_trace = FlatTrace {
@ -220,8 +219,8 @@ mod tests {
FlatTransactionTraces(vec![flat_trace1, flat_trace2])
]);
let encoded = rlp::encode(&block_traces);
let decoded = rlp::decode(&encoded);
let encoded = ::rlp::encode(&block_traces);
let decoded = ::rlp::decode(&encoded);
assert_eq!(block_traces, decoded);
}
}

View File

@ -17,9 +17,10 @@
//! Tracing datatypes.
use util::{U256, Bytes, Address};
use util::rlp::*;
use util::sha3::Hashable;
use util::bloom::Bloomable;
use rlp::*;
use action_params::ActionParams;
use basic_types::LogBloom;
use types::executed::CallType;

View File

@ -18,7 +18,7 @@
use std::ops::Deref;
use std::cell::*;
use util::rlp::*;
use rlp::*;
use util::sha3::Hashable;
use util::{H256, Address, U256, Bytes};
use ethkey::{Signature, sign, Secret, recover, public_to_address, Error as EthkeyError};
@ -275,7 +275,7 @@ impl SignedTransaction {
match hash {
Some(h) => h,
None => {
let h = self.rlp_sha3();
let h = (&*self.rlp_bytes()).sha3();
self.hash.set(Some(h));
h
}

View File

@ -24,6 +24,7 @@
use common::*;
use engines::Engine;
use blockchain::*;
use rlp::{UntrustedRlp, View};
/// Preprocessed block data gathered in `verify_block_unordered` call
pub struct PreverifiedBlock {
@ -240,6 +241,7 @@ mod tests {
use spec::*;
use transaction::*;
use tests::helpers::*;
use rlp::View;
fn check_ok(result: Result<(), Error>) {
result.unwrap_or_else(|e| panic!("Block verification failed: {:?}", e));
@ -346,6 +348,8 @@ mod tests {
#[test]
#[cfg_attr(feature="dev", allow(similar_names))]
fn test_verify_block() {
use rlp::{RlpStream, Stream};
// Test against morden
let mut good = Header::new();
let spec = Spec::new_test();
@ -411,7 +415,7 @@ mod tests {
let mut uncles_rlp = RlpStream::new();
uncles_rlp.append(&good_uncles);
let good_uncles_hash = uncles_rlp.as_raw().sha3();
let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| encode::<SignedTransaction>(t).to_vec()).collect());
let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| ::rlp::encode::<SignedTransaction>(t).to_vec()).collect());
let mut parent = good.clone();
parent.set_number(9);

View File

@ -20,6 +20,7 @@ use util::*;
use header::*;
use transaction::*;
use super::{TransactionView, HeaderView};
use rlp::{Rlp, View};
/// View onto block rlp.
pub struct BlockView<'a> {

View File

@ -20,6 +20,7 @@ use util::*;
use header::*;
use transaction::*;
use super::{TransactionView, HeaderView};
use rlp::{Rlp, View};
/// View onto block rlp.
pub struct BodyView<'a> {

View File

@ -16,7 +16,8 @@
//! View onto block header rlp
use util::{Rlp, U256, Bytes, Hashable, H256, Address, H2048, View};
use util::{U256, Bytes, Hashable, H256, Address, H2048};
use rlp::{Rlp, View};
use header::BlockNumber;
/// View onto block header rlp.

View File

@ -15,7 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! View onto transaction rlp
use util::{Rlp, U256, Bytes, Hashable, H256, View};
use util::{U256, Bytes, Hashable, H256};
use rlp::{Rlp, View};
/// View onto transaction rlp.
pub struct TransactionView<'a> {

View File

@ -20,7 +20,7 @@ extern crate sha3 as sha3_ext;
use std::io;
use std::mem::uninitialized;
use tiny_keccak::Keccak;
use bytes::{BytesConvertable, Populatable};
use bytes::{Populatable};
use hash::{H256, FixedHash};
use self::sha3_ext::*;
@ -55,7 +55,7 @@ pub trait Hashable {
}
}
impl<T> Hashable for T where T: BytesConvertable {
impl<T> Hashable for T where T: AsRef<[u8]> {
fn sha3(&self) -> H256 {
unsafe {
let mut ret: H256 = uninitialized();
@ -65,7 +65,7 @@ impl<T> Hashable for T where T: BytesConvertable {
}
fn sha3_into(&self, dest: &mut [u8]) {
unsafe {
let input: &[u8] = self.as_slice();
let input: &[u8] = self.as_ref();
sha3_256(dest.as_mut_ptr(), dest.len(), input.as_ptr(), input.len());
}
}