simplify ethcore errors by removing BlockImportError (#9593)

This commit is contained in:
Marek Kotewicz
2018-09-24 11:28:54 +01:00
committed by GitHub
parent 2f159d4f45
commit b57607e7d3
12 changed files with 56 additions and 112 deletions

View File

@@ -33,7 +33,7 @@ use cht;
use ethcore::block_status::BlockStatus;
use ethcore::encoded;
use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use ethcore::error::{Error, BlockImportError, BlockImportErrorKind, BlockError};
use ethcore::error::{Error, EthcoreResult, ErrorKind as EthcoreErrorKind, BlockError};
use ethcore::header::Header;
use ethcore::ids::BlockId;
use ethcore::spec::{Spec, SpecHardcodedSync};
@@ -351,7 +351,7 @@ impl HeaderChain {
transaction: &mut DBTransaction,
header: &Header,
transition_proof: Option<Vec<u8>>,
) -> Result<PendingChanges, BlockImportError> {
) -> EthcoreResult<PendingChanges> {
self.insert_inner(transaction, header, None, transition_proof)
}
@@ -364,7 +364,7 @@ impl HeaderChain {
header: &Header,
total_difficulty: U256,
transition_proof: Option<Vec<u8>>,
) -> Result<PendingChanges, BlockImportError> {
) -> EthcoreResult<PendingChanges> {
self.insert_inner(transaction, header, Some(total_difficulty), transition_proof)
}
@@ -374,7 +374,7 @@ impl HeaderChain {
header: &Header,
total_difficulty: Option<U256>,
transition_proof: Option<Vec<u8>>,
) -> Result<PendingChanges, BlockImportError> {
) -> EthcoreResult<PendingChanges> {
let hash = header.hash();
let number = header.number();
let parent_hash = *header.parent_hash();
@@ -403,7 +403,7 @@ impl HeaderChain {
.and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash))
.map(|c| c.total_difficulty)
.ok_or_else(|| BlockError::UnknownParent(parent_hash))
.map_err(BlockImportErrorKind::Block)?
.map_err(EthcoreErrorKind::Block)?
};
parent_td + *header.difficulty()

View File

@@ -22,7 +22,7 @@ use ethcore::block_status::BlockStatus;
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
use ethcore::engines::{epoch, EthEngine, EpochChange, EpochTransition, Proof};
use ethcore::machine::EthereumMachine;
use ethcore::error::{Error, BlockImportError};
use ethcore::error::{Error, EthcoreResult};
use ethcore::ids::BlockId;
use ethcore::header::{BlockNumber, Header};
use ethcore::verification::queue::{self, HeaderQueue};
@@ -85,7 +85,7 @@ pub trait LightChainClient: Send + Sync {
/// Queue header to be verified. Required that all headers queued have their
/// parent queued prior.
fn queue_header(&self, header: Header) -> Result<H256, BlockImportError>;
fn queue_header(&self, header: Header) -> EthcoreResult<H256>;
/// Attempt to get a block hash by block id.
fn block_hash(&self, id: BlockId) -> Option<H256>;
@@ -206,7 +206,7 @@ impl<T: ChainDataFetcher> Client<T> {
}
/// Import a header to the queue for additional verification.
pub fn import_header(&self, header: Header) -> Result<H256, BlockImportError> {
pub fn import_header(&self, header: Header) -> EthcoreResult<H256> {
self.queue.import(header).map_err(Into::into)
}
@@ -526,7 +526,7 @@ impl<T: ChainDataFetcher> LightChainClient for Client<T> {
fn chain_info(&self) -> BlockChainInfo { Client::chain_info(self) }
fn queue_header(&self, header: Header) -> Result<H256, BlockImportError> {
fn queue_header(&self, header: Header) -> EthcoreResult<H256> {
self.import_header(header)
}