Separate migrations from util (#6690)

* separate migration from util and make its dependencies into libs:

* snappy
* kvdb
* error
* common

* renamed common -> macros

* util error does not depend on snappy module

* ethsync does not depend on util nor ethcore_error

* nibbleslice and nibblevec merged with patricia_trie crate

* removed unused dependencies from util

* util journaldb traits does not need to be public

* util_error

* fixed ethcore compile error

* ignore .swo files

* Update chain.rs
This commit is contained in:
Marek Kotewicz 2017-10-10 20:01:27 +02:00 committed by GitHub
parent 4e8853c9f7
commit 6279ff32f5
86 changed files with 322 additions and 170 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@
# vim stuff
*.swp
*.swo
# mac stuff
.DS_Store

86
Cargo.lock generated
View File

@ -600,11 +600,14 @@ dependencies = [
"heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"macros 0.1.0",
"memorydb 0.1.0",
"migration 0.1.0",
"native-contracts 0.1.0",
"num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -619,6 +622,7 @@ dependencies = [
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"semantic_version 0.1.0",
"snappy 0.1.0",
"stats 0.1.0",
"table 0.1.0",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
@ -626,6 +630,7 @@ dependencies = [
"triehash 0.1.0",
"unexpected 0.1.0",
"using_queue 0.1.0",
"util-error 0.1.0",
"vm 0.1.0",
"wasm 0.1.0",
]
@ -752,6 +757,7 @@ dependencies = [
"hash 0.1.0",
"heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memorydb 0.1.0",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -837,6 +843,7 @@ dependencies = [
"futures-cpupool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hash 0.1.0",
"hyper 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"native-contracts 0.1.0",
@ -885,22 +892,19 @@ dependencies = [
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.3",
"ethcore-bloom-journal 0.1.0",
"ethcore-bytes 0.1.0",
"ethcore-devtools 1.8.0",
"ethcore-logger 1.8.0",
"hash 0.1.0",
"hashdb 0.1.0",
"heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memorydb 0.1.0",
"nibbleslice 0.1.0",
"nibblevec 0.1.0",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia_trie 0.1.0",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0",
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -908,6 +912,7 @@ dependencies = [
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash 0.1.0",
"util-error 0.1.0",
"vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1018,7 +1023,9 @@ dependencies = [
"hash 0.1.0",
"heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"macros 0.1.0",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0",
@ -1501,6 +1508,23 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kvdb"
version = "0.1.0"
dependencies = [
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3",
"ethcore-bytes 0.1.0",
"ethcore-devtools 1.8.0",
"hashdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0",
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)",
]
[[package]]
name = "language-tags"
version = "0.2.2"
@ -1582,6 +1606,10 @@ dependencies = [
"linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "macros"
version = "0.1.0"
[[package]]
name = "magenta"
version = "0.1.1"
@ -1636,6 +1664,16 @@ dependencies = [
"rlp 0.2.0",
]
[[package]]
name = "migration"
version = "0.1.0"
dependencies = [
"ethcore-devtools 1.8.0",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"macros 0.1.0",
]
[[package]]
name = "mime"
version = "0.2.6"
@ -1810,21 +1848,6 @@ dependencies = [
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nibbleslice"
version = "0.1.0"
dependencies = [
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nibblevec"
version = "0.1.0"
dependencies = [
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nibbleslice 0.1.0",
]
[[package]]
name = "node-filter"
version = "1.8.0"
@ -1836,6 +1859,7 @@ dependencies = [
"ethcore-network 1.8.0",
"ethcore-util 1.8.0",
"futures 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"native-contracts 0.1.0",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2066,7 +2090,9 @@ dependencies = [
"ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)",
"isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"migration 0.1.0",
"node-filter 1.8.0",
"node-health 0.1.0",
"num_cpus 1.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2210,6 +2236,7 @@ dependencies = [
"ethcore-io 1.8.0",
"ethcore-util 1.8.0",
"ethkey 0.2.0",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0",
"serde 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2267,7 +2294,9 @@ dependencies = [
"jsonrpc-macros 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)",
"jsonrpc-pubsub 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)",
"jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)",
"kvdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"macros 0.1.0",
"multihash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"node-health 0.1.0",
"order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2456,8 +2485,6 @@ dependencies = [
"hashdb 0.1.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memorydb 0.1.0",
"nibbleslice 0.1.0",
"nibblevec 0.1.0",
"rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0",
"triehash 0.1.0",
@ -3070,6 +3097,13 @@ dependencies = [
"heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "snappy"
version = "0.1.0"
dependencies = [
"libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "spmc"
version = "0.2.2"
@ -3480,6 +3514,16 @@ name = "utf8-ranges"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "util-error"
version = "0.1.0"
dependencies = [
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3",
"rlp 0.2.0",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "vcpkg"
version = "0.2.2"

View File

@ -62,6 +62,8 @@ parity-whisper = { path = "whisper" }
path = { path = "util/path" }
panic_hook = { path = "panic_hook" }
hash = { path = "util/hash" }
migration = { path = "util/migration" }
kvdb = { path = "util/kvdb" }
parity-dapps = { path = "dapps", optional = true }
clippy = { version = "0.0.103", optional = true}

View File

@ -55,6 +55,11 @@ rayon = "0.8"
rand = "0.3"
rlp = { path = "../util/rlp" }
rlp_derive = { path = "../util/rlp_derive" }
kvdb = { path = "../util/kvdb" }
util-error = { path = "../util/error" }
snappy = { path = "../util/snappy" }
migration = { path = "../util/migration" }
macros = { path = "../util/macros" }
rust-crypto = "0.2.34"
rustc-hex = "1.0"
stats = { path = "../util/stats" }

View File

@ -39,6 +39,7 @@ parking_lot = "0.4"
stats = { path = "../../util/stats" }
hash = { path = "../../util/hash" }
triehash = { path = "../../util/triehash" }
kvdb = { path = "../../util/kvdb" }
[features]
default = []

View File

@ -45,7 +45,7 @@ use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp, UntrustedRlp};
use heapsize::HeapSizeOf;
use bigint::prelude::U256;
use bigint::hash::{H256, H256FastMap, H264};
use util::kvdb::{DBTransaction, KeyValueDB};
use kvdb::{DBTransaction, KeyValueDB};
use cache::Cache;
use parking_lot::{Mutex, RwLock};
@ -728,12 +728,13 @@ mod tests {
use ethcore::header::Header;
use ethcore::spec::Spec;
use cache::Cache;
use kvdb::{in_memory, KeyValueDB};
use time::Duration;
use parking_lot::Mutex;
fn make_db() -> Arc<::util::KeyValueDB> {
Arc::new(::util::kvdb::in_memory(0))
fn make_db() -> Arc<KeyValueDB> {
Arc::new(in_memory(0))
}
#[test]

View File

@ -36,7 +36,7 @@ use bigint::prelude::U256;
use bigint::hash::H256;
use futures::{IntoFuture, Future};
use util::kvdb::{KeyValueDB, CompactionProfile};
use kvdb::{KeyValueDB, CompactionProfile};
use self::fetch::ChainDataFetcher;
use self::header_chain::{AncestryIter, HeaderChain};
@ -214,7 +214,7 @@ impl<T: ChainDataFetcher> Client<T> {
io_channel: IoChannel<ClientIoMessage>,
cache: Arc<Mutex<Cache>>
) -> Self {
let db = ::util::kvdb::in_memory(0);
let db = ::kvdb::in_memory(0);
Client::new(
config,

View File

@ -25,7 +25,7 @@ use ethcore::db;
use ethcore::service::ClientIoMessage;
use ethcore::spec::Spec;
use io::{IoContext, IoError, IoHandler, IoService};
use util::kvdb::{Database, DatabaseConfig};
use kvdb::{Database, DatabaseConfig};
use cache::Cache;
use parking_lot::Mutex;

View File

@ -91,6 +91,7 @@ extern crate time;
extern crate vm;
extern crate hash;
extern crate triehash;
extern crate kvdb;
#[cfg(feature = "ipc")]
extern crate ethcore_ipc as ipc;

View File

@ -13,6 +13,7 @@ ethcore-bigint = { path = "../../util/bigint" }
ethcore-bytes = { path = "../../util/bytes" }
ethcore-io = { path = "../../util/io" }
ethcore-network = { path = "../../util/network" }
kvdb = { path = "../../util/kvdb" }
native-contracts = { path = "../native_contracts" }
futures = "0.1"
log = "0.3"

View File

@ -24,6 +24,7 @@ extern crate ethcore_network as network;
extern crate native_contracts;
extern crate futures;
extern crate parking_lot;
extern crate kvdb;
#[cfg(test)] extern crate ethcore_io as io;
#[macro_use] extern crate log;
@ -134,7 +135,7 @@ mod test {
let contract_addr = Address::from_str("0000000000000000000000000000000000000005").unwrap();
let data = include_bytes!("../res/node_filter.json");
let spec = Spec::load(&::std::env::temp_dir(), &data[..]).unwrap();
let client_db = Arc::new(::util::kvdb::in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0)));
let client_db = Arc::new(::kvdb::in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0)));
let client = Client::new(
ClientConfig::default(),

View File

@ -26,7 +26,6 @@ use bigint::prelude::U256;
use bigint::hash::{H256, H2048};
use parking_lot::{Mutex, RwLock};
use bytes::Bytes;
use util::*;
use rlp::*;
use header::*;
use super::extras::*;
@ -47,6 +46,7 @@ use encoded;
use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use rayon::prelude::*;
use ansi_term::Colour;
use kvdb::{DBTransaction, KeyValueDB};
const LOG_BLOOMS_LEVELS: usize = 3;
const LOG_BLOOMS_ELEMENTS_PER_INDEX: usize = 16;
@ -1479,7 +1479,7 @@ mod tests {
use std::sync::Arc;
use rustc_hex::FromHex;
use hash::keccak;
use util::kvdb::KeyValueDB;
use kvdb::{in_memory, KeyValueDB};
use bigint::hash::*;
use receipt::{Receipt, TransactionOutcome};
use blockchain::{BlockProvider, BlockChain, Config, ImportRoute};
@ -1493,7 +1493,7 @@ mod tests {
use header::BlockNumber;
fn new_db() -> Arc<KeyValueDB> {
Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
Arc::new(in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
}
fn new_chain(genesis: &[u8], db: Arc<KeyValueDB>) -> BlockChain {

View File

@ -28,7 +28,7 @@ use receipt::Receipt;
use heapsize::HeapSizeOf;
use bigint::prelude::U256;
use bigint::hash::{H256, H264};
use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN;
use kvdb::PREFIX_LEN as DB_PREFIX_LEN;
/// Represents index of extra data in database
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]

View File

@ -26,10 +26,10 @@ use itertools::Itertools;
use hash::keccak;
use timer::PerfTimer;
use bytes::Bytes;
use util::{journaldb, DBValue};
use util::{Address, UtilError};
use util::{Address, journaldb, DBValue};
use util_error::UtilError;
use trie::{TrieSpec, TrieFactory, Trie};
use util::kvdb::*;
use kvdb::*;
// other
use bigint::prelude::U256;
@ -2090,7 +2090,7 @@ mod tests {
use std::time::Duration;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use util::kvdb::DBTransaction;
use kvdb::DBTransaction;
let client = generate_dummy_client(0);
let genesis = client.chain_info().best_block_hash;

View File

@ -20,7 +20,8 @@ use std::fmt::{Display, Formatter, Error as FmtError};
use mode::Mode as IpcMode;
use verification::{VerifierType, QueueConfig};
use util::{journaldb, CompactionProfile};
use util::journaldb;
use kvdb::CompactionProfile;
pub use std::time::Duration;
pub use blockchain::Config as BlockChainConfig;

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::UtilError;
use util_error::UtilError;
use std::fmt::{Display, Formatter, Error as FmtError};
use trie::TrieError;

View File

@ -23,7 +23,7 @@ use bigint::hash::H256;
use util::journaldb;
use trie;
use bytes;
use util::kvdb::{self, KeyValueDB};
use kvdb::{self, KeyValueDB};
use {state, state_db, client, executive, trace, transaction, db, spec, pod_state};
use factory::Factories;
use evm::{self, VMType, FinalizationResult};

View File

@ -27,6 +27,7 @@ use bigint::prelude::U256;
use bigint::hash::H256;
use parking_lot::RwLock;
use util::*;
use kvdb::{Database, DatabaseConfig};
use bytes::Bytes;
use rlp::*;
use ethkey::{Generator, Random};

View File

@ -20,7 +20,7 @@ use std::ops::Deref;
use std::hash::Hash;
use std::collections::HashMap;
use parking_lot::RwLock;
use util::{DBTransaction, KeyValueDB};
use kvdb::{DBTransaction, KeyValueDB};
use rlp;

View File

@ -17,9 +17,12 @@
//! General error types for use in ethcore.
use std::fmt;
use kvdb;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*;
use util_error::UtilError;
use snappy::InvalidInput;
use unexpected::{Mismatch, OutOfBounds};
use trie::TrieError;
use io::*;
@ -299,6 +302,8 @@ impl From<Error> for TransactionImportError {
pub enum Error {
/// Client configuration error.
Client(ClientError),
/// Database error.
Database(kvdb::Error),
/// Error concerning a utility.
Util(UtilError),
/// Error concerning block processing.
@ -322,7 +327,7 @@ pub enum Error {
/// Standard io error.
StdIo(::std::io::Error),
/// Snappy error.
Snappy(::util::snappy::InvalidInput),
Snappy(InvalidInput),
/// Snapshot error.
Snapshot(SnapshotError),
/// Consensus vote error.
@ -337,6 +342,7 @@ impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Client(ref err) => err.fmt(f),
Error::Database(ref err) => err.fmt(f),
Error::Util(ref err) => err.fmt(f),
Error::Io(ref err) => err.fmt(f),
Error::Block(ref err) => err.fmt(f),
@ -370,6 +376,12 @@ impl From<ClientError> for Error {
}
}
impl From<kvdb::Error> for Error {
fn from(err: kvdb::Error) -> Error {
Error::Database(err)
}
}
impl From<TransactionError> for Error {
fn from(err: TransactionError) -> Error {
Error::Transaction(err)
@ -434,8 +446,8 @@ impl From<BlockImportError> for Error {
}
}
impl From<snappy::InvalidInput> for Error {
fn from(err: snappy::InvalidInput) -> Error {
impl From<::snappy::InvalidInput> for Error {
fn from(err: ::snappy::InvalidInput) -> Error {
Error::Snappy(err)
}
}

View File

@ -57,7 +57,7 @@ pub fn json_chain_test(json_data: &[u8]) -> Vec<String> {
};
{
let db = Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)));
let db = Arc::new(::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)));
let client = Client::new(
ClientConfig::default(),
&spec,

View File

@ -112,6 +112,10 @@ extern crate triehash;
extern crate ansi_term;
extern crate semantic_version;
extern crate unexpected;
extern crate kvdb;
extern crate util_error;
extern crate snappy;
extern crate migration;
#[macro_use]
extern crate rlp_derive;
@ -124,11 +128,12 @@ extern crate table;
extern crate bloomable;
extern crate vm;
extern crate wasm;
extern crate ethcore_util as util;
#[macro_use]
extern crate log;
extern crate macros;
#[macro_use]
extern crate ethcore_util as util;
extern crate log;
#[macro_use]
extern crate lazy_static;
#[macro_use]

View File

@ -16,7 +16,7 @@
//! This migration compresses the state db.
use util::migration::{SimpleMigration, Progress};
use migration::{SimpleMigration, Progress};
use rlp::{Compressible, UntrustedRlp, RlpType};
/// Compressing migration.

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::migration::SimpleMigration;
use migration::SimpleMigration;
/// This migration reduces the sizes of keys and moves `ExtrasIndex` byte from back to the front.
pub struct ToV6;

View File

@ -16,7 +16,7 @@
//! Database migrations.
use util::migration::ChangeColumns;
use migration::ChangeColumns;
pub mod state;
pub mod blocks;

View File

@ -22,8 +22,8 @@ use std::collections::HashMap;
use bigint::hash::H256;
use util::Address;
use bytes::Bytes;
use util::kvdb::Database;
use util::migration::{Batch, Config, Error, Migration, SimpleMigration, Progress};
use kvdb::Database;
use migration::{Batch, Config, Error, Migration, SimpleMigration, Progress};
use hash::keccak;
use std::sync::Arc;

View File

@ -22,11 +22,11 @@ use state_db::{ACCOUNT_BLOOM_SPACE, DEFAULT_ACCOUNT_PRESET, StateDB};
use trie::TrieDB;
use views::HeaderView;
use bloom_journal::Bloom;
use util::migration::{Error, Migration, Progress, Batch, Config};
use migration::{Error, Migration, Progress, Batch, Config};
use util::journaldb;
use bigint::hash::H256;
use trie::Trie;
use util::{Database, DBTransaction};
use kvdb::{Database, DBTransaction};
/// Account bloom upgrade routine. If bloom already present, does nothing.
/// If database empty (no best block), does nothing.

View File

@ -18,8 +18,8 @@
//! This migration consolidates all databases into single one using Column Families.
use rlp::{Rlp, RlpStream};
use util::kvdb::Database;
use util::migration::{Batch, Config, Error, Migration, Progress};
use kvdb::Database;
use migration::{Batch, Config, Error, Migration, Progress};
use std::sync::Arc;
/// Which part of block to preserve

View File

@ -19,7 +19,7 @@
use std::sync::Arc;
use std::path::Path;
use bigint::hash::H256;
use util::*;
use kvdb::{Database, DatabaseConfig, KeyValueDB};
use bytes::Bytes;
use io::*;
use spec::Spec;

View File

@ -35,7 +35,7 @@ use snapshot::{Error, ManifestData};
use itertools::{Position, Itertools};
use rlp::{RlpStream, UntrustedRlp};
use bigint::hash::H256;
use util::KeyValueDB;
use kvdb::KeyValueDB;
use bytes::Bytes;
/// Snapshot creation and restoration for PoA chains.

View File

@ -25,7 +25,7 @@ use engines::EthEngine;
use snapshot::{Error, ManifestData};
use bigint::hash::H256;
use util::kvdb::KeyValueDB;
use kvdb::KeyValueDB;
mod authority;
mod work;

View File

@ -31,7 +31,7 @@ use engines::EthEngine;
use snapshot::{Error, ManifestData};
use snapshot::block::AbridgedBlock;
use bigint::hash::H256;
use util::KeyValueDB;
use kvdb::KeyValueDB;
use bytes::Bytes;
use rlp::{RlpStream, UntrustedRlp};
use rand::OsRng;

View File

@ -32,11 +32,12 @@ use ids::BlockId;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{HashDB, DBValue, snappy};
use util::{HashDB, DBValue};
use snappy;
use bytes::Bytes;
use parking_lot::Mutex;
use util::journaldb::{self, Algorithm, JournalDB};
use util::kvdb::KeyValueDB;
use kvdb::KeyValueDB;
use trie::{TrieDB, TrieDBMut, Trie, TrieMut};
use rlp::{RlpStream, UntrustedRlp};
use bloom_journal::Bloom;

View File

@ -37,11 +37,11 @@ use io::IoChannel;
use bigint::hash::H256;
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
use util::UtilError;
use util_error::UtilError;
use bytes::Bytes;
use util::journaldb::Algorithm;
use util::kvdb::{Database, DatabaseConfig};
use util::snappy;
use kvdb::{Database, DatabaseConfig};
use snappy;
/// Helper for removing directories in case of error.
struct Guard(bool, PathBuf);
@ -682,7 +682,7 @@ mod tests {
#[test]
fn cannot_finish_with_invalid_chunks() {
use bigint::hash::H256;
use util::kvdb::DatabaseConfig;
use kvdb::DatabaseConfig;
let spec = get_test_spec();
let dir = RandomTempPath::new();

View File

@ -31,7 +31,8 @@ use snapshot::io::{SnapshotReader, PackedWriter, PackedReader};
use devtools::{RandomTempPath, GuardedTempResult};
use rand::Rng;
use util::{DBValue, KeyValueDB};
use util::DBValue;
use kvdb::KeyValueDB;
use bigint::hash::H256;
use hashdb::HashDB;
use util::journaldb;
@ -165,7 +166,7 @@ pub fn restore(
genesis: &[u8],
) -> Result<(), ::error::Error> {
use std::sync::atomic::AtomicBool;
use util::snappy;
use snappy;
let flag = AtomicBool::new(true);
let components = engine.snapshot_components().unwrap();

View File

@ -31,7 +31,7 @@ use tests::helpers;
use transaction::{Transaction, Action, SignedTransaction};
use util::Address;
use util::kvdb;
use kvdb;
const PASS: &'static str = "";
const TRANSITION_BLOCK_1: usize = 2; // block at which the contract becomes activated.

View File

@ -25,8 +25,8 @@ use snapshot::{chunk_secondary, Error as SnapshotError, Progress, SnapshotCompon
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
use parking_lot::Mutex;
use util::snappy;
use util::kvdb::{self, KeyValueDB, DBTransaction};
use snappy;
use kvdb::{self, KeyValueDB, DBTransaction};
use std::sync::Arc;
use std::sync::atomic::AtomicBool;

View File

@ -27,7 +27,7 @@ use tests::helpers::generate_dummy_client_with_spec_and_data;
use devtools::RandomTempPath;
use io::IoChannel;
use util::kvdb::{Database, DatabaseConfig};
use kvdb::{Database, DatabaseConfig};
struct NoopDBRestore;

View File

@ -27,7 +27,7 @@ use error::Error;
use rand::{XorShiftRng, SeedableRng};
use bigint::hash::H256;
use util::journaldb::{self, Algorithm};
use util::kvdb::{Database, DatabaseConfig};
use kvdb::{Database, DatabaseConfig};
use memorydb::MemoryDB;
use parking_lot::Mutex;
use devtools::RandomTempPath;
@ -76,7 +76,7 @@ fn snap_and_restore() {
for chunk_hash in &reader.manifest().state_hashes {
let raw = reader.chunk(*chunk_hash).unwrap();
let chunk = ::util::snappy::decompress(&raw).unwrap();
let chunk = ::snappy::decompress(&raw).unwrap();
rebuilder.feed(&chunk, &flag).unwrap();
}
@ -190,7 +190,7 @@ fn checks_flag() {
for chunk_hash in &reader.manifest().state_hashes {
let raw = reader.chunk(*chunk_hash).unwrap();
let chunk = ::util::snappy::decompress(&raw).unwrap();
let chunk = ::snappy::decompress(&raw).unwrap();
match rebuilder.feed(&chunk, &flag) {
Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {},

View File

@ -667,7 +667,8 @@ impl Spec {
/// constructor.
pub fn genesis_epoch_data(&self) -> Result<Vec<u8>, String> {
use transaction::{Action, Transaction};
use util::{journaldb, kvdb};
use util::journaldb;
use kvdb;
let genesis = self.genesis_header();

View File

@ -19,14 +19,15 @@ use std::sync::Arc;
use lru_cache::LruCache;
use util::cache::MemoryLruCache;
use util::journaldb::JournalDB;
use util::kvdb::KeyValueDB;
use kvdb::{KeyValueDB, DBTransaction};
use bigint::hash::H256;
use hashdb::HashDB;
use state::{self, Account};
use header::BlockNumber;
use hash::keccak;
use parking_lot::Mutex;
use util::{Address, DBTransaction, UtilError};
use util::Address;
use util_error::UtilError;
use bloom_journal::{Bloom, BloomJournal};
use db::COL_ACCOUNT_BLOOM;
use byteorder::{LittleEndian, ByteOrder};
@ -460,7 +461,8 @@ impl state::Backend for StateDB {
mod tests {
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{Address, DBTransaction};
use util::Address;
use kvdb::DBTransaction;
use tests::helpers::*;
use state::{Account, Backend};
use ethcore_logger::init_log;

View File

@ -27,6 +27,7 @@ use tests::helpers::*;
use types::filter::Filter;
use bigint::prelude::U256;
use util::*;
use kvdb::{Database, DatabaseConfig};
use devtools::*;
use miner::Miner;
use spec::Spec;

View File

@ -231,8 +231,8 @@ pub fn get_test_client_with_blocks(blocks: Vec<Bytes>) -> Arc<Client> {
client
}
fn new_db() -> Arc<KeyValueDB> {
Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
fn new_db() -> Arc<::kvdb::KeyValueDB> {
Arc::new(::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
}
pub fn generate_dummy_blockchain(block_number: u32) -> BlockChain {

View File

@ -27,7 +27,7 @@ use client::*;
use tests::helpers::*;
use devtools::RandomTempPath;
use client::{BlockChainClient, Client, ClientConfig};
use util::kvdb::{Database, DatabaseConfig};
use kvdb::{Database, DatabaseConfig};
use std::sync::Arc;
use header::Header;
use miner::Miner;

View File

@ -22,7 +22,7 @@ use bloomchain::{Number, Config as BloomConfig};
use bloomchain::group::{BloomGroupDatabase, BloomGroupChain, GroupPosition, BloomGroup};
use heapsize::HeapSizeOf;
use bigint::hash::{H256, H264};
use util::{KeyValueDB, DBTransaction};
use kvdb::{KeyValueDB, DBTransaction};
use parking_lot::RwLock;
use header::BlockNumber;
use trace::{LocalizedTrace, Config, Filter, Database as TraceDatabase, ImportRequest, DatabaseExtras};
@ -415,7 +415,8 @@ mod tests {
use std::sync::Arc;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{Address, DBTransaction};
use util::Address;
use kvdb::{DBTransaction, in_memory, KeyValueDB};
use header::BlockNumber;
use trace::{Config, TraceDB, Database as TraceDatabase, DatabaseExtras, ImportRequest};
use trace::{Filter, LocalizedTrace, AddressesFilter, TraceError};
@ -465,8 +466,8 @@ mod tests {
}
}
fn new_db() -> Arc<::util::kvdb::KeyValueDB> {
Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
fn new_db() -> Arc<KeyValueDB> {
Arc::new(in_memory(::db::NUM_COLUMNS.unwrap_or(0)))
}
#[test]

View File

@ -39,7 +39,8 @@ pub use self::types::filter::{Filter, AddressesFilter};
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{Address, DBTransaction};
use util::Address;
use kvdb::DBTransaction;
use bytes::Bytes;
use self::trace::{Call, Create};
use vm::ActionParams;

View File

@ -178,7 +178,7 @@ mod test {
"#;
let spec = Spec::load(&::std::env::temp_dir(), spec_data.as_bytes()).unwrap();
let client_db = Arc::new(::util::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)));
let client_db = Arc::new(::kvdb::in_memory(::db::NUM_COLUMNS.unwrap_or(0)));
let client = Client::new(
ClientConfig::default(),

View File

@ -8,7 +8,8 @@ authors = ["Parity Technologies <admin@parity.io>"]
ethcore-util = { path = "../util" }
ethcore-io = { path = "../util/io" }
ethcore = { path = "../ethcore" }
rlp = {path = "../util/rlp" }
rlp = { path = "../util/rlp" }
kvdb = { path = "../util/kvdb" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"

View File

@ -26,7 +26,7 @@ use ethcore::transaction::{
use ethcore::service::ClientIoMessage;
use io::IoHandler;
use rlp::UntrustedRlp;
use util::kvdb::KeyValueDB;
use kvdb::KeyValueDB;
extern crate ethcore;
extern crate ethcore_util as util;
@ -34,6 +34,7 @@ extern crate ethcore_io as io;
extern crate rlp;
extern crate serde_json;
extern crate serde;
extern crate kvdb;
#[macro_use]
extern crate serde_derive;
@ -242,7 +243,7 @@ mod tests {
#[test]
fn twice_empty() {
let db = Arc::new(::util::kvdb::in_memory(0));
let db = Arc::new(::kvdb::in_memory(0));
{
let store = super::create(db.clone(), None, Dummy(vec![]));
@ -271,7 +272,7 @@ mod tests {
PendingTransaction::new(signed, condition)
}).collect();
let db = Arc::new(::util::kvdb::in_memory(0));
let db = Arc::new(::kvdb::in_memory(0));
{
// nothing written yet, will write pending.
@ -310,7 +311,7 @@ mod tests {
PendingTransaction::new(signed, None)
});
let db = Arc::new(::util::kvdb::in_memory(0));
let db = Arc::new(::kvdb::in_memory(0));
{
// nothing written, will write bad.
let store = super::create(db.clone(), None, Dummy(transactions.clone()));

View File

@ -20,7 +20,8 @@ use std::time::Duration;
use std::fs::File;
use bigint::prelude::U256;
use bigint::hash::clean_0x;
use util::{Address, CompactionProfile};
use util::Address;
use kvdb::CompactionProfile;
use util::journaldb::Algorithm;
use ethcore::client::{Mode, BlockId, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType};
use ethcore::miner::{PendingSet, GasLimit, PrioritizationStrategy};

View File

@ -61,6 +61,8 @@ extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate ethcore_bytes as bytes;
extern crate ethcore_network as network;
extern crate migration as migr;
extern crate kvdb;
extern crate ethkey;
extern crate ethsync;
extern crate node_health;

View File

@ -21,8 +21,8 @@ use std::path::{Path, PathBuf};
use std::fmt::{Display, Formatter, Error as FmtError};
use std::sync::Arc;
use util::journaldb::Algorithm;
use util::migration::{Manager as MigrationManager, Config as MigrationConfig, Error as MigrationError, Migration};
use util::kvdb::{CompactionProfile, Database, DatabaseConfig};
use migr::{Manager as MigrationManager, Config as MigrationConfig, Error as MigrationError, Migration};
use kvdb::{CompactionProfile, Database, DatabaseConfig};
use ethcore::migrations;
use ethcore::db;
use ethcore::migrations::Extract;
@ -282,8 +282,8 @@ mod legacy {
use super::*;
use std::path::{Path, PathBuf};
use util::journaldb::Algorithm;
use util::migration::{Manager as MigrationManager};
use util::kvdb::CompactionProfile;
use migr::{Manager as MigrationManager};
use kvdb::CompactionProfile;
use ethcore::migrations;
/// Blocks database path.

View File

@ -57,12 +57,14 @@ rlp = { path = "../util/rlp" }
stats = { path = "../util/stats" }
vm = { path = "../ethcore/vm" }
hash = { path = "../util/hash" }
kvdb = { path = "../util/kvdb" }
hardware-wallet = { path = "../hw" }
clippy = { version = "0.0.103", optional = true}
pretty_assertions = "0.1"
[dev-dependencies]
macros = { path = "../util/macros" }
ethcore-network = { path = "../util/network" }
[features]

View File

@ -50,6 +50,7 @@ extern crate ethcore_devtools as devtools;
extern crate ethcore_io as io;
extern crate ethcore_ipc;
extern crate ethcore_light as light;
extern crate ethcore_util as util;
extern crate ethcrypto as crypto;
extern crate ethkey;
extern crate ethstore;
@ -64,11 +65,10 @@ extern crate rlp;
extern crate stats;
extern crate hash;
extern crate hardware_wallet;
extern crate kvdb;
#[macro_use]
extern crate log;
#[cfg_attr(test, macro_use)]
extern crate ethcore_util as util;
#[macro_use]
extern crate jsonrpc_macros;
#[macro_use]
@ -81,6 +81,10 @@ extern crate ethjson;
#[macro_use]
extern crate pretty_assertions;
#[cfg(test)]
#[macro_use]
extern crate macros;
pub extern crate jsonrpc_ws_server as ws;
mod authcodes;

View File

@ -33,6 +33,7 @@ use io::IoChannel;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::Address;
use kvdb::in_memory;
use jsonrpc_core::IoHandler;
use v1::impls::{EthClient, SigningUnsafeClient};
@ -130,7 +131,7 @@ impl EthTester {
let client = Client::new(
ClientConfig::default(),
&spec,
Arc::new(::util::kvdb::in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0))),
Arc::new(in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0))),
miner_service.clone(),
IoChannel::disconnected(),
).unwrap();

View File

@ -32,6 +32,7 @@ ethcore-bytes = { path = "../util/bytes" }
ethcore-devtools = { path = "../devtools" }
ethcore-util = { path = "../util" }
ethcore-bigint = { path = "../util/bigint" }
kvdb = { path = "../util/kvdb" }
hash = { path = "../util/hash" }
ethcore-ipc = { path = "../ipc/rpc" }
ethcore-ipc-nano = { path = "../ipc/nano" }

View File

@ -18,7 +18,7 @@ use std::path::PathBuf;
use std::collections::BTreeMap;
use serde_json;
use ethkey::{Secret, Public};
use util::{Database, DatabaseIterator};
use kvdb::{Database, DatabaseIterator};
use types::all::{Error, ServiceConfiguration, ServerKeyId, NodeId};
use serialization::{SerializablePublic, SerializableSecret};
@ -153,7 +153,7 @@ fn upgrade_db(db: Database) -> Result<Database, Error> {
let v2_key = CurrentSerializableDocumentKeyShare {
// author is used in separate generation + encrypt sessions.
// in v0 there have been only simultaneous GenEnc sessions.
author: Public::default().into(), // added in v1
author: Public::default().into(), // added in v1
threshold: v0_key.threshold,
id_numbers: v0_key.id_numbers,
secret_share: v0_key.secret_share,
@ -293,7 +293,7 @@ pub mod tests {
use serde_json;
use devtools::RandomTempPath;
use ethkey::{Random, Generator, Public, Secret};
use util::Database;
use kvdb::Database;
use types::all::{Error, NodeAddress, ServiceConfiguration, ClusterConfiguration, ServerKeyId};
use super::{DB_META_KEY_VERSION, CURRENT_VERSION, KeyStorage, PersistentKeyStorage, DocumentKeyShare,
SerializableDocumentKeyShareV0, SerializableDocumentKeyShareV1,
@ -352,7 +352,7 @@ pub mod tests {
admin_public: None,
},
};
let key1 = ServerKeyId::from(1);
let value1 = DocumentKeyShare {
author: Public::default(),

View File

@ -48,6 +48,7 @@ extern crate ethcrypto;
extern crate ethkey;
extern crate native_contracts;
extern crate hash;
extern crate kvdb;
mod key_server_cluster;
mod types;

View File

@ -22,6 +22,8 @@ ethcore = { path = "../ethcore" }
rlp = { path = "../util/rlp" }
hash = { path = "../util/hash" }
triehash = { path = "../util/triehash" }
kvdb = { path = "../util/kvdb" }
macros = { path = "../util/macros" }
clippy = { version = "0.0.103", optional = true}
log = "0.3"
env_logger = "0.4"

View File

@ -21,7 +21,6 @@ use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP};
use heapsize::HeapSizeOf;
use bigint::hash::H256;
use triehash::ordered_trie_root;
use util::*;
use bytes::Bytes;
use rlp::*;
use network::NetworkError;
@ -406,7 +405,7 @@ impl BlockCollection {
}
}
fn insert_header(&mut self, header: Bytes) -> Result<H256, UtilError> {
fn insert_header(&mut self, header: Bytes) -> Result<H256, DecoderError> {
let info: BlockHeader = UntrustedRlp::new(&header).as_val()?;
let hash = info.hash();
if self.blocks.contains_key(&hash) {

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
///
/// `BlockChain` synchronization strategy.
/// Syncs to peers and keeps up to date.
/// This implementation uses ethereum protocol v63
@ -2230,19 +2229,18 @@ fn accepts_service_transaction(client_id: &str) -> bool {
#[cfg(test)]
mod tests {
use std::collections::{HashSet, VecDeque};
use {ethkey, Address};
use network::PeerId;
use tests::helpers::*;
use tests::snapshot::TestSnapshotService;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::Address;
use parking_lot::RwLock;
use bytes::Bytes;
use rlp::{Rlp, RlpStream, UntrustedRlp};
use super::*;
use ::SyncConfig;
use super::{PeerInfo, PeerAsking};
use ethkey;
use ethcore::header::*;
use ethcore::client::{BlockChainClient, EachBlockWith, TestBlockChainClient};
use ethcore::transaction::UnverifiedTransaction;

View File

@ -42,6 +42,7 @@ extern crate rlp;
extern crate ipnetwork;
extern crate hash;
extern crate triehash;
extern crate kvdb;
extern crate ethcore_light as light;
@ -49,9 +50,9 @@ extern crate ethcore_light as light;
#[cfg(test)] extern crate ethkey;
#[macro_use]
extern crate log;
extern crate macros;
#[macro_use]
extern crate ethcore_util as util;
extern crate log;
#[macro_use]
extern crate heapsize;
#[macro_use]
@ -82,6 +83,9 @@ pub use api::*;
pub use chain::{SyncStatus, SyncState};
pub use network::{is_valid_node_url, NonReservedPeerMode, NetworkError, ConnectionFilter, ConnectionDirection};
#[cfg(test)]
pub(crate) type Address = bigint::hash::H160;
/// IPC interfaces
#[cfg(feature="ipc")]
pub mod remote {

View File

@ -17,7 +17,6 @@
use std::sync::Arc;
use hash::keccak;
use bigint::prelude::U256;
use util::*;
use io::{IoHandler, IoContext, IoChannel};
use ethcore::client::{BlockChainClient, Client};
use ethcore::service::ClientIoMessage;
@ -27,7 +26,7 @@ use ethcore::transaction::*;
use ethcore::account_provider::AccountProvider;
use ethkey::{KeyPair, Secret};
use super::helpers::*;
use SyncConfig;
use {SyncConfig, Address};
struct TestIoHandler {
client: Arc<Client>,

View File

@ -291,7 +291,7 @@ impl TestNet<EthPeer<EthcoreClient>> {
let client = EthcoreClient::new(
ClientConfig::default(),
&spec,
Arc::new(::util::kvdb::in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0))),
Arc::new(::kvdb::in_memory(::ethcore::db::NUM_COLUMNS.unwrap_or(0))),
Arc::new(Miner::with_spec_and_accounts(&spec, accounts)),
IoChannel::disconnected(),
).unwrap();

View File

@ -24,18 +24,16 @@ target_info = "0.1"
ethcore-bigint = { path = "bigint", features = ["heapsizeof"] }
parking_lot = "0.4"
tiny-keccak= "1.0"
ethcore-bloom-journal = { path = "bloom" }
regex = "0.2"
lru-cache = "0.1.0"
ethcore-logger = { path = "../logger" }
triehash = { path = "triehash" }
error-chain = "0.11.0-rc.2"
hashdb = { path = "hashdb" }
patricia_trie = { path = "patricia_trie" }
nibbleslice = { path = "nibbleslice" }
nibblevec = { path = "nibblevec" }
ethcore-bytes = { path = "bytes" }
memorydb = { path = "memorydb" }
util-error = { path = "error" }
kvdb = { path = "kvdb" }
[features]
default = []

10
util/error/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "util-error"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
rlp = { path = "../rlp" }
ethcore-bigint = { path = "../bigint" }
error-chain = "0.11.0-rc.2"
rustc-hex = "1.0"

View File

@ -19,7 +19,14 @@
#![allow(missing_docs)]
#![allow(unknown_lints)]
use std::{self, fmt};
#[macro_use]
extern crate error_chain;
extern crate ethcore_bigint as bigint;
extern crate rlp;
extern crate rustc_hex;
use std::fmt;
use rustc_hex::FromHexError;
use rlp::DecoderError;
use bigint::hash::H256;
@ -59,7 +66,6 @@ error_chain! {
Io(::std::io::Error);
FromHex(FromHexError);
Decoder(DecoderError);
Snappy(::snappy::InvalidInput);
BaseData(BaseDataError);
}
}

17
util/kvdb/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
name = "kvdb"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
log = "0.3"
ethcore-bytes = { path = "../bytes" }
ethcore-bigint = { path = "../bigint" }
ethcore-devtools = { path = "../../devtools" }
elastic-array = "0.9"
hashdb = { path = "../hashdb" }
parking_lot = "0.4"
regex = "0.2"
rlp = { path = "../rlp" }
rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
error-chain = "0.11.0-rc.2"

View File

@ -16,9 +16,23 @@
//! Key-Value store abstraction with `RocksDB` backend.
use std::{mem, fs};
#[macro_use]
extern crate log;
#[macro_use]
extern crate error_chain;
extern crate ethcore_bytes as bytes;
extern crate ethcore_bigint as bigint;
extern crate ethcore_devtools as devtools;
extern crate elastic_array;
extern crate hashdb;
extern crate parking_lot;
extern crate rlp;
extern crate rocksdb;
extern crate regex;
use std::{mem, fs, io};
use std::collections::{HashMap, BTreeMap};
use std::io::ErrorKind;
use std::marker::PhantomData;
use std::path::{PathBuf, Path};
use parking_lot::{Mutex, MutexGuard, RwLock};
@ -28,10 +42,8 @@ use hashdb::DBValue;
use rlp::{UntrustedRlp, RlpType, Compressible};
use rocksdb::{DB, Writable, WriteBatch, WriteOptions, IteratorMode, DBIterator,
Options, DBCompactionStyle, BlockBasedOptions, Direction, Cache, Column, ReadOptions};
use UtilError;
use bytes::Bytes;
#[cfg(target_os = "linux")]
use regex::Regex;
#[cfg(target_os = "linux")]
@ -46,6 +58,16 @@ const DB_WRITE_BUFFER_SIZE: usize = 2048 * 1000;
/// Required length of prefixes.
pub const PREFIX_LEN: usize = 12;
error_chain! {
types {
Error, ErrorKind, ResultExt;
}
foreign_links {
Io(io::Error);
}
}
/// Write transaction. Batches a sequence of put/delete operations for efficiency.
#[derive(Default, Clone, PartialEq)]
pub struct DBTransaction {
@ -182,7 +204,7 @@ pub trait KeyValueDB: Sync + Send {
-> Box<Iterator<Item=(Box<[u8]>, Box<[u8]>)> + 'a>;
/// Attempt to replace this database with a new one located at the given path.
fn restore(&self, new_db: &str) -> Result<(), UtilError>;
fn restore(&self, new_db: &str) -> Result<(), Error>;
}
/// A key-value database fulfilling the `KeyValueDB` trait, living in memory.
@ -279,7 +301,7 @@ impl KeyValueDB for InMemory {
}
}
fn restore(&self, _new_db: &str) -> Result<(), UtilError> {
fn restore(&self, _new_db: &str) -> Result<(), Error> {
Err("Attempted to restore in-memory database".into())
}
}
@ -777,7 +799,7 @@ impl Database {
}
/// Restore the database from a copy at given path.
pub fn restore(&self, new_db: &str) -> Result<(), UtilError> {
pub fn restore(&self, new_db: &str) -> Result<(), Error> {
self.close();
let mut backup_db = PathBuf::from(&self.path);
@ -786,7 +808,7 @@ impl Database {
let existed = match fs::rename(&self.path, &backup_db) {
Ok(_) => true,
Err(e) => if let ErrorKind::NotFound = e.kind() {
Err(e) => if let io::ErrorKind::NotFound = e.kind() {
false
} else {
return Err(e.into());
@ -889,7 +911,7 @@ impl KeyValueDB for Database {
Box::new(unboxed.into_iter().flat_map(|inner| inner))
}
fn restore(&self, new_db: &str) -> Result<(), UtilError> {
fn restore(&self, new_db: &str) -> Result<(), Error> {
Database::restore(self, new_db)
}
}

View File

@ -1,7 +1,6 @@
[package]
name = "nibbleslice"
name = "macros"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
elastic-array = "0.9"

View File

@ -82,8 +82,8 @@ macro_rules! map_into {
#[macro_export]
macro_rules! flush {
($arg:expr) => ($crate::common::flush($arg.into()));
($($arg:tt)*) => ($crate::common::flush(format!("{}", format_args!($($arg)*))));
($arg:expr) => ($crate::flush($arg.into()));
($($arg:tt)*) => ($crate::flush(format!("{}", format_args!($($arg)*))));
}
#[macro_export]

10
util/migration/Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "migration"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
log = "0.3"
macros = { path = "../macros" }
kvdb = { path = "../kvdb" }
ethcore-devtools = { path = "../../devtools" }

View File

@ -18,13 +18,21 @@
#[cfg(test)]
mod tests;
#[macro_use]
extern crate log;
#[macro_use]
extern crate macros;
extern crate ethcore_devtools as devtools;
extern crate kvdb;
use std::collections::BTreeMap;
use std::fs;
use std::fmt;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use ::kvdb::{CompactionProfile, Database, DatabaseConfig, DBTransaction};
use kvdb::{CompactionProfile, Database, DatabaseConfig, DBTransaction};
/// Migration config.
#[derive(Clone)]

View File

@ -21,7 +21,7 @@
use std::collections::BTreeMap;
use std::sync::Arc;
use std::path::{Path, PathBuf};
use migration::{Batch, Config, Error, SimpleMigration, Migration, Manager};
use {Batch, Config, Error, SimpleMigration, Migration, Manager, ChangeColumns};
use kvdb::Database;
use devtools::RandomTempPath;
@ -232,7 +232,7 @@ fn change_columns() {
use kvdb::DatabaseConfig;
let mut manager = Manager::new(Config::default());
manager.add_migration(::migration::ChangeColumns {
manager.add_migration(ChangeColumns {
pre_columns: None,
post_columns: Some(4),
version: 1,

View File

@ -12,8 +12,6 @@ ethcore-bigint = { path = "../bigint" }
hash = { path = "../hash" }
hashdb = { path = "../hashdb" }
rlp = { path = "../rlp" }
nibbleslice = { path = "../nibbleslice" }
nibblevec = { path = "../nibblevec" }
triehash = { path = "../triehash" }
memorydb = { path = "../memorydb" }
ethcore-logger = { path = "../../logger" }

View File

@ -21,8 +21,6 @@ extern crate hash as keccak;
extern crate rlp;
extern crate hashdb;
extern crate ethcore_bytes as bytes;
extern crate nibbleslice;
extern crate nibblevec;
extern crate elastic_array;
extern crate memorydb;
extern crate ethcore_logger;
@ -54,6 +52,8 @@ pub mod recorder;
mod fatdb;
mod fatdbmut;
mod lookup;
mod nibbleslice;
mod nibblevec;
pub use self::standardmap::{Alphabet, StandardMap, ValueMode};
pub use self::triedbmut::TrieDBMut;

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Nibble-orientated view onto byte-slice, allowing nibble-precision offsets.
extern crate elastic_array;
use std::cmp::*;
use std::fmt;
@ -26,9 +25,8 @@ use elastic_array::ElasticArray36;
/// This is an immutable struct. No operations actually change it.
///
/// # Example
/// ```rust
/// extern crate nibbleslice;
/// use nibbleslice::*;
/// ```snippet
/// use patricia_trie::nibbleslice::NibbleSlice;
/// fn main() {
/// let d1 = &[0x01u8, 0x23, 0x45];
/// let d2 = &[0x34u8, 0x50, 0x12];

View File

@ -14,13 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! An owning, nibble-oriented byte vector.
extern crate nibbleslice;
extern crate elastic_array;
use nibbleslice::NibbleSlice;
use elastic_array::ElasticArray36;
use nibbleslice::NibbleSlice;
/// Owning, nibble-oriented byte vector. Counterpart to `NibbleSlice`.
#[derive(Clone, PartialEq, Eq, Debug)]

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use elastic_array::ElasticArray36;
use nibbleslice::*;
use nibbleslice::NibbleSlice;
use nibblevec::NibbleVec;
use bytes::*;
use rlp::*;

View File

@ -16,7 +16,7 @@
use std::fmt;
use hashdb::*;
use nibbleslice::*;
use nibbleslice::NibbleSlice;
use rlp::*;
use super::node::{Node, OwnedNode};
use super::lookup::Lookup;

View File

@ -1,8 +1,7 @@
[package]
name = "nibblevec"
name = "snappy"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
elastic-array = "0.9"
nibbleslice = { path = "../nibbleslice" }
libc = "0.2.7"

View File

@ -15,8 +15,9 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Snappy compression bindings.
extern crate libc;
use std::{self, fmt};
use std::fmt;
use libc::{c_char, c_int, size_t};
const SNAPPY_OK: c_int = 0;

View File

@ -20,7 +20,7 @@ use std::{fmt, str};
use std::sync::Arc;
/// Export the journaldb module.
pub mod traits;
mod traits;
mod archivedb;
mod earlymergedb;
mod overlayrecentdb;

View File

@ -27,7 +27,7 @@ use super::{DB_PREFIX_LEN, LATEST_ERA_KEY};
use super::traits::JournalDB;
use kvdb::{KeyValueDB, DBTransaction};
use bigint::hash::H256;
use UtilError;
use error::UtilError;
use bytes::Bytes;
/// Implementation of the `HashDB` trait for a disk-backed database with a memory overlay

View File

@ -20,7 +20,7 @@ use std::sync::Arc;
use hashdb::*;
use kvdb::{self, DBTransaction};
use bigint::hash::H256;
use UtilError;
use error::UtilError;
use bytes::Bytes;
/// A `HashDB` which can manage a short-term journal potentially containing many forks of mutually

View File

@ -100,7 +100,6 @@ extern crate ethcore_bytes as bytes;
extern crate parking_lot;
extern crate tiny_keccak;
extern crate rlp;
extern crate regex;
extern crate lru_cache;
extern crate heapsize;
extern crate ethcore_logger;
@ -108,22 +107,15 @@ extern crate hash as keccak;
extern crate hashdb;
extern crate memorydb;
extern crate patricia_trie as trie;
#[macro_use]
extern crate error_chain;
extern crate kvdb;
extern crate util_error as error;
#[macro_use]
extern crate log as rlog;
#[macro_use]
pub mod common;
pub mod error;
pub mod misc;
pub mod migration;
pub mod overlaydb;
pub mod journaldb;
pub mod kvdb;
pub mod snappy;
pub mod cache;
pub use misc::*;
@ -131,8 +123,6 @@ pub use hashdb::*;
pub use memorydb::MemoryDB;
pub use overlaydb::*;
pub use journaldb::JournalDB;
pub use kvdb::*;
pub use error::UtilError;
/// 160-bit integer representing account address
pub type Address = bigint::hash::H160;