Merge pull request #5949 from Vurich/upgrade-elastic-array

Upgrade elastic array
This commit is contained in:
Robert Habermeier 2017-06-29 17:12:53 +02:00 committed by GitHub
commit a4195f2780
64 changed files with 158 additions and 157 deletions

8
Cargo.lock generated
View File

@ -317,7 +317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "elastic-array" name = "elastic-array"
version = "0.8.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -635,7 +635,7 @@ version = "1.7.0"
dependencies = [ dependencies = [
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)", "eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.3", "ethcore-bigint 0.1.3",
@ -2129,7 +2129,7 @@ name = "rlp"
version = "0.2.0" version = "0.2.0"
dependencies = [ dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3", "ethcore-bigint 0.1.3",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2942,7 +2942,7 @@ dependencies = [
"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8" "checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8"
"checksum dtoa 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5edd69c67b2f8e0911629b7e6b8a34cb3956613cd7c6e6414966dee349c2db4f" "checksum dtoa 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5edd69c67b2f8e0911629b7e6b8a34cb3956613cd7c6e6414966dee349c2db4f"
"checksum either 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b503c86dad62aaf414ecf2b8c527439abedb3f8d812537f0b12bfd6f32a91" "checksum either 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b503c86dad62aaf414ecf2b8c527439abedb3f8d812537f0b12bfd6f32a91"
"checksum elastic-array 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "561b1b1bb58e6d9212b75a28cca442f8a87cceb35cb1b6d6f39f5df5346a9160" "checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85"
"checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83" "checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83"
"checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>" "checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>"
"checksum ethabi 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "65f71b9ac0b0f8e6230d32dbf5acf7c2c61334af1148175d0a7e72b14c3d475e" "checksum ethabi 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "65f71b9ac0b0f8e6230d32dbf5acf7c2c61334af1148175d0a7e72b14c3d475e"

View File

@ -126,7 +126,7 @@ pub fn compute_root<I>(cht_num: u64, iterable: I) -> Option<H256>
let start_num = start_number(cht_num) as usize; let start_num = start_number(cht_num) as usize;
for (i, (h, td)) in iterable.into_iter().take(SIZE as usize).enumerate() { for (i, (h, td)) in iterable.into_iter().take(SIZE as usize).enumerate() {
v.push((key!(i + start_num).to_vec(), val!(h, td).to_vec())) v.push((key!(i + start_num).into_vec(), val!(h, td).into_vec()))
} }
if v.len() == SIZE as usize { if v.len() == SIZE as usize {

View File

@ -388,7 +388,7 @@ impl HeaderChain {
None => { None => {
match self.db.get(self.col, &hash) { match self.db.get(self.col, &hash) {
Ok(db_value) => { Ok(db_value) => {
db_value.map(|x| x.to_vec()).map(encoded::Header::new) db_value.map(|x| x.into_vec()).map(encoded::Header::new)
.and_then(|header| { .and_then(|header| {
cache.insert_block_header(hash.clone(), header.clone()); cache.insert_block_header(hash.clone(), header.clone());
Some(header) Some(header)

View File

@ -137,7 +137,7 @@ impl Provider for TestProvider {
fn storage_proof(&self, req: request::CompleteStorageRequest) -> Option<request::StorageResponse> { fn storage_proof(&self, req: request::CompleteStorageRequest) -> Option<request::StorageResponse> {
Some(StorageResponse { Some(StorageResponse {
proof: vec![::rlp::encode(&req.key_hash).to_vec()], proof: vec![::rlp::encode(&req.key_hash).into_vec()],
value: req.key_hash | req.address_hash, value: req.key_hash | req.address_hash,
}) })
} }

View File

@ -738,7 +738,7 @@ impl BlockReceipts {
/// Check a response with receipts against the stored header. /// Check a response with receipts against the stored header.
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result<Vec<Receipt>, Error> { pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result<Vec<Receipt>, Error> {
let receipts_root = self.0.as_ref()?.receipts_root(); let receipts_root = self.0.as_ref()?.receipts_root();
let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).to_vec())); let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec()));
match receipts_root == found_root { match receipts_root == found_root {
true => { true => {
@ -902,7 +902,7 @@ mod tests {
header.set_number(10_000); header.set_number(10_000);
header.set_extra_data(b"test_header".to_vec()); header.set_extra_data(b"test_header".to_vec());
let hash = header.hash(); let hash = header.hash();
let raw_header = encoded::Header::new(::rlp::encode(&header).to_vec()); let raw_header = encoded::Header::new(::rlp::encode(&header).into_vec());
let cache = Mutex::new(make_cache()); let cache = Mutex::new(make_cache());
assert!(HeaderByHash(hash.into()).check_response(&cache, &hash.into(), &[raw_header]).is_ok()) assert!(HeaderByHash(hash.into()).check_response(&cache, &hash.into(), &[raw_header]).is_ok())
@ -916,10 +916,10 @@ mod tests {
let mut body_stream = RlpStream::new_list(2); let mut body_stream = RlpStream::new_list(2);
body_stream.begin_list(0).begin_list(0); body_stream.begin_list(0).begin_list(0);
let req = Body(encoded::Header::new(::rlp::encode(&header).to_vec()).into()); let req = Body(encoded::Header::new(::rlp::encode(&header).into_vec()).into());
let cache = Mutex::new(make_cache()); let cache = Mutex::new(make_cache());
let response = encoded::Body::new(body_stream.drain().to_vec()); let response = encoded::Body::new(body_stream.drain().into_vec());
assert!(req.check_response(&cache, &response).is_ok()) assert!(req.check_response(&cache, &response).is_ok())
} }
@ -934,12 +934,12 @@ mod tests {
let mut header = Header::new(); let mut header = Header::new();
let receipts_root = ::util::triehash::ordered_trie_root( let receipts_root = ::util::triehash::ordered_trie_root(
receipts.iter().map(|x| ::rlp::encode(x).to_vec()) receipts.iter().map(|x| ::rlp::encode(x).into_vec())
); );
header.set_receipts_root(receipts_root); header.set_receipts_root(receipts_root);
let req = BlockReceipts(encoded::Header::new(::rlp::encode(&header).to_vec()).into()); let req = BlockReceipts(encoded::Header::new(::rlp::encode(&header).into_vec()).into());
let cache = Mutex::new(make_cache()); let cache = Mutex::new(make_cache());
assert!(req.check_response(&cache, &receipts).is_ok()) assert!(req.check_response(&cache, &receipts).is_ok())
@ -987,7 +987,7 @@ mod tests {
header.set_state_root(root.clone()); header.set_state_root(root.clone());
let req = Account { let req = Account {
header: encoded::Header::new(::rlp::encode(&header).to_vec()).into(), header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(),
address: addr, address: addr,
}; };
@ -1001,7 +1001,7 @@ mod tests {
let code_hash = ::util::Hashable::sha3(&code); let code_hash = ::util::Hashable::sha3(&code);
let header = Header::new(); let header = Header::new();
let req = Code { let req = Code {
header: encoded::Header::new(::rlp::encode(&header).to_vec()).into(), header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(),
code_hash: code_hash.into(), code_hash: code_hash.into(),
}; };

View File

@ -1673,7 +1673,7 @@ mod tests {
let full_req = Request::Headers(req.clone()); let full_req = Request::Headers(req.clone());
let res = HeadersResponse { let res = HeadersResponse {
headers: vec![ headers: vec![
::ethcore::encoded::Header::new(::rlp::encode(&Header::default()).to_vec()) ::ethcore::encoded::Header::new(::rlp::encode(&Header::default()).into_vec())
] ]
}; };
let full_res = Response::Headers(res.clone()); let full_res = Response::Headers(res.clone());

View File

@ -382,11 +382,11 @@ impl<'x> OpenBlock<'x> {
if let Err(e) = s.block.state.commit() { if let Err(e) = s.block.state.commit() {
warn!("Encountered error on state commit: {}", e); warn!("Encountered error on state commit: {}", e);
} }
s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().to_vec()))); s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec())));
let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out();
s.block.header.set_uncles_hash(uncle_bytes.sha3()); s.block.header.set_uncles_hash(uncle_bytes.sha3());
s.block.header.set_state_root(s.block.state.root().clone()); s.block.header.set_state_root(s.block.state.root().clone());
s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec())));
s.block.header.set_log_bloom(s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b})); //TODO: use |= operator s.block.header.set_log_bloom(s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b})); //TODO: use |= operator
s.block.header.set_gas_used(s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used)); s.block.header.set_gas_used(s.block.receipts.last().map_or(U256::zero(), |r| r.gas_used));
@ -410,14 +410,14 @@ impl<'x> OpenBlock<'x> {
warn!("Encountered error on state commit: {}", e); warn!("Encountered error on state commit: {}", e);
} }
if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &SHA3_NULL_RLP { if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &SHA3_NULL_RLP {
s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().to_vec()))); s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec())));
} }
let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out();
if s.block.header.uncles_hash().is_zero() { if s.block.header.uncles_hash().is_zero() {
s.block.header.set_uncles_hash(uncle_bytes.sha3()); s.block.header.set_uncles_hash(uncle_bytes.sha3());
} }
if s.block.header.receipts_root().is_zero() || s.block.header.receipts_root() == &SHA3_NULL_RLP { if s.block.header.receipts_root().is_zero() || s.block.header.receipts_root() == &SHA3_NULL_RLP {
s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec())));
} }
s.block.header.set_state_root(s.block.state.root().clone()); s.block.header.set_state_root(s.block.state.root().clone());
@ -510,7 +510,7 @@ impl LockedBlock {
for receipt in &mut block.block.receipts { for receipt in &mut block.block.receipts {
receipt.state_root = None; receipt.state_root = None;
} }
block.block.header.set_receipts_root(ordered_trie_root(block.block.receipts.iter().map(|r| r.rlp_bytes().to_vec()))); block.block.header.set_receipts_root(ordered_trie_root(block.block.receipts.iter().map(|r| r.rlp_bytes().into_vec())));
block block
} }
} }

View File

@ -266,7 +266,7 @@ impl BlockProvider for BlockChain {
let result = match opt { let result = match opt {
Some(b) => { Some(b) => {
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec(); let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec();
let mut write = self.block_headers.write(); let mut write = self.block_headers.write();
write.insert(hash.clone(), bytes.clone()); write.insert(hash.clone(), bytes.clone());
Some(encoded::Header::new(bytes)) Some(encoded::Header::new(bytes))
@ -302,7 +302,7 @@ impl BlockProvider for BlockChain {
let result = match opt { let result = match opt {
Some(b) => { Some(b) => {
let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).to_vec(); let bytes: Bytes = UntrustedRlp::new(&b).decompress(RlpType::Blocks).into_vec();
let mut write = self.block_bodies.write(); let mut write = self.block_bodies.write();
write.insert(hash.clone(), bytes.clone()); write.insert(hash.clone(), bytes.clone());
Some(encoded::Body::new(bytes)) Some(encoded::Body::new(bytes))
@ -536,7 +536,7 @@ impl BlockChain {
let best_block_rlp = bc.block(&best_block_hash).unwrap().into_inner(); let best_block_rlp = bc.block(&best_block_hash).unwrap().into_inner();
let best_block_timestamp = BlockView::new(&best_block_rlp).header().timestamp(); let best_block_timestamp = BlockView::new(&best_block_rlp).header().timestamp();
let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.to_vec()); let raw_first = bc.db.get(db::COL_EXTRA, b"first").unwrap().map(|v| v.into_vec());
let mut best_ancient = bc.db.get(db::COL_EXTRA, b"ancient").unwrap().map(|h| H256::from_slice(&h)); let mut best_ancient = bc.db.get(db::COL_EXTRA, b"ancient").unwrap().map(|h| H256::from_slice(&h));
let best_ancient_number; let best_ancient_number;
if best_ancient.is_none() && best_block_number > 1 && bc.block_hash(1).is_none() { if best_ancient.is_none() && best_block_number > 1 && bc.block_hash(1).is_none() {

View File

@ -67,6 +67,6 @@ impl WithTransaction for Block {
impl CompleteBlock for Block { impl CompleteBlock for Block {
fn complete(mut self, parent_hash: H256) -> Bytes { fn complete(mut self, parent_hash: H256) -> Bytes {
self.header.set_parent_hash(parent_hash); self.header.set_parent_hash(parent_hash);
encode(&self).to_vec() encode(&self).into_vec()
} }
} }

View File

@ -1443,7 +1443,7 @@ impl BlockChainClient for Client {
} }
fn block_receipts(&self, hash: &H256) -> Option<Bytes> { fn block_receipts(&self, hash: &H256) -> Option<Bytes> {
self.chain.read().block_receipts(hash).map(|receipts| ::rlp::encode(&receipts).to_vec()) self.chain.read().block_receipts(hash).map(|receipts| ::rlp::encode(&receipts).into_vec())
} }
fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError> { fn import_block(&self, bytes: Bytes) -> Result<H256, BlockImportError> {

View File

@ -517,7 +517,7 @@ impl Engine for AuthorityRound {
// only issue the seal if we were the first to reach the compare_and_swap. // only issue the seal if we were the first to reach the compare_and_swap.
if !self.proposed.compare_and_swap(false, true, AtomicOrdering::SeqCst) { if !self.proposed.compare_and_swap(false, true, AtomicOrdering::SeqCst) {
return Seal::Regular(vec![encode(&step).to_vec(), encode(&(&H520::from(signature) as &[u8])).to_vec()]); return Seal::Regular(vec![encode(&step).into_vec(), encode(&(&H520::from(signature) as &[u8])).into_vec()]);
} }
} else { } else {
warn!(target: "engine", "generate_seal: FAIL: Accounts secret key unavailable."); warn!(target: "engine", "generate_seal: FAIL: Accounts secret key unavailable.");
@ -880,7 +880,7 @@ mod tests {
fn can_do_signature_verification_fail() { fn can_do_signature_verification_fail() {
let engine = Spec::new_test_round().engine; let engine = Spec::new_test_round().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![encode(&H520::default()).to_vec()]); header.set_seal(vec![encode(&H520::default()).into_vec()]);
let verify_result = engine.verify_block_external(&header, None); let verify_result = engine.verify_block_external(&header, None);
assert!(verify_result.is_err()); assert!(verify_result.is_err());
@ -923,7 +923,7 @@ mod tests {
let tap = AccountProvider::transient_provider(); let tap = AccountProvider::transient_provider();
let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
let mut parent_header: Header = Header::default(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&0usize).to_vec()]); parent_header.set_seal(vec![encode(&0usize).into_vec()]);
parent_header.set_gas_limit(U256::from_str("222222").unwrap()); parent_header.set_gas_limit(U256::from_str("222222").unwrap());
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_number(1); header.set_number(1);
@ -935,10 +935,10 @@ mod tests {
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
// Two validators. // Two validators.
// Spec starts with step 2. // Spec starts with step 2.
header.set_seal(vec![encode(&2usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&2usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
assert!(engine.verify_block_external(&header, None).is_err()); assert!(engine.verify_block_external(&header, None).is_err());
header.set_seal(vec![encode(&1usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
assert!(engine.verify_block_external(&header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_ok());
} }
@ -949,7 +949,7 @@ mod tests {
let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
let mut parent_header: Header = Header::default(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&0usize).to_vec()]); parent_header.set_seal(vec![encode(&0usize).into_vec()]);
parent_header.set_gas_limit(U256::from_str("222222").unwrap()); parent_header.set_gas_limit(U256::from_str("222222").unwrap());
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_number(1); header.set_number(1);
@ -961,10 +961,10 @@ mod tests {
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
// Two validators. // Two validators.
// Spec starts with step 2. // Spec starts with step 2.
header.set_seal(vec![encode(&1usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&1usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
assert!(engine.verify_block_external(&header, None).is_ok()); assert!(engine.verify_block_external(&header, None).is_ok());
header.set_seal(vec![encode(&5usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
assert!(engine.verify_block_external(&header, None).is_err()); assert!(engine.verify_block_external(&header, None).is_err());
} }
@ -975,7 +975,7 @@ mod tests {
let addr = tap.insert_account("0".sha3().into(), "0").unwrap(); let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
let mut parent_header: Header = Header::default(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&4usize).to_vec()]); parent_header.set_seal(vec![encode(&4usize).into_vec()]);
parent_header.set_gas_limit(U256::from_str("222222").unwrap()); parent_header.set_gas_limit(U256::from_str("222222").unwrap());
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_number(1); header.set_number(1);
@ -987,9 +987,9 @@ mod tests {
let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap(); let signature = tap.sign(addr, Some("0".into()), header.bare_hash()).unwrap();
// Two validators. // Two validators.
// Spec starts with step 2. // Spec starts with step 2.
header.set_seal(vec![encode(&5usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&5usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
header.set_seal(vec![encode(&3usize).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); header.set_seal(vec![encode(&3usize).into_vec(), encode(&(&*signature as &[u8])).into_vec()]);
assert!(engine.verify_block_family(&header, &parent_header, None).is_err()); assert!(engine.verify_block_family(&header, &parent_header, None).is_err());
} }
@ -1011,12 +1011,12 @@ mod tests {
let aura = AuthorityRound::new(Default::default(), params, Default::default()).unwrap(); let aura = AuthorityRound::new(Default::default(), params, Default::default()).unwrap();
let mut parent_header: Header = Header::default(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&1usize).to_vec()]); parent_header.set_seal(vec![encode(&1usize).into_vec()]);
parent_header.set_gas_limit(U256::from_str("222222").unwrap()); parent_header.set_gas_limit(U256::from_str("222222").unwrap());
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_number(1); header.set_number(1);
header.set_gas_limit(U256::from_str("222222").unwrap()); header.set_gas_limit(U256::from_str("222222").unwrap());
header.set_seal(vec![encode(&3usize).to_vec()]); header.set_seal(vec![encode(&3usize).into_vec()]);
assert!(aura.verify_block_family(&header, &parent_header, None).is_ok()); assert!(aura.verify_block_family(&header, &parent_header, None).is_ok());
assert_eq!(last_benign.load(AtomicOrdering::SeqCst), 1); assert_eq!(last_benign.load(AtomicOrdering::SeqCst), 1);

View File

@ -139,7 +139,7 @@ impl Engine for BasicAuthority {
if self.validators.contains(header.parent_hash(), author) { if self.validators.contains(header.parent_hash(), author) {
// account should be pernamently unlocked, otherwise sealing will fail // account should be pernamently unlocked, otherwise sealing will fail
if let Ok(signature) = self.signer.sign(header.bare_hash()) { if let Ok(signature) = self.signer.sign(header.bare_hash()) {
return Seal::Regular(vec![::rlp::encode(&(&H520::from(signature) as &[u8])).to_vec()]); return Seal::Regular(vec![::rlp::encode(&(&H520::from(signature) as &[u8])).into_vec()]);
} else { } else {
trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable"); trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable");
} }
@ -301,7 +301,7 @@ mod tests {
fn can_do_signature_verification_fail() { fn can_do_signature_verification_fail() {
let engine = new_test_authority().engine; let engine = new_test_authority().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![::rlp::encode(&H520::default()).to_vec()]); header.set_seal(vec![::rlp::encode(&H520::default()).into_vec()]);
let verify_result = engine.verify_block_family(&header, &Default::default(), None); let verify_result = engine.verify_block_family(&header, &Default::default(), None);
assert!(verify_result.is_err()); assert!(verify_result.is_err());

View File

@ -93,7 +93,7 @@ mod tests {
assert!(engine.verify_block_basic(&header, None).is_ok()); 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()).into_vec()]);
assert!(engine.verify_block_unordered(&header, None).is_ok()); assert!(engine.verify_block_unordered(&header, None).is_ok());
} }

View File

@ -228,7 +228,7 @@ mod tests {
}, },
block_hash: Some("1".sha3()) block_hash: Some("1".sha3())
}; };
let raw_rlp = ::rlp::encode(&message).to_vec(); let raw_rlp = ::rlp::encode(&message).into_vec();
let rlp = Rlp::new(&raw_rlp); let rlp = Rlp::new(&raw_rlp);
assert_eq!(message, rlp.as_val()); assert_eq!(message, rlp.as_val());
@ -265,8 +265,8 @@ mod tests {
fn proposal_message() { fn proposal_message() {
let mut header = Header::default(); let mut header = Header::default();
let seal = vec![ let seal = vec![
::rlp::encode(&0u8).to_vec(), ::rlp::encode(&0u8).into_vec(),
::rlp::encode(&H520::default()).to_vec(), ::rlp::encode(&H520::default()).into_vec(),
Vec::new() Vec::new()
]; ];

View File

@ -342,9 +342,9 @@ impl Tendermint {
let precommits = self.votes.round_signatures(vote_step, &bh); let precommits = self.votes.round_signatures(vote_step, &bh);
trace!(target: "engine", "Collected seal: {:?}", precommits); trace!(target: "engine", "Collected seal: {:?}", precommits);
let seal = vec![ let seal = vec![
::rlp::encode(&vote_step.view).to_vec(), ::rlp::encode(&vote_step.view).into_vec(),
::rlp::NULL_RLP.to_vec(), ::rlp::NULL_RLP.to_vec(),
::rlp::encode_list(&precommits).to_vec() ::rlp::encode_list(&precommits).into_vec()
]; ];
self.submit_seal(bh, seal); self.submit_seal(bh, seal);
self.votes.throw_out_old(&vote_step); self.votes.throw_out_old(&vote_step);
@ -446,8 +446,8 @@ impl Engine for Tendermint {
*self.proposal.write() = bh; *self.proposal.write() = bh;
*self.proposal_parent.write() = header.parent_hash().clone(); *self.proposal_parent.write() = header.parent_hash().clone();
Seal::Proposal(vec![ Seal::Proposal(vec![
::rlp::encode(&view).to_vec(), ::rlp::encode(&view).into_vec(),
::rlp::encode(&signature).to_vec(), ::rlp::encode(&signature).into_vec(),
::rlp::EMPTY_LIST_RLP.to_vec() ::rlp::EMPTY_LIST_RLP.to_vec()
]) ])
} else { } else {
@ -467,7 +467,7 @@ impl Engine for Tendermint {
self.broadcast_message(rlp.as_raw().to_vec()); self.broadcast_message(rlp.as_raw().to_vec());
if let Some(double) = self.votes.vote(message.clone(), &sender) { if let Some(double) = self.votes.vote(message.clone(), &sender) {
let height = message.vote_step.height as BlockNumber; let height = message.vote_step.height as BlockNumber;
self.validators.report_malicious(&sender, height, height, ::rlp::encode(&double).to_vec()); self.validators.report_malicious(&sender, height, height, ::rlp::encode(&double).into_vec());
return Err(EngineError::DoubleVote(sender).into()); return Err(EngineError::DoubleVote(sender).into());
} }
trace!(target: "engine", "Handling a valid {:?} from {}.", message, sender); trace!(target: "engine", "Handling a valid {:?} from {}.", message, sender);
@ -696,8 +696,8 @@ mod tests {
let vote_info = message_info_rlp(&VoteStep::new(header.number() as Height, view, Step::Propose), Some(header.bare_hash())); let vote_info = message_info_rlp(&VoteStep::new(header.number() as Height, view, Step::Propose), Some(header.bare_hash()));
let signature = tap.sign(*author, None, vote_info.sha3()).unwrap(); let signature = tap.sign(*author, None, vote_info.sha3()).unwrap();
vec![ vec![
::rlp::encode(&view).to_vec(), ::rlp::encode(&view).into_vec(),
::rlp::encode(&H520::from(signature)).to_vec(), ::rlp::encode(&H520::from(signature)).into_vec(),
::rlp::EMPTY_LIST_RLP.to_vec() ::rlp::EMPTY_LIST_RLP.to_vec()
] ]
} }
@ -813,7 +813,7 @@ mod tests {
let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap(); let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap();
seal[1] = ::rlp::NULL_RLP.to_vec(); seal[1] = ::rlp::NULL_RLP.to_vec();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).to_vec(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_vec();
header.set_seal(seal.clone()); header.set_seal(seal.clone());
// One good signature is not enough. // One good signature is not enough.
@ -825,7 +825,7 @@ mod tests {
let voter = insert_and_unlock(&tap, "0"); let voter = insert_and_unlock(&tap, "0");
let signature0 = tap.sign(voter, None, vote_info.sha3()).unwrap(); let signature0 = tap.sign(voter, None, vote_info.sha3()).unwrap();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).to_vec(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).into_vec();
header.set_seal(seal.clone()); header.set_seal(seal.clone());
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
@ -833,7 +833,7 @@ mod tests {
let bad_voter = insert_and_unlock(&tap, "101"); let bad_voter = insert_and_unlock(&tap, "101");
let bad_signature = tap.sign(bad_voter, None, vote_info.sha3()).unwrap(); let bad_signature = tap.sign(bad_voter, None, vote_info.sha3()).unwrap();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).to_vec(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec();
header.set_seal(seal); header.set_seal(seal);
// One good and one bad signature. // One good and one bad signature.

View File

@ -161,7 +161,7 @@ mod tests {
client.miner().set_engine_signer(v1, "".into()).unwrap(); client.miner().set_engine_signer(v1, "".into()).unwrap();
let mut header = Header::default(); let mut header = Header::default();
let seal = vec![encode(&5u8).to_vec(), encode(&(&H520::default() as &[u8])).to_vec()]; let seal = vec![encode(&5u8).into_vec(), encode(&(&H520::default() as &[u8])).into_vec()];
header.set_seal(seal); header.set_seal(seal);
header.set_author(v1); header.set_author(v1);
header.set_number(2); header.set_number(2);

View File

@ -80,7 +80,7 @@ fn decode_first_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec<DBValue>), ::er
fn encode_proof(header: &Header, receipts: &[Receipt]) -> Bytes { fn encode_proof(header: &Header, receipts: &[Receipt]) -> Bytes {
let mut stream = RlpStream::new_list(2); let mut stream = RlpStream::new_list(2);
stream.append(header).append_list(receipts); stream.append(header).append_list(receipts);
stream.drain().to_vec() stream.drain().into_vec()
} }
fn decode_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec<Receipt>), ::error::Error> { fn decode_proof(rlp: &UntrustedRlp) -> Result<(Header, Vec<Receipt>), ::error::Error> {

View File

@ -540,7 +540,7 @@ impl Header {
/// Set the nonce and mix hash fields of the header. /// Set the nonce and mix hash fields of the header.
pub fn set_nonce_and_mix_hash(&mut self, nonce: &H64, mix_hash: &H256) { pub fn set_nonce_and_mix_hash(&mut self, nonce: &H64, mix_hash: &H256) {
self.set_seal(vec![rlp::encode(mix_hash).to_vec(), rlp::encode(nonce).to_vec()]); self.set_seal(vec![rlp::encode(mix_hash).into_vec(), rlp::encode(nonce).into_vec()]);
} }
} }
@ -622,7 +622,7 @@ mod tests {
fn can_do_difficulty_verification_fail() { fn can_do_difficulty_verification_fail() {
let engine = new_morden().engine; let engine = new_morden().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]);
let verify_result = engine.verify_block_basic(&header, None); let verify_result = engine.verify_block_basic(&header, None);
@ -637,7 +637,7 @@ mod tests {
fn can_do_proof_of_work_verification_fail() { fn can_do_proof_of_work_verification_fail() {
let engine = new_morden().engine; let engine = new_morden().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]);
header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap());
let verify_result = engine.verify_block_basic(&header, None); let verify_result = engine.verify_block_basic(&header, None);
@ -667,7 +667,7 @@ mod tests {
fn can_do_seal256_verification_fail() { fn can_do_seal256_verification_fail() {
let engine = new_morden().engine; let engine = new_morden().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::zero()).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_seal(vec![rlp::encode(&H256::zero()).into_vec(), rlp::encode(&H64::zero()).into_vec()]);
let verify_result = engine.verify_block_unordered(&header, None); let verify_result = engine.verify_block_unordered(&header, None);
match verify_result { match verify_result {
@ -681,7 +681,7 @@ mod tests {
fn can_do_proof_of_work_unordered_verification_fail() { fn can_do_proof_of_work_unordered_verification_fail() {
let engine = new_morden().engine; let engine = new_morden().engine;
let mut header: Header = Header::default(); let mut header: Header = Header::default();
header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).to_vec(), rlp::encode(&H64::zero()).to_vec()]); header.set_seal(vec![rlp::encode(&H256::from("b251bd2e0283d0658f2cadfdc8ca619b5de94eca5742725e2e757dd13ed7503d")).into_vec(), rlp::encode(&H64::zero()).into_vec()]);
header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap()); header.set_difficulty(U256::from_str("ffffffffffffffffffffffffffffffffffffffffffffaaaaaaaaaaaaaaaaaaaa").unwrap());
let verify_result = engine.verify_block_unordered(&header, None); let verify_result = engine.verify_block_unordered(&header, None);

View File

@ -329,7 +329,7 @@ mod tests {
let header_rlp = "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23".from_hex().unwrap(); let header_rlp = "f901f9a0d405da4e66f1445d455195229624e133f5baafe72b5cf7b3c36c12c8146e98b7a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a05fb2b4bfdef7b314451cb138a534d225c922fc0e5fbe25e451142732c3e25c25a088d2ec6b9860aae1a2c3b299f72b6a5d70d7f7ba4722c78f2c49ba96273c2158a007c6fdfa8eea7e86b81f5b0fc0f78f90cc19f4aa60d323151e0cac660199e9a1b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefba82524d84568e932a80a0a0349d8c3df71f1a48a9df7d03fd5f14aeee7d91332c009ecaff0a71ead405bd88ab4e252a7e8c2a23".from_hex().unwrap();
let header: Header = rlp::decode(&header_rlp); let header: Header = rlp::decode(&header_rlp);
let encoded_header = rlp::encode(&header).to_vec(); let encoded_header = rlp::encode(&header).into_vec();
assert_eq!(header_rlp, encoded_header); assert_eq!(header_rlp, encoded_header);
} }

View File

@ -32,6 +32,6 @@ impl SimpleMigration for V8 {
fn simple_migrate(&mut self, key: Vec<u8>, value: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> { fn simple_migrate(&mut self, key: Vec<u8>, value: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> {
self.0.tick(); self.0.tick();
Some((key,UntrustedRlp::new(&value).compress(RlpType::Blocks).to_vec())) Some((key,UntrustedRlp::new(&value).compress(RlpType::Blocks).into_vec()))
} }
} }

View File

@ -39,8 +39,7 @@ impl SimpleMigration for ToV6 {
fn version(&self) -> u32 { 6 } fn version(&self) -> u32 { 6 }
fn simple_migrate(&mut self, key: Vec<u8>, value: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> { fn simple_migrate(&mut self, mut key: Vec<u8>, value: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> {
//// at this version all extras keys are 33 bytes long. //// at this version all extras keys are 33 bytes long.
if key.len() == 33 { if key.len() == 33 {
// block details key changes: // block details key changes:
@ -72,19 +71,21 @@ impl SimpleMigration for ToV6 {
// - index is moved to the front // - index is moved to the front
// - index is changed 4 -> 3 // - index is changed 4 -> 3
if key[32] == 4 { if key[32] == 4 {
key.reverse();
// i have no idea why it was reversed // i have no idea why it was reversed
let reverse = key.into_iter().rev().collect::<Vec<_>>(); let reverse = key;
let mut result = [0u8; 6]; let result = vec![
// new extras index is 3 // new extras index is 3
result[0] = 3; 3,
// 9th (+ prefix) byte was the level. Now it's second. // 9th (+ prefix) byte was the level. Now it's second.
result[1] = reverse[9]; reverse[9],
result[2] = reverse[4]; reverse[4],
result[3] = reverse[3]; reverse[3],
result[4] = reverse[2]; reverse[2],
result[5] = reverse[1]; reverse[1],
];
return Some((result.to_vec(), value)); return Some((result, value));
} }
// blocks receipts key changes: // blocks receipts key changes:

View File

@ -153,7 +153,7 @@ impl OverlayRecentV7 {
// and commit the altered entries. // and commit the altered entries.
fn migrate_journal(&self, source: Arc<Database>, mut batch: Batch, dest: &mut Database) -> Result<(), Error> { fn migrate_journal(&self, source: Arc<Database>, mut batch: Batch, dest: &mut Database) -> Result<(), Error> {
if let Some(val) = source.get(None, V7_LATEST_ERA_KEY).map_err(Error::Custom)? { if let Some(val) = source.get(None, V7_LATEST_ERA_KEY).map_err(Error::Custom)? {
batch.insert(V7_LATEST_ERA_KEY.into(), val.clone().to_vec(), dest)?; batch.insert(V7_LATEST_ERA_KEY.into(), val.clone().into_vec(), dest)?;
let mut era = decode::<u64>(&val); let mut era = decode::<u64>(&val);
loop { loop {

View File

@ -104,7 +104,7 @@ impl Migration for ToV10 {
let mut batch = Batch::new(config, col); let mut batch = Batch::new(config, col);
for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) { for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) {
self.progress.tick(); self.progress.tick();
batch.insert(key.to_vec(), value.to_vec(), dest)?; batch.insert(key.into_vec(), value.into_vec(), dest)?;
} }
batch.commit(dest)?; batch.commit(dest)?;

View File

@ -62,17 +62,17 @@ impl Migration for ToV9 {
self.progress.tick(); self.progress.tick();
match self.extract { match self.extract {
Extract::Header => { Extract::Header => {
batch.insert(key.to_vec(), Rlp::new(&value).at(0).as_raw().to_vec(), dest)? batch.insert(key.into_vec(), Rlp::new(&value).at(0).as_raw().to_vec(), dest)?
}, },
Extract::Body => { Extract::Body => {
let mut body = RlpStream::new_list(2); let mut body = RlpStream::new_list(2);
let block_rlp = Rlp::new(&value); let block_rlp = Rlp::new(&value);
body.append_raw(block_rlp.at(1).as_raw(), 1); body.append_raw(block_rlp.at(1).as_raw(), 1);
body.append_raw(block_rlp.at(2).as_raw(), 1); body.append_raw(block_rlp.at(2).as_raw(), 1);
batch.insert(key.to_vec(), body.out(), dest)? batch.insert(key.into_vec(), body.out(), dest)?
}, },
Extract::All => { Extract::All => {
batch.insert(key.to_vec(), value.to_vec(), dest)? batch.insert(key.into_vec(), value.into_vec(), dest)?
} }
} }
} }

View File

@ -145,7 +145,7 @@ impl JobDispatcher for StratumJobDispatcher {
); );
self.with_core_void(|client, miner| { self.with_core_void(|client, miner| {
let seal = vec![encode(&payload.mix_hash).to_vec(), encode(&payload.nonce).to_vec()]; let seal = vec![encode(&payload.mix_hash).into_vec(), encode(&payload.nonce).into_vec()];
if let Err(e) = miner.submit_seal(&*client, payload.pow_hash, seal) { if let Err(e) = miner.submit_seal(&*client, payload.pow_hash, seal) {
warn!(target: "stratum", "submit_seal error: {:?}", e); warn!(target: "stratum", "submit_seal error: {:?}", e);
}; };

View File

@ -121,7 +121,7 @@ pub fn to_fat_rlps(account_hash: &H256, acc: &BasicAccount, acct_db: &AccountDB,
let stream = ::std::mem::replace(&mut account_stream, RlpStream::new_list(2)); let stream = ::std::mem::replace(&mut account_stream, RlpStream::new_list(2));
chunks.push(stream.out()); chunks.push(stream.out());
target_chunk_size = max_chunk_size; target_chunk_size = max_chunk_size;
leftover = Some(pair.to_vec()); leftover = Some(pair.into_vec());
break; break;
} }
}, },

View File

@ -190,7 +190,7 @@ mod tests {
let receipts_root = b.header.receipts_root().clone(); let receipts_root = b.header.receipts_root().clone();
b.header.set_transactions_root(::util::triehash::ordered_trie_root( b.header.set_transactions_root(::util::triehash::ordered_trie_root(
b.transactions.iter().map(::rlp::encode).map(|out| out.to_vec()) b.transactions.iter().map(::rlp::encode).map(|out| out.into_vec())
)); ));
let encoded = encode_block(&b); let encoded = encode_block(&b);

View File

@ -462,7 +462,7 @@ fn rebuild_accounts(
} }
} }
::rlp::encode(&acc).to_vec() ::rlp::encode(&acc).into_vec()
}; };
*out = (hash, thin_rlp); *out = (hash, thin_rlp);

View File

@ -77,7 +77,7 @@ impl StateProducer {
let mut account: BasicAccount = ::rlp::decode(&*account_data); let mut account: BasicAccount = ::rlp::decode(&*account_data);
let acct_db = AccountDBMut::from_hash(db, *address_hash); let acct_db = AccountDBMut::from_hash(db, *address_hash);
fill_storage(acct_db, &mut account.storage_root, &mut self.storage_seed); fill_storage(acct_db, &mut account.storage_root, &mut self.storage_seed);
*account_data = DBValue::from_vec(::rlp::encode(&account).to_vec()); *account_data = DBValue::from_vec(::rlp::encode(&account).into_vec());
} }
// sweep again to alter account trie. // sweep again to alter account trie.

View File

@ -257,7 +257,7 @@ impl Account {
match db.get(&self.code_hash) { match db.get(&self.code_hash) {
Some(x) => { Some(x) => {
self.code_size = Some(x.len()); self.code_size = Some(x.len());
self.code_cache = Arc::new(x.to_vec()); self.code_cache = Arc::new(x.into_vec());
Some(self.code_cache.clone()) Some(self.code_cache.clone())
}, },
_ => { _ => {
@ -476,10 +476,10 @@ mod tests {
fn account_compress() { fn account_compress() {
let raw = Account::new_basic(2.into(), 4.into()).rlp(); let raw = Account::new_basic(2.into(), 4.into()).rlp();
let rlp = UntrustedRlp::new(&raw); let rlp = UntrustedRlp::new(&raw);
let compact_vec = rlp.compress(RlpType::Snapshot).to_vec(); let compact_vec = rlp.compress(RlpType::Snapshot).into_vec();
assert!(raw.len() > compact_vec.len()); assert!(raw.len() > compact_vec.len());
let again_raw = UntrustedRlp::new(&compact_vec).decompress(RlpType::Snapshot); let again_raw = UntrustedRlp::new(&compact_vec).decompress(RlpType::Snapshot);
assert_eq!(raw, again_raw.to_vec()); assert_eq!(raw, again_raw.into_vec());
} }
#[test] #[test]

View File

@ -1826,14 +1826,14 @@ mod tests {
let mut state = get_temp_state(); let mut state = get_temp_state();
state.require_or_from(&a, false, ||Account::new_contract(42.into(), 0.into()), |_|{}).unwrap(); state.require_or_from(&a, false, ||Account::new_contract(42.into(), 0.into()), |_|{}).unwrap();
state.init_code(&a, vec![1, 2, 3]).unwrap(); state.init_code(&a, vec![1, 2, 3]).unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
state.commit().unwrap(); state.commit().unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
state.drop() state.drop()
}; };
let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap(); let state = State::from_existing(db, root, U256::from(0u8), Default::default()).unwrap();
assert_eq!(state.code(&a).unwrap(), Some(Arc::new([1u8, 2, 3].to_vec()))); assert_eq!(state.code(&a).unwrap(), Some(Arc::new(vec![1u8, 2, 3])));
} }
#[test] #[test]

View File

@ -133,7 +133,7 @@ pub fn create_test_block_with_data(header: &Header, transactions: &[SignedTransa
rlp.append(header); rlp.append(header);
rlp.begin_list(transactions.len()); rlp.begin_list(transactions.len());
for t in transactions { for t in transactions {
rlp.append_raw(&rlp::encode(t).to_vec(), 1); rlp.append_raw(&rlp::encode(t).into_vec(), 1);
} }
rlp.append_list(&uncles); rlp.append_list(&uncles);
rlp.out() rlp.out()

View File

@ -475,7 +475,7 @@ mod tests {
let mut uncles_rlp = RlpStream::new(); let mut uncles_rlp = RlpStream::new();
uncles_rlp.append_list(&good_uncles); uncles_rlp.append_list(&good_uncles);
let good_uncles_hash = uncles_rlp.as_raw().sha3(); let good_uncles_hash = uncles_rlp.as_raw().sha3();
let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| ::rlp::encode::<UnverifiedTransaction>(t).to_vec())); let good_transactions_root = ordered_trie_root(good_transactions.iter().map(|t| ::rlp::encode::<UnverifiedTransaction>(t).into_vec()));
let mut parent = good.clone(); let mut parent = good.clone();
parent.set_number(9); parent.set_number(9);

View File

@ -104,7 +104,7 @@ impl Crypto {
cipher: Cipher::Aes128Ctr(Aes128Ctr { cipher: Cipher::Aes128Ctr(Aes128Ctr {
iv: iv, iv: iv,
}), }),
ciphertext: (*ciphertext).to_vec(), ciphertext: ciphertext.into_vec(),
kdf: Kdf::Pbkdf2(Pbkdf2 { kdf: Kdf::Pbkdf2(Pbkdf2 {
dklen: crypto::KEY_LENGTH as u32, dklen: crypto::KEY_LENGTH as u32,
salt: salt, salt: salt,

View File

@ -122,7 +122,7 @@ impl trace::VMTracer for Informant {
fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized { fn prepare_subtrace(&self, code: &[u8]) -> Self where Self: Sized {
let mut vm = Informant::default(); let mut vm = Informant::default();
vm.depth = self.depth + 1; vm.depth = self.depth + 1;
vm.code = code.to_vec(); vm.code = code.into_vec();
vm.gas_used = self.gas_used; vm.gas_used = self.gas_used;
vm vm
} }

View File

@ -233,7 +233,7 @@ mod tests {
let _ = write_chunk(&mut transport, &mut progress, b"foobar"); let _ = write_chunk(&mut transport, &mut progress, b"foobar");
assert_eq!(b"foobar".to_vec(), transport); assert_eq!(b"foobar".into_vec(), transport);
assert_eq!(6, progress); assert_eq!(6, progress);
} }
@ -244,7 +244,7 @@ mod tests {
let _ = write_chunk(&mut transport, &mut progress, b"foobar"); let _ = write_chunk(&mut transport, &mut progress, b"foobar");
assert_eq!(b"bar".to_vec(), transport); assert_eq!(b"bar".into_vec(), transport);
assert_eq!(6, progress); assert_eq!(6, progress);
} }

View File

@ -79,7 +79,7 @@ impl IpfsHandler {
fn block_list(&self, hash: H256) -> Result<Out> { fn block_list(&self, hash: H256) -> Result<Out> {
let uncles = self.client().find_uncles(&hash).ok_or(Error::BlockNotFound)?; let uncles = self.client().find_uncles(&hash).ok_or(Error::BlockNotFound)?;
Ok(Out::OctetStream(rlp::encode_list(&uncles).to_vec())) Ok(Out::OctetStream(rlp::encode_list(&uncles).into_vec()))
} }
/// Get transaction by hash and return as raw binary. /// Get transaction by hash and return as raw binary.
@ -87,7 +87,7 @@ impl IpfsHandler {
let tx_id = TransactionId::Hash(hash); let tx_id = TransactionId::Hash(hash);
let tx = self.client().transaction(tx_id).ok_or(Error::TransactionNotFound)?; let tx = self.client().transaction(tx_id).ok_or(Error::TransactionNotFound)?;
Ok(Out::OctetStream(rlp::encode(&*tx).to_vec())) Ok(Out::OctetStream(rlp::encode(&*tx).into_vec()))
} }
/// Get state trie node by hash and return as raw binary. /// Get state trie node by hash and return as raw binary.

View File

@ -121,7 +121,7 @@ impl TransactionEntry {
impl From<PendingTransaction> for TransactionEntry { impl From<PendingTransaction> for TransactionEntry {
fn from(pending: PendingTransaction) -> Self { fn from(pending: PendingTransaction) -> Self {
TransactionEntry { TransactionEntry {
rlp_bytes: ::rlp::encode(&pending.transaction).to_vec(), rlp_bytes: ::rlp::encode(&pending.transaction).into_vec(),
condition: pending.condition.map(Into::into), condition: pending.condition.map(Into::into),
} }
} }

View File

@ -36,6 +36,6 @@ pub fn sign_call<B: MiningBlockChainClient, M: MinerService>(
gas: request.gas.unwrap_or(50_000_000.into()), gas: request.gas.unwrap_or(50_000_000.into()),
gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(&**client, &**miner)), gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(&**client, &**miner)),
value: request.value.unwrap_or(0.into()), value: request.value.unwrap_or(0.into()),
data: request.data.map_or_else(Vec::new, |d| d.to_vec()) data: request.data.unwrap_or_default(),
}.fake_sign(from)) }.fake_sign(from))
} }

View File

@ -192,7 +192,7 @@ impl LightFetch {
let action = req.to.map_or(Action::Create, Action::Call); let action = req.to.map_or(Action::Create, Action::Call);
let gas = req.gas.unwrap_or(U256::from(10_000_000)); // better gas amount? let gas = req.gas.unwrap_or(U256::from(10_000_000)); // better gas amount?
let value = req.value.unwrap_or_else(U256::zero); let value = req.value.unwrap_or_else(U256::zero);
let data = req.data.map_or_else(Vec::new, |d| d.to_vec()); let data = req.data.unwrap_or_default();
future::done(match nonce { future::done(match nonce {
Some(n) => Ok(EthTransaction { Some(n) => Ok(EthTransaction {

View File

@ -607,7 +607,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM> Eth for EthClient<C, SN, S, M, EM> where
let mix_hash: H256 = mix_hash.into(); let mix_hash: H256 = mix_hash.into();
trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash); trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
let seal = vec![rlp::encode(&mix_hash).to_vec(), rlp::encode(&nonce).to_vec()]; let seal = vec![rlp::encode(&mix_hash).into_vec(), rlp::encode(&nonce).into_vec()];
Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok()) Ok(self.miner.submit_seal(&*self.client, pow_hash, seal).is_ok())
} }

View File

@ -154,7 +154,7 @@ impl EthClient {
true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(|t| Transaction::from_localized(t, eip86_transition)).collect()), true => BlockTransactions::Full(block.view().localized_transactions().into_iter().map(|t| Transaction::from_localized(t, eip86_transition)).collect()),
_ => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()), _ => BlockTransactions::Hashes(block.transaction_hashes().into_iter().map(Into::into).collect()),
}, },
extra_data: Bytes::new(header.extra_data().to_vec()), extra_data: Bytes::new(header.extra_data().clone()),
}, },
extra_info: extra_info extra_info: extra_info
} }

View File

@ -126,7 +126,7 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
.and_then(|(pending_tx, dispatcher)| { .and_then(|(pending_tx, dispatcher)| {
let network_id = pending_tx.network_id(); let network_id = pending_tx.network_id();
trace!(target: "miner", "send_transaction: dispatching tx: {} for network ID {:?}", trace!(target: "miner", "send_transaction: dispatching tx: {} for network ID {:?}",
::rlp::encode(&*pending_tx).to_vec().pretty(), network_id); ::rlp::encode(&*pending_tx).into_vec().pretty(), network_id);
dispatcher.dispatch_transaction(pending_tx).map(Into::into) dispatcher.dispatch_transaction(pending_tx).map(Into::into)
}) })

View File

@ -963,7 +963,7 @@ fn rpc_eth_send_raw_transaction() {
let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap(); let signature = tester.accounts_provider.sign(address, None, t.hash(None)).unwrap();
let t = t.with_signature(signature, None); let t = t.with_signature(signature, None);
let rlp = rlp::encode(&t).to_vec().to_hex(); let rlp = rlp::encode(&t).into_vec().to_hex();
let req = r#"{ let req = r#"{
"jsonrpc": "2.0", "jsonrpc": "2.0",

View File

@ -195,7 +195,7 @@ impl Transaction {
Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()), Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()),
Action::Call(_) => None, Action::Call(_) => None,
}, },
raw: ::rlp::encode(&t.signed).to_vec().into(), raw: ::rlp::encode(&t.signed).into_vec().into(),
public_key: t.recover_public().ok().map(Into::into), public_key: t.recover_public().ok().map(Into::into),
network_id: t.network_id(), network_id: t.network_id(),
standard_v: t.standard_v().into(), standard_v: t.standard_v().into(),
@ -229,7 +229,7 @@ impl Transaction {
Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()), Action::Create => Some(contract_address(scheme, &t.sender(), &t.nonce, &t.data.sha3()).into()),
Action::Call(_) => None, Action::Call(_) => None,
}, },
raw: ::rlp::encode(&t).to_vec().into(), raw: ::rlp::encode(&t).into_vec().into(),
public_key: t.public_key().map(Into::into), public_key: t.public_key().map(Into::into),
network_id: t.network_id(), network_id: t.network_id(),
standard_v: t.standard_v().into(), standard_v: t.standard_v().into(),

View File

@ -93,7 +93,7 @@ impl KeyStorage for PersistentKeyStorage {
self.db.get(None, document) self.db.get(None, document)
.map_err(Error::Database)? .map_err(Error::Database)?
.ok_or(Error::DocumentNotFound) .ok_or(Error::DocumentNotFound)
.map(|key| key.to_vec()) .map(|key| key.into_vec())
.and_then(|key| serde_json::from_slice::<SerializableDocumentKeyShare>(&key).map_err(|e| Error::Database(e.to_string()))) .and_then(|key| serde_json::from_slice::<SerializableDocumentKeyShare>(&key).map_err(|e| Error::Database(e.to_string())))
.map(Into::into) .map(Into::into)
} }

View File

@ -342,7 +342,7 @@ mod tests {
let mut core = Core::new().expect("Tokio Core should be created with no errors"); let mut core = Core::new().expect("Tokio Core should be created with no errors");
let mut buffer = vec![0u8; 2048]; let mut buffer = vec![0u8; 2048];
let mut data_vec = data.as_bytes().to_vec(); let mut data_vec = data.as_bytes().into_vec();
data_vec.extend(b"\n"); data_vec.extend(b"\n");
let stream = TcpStream::connect(addr, &core.handle()) let stream = TcpStream::connect(addr, &core.handle())
@ -353,7 +353,7 @@ mod tests {
io::read(stream, &mut buffer) io::read(stream, &mut buffer)
}) })
.and_then(|(_, read_buf, len)| { .and_then(|(_, read_buf, len)| {
future::ok(read_buf[0..len].to_vec()) future::ok(read_buf[0..len].into_vec())
}); });
let result = core.run(stream).expect("Core should run with no errors"); let result = core.run(stream).expect("Core should run with no errors");
@ -454,7 +454,7 @@ mod tests {
let mut auth_request = let mut auth_request =
r#"{"jsonrpc": "2.0", "method": "mining.authorize", "params": ["miner1", ""], "id": 1}"# r#"{"jsonrpc": "2.0", "method": "mining.authorize", "params": ["miner1", ""], "id": 1}"#
.as_bytes() .as_bytes()
.to_vec(); .into_vec();
auth_request.extend(b"\n"); auth_request.extend(b"\n");
let mut core = Core::new().expect("Tokio Core should be created with no errors"); let mut core = Core::new().expect("Tokio Core should be created with no errors");
@ -487,7 +487,7 @@ mod tests {
}) })
.and_then(|(_, read_buf, len)| { .and_then(|(_, read_buf, len)| {
trace!(target: "stratum", "Received work from server"); trace!(target: "stratum", "Received work from server");
future::ok(read_buf[0..len].to_vec()) future::ok(read_buf[0..len].into_vec())
}); });
let response = String::from_utf8( let response = String::from_utf8(
core.run(stream).expect("Core should run with no errors") core.run(stream).expect("Core should run with no errors")

View File

@ -427,7 +427,7 @@ struct TxRelay(Arc<BlockChainClient>);
impl LightHandler for TxRelay { impl LightHandler for TxRelay {
fn on_transactions(&self, ctx: &EventContext, relay: &[::ethcore::transaction::UnverifiedTransaction]) { fn on_transactions(&self, ctx: &EventContext, relay: &[::ethcore::transaction::UnverifiedTransaction]) {
trace!(target: "pip", "Relaying {} transactions from peer {}", relay.len(), ctx.peer()); trace!(target: "pip", "Relaying {} transactions from peer {}", relay.len(), ctx.peer());
self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx).to_vec()).collect(), ctx.peer()) self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx).into_vec()).collect(), ctx.peer())
} }
} }

View File

@ -177,7 +177,7 @@ mod tests {
parent_hash = Some(header.hash()); parent_hash = Some(header.hash());
encoded::Header::new(::rlp::encode(&header).to_vec()) encoded::Header::new(::rlp::encode(&header).into_vec())
}).collect(); }).collect();
assert!(verify(&headers, &request).is_ok()); assert!(verify(&headers, &request).is_ok());
@ -203,7 +203,7 @@ mod tests {
parent_hash = Some(header.hash()); parent_hash = Some(header.hash());
encoded::Header::new(::rlp::encode(&header).to_vec()) encoded::Header::new(::rlp::encode(&header).into_vec())
}).collect(); }).collect();
assert!(verify(&headers, &request).is_ok()); assert!(verify(&headers, &request).is_ok());
@ -229,7 +229,7 @@ mod tests {
parent_hash = Some(header.hash()); parent_hash = Some(header.hash());
encoded::Header::new(::rlp::encode(&header).to_vec()) encoded::Header::new(::rlp::encode(&header).into_vec())
}).collect(); }).collect();
assert_eq!(verify(&headers, &request), Err(BasicError::TooManyHeaders(20, 25))); assert_eq!(verify(&headers, &request), Err(BasicError::TooManyHeaders(20, 25)));
@ -248,7 +248,7 @@ mod tests {
let mut header = Header::default(); let mut header = Header::default();
header.set_number(x); header.set_number(x);
encoded::Header::new(::rlp::encode(&header).to_vec()) encoded::Header::new(::rlp::encode(&header).into_vec())
}).collect(); }).collect();
assert_eq!(verify(&headers, &request), Err(BasicError::WrongSkip(5, Some(2)))); assert_eq!(verify(&headers, &request), Err(BasicError::WrongSkip(5, Some(2))));

View File

@ -16,7 +16,7 @@ time = "0.1.34"
rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
rust-crypto = "0.2.34" rust-crypto = "0.2.34"
elastic-array = "0.8" elastic-array = "0.9"
rlp = { path = "rlp" } rlp = { path = "rlp" }
heapsize = "0.4" heapsize = "0.4"
itertools = "0.5" itertools = "0.5"

View File

@ -45,14 +45,14 @@ fn random_bytes(min_count: usize, diff_count: usize, seed: &mut H256) -> Vec<u8>
assert!(min_count + diff_count <= 32); assert!(min_count + diff_count <= 32);
*seed = seed.sha3(); *seed = seed.sha3();
let r = min_count + (seed[31] as usize % (diff_count + 1)); let r = min_count + (seed[31] as usize % (diff_count + 1));
seed[0..r].to_vec() seed[0..r].into_vec()
} }
fn random_value(seed: &mut H256) -> Bytes { fn random_value(seed: &mut H256) -> Bytes {
*seed = seed.sha3(); *seed = seed.sha3();
match seed[0] % 2 { match seed[0] % 2 {
1 => vec![seed[31];1], 1 => vec![seed[31];1],
_ => seed.to_vec(), _ => seed.into_vec(),
} }
} }

View File

@ -7,7 +7,7 @@ version = "0.2.0"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
[dependencies] [dependencies]
elastic-array = "0.8" elastic-array = "0.9"
ethcore-bigint = { path = "../bigint" } ethcore-bigint = { path = "../bigint" }
lazy_static = "0.2" lazy_static = "0.2"
rustc-serialize = "0.3" rustc-serialize = "0.3"

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,7 @@ pub fn decode_list<T>(bytes: &[u8]) -> Vec<T> where T: Decodable {
/// ///
/// fn main () { /// fn main () {
/// let animal = "cat"; /// let animal = "cat";
/// let out = rlp::encode(&animal).to_vec(); /// let out = rlp::encode(&animal).into_vec();
/// assert_eq!(out, vec![0x83, b'c', b'a', b't']); /// assert_eq!(out, vec![0x83, b'c', b'a', b't']);
/// } /// }
/// ``` /// ```

View File

@ -264,8 +264,8 @@ impl RlpStream {
/// panic! if stream is not finished. /// panic! if stream is not finished.
pub fn out(self) -> Vec<u8> { pub fn out(self) -> Vec<u8> {
match self.is_finished() { match self.is_finished() {
//true => self.encoder.out().to_vec(), //true => self.encoder.out().into_vec(),
true => self.buffer.to_vec(), true => self.buffer.into_vec(),
false => panic!() false => panic!()
} }
} }

View File

@ -242,8 +242,8 @@ impl JournalDB for OverlayRecentDB {
fn state(&self, key: &H256) -> Option<Bytes> { fn state(&self, key: &H256) -> Option<Bytes> {
let journal_overlay = self.journal_overlay.read(); let journal_overlay = self.journal_overlay.read();
let key = to_short_key(key); let key = to_short_key(key);
journal_overlay.backing_overlay.get(&key).map(|v| v.to_vec()) journal_overlay.backing_overlay.get(&key).map(|v| v.into_vec())
.or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().to_vec())) .or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().into_vec()))
.or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.into_vec())) .or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.into_vec()))
} }
@ -288,7 +288,7 @@ impl JournalDB for OverlayRecentDB {
batch.put_vec(self.column, &k.drain(), r.out()); batch.put_vec(self.column, &k.drain(), r.out());
if journal_overlay.latest_era.map_or(true, |e| now > e) { if journal_overlay.latest_era.map_or(true, |e| now > e) {
trace!(target: "journaldb", "Set latest era to {}", now); trace!(target: "journaldb", "Set latest era to {}", now);
batch.put_vec(self.column, &LATEST_ERA_KEY, encode(&now).to_vec()); batch.put_vec(self.column, &LATEST_ERA_KEY, encode(&now).into_vec());
journal_overlay.latest_era = Some(now); journal_overlay.latest_era = Some(now);
} }

View File

@ -216,7 +216,7 @@ impl KeyValueDB for InMemory {
Some(map) => Some(map) =>
map.iter() map.iter()
.find(|&(ref k ,_)| k.starts_with(prefix)) .find(|&(ref k ,_)| k.starts_with(prefix))
.map(|(_, v)| (&**v).to_vec().into_boxed_slice()) .map(|(_, v)| v.to_vec().into_boxed_slice())
} }
} }
@ -227,7 +227,7 @@ impl KeyValueDB for InMemory {
match op { match op {
DBOp::Insert { col, key, value } => { DBOp::Insert { col, key, value } => {
if let Some(mut col) = columns.get_mut(&col) { if let Some(mut col) = columns.get_mut(&col) {
col.insert(key.to_vec(), value); col.insert(key.into_vec(), value);
} }
}, },
DBOp::InsertCompressed { col, key, value } => { DBOp::InsertCompressed { col, key, value } => {
@ -235,7 +235,7 @@ impl KeyValueDB for InMemory {
let compressed = UntrustedRlp::new(&value).compress(RlpType::Blocks); let compressed = UntrustedRlp::new(&value).compress(RlpType::Blocks);
let mut value = DBValue::new(); let mut value = DBValue::new();
value.append_slice(&compressed); value.append_slice(&compressed);
col.insert(key.to_vec(), value); col.insert(key.into_vec(), value);
} }
}, },
DBOp::Delete { col, key } => { DBOp::Delete { col, key } => {
@ -253,7 +253,7 @@ impl KeyValueDB for InMemory {
Some(map) => Box::new( // TODO: worth optimizing at all? Some(map) => Box::new( // TODO: worth optimizing at all?
map.clone() map.clone()
.into_iter() .into_iter()
.map(|(k, v)| (k.into_boxed_slice(), v.to_vec().into_boxed_slice())) .map(|(k, v)| (k.into_boxed_slice(), v.into_vec().into_boxed_slice()))
), ),
None => Box::new(None.into_iter()), None => Box::new(None.into_iter()),
} }
@ -267,7 +267,7 @@ impl KeyValueDB for InMemory {
map.clone() map.clone()
.into_iter() .into_iter()
.skip_while(move |&(ref k, _)| !k.starts_with(prefix)) .skip_while(move |&(ref k, _)| !k.starts_with(prefix))
.map(|(k, v)| (k.into_boxed_slice(), v.to_vec().into_boxed_slice())) .map(|(k, v)| (k.into_boxed_slice(), v.into_vec().into_boxed_slice()))
), ),
None => Box::new(None.into_iter()), None => Box::new(None.into_iter()),
} }

View File

@ -163,7 +163,7 @@ impl<T: SimpleMigration> Migration for T {
}; };
for (key, value) in iter { for (key, value) in iter {
if let Some((key, value)) = self.simple_migrate(key.to_vec(), value.to_vec()) { if let Some((key, value)) = self.simple_migrate(key.into_vec(), value.into_vec()) {
batch.insert(key, value, dest)?; batch.insert(key, value, dest)?;
} }
} }

View File

@ -95,7 +95,7 @@ impl Migration for AddsColumn {
let mut batch = Batch::new(config, col); let mut batch = Batch::new(config, col);
for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) { for (key, value) in source.iter(col).into_iter().flat_map(|inner| inner) {
batch.insert(key.to_vec(), value.to_vec(), dest)?; batch.insert(key.into_vec(), value.into_vec(), dest)?;
} }

View File

@ -95,7 +95,7 @@ impl<'db> Iterator for FatDBIterator<'db> {
.map(|res| .map(|res|
res.map(|(hash, value)| { res.map(|(hash, value)| {
let aux_hash = hash.sha3(); let aux_hash = hash.sha3();
(self.trie.db().get(&aux_hash).expect("Missing fatdb hash").to_vec(), value) (self.trie.db().get(&aux_hash).expect("Missing fatdb hash").into_vec(), value)
}) })
) )
} }

View File

@ -111,7 +111,7 @@ impl StandardMap {
let v = match self.value_mode { let v = match self.value_mode {
ValueMode::Mirror => k.clone(), ValueMode::Mirror => k.clone(),
ValueMode::Random => Self::random_value(seed), ValueMode::Random => Self::random_value(seed),
ValueMode::Index => encode(&index).to_vec(), ValueMode::Index => encode(&index).into_vec(),
}; };
d.push((k, v)) d.push((k, v))
} }

View File

@ -378,7 +378,7 @@ fn iterator() {
} }
let t = TrieDB::new(&memdb, &root).unwrap(); let t = TrieDB::new(&memdb, &root).unwrap();
assert_eq!(d.iter().map(|i| i.clone().to_vec()).collect::<Vec<_>>(), t.iter().unwrap().map(|x| x.unwrap().0).collect::<Vec<_>>()); assert_eq!(d.iter().map(|i| i.clone().into_vec()).collect::<Vec<_>>(), t.iter().unwrap().map(|x| x.unwrap().0).collect::<Vec<_>>());
assert_eq!(d, t.iter().unwrap().map(|x| x.unwrap().1).collect::<Vec<_>>()); assert_eq!(d, t.iter().unwrap().map(|x| x.unwrap().1).collect::<Vec<_>>());
} }

View File

@ -1026,14 +1026,14 @@ mod tests {
let mut memdb = MemoryDB::new(); let mut memdb = MemoryDB::new();
let mut root = H256::new(); let mut root = H256::new();
let mut t1 = TrieDBMut::new(&mut memdb, &mut root); let mut t1 = TrieDBMut::new(&mut memdb, &mut root);
t1.insert(&[0x01, 0x23], &big_value.to_vec()).unwrap(); t1.insert(&[0x01, 0x23], big_value).unwrap();
t1.insert(&[0x01, 0x34], &big_value.to_vec()).unwrap(); t1.insert(&[0x01, 0x34], big_value).unwrap();
let mut memdb2 = MemoryDB::new(); let mut memdb2 = MemoryDB::new();
let mut root2 = H256::new(); let mut root2 = H256::new();
let mut t2 = TrieDBMut::new(&mut memdb2, &mut root2); let mut t2 = TrieDBMut::new(&mut memdb2, &mut root2);
t2.insert(&[0x01], &big_value.to_vec()).unwrap(); t2.insert(&[0x01], big_value).unwrap();
t2.insert(&[0x01, 0x23], &big_value.to_vec()).unwrap(); t2.insert(&[0x01, 0x23], big_value).unwrap();
t2.insert(&[0x01, 0x34], &big_value.to_vec()).unwrap(); t2.insert(&[0x01, 0x34], big_value).unwrap();
t2.remove(&[0x01]).unwrap(); t2.remove(&[0x01]).unwrap();
} }

View File

@ -48,7 +48,7 @@ pub fn ordered_trie_root<I>(input: I) -> H256
// optimize it later // optimize it later
.into_iter() .into_iter()
.enumerate() .enumerate()
.map(|(i, vec)| (rlp::encode(&i).to_vec(), vec)) .map(|(i, vec)| (rlp::encode(&i).into_vec(), vec))
.collect::<BTreeMap<_, _>>() .collect::<BTreeMap<_, _>>()
// then move them to a vector // then move them to a vector
.into_iter() .into_iter()