Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ rlp_compress = { path = "../util/rlp_compress" }
rlp_derive = { path = "../util/rlp_derive" }
kvdb = { path = "../util/kvdb" }
kvdb-memorydb = { path = "../util/kvdb-memorydb" }
util-error = { path = "../util/error" }
snappy = { git = "https://github.com/paritytech/rust-snappy" }
stop-guard = { path = "../util/stop-guard" }
macros = { path = "../util/macros" }
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use itertools::Itertools;
use journaldb;
use trie::{TrieSpec, TrieFactory, Trie};
use kvdb::{DBValue, KeyValueDB, DBTransaction};
use util_error::UtilError;

// other
use ethereum_types::{H256, Address, U256};
Expand Down Expand Up @@ -442,7 +441,7 @@ impl Importer {
{
trace_time!("import_old_block");
// verify the block, passing the chain for updating the epoch verifier.
let mut rng = OsRng::new().map_err(UtilError::from)?;
let mut rng = OsRng::new()?;
self.ancient_verifier.verify(&mut rng, &header, &chain)?;

// Commit results
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl Default for ClientConfig {
}
#[cfg(test)]
mod test {
use super::{DatabaseCompactionProfile};
use super::DatabaseCompactionProfile;

#[test]
fn test_default_compaction_profile() {
Expand Down
14 changes: 7 additions & 7 deletions ethcore/src/client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::fmt::{Display, Formatter, Error as FmtError};
use util_error::UtilError;
use std::io;
use ethtrie::TrieError;

/// Client configuration errors.
#[derive(Debug)]
pub enum Error {
/// TrieDB-related error.
Trie(TrieError),
/// Util error
Util(UtilError),
/// Io error.
Io(io::Error),
}

impl From<TrieError> for Error {
Expand All @@ -33,9 +33,9 @@ impl From<TrieError> for Error {
}
}

impl From<UtilError> for Error {
fn from(err: UtilError) -> Self {
Error::Util(err)
impl From<io::Error> for Error {
fn from(err: io::Error) -> Self {
Error::Io(err)
}
}

Expand All @@ -49,7 +49,7 @@ impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> {
match *self {
Error::Trie(ref err) => write!(f, "{}", err),
Error::Util(ref err) => write!(f, "{}", err),
Error::Io(ref err) => write!(f, "{}", err),
}
}
}
4 changes: 0 additions & 4 deletions ethcore/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use std::{fmt, error};
use std::time::SystemTime;
use ethereum_types::{H256, U256, Address, Bloom};
use util_error::{self, UtilError};
use snappy::InvalidInput;
use unexpected::{Mismatch, OutOfBounds};
use ethtrie::TrieError;
Expand Down Expand Up @@ -206,7 +205,6 @@ impl From<Error> for BlockImportError {
match e {
Error(ErrorKind::Block(block_error), _) => BlockImportErrorKind::Block(block_error).into(),
Error(ErrorKind::Import(import_error), _) => BlockImportErrorKind::Import(import_error.into()).into(),
Error(ErrorKind::Util(util_error::ErrorKind::Decoder(decoder_err)), _) => BlockImportErrorKind::Decoder(decoder_err).into(),
_ => BlockImportErrorKind::Other(format!("other block import error: {:?}", e)).into(),
}
}
Expand Down Expand Up @@ -236,7 +234,6 @@ error_chain! {
}

links {
Util(UtilError, util_error::ErrorKind) #[doc = "Error concerning a utility"];
Import(ImportError, ImportErrorKind) #[doc = "Error concerning block import." ];
}

Expand Down Expand Up @@ -326,7 +323,6 @@ impl From<BlockImportError> for Error {
match err {
BlockImportError(BlockImportErrorKind::Block(e), _) => ErrorKind::Block(e).into(),
BlockImportError(BlockImportErrorKind::Import(e), _) => ErrorKind::Import(e).into(),
BlockImportError(BlockImportErrorKind::Other(s), _) => UtilError::from(s).into(),
_ => ErrorKind::Msg(format!("other block import error: {:?}", err)).into(),
}
}
Expand Down
1 change: 0 additions & 1 deletion ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ extern crate patricia_trie_ethereum as ethtrie;
extern crate triehash;
extern crate ansi_term;
extern crate unexpected;
extern crate util_error;
extern crate snappy;
extern crate ethabi;
extern crate rustc_hex;
Expand Down
8 changes: 5 additions & 3 deletions ethcore/src/snapshot/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use io::IoChannel;

use ethereum_types::H256;
use parking_lot::{Mutex, RwLock, RwLockReadGuard};
use util_error::UtilError;
use bytes::Bytes;
use journaldb::Algorithm;
use snappy;
Expand Down Expand Up @@ -621,7 +620,7 @@ impl Service {

match is_done {
true => {
db.key_value().flush().map_err(UtilError::from)?;
db.key_value().flush()?;
drop(db);
return self.finalize_restoration(&mut *restoration);
},
Expand All @@ -634,7 +633,10 @@ impl Service {
}
}
};
result.and_then(|_| db.key_value().flush().map_err(|e| UtilError::from(e).into()))

result?;
db.key_value().flush()?;
Ok(())
}

/// Feed a state chunk to be processed synchronously.
Expand Down
13 changes: 7 additions & 6 deletions ethcore/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

//! State database abstraction. For more info, see the doc for `StateDB`

use std::collections::{VecDeque, HashSet};
use std::io;
use std::sync::Arc;

use bloom_journal::{Bloom, BloomJournal};
use byteorder::{LittleEndian, ByteOrder};
use db::COL_ACCOUNT_BLOOM;
Expand All @@ -30,9 +34,6 @@ use lru_cache::LruCache;
use memory_cache::MemoryLruCache;
use parking_lot::Mutex;
use state::{self, Account};
use std::collections::{VecDeque, HashSet};
use std::sync::Arc;
use util_error::UtilError;

/// Value used to initialize bloom bitmap size.
///
Expand Down Expand Up @@ -181,7 +182,7 @@ impl StateDB {
}

/// Commit blooms journal to the database transaction
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> Result<(), UtilError> {
pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> io::Result<()> {
assert!(journal.hash_functions <= 255);
batch.put(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY, &[journal.hash_functions as u8]);
let mut key = [0u8; 8];
Expand All @@ -196,7 +197,7 @@ impl StateDB {
}

/// Journal all recent operations under the given era and ID.
pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> Result<u32, UtilError> {
pub fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, id: &H256) -> io::Result<u32> {
{
let mut bloom_lock = self.account_bloom.lock();
Self::commit_bloom(batch, bloom_lock.drain_journal())?;
Expand All @@ -209,7 +210,7 @@ impl StateDB {

/// Mark a given candidate from an ancient era as canonical, enacting its removals from the
/// backing database and reverting any non-canonical historical commit's insertions.
pub fn mark_canonical(&mut self, batch: &mut DBTransaction, end_era: u64, canon_id: &H256) -> Result<u32, UtilError> {
pub fn mark_canonical(&mut self, batch: &mut DBTransaction, end_era: u64, canon_id: &H256) -> io::Result<u32> {
self.db.mark_canonical(batch, end_era, canon_id)
}

Expand Down
10 changes: 0 additions & 10 deletions util/error/Cargo.toml

This file was deleted.

71 changes: 0 additions & 71 deletions util/error/src/lib.rs

This file was deleted.

1 change: 0 additions & 1 deletion util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ memorydb = { version = "0.2.0", path = "../memorydb" }
parking_lot = "0.6"
plain_hasher = { path = "../plain_hasher" }
rlp = { path = "../rlp" }
util-error = { path = "../error" }

[dev-dependencies]
ethcore-logger = { path = "../../logger" }
Expand Down
14 changes: 7 additions & 7 deletions util/journaldb/src/archivedb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::io;
use std::sync::Arc;

use bytes::Bytes;
use error::{BaseDataError, UtilError};
use ethereum_types::H256;
use hashdb::*;
use keccak_hasher::KeccakHasher;
use kvdb::{KeyValueDB, DBTransaction};
use rlp::{encode, decode};
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY};
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, error_key_already_exists, error_negatively_reference_hash};
use super::memorydb::*;
use traits::JournalDB;

Expand Down Expand Up @@ -127,7 +127,7 @@ impl JournalDB for ArchiveDB {
self.latest_era.is_none()
}

fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, _id: &H256) -> Result<u32, UtilError> {
fn journal_under(&mut self, batch: &mut DBTransaction, now: u64, _id: &H256) -> io::Result<u32> {
let mut inserts = 0usize;
let mut deletes = 0usize;

Expand All @@ -150,28 +150,28 @@ impl JournalDB for ArchiveDB {
Ok((inserts + deletes) as u32)
}

fn mark_canonical(&mut self, _batch: &mut DBTransaction, _end_era: u64, _canon_id: &H256) -> Result<u32, UtilError> {
fn mark_canonical(&mut self, _batch: &mut DBTransaction, _end_era: u64, _canon_id: &H256) -> io::Result<u32> {
// keep everything! it's an archive, after all.
Ok(0)
}

fn inject(&mut self, batch: &mut DBTransaction) -> Result<u32, UtilError> {
fn inject(&mut self, batch: &mut DBTransaction) -> io::Result<u32> {
let mut inserts = 0usize;
let mut deletes = 0usize;

for i in self.overlay.drain() {
let (key, (value, rc)) = i;
if rc > 0 {
if self.backing.get(self.column, &key)?.is_some() {
return Err(BaseDataError::AlreadyExists(key).into());
return Err(error_key_already_exists(&key));
}
batch.put(self.column, &key, &value);
inserts += 1;
}
if rc < 0 {
assert!(rc == -1);
if self.backing.get(self.column, &key)?.is_none() {
return Err(BaseDataError::NegativelyReferencedHash(key).into());
return Err(error_negatively_reference_hash(&key));
}
batch.delete(self.column, &key);
deletes += 1;
Expand Down
Loading