committed by
Niklas Adolfsson
parent
e9bd41b3f1
commit
8d171a37f8
@@ -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};
|
||||
@@ -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
|
||||
|
||||
@@ -152,7 +152,7 @@ impl Default for ClientConfig {
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::{DatabaseCompactionProfile};
|
||||
use super::DatabaseCompactionProfile;
|
||||
|
||||
#[test]
|
||||
fn test_default_compaction_profile() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// 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.
|
||||
@@ -23,8 +23,8 @@ use ethtrie::TrieError;
|
||||
pub enum Error {
|
||||
/// TrieDB-related error.
|
||||
Trie(TrieError),
|
||||
/// Util error
|
||||
Util(UtilError),
|
||||
/// Io error.
|
||||
Io(io::Error),
|
||||
}
|
||||
|
||||
impl From<TrieError> for Error {
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
@@ -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." ];
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
},
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
@@ -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.
|
||||
///
|
||||
@@ -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];
|
||||
@@ -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())?;
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user