[ethcore] remove error_chain (#10616)
* Derive Display for BlockError * Convert error_chain errors * Convert ethcore usages of errors * Fix remaining compile errors in ethcore * Fix other crates * Fix tests compilation * Implement error for Snapshot error * Remove redundant into
This commit is contained in:
committed by
Andronik Ordian
parent
b30b54e446
commit
98b89c8e4f
@@ -25,7 +25,7 @@ use ethereum_types::H256;
|
||||
use rlp::{self, Rlp};
|
||||
use types::BlockNumber;
|
||||
use ethcore::client::{BlockStatus, BlockId};
|
||||
use ethcore::error::{ImportErrorKind, QueueErrorKind, BlockError, Error as EthcoreError, ErrorKind as EthcoreErrorKind};
|
||||
use ethcore::error::{ImportError, QueueError, BlockError, Error as EthcoreError};
|
||||
use sync_io::SyncIo;
|
||||
use blocks::{BlockCollection, SyncBody, SyncHeader};
|
||||
use chain::BlockSet;
|
||||
@@ -556,11 +556,11 @@ impl BlockDownloader {
|
||||
};
|
||||
|
||||
match result {
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
|
||||
trace_sync!(self, "Block already in chain {:?}", h);
|
||||
self.block_imported(&h, number, &parent);
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
|
||||
trace_sync!(self, "Block already queued {:?}", h);
|
||||
self.block_imported(&h, number, &parent);
|
||||
},
|
||||
@@ -569,18 +569,18 @@ impl BlockDownloader {
|
||||
imported.insert(h.clone());
|
||||
self.block_imported(&h, number, &parent);
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(_)), _)) if allow_out_of_order => {
|
||||
Err(EthcoreError::Block(BlockError::UnknownParent(_))) if allow_out_of_order => {
|
||||
break;
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(_)), _)) => {
|
||||
Err(EthcoreError::Block(BlockError::UnknownParent(_))) => {
|
||||
trace_sync!(self, "Unknown new block parent, restarting sync");
|
||||
break;
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::TemporarilyInvalid(_)), _)) => {
|
||||
Err(EthcoreError::Block(BlockError::TemporarilyInvalid(_))) => {
|
||||
debug_sync!(self, "Block temporarily invalid: {:?}, restarting sync", h);
|
||||
break;
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Queue(QueueErrorKind::Full(limit)), _)) => {
|
||||
Err(EthcoreError::Queue(QueueError::Full(limit))) => {
|
||||
debug_sync!(self, "Block import queue full ({}), restarting sync", limit);
|
||||
download_action = DownloadAction::Reset;
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,7 @@ use api::WARP_SYNC_PROTOCOL_ID;
|
||||
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
|
||||
use bytes::Bytes;
|
||||
use enum_primitive::FromPrimitive;
|
||||
use ethcore::error::{Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind, BlockError};
|
||||
use ethcore::error::{Error as EthcoreError, ImportError, BlockError};
|
||||
use ethcore::snapshot::{ManifestData, RestorationStatus};
|
||||
use ethcore::verification::queue::kind::blocks::Unverified;
|
||||
use ethereum_types::{H256, U256};
|
||||
@@ -183,10 +183,10 @@ impl SyncHandler {
|
||||
return Err(DownloaderImportError::Invalid);
|
||||
}
|
||||
match io.chain().import_block(block) {
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
|
||||
trace!(target: "sync", "New block already in chain {:?}", hash);
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
|
||||
trace!(target: "sync", "New block already queued {:?}", hash);
|
||||
},
|
||||
Ok(_) => {
|
||||
@@ -195,7 +195,7 @@ impl SyncHandler {
|
||||
sync.new_blocks.mark_as_known(&hash, number);
|
||||
trace!(target: "sync", "New block queued {:?} ({})", hash, number);
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(p)), _)) => {
|
||||
Err(EthcoreError::Block(BlockError::UnknownParent(p))) => {
|
||||
unknown = true;
|
||||
trace!(target: "sync", "New block with unknown parent ({:?}) {:?}", p, hash);
|
||||
},
|
||||
|
||||
@@ -493,7 +493,7 @@ impl<L: AsLightClient> LightSync<L> {
|
||||
|
||||
// handles request dispatch, block import, state machine transitions, and timeouts.
|
||||
fn maintain_sync(&self, ctx: &BasicContext) {
|
||||
use ethcore::error::{Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind};
|
||||
use ethcore::error::{Error as EthcoreError, ImportError};
|
||||
|
||||
const DRAIN_AMOUNT: usize = 128;
|
||||
|
||||
@@ -524,10 +524,10 @@ impl<L: AsLightClient> LightSync<L> {
|
||||
for header in sink.drain(..) {
|
||||
match client.queue_header(header) {
|
||||
Ok(_) => {}
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
|
||||
trace!(target: "sync", "Block already in chain. Continuing.");
|
||||
},
|
||||
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => {
|
||||
Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
|
||||
trace!(target: "sync", "Block already queued. Continuing.");
|
||||
},
|
||||
Err(e) => {
|
||||
|
||||
Reference in New Issue
Block a user