ethcore does not use byteorder (#10829)
This commit is contained in:
parent
5dc5be1e58
commit
9d9e2b43f2
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -867,7 +867,6 @@ dependencies = [
|
|||||||
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"blooms-db 0.1.0",
|
"blooms-db 0.1.0",
|
||||||
"bn 0.4.4 (git+https://github.com/paritytech/bn)",
|
"bn 0.4.4 (git+https://github.com/paritytech/bn)",
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"common-types 0.1.0",
|
"common-types 0.1.0",
|
||||||
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -10,7 +10,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
ansi_term = "0.11"
|
ansi_term = "0.11"
|
||||||
blooms-db = { path = "../util/blooms-db", optional = true }
|
blooms-db = { path = "../util/blooms-db", optional = true }
|
||||||
bn = { git = "https://github.com/paritytech/bn", default-features = false }
|
bn = { git = "https://github.com/paritytech/bn", default-features = false }
|
||||||
byteorder = "1.0"
|
|
||||||
common-types = { path = "types" }
|
common-types = { path = "types" }
|
||||||
crossbeam = "0.4"
|
crossbeam = "0.4"
|
||||||
derive_more = "0.14.0"
|
derive_more = "0.14.0"
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
||||||
use byteorder::{ByteOrder, BigEndian};
|
|
||||||
use parity_crypto::digest;
|
use parity_crypto::digest;
|
||||||
use num::{BigUint, Zero, One};
|
use num::{BigUint, Zero, One};
|
||||||
|
|
||||||
@ -369,7 +368,9 @@ impl Impl for ModexpImpl {
|
|||||||
// but so would running out of addressable memory!
|
// but so would running out of addressable memory!
|
||||||
let mut read_len = |reader: &mut io::Chain<&[u8], io::Repeat>| {
|
let mut read_len = |reader: &mut io::Chain<&[u8], io::Repeat>| {
|
||||||
reader.read_exact(&mut buf[..]).expect("reading from zero-extended memory cannot fail; qed");
|
reader.read_exact(&mut buf[..]).expect("reading from zero-extended memory cannot fail; qed");
|
||||||
BigEndian::read_u64(&buf[24..]) as usize
|
let mut len_bytes = [0u8; 8];
|
||||||
|
len_bytes.copy_from_slice(&buf[24..]);
|
||||||
|
u64::from_be_bytes(len_bytes) as usize
|
||||||
};
|
};
|
||||||
|
|
||||||
let base_len = read_len(&mut reader);
|
let base_len = read_len(&mut reader);
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
|
|
||||||
extern crate ansi_term;
|
extern crate ansi_term;
|
||||||
extern crate bn;
|
extern crate bn;
|
||||||
extern crate byteorder;
|
|
||||||
extern crate common_types as types;
|
extern crate common_types as types;
|
||||||
extern crate crossbeam;
|
extern crate crossbeam;
|
||||||
extern crate ethabi;
|
extern crate ethabi;
|
||||||
|
@ -21,7 +21,6 @@ use std::io;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bloom_journal::{Bloom, BloomJournal};
|
use bloom_journal::{Bloom, BloomJournal};
|
||||||
use byteorder::{LittleEndian, ByteOrder};
|
|
||||||
use db::COL_ACCOUNT_BLOOM;
|
use db::COL_ACCOUNT_BLOOM;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
@ -169,11 +168,15 @@ impl StateDB {
|
|||||||
let hash_count = hash_count_bytes[0];
|
let hash_count = hash_count_bytes[0];
|
||||||
|
|
||||||
let mut bloom_parts = vec![0u64; ACCOUNT_BLOOM_SPACE / 8];
|
let mut bloom_parts = vec![0u64; ACCOUNT_BLOOM_SPACE / 8];
|
||||||
let mut key = [0u8; 8];
|
|
||||||
for i in 0..ACCOUNT_BLOOM_SPACE / 8 {
|
for i in 0..ACCOUNT_BLOOM_SPACE / 8 {
|
||||||
LittleEndian::write_u64(&mut key, i as u64);
|
let key: [u8; 8] = (i as u64).to_le_bytes();
|
||||||
bloom_parts[i] = db.get(COL_ACCOUNT_BLOOM, &key).expect("low-level database error")
|
bloom_parts[i] = db.get(COL_ACCOUNT_BLOOM, &key).expect("low-level database error")
|
||||||
.and_then(|val| Some(LittleEndian::read_u64(&val[..])))
|
.map(|val| {
|
||||||
|
assert!(val.len() == 8, "low-level database error");
|
||||||
|
let mut buff = [0u8; 8];
|
||||||
|
buff.copy_from_slice(&*val);
|
||||||
|
u64::from_le_bytes(buff)
|
||||||
|
})
|
||||||
.unwrap_or(0u64);
|
.unwrap_or(0u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,12 +189,10 @@ impl StateDB {
|
|||||||
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> io::Result<()> {
|
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> io::Result<()> {
|
||||||
assert!(journal.hash_functions <= 255);
|
assert!(journal.hash_functions <= 255);
|
||||||
batch.put(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY, &[journal.hash_functions as u8]);
|
batch.put(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY, &[journal.hash_functions as u8]);
|
||||||
let mut key = [0u8; 8];
|
|
||||||
let mut val = [0u8; 8];
|
|
||||||
|
|
||||||
for (bloom_part_index, bloom_part_value) in journal.entries {
|
for (bloom_part_index, bloom_part_value) in journal.entries {
|
||||||
LittleEndian::write_u64(&mut key, bloom_part_index as u64);
|
let key: [u8; 8] = (bloom_part_index as u64).to_le_bytes();
|
||||||
LittleEndian::write_u64(&mut val, bloom_part_value);
|
let val: [u8; 8] = bloom_part_value.to_le_bytes();
|
||||||
batch.put(COL_ACCOUNT_BLOOM, &key, &val);
|
batch.put(COL_ACCOUNT_BLOOM, &key, &val);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user