Merge remote-tracking branch 'parity/master'
This commit is contained in:
@@ -23,12 +23,12 @@ rlp = { path = "rlp" }
|
||||
heapsize = { version = "0.3", features = ["unstable"] }
|
||||
itertools = "0.4"
|
||||
sha3 = { path = "sha3" }
|
||||
clippy = { version = "0.0.85", optional = true}
|
||||
clippy = { version = "0.0.90", optional = true}
|
||||
ethcore-devtools = { path = "../devtools" }
|
||||
libc = "0.2.7"
|
||||
vergen = "0.1"
|
||||
target_info = "0.1"
|
||||
bigint = { path = "bigint" }
|
||||
ethcore-bigint = { path = "bigint" }
|
||||
parking_lot = "0.2.6"
|
||||
using_queue = { path = "using_queue" }
|
||||
table = { path = "table" }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[package]
|
||||
description = "Rust-assembler implementation of big integers arithmetic"
|
||||
description = "Large fixed-size integers and hash function outputs"
|
||||
homepage = "http://ethcore.io"
|
||||
repository = "https://github.com/ethcore/parity"
|
||||
license = "GPL-3.0"
|
||||
name = "bigint"
|
||||
name = "ethcore-bigint"
|
||||
version = "0.1.0"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
@@ -14,6 +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/>.
|
||||
|
||||
//! Efficient large, fixed-size big integers and hashes.
|
||||
|
||||
#![cfg_attr(asm_available, feature(asm))]
|
||||
|
||||
extern crate rand;
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
//
|
||||
|
||||
//! Big unsigned integer types
|
||||
//! Big unsigned integer types.
|
||||
//!
|
||||
//! Implementation of a various large-but-fixed sized unsigned integer types.
|
||||
//! The functions here are designed to be fast.
|
||||
//!
|
||||
//! The functions here are designed to be fast. There are optional `x86_64`
|
||||
//! implementations for even more speed, hidden behind the `x64_arithmetic`
|
||||
//! feature flag.
|
||||
|
||||
use std::{mem, fmt};
|
||||
use std::str::{FromStr};
|
||||
|
||||
@@ -14,7 +14,7 @@ time = "0.1.34"
|
||||
tiny-keccak = "1.0"
|
||||
rust-crypto = "0.2.34"
|
||||
slab = "0.2"
|
||||
clippy = { version = "0.0.85", optional = true}
|
||||
clippy = { version = "0.0.90", optional = true}
|
||||
igd = "0.5.0"
|
||||
libc = "0.2.7"
|
||||
parking_lot = "0.2.6"
|
||||
|
||||
@@ -7,6 +7,6 @@ authors = ["Ethcore <admin@ethcore.io>"]
|
||||
|
||||
[dependencies]
|
||||
elastic-array = "0.5"
|
||||
bigint = { path = "../bigint" }
|
||||
ethcore-bigint = { path = "../bigint" }
|
||||
lazy_static = "0.2"
|
||||
rustc-serialize = "0.3"
|
||||
@@ -65,7 +65,7 @@ pub use self::rlpin::{Rlp, RlpIterator};
|
||||
pub use self::rlpstream::RlpStream;
|
||||
pub use self::rlpcompression::RlpType;
|
||||
|
||||
extern crate bigint;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate elastic_array;
|
||||
extern crate rustc_serialize;
|
||||
|
||||
|
||||
@@ -330,8 +330,8 @@ impl Database {
|
||||
|
||||
/// Commit buffered changes to database.
|
||||
pub fn flush(&self) -> Result<(), String> {
|
||||
match &*self.db.read() {
|
||||
&Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
match *self.db.read() {
|
||||
Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
let batch = WriteBatch::new();
|
||||
let mut overlay = self.overlay.write();
|
||||
|
||||
@@ -366,15 +366,15 @@ impl Database {
|
||||
}
|
||||
db.write_opt(batch, &self.write_opts)
|
||||
},
|
||||
&None => Err("Database is closed".to_owned())
|
||||
None => Err("Database is closed".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Commit transaction to database.
|
||||
pub fn write(&self, tr: DBTransaction) -> Result<(), String> {
|
||||
match &*self.db.read() {
|
||||
&Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
match *self.db.read() {
|
||||
Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
let batch = WriteBatch::new();
|
||||
let ops = tr.ops;
|
||||
for op in ops {
|
||||
@@ -393,14 +393,14 @@ impl Database {
|
||||
}
|
||||
db.write_opt(batch, &self.write_opts)
|
||||
},
|
||||
&None => Err("Database is closed".to_owned())
|
||||
None => Err("Database is closed".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
/// Get value by key.
|
||||
pub fn get(&self, col: Option<u32>, key: &[u8]) -> Result<Option<Bytes>, String> {
|
||||
match &*self.db.read() {
|
||||
&Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
match *self.db.read() {
|
||||
Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
let overlay = &self.overlay.read()[Self::to_overlay_column(col)];
|
||||
match overlay.get(key) {
|
||||
Some(&KeyState::Insert(ref value)) | Some(&KeyState::InsertCompressed(ref value)) => Ok(Some(value.clone())),
|
||||
@@ -412,15 +412,15 @@ impl Database {
|
||||
},
|
||||
}
|
||||
},
|
||||
&None => Ok(None),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get value by partial key. Prefix size should match configured prefix size. Only searches flushed values.
|
||||
// TODO: support prefix seek for unflushed data
|
||||
pub fn get_by_prefix(&self, col: Option<u32>, prefix: &[u8]) -> Option<Box<[u8]>> {
|
||||
match &*self.db.read() {
|
||||
&Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
match *self.db.read() {
|
||||
Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
let mut iter = col.map_or_else(|| db.iterator(IteratorMode::From(prefix, Direction::Forward)),
|
||||
|c| db.iterator_cf(cfs[c as usize], IteratorMode::From(prefix, Direction::Forward)).unwrap());
|
||||
match iter.next() {
|
||||
@@ -429,19 +429,19 @@ impl Database {
|
||||
_ => None
|
||||
}
|
||||
},
|
||||
&None => None,
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get database iterator for flushed data.
|
||||
pub fn iter(&self, col: Option<u32>) -> DatabaseIterator {
|
||||
//TODO: iterate over overlay
|
||||
match &*self.db.read() {
|
||||
&Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
match *self.db.read() {
|
||||
Some(DBAndColumns { ref db, ref cfs }) => {
|
||||
col.map_or_else(|| DatabaseIterator { iter: db.iterator(IteratorMode::Start) },
|
||||
|c| DatabaseIterator { iter: db.iterator_cf(cfs[c as usize], IteratorMode::Start).unwrap() })
|
||||
},
|
||||
&None => panic!("Not supported yet") //TODO: return an empty iterator or change return type
|
||||
None => panic!("Not supported yet") //TODO: return an empty iterator or change return type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ extern crate time;
|
||||
extern crate ethcore_devtools as devtools;
|
||||
extern crate libc;
|
||||
extern crate target_info;
|
||||
extern crate bigint;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate parking_lot;
|
||||
extern crate ansi_term;
|
||||
extern crate tiny_keccak;
|
||||
|
||||
@@ -63,6 +63,12 @@ pub struct BasicRecorder {
|
||||
min_depth: u32,
|
||||
}
|
||||
|
||||
impl Default for BasicRecorder {
|
||||
fn default() -> Self {
|
||||
BasicRecorder::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl BasicRecorder {
|
||||
/// Create a new `BasicRecorder` which records all given nodes.
|
||||
#[inline]
|
||||
@@ -233,4 +239,4 @@ mod tests {
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ impl<'db> TrieDB<'db> {
|
||||
}
|
||||
|
||||
/// Get the root node's RLP.
|
||||
fn root_node<'a, R: 'a + Recorder>(&self, r: &'a mut R) -> super::Result<Node> {
|
||||
fn root_node<R: Recorder>(&self, r: &mut R) -> super::Result<Node> {
|
||||
self.root_data(r).map(Node::decoded)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user