UtilError uses error_chain!, moved OutOfBounds and Mismatched to unexpected crate

This commit is contained in:
debris
2017-09-05 12:14:03 +02:00
parent ccd6ad52cc
commit 236b6f1c3e
25 changed files with 137 additions and 131 deletions

View File

@@ -26,7 +26,7 @@ use rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, DecoderError};
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{Bytes, Address};
use util::error::{Mismatch, OutOfBounds};
use unexpected::{Mismatch, OutOfBounds};
use basic_types::{LogBloom, Seal};
use vm::{EnvInfo, LastHashes};

View File

@@ -25,6 +25,7 @@ use itertools::Itertools;
// util
use hash::keccak;
use timer::PerfTimer;
use util::UtilError;
use util::Bytes;
use util::{journaldb, DBValue, TrieFactory, Trie};
use util::Address;
@@ -252,7 +253,7 @@ impl Client {
last_hashes: RwLock::new(VecDeque::new()),
factories: factories,
history: history,
rng: Mutex::new(OsRng::new().map_err(::util::UtilError::StdIo)?),
rng: Mutex::new(OsRng::new().map_err(UtilError::from)?),
ancient_verifier: Mutex::new(None),
on_user_defaults_change: Mutex::new(None),
registrar: Mutex::new(None),

View File

@@ -46,6 +46,7 @@ use bigint::prelude::{U256, U128};
use bigint::hash::{H256, H520};
use semantic_version::SemanticVersion;
use parking_lot::{Mutex, RwLock};
use unexpected::{Mismatch, OutOfBounds};
use util::*;
mod finality;

View File

@@ -23,6 +23,7 @@ use bigint::prelude::U256;
use bigint::hash::{H256, H520};
use parking_lot::RwLock;
use util::*;
use unexpected::{Mismatch, OutOfBounds};
use ethkey::{recover, public_to_address, Signature};
use account_provider::AccountProvider;
use block::*;

View File

@@ -58,6 +58,7 @@ use bigint::prelude::U256;
use bigint::hash::H256;
use semantic_version::SemanticVersion;
use util::*;
use unexpected::{Mismatch, OutOfBounds};
/// Default EIP-210 contrat code.
/// As defined in https://github.com/ethereum/EIPs/pull/210/commits/9df24a3714af42e3bf350265bdc75b486c909d7f#diff-e02a92c2fb96c1a1bfb05e4c6e2ef5daR49

View File

@@ -34,6 +34,7 @@ use bigint::prelude::{U128, U256};
use bigint::hash::{H256, H520};
use parking_lot::RwLock;
use util::*;
use unexpected::{OutOfBounds, Mismatch};
use client::EngineClient;
use error::{Error, BlockError};
use header::{Header, BlockNumber};

View File

@@ -27,6 +27,7 @@ use parking_lot::{Mutex, RwLock};
use util::*;
use util::cache::MemoryLruCache;
use unexpected::Mismatch;
use rlp::{UntrustedRlp, RlpStream};
use basic_types::LogBloom;

View File

@@ -20,6 +20,7 @@ use std::fmt;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*;
use unexpected::{Mismatch, OutOfBounds};
use io::*;
use header::BlockNumber;
use basic_types::LogBloom;
@@ -391,7 +392,7 @@ impl From<ExecutionError> for Error {
impl From<::rlp::DecoderError> for Error {
fn from(err: ::rlp::DecoderError) -> Error {
Error::Util(UtilError::Decoder(err))
Error::Util(UtilError::from(err))
}
}
@@ -424,7 +425,7 @@ impl From<BlockImportError> for Error {
match err {
BlockImportError::Block(e) => Error::Block(e),
BlockImportError::Import(e) => Error::Import(e),
BlockImportError::Other(s) => Error::Util(UtilError::SimpleString(s)),
BlockImportError::Other(s) => Error::Util(UtilError::from(s)),
}
}
}

View File

@@ -23,6 +23,7 @@ use ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager};
use bigint::prelude::U256;
use bigint::hash::{H256, H64};
use util::*;
use unexpected::{OutOfBounds, Mismatch};
use block::*;
use builtin::Builtin;
use vm::EnvInfo;

View File

@@ -108,6 +108,7 @@ extern crate heapsize;
extern crate triehash;
extern crate ansi_term;
extern crate semantic_version;
extern crate unexpected;
#[macro_use]
extern crate rlp_derive;

View File

@@ -102,7 +102,7 @@ impl Restoration {
let block_chunks = manifest.block_hashes.iter().cloned().collect();
let raw_db = Arc::new(Database::open(params.db_config, &*params.db_path.to_string_lossy())
.map_err(UtilError::SimpleString)?);
.map_err(UtilError::from)?);
let chain = BlockChain::new(Default::default(), params.genesis, raw_db.clone());
let components = params.engine.snapshot_components()
@@ -519,7 +519,7 @@ impl Service {
match is_done {
true => {
db.flush().map_err(::util::UtilError::SimpleString)?;
db.flush().map_err(UtilError::from)?;
drop(db);
return self.finalize_restoration(&mut *restoration);
},
@@ -532,7 +532,7 @@ impl Service {
}
}
};
result.and_then(|_| db.flush().map_err(|e| ::util::UtilError::SimpleString(e).into()))
result.and_then(|_| db.flush().map_err(|e| UtilError::from(e).into()))
}
/// Feed a state chunk to be processed synchronously.

View File

@@ -27,6 +27,7 @@ use triehash::ordered_trie_root;
use heapsize::HeapSizeOf;
use bigint::hash::H256;
use util::*;
use unexpected::{Mismatch, OutOfBounds};
use engines::Engine;
use error::{BlockError, Error};
use blockchain::*;
@@ -274,6 +275,7 @@ mod tests {
use bigint::prelude::U256;
use bigint::hash::{H256, H2048};
use triehash::ordered_trie_root;
use unexpected::{Mismatch, OutOfBounds};
use util::*;
use ethkey::{Random, Generator};
use header::*;