Replace error-chain for client error (#2231)

* WIP: convert client error

* Remove error_chain for client error

* Ignore tx-pool error deprecation warning

* Update Cargo.lock files

* Fix tests

* Increment impl_version

* Derive From impls, remove allow(missing_docs)

* Remove space

* Remove redundant into()s

* Blockchain Error source

* Bump impl version
This commit is contained in:
Andrew Jones
2019-04-11 20:33:43 +01:00
committed by Bastian Köcher
parent 1e0c1d8850
commit 7f59cdb900
39 changed files with 298 additions and 290 deletions
+12 -12
View File
@@ -29,7 +29,7 @@ use crate::backend::{AuxStore, NewBlockState};
use crate::blockchain::{Backend as BlockchainBackend, BlockStatus, Cache as BlockchainCache,
HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, ProvideCache};
use crate::cht;
use crate::error::{ErrorKind as ClientErrorKind, Result as ClientResult};
use crate::error::{Error as ClientError, Result as ClientResult};
use crate::light::fetcher::{Fetcher, RemoteHeaderRequest};
/// Light client blockchain storage.
@@ -114,7 +114,7 @@ impl<S, F, Block> BlockchainHeaderBackend<Block> for Blockchain<S, F> where Bloc
return Ok(None);
}
self.fetcher().upgrade().ok_or(ClientErrorKind::NotAvailableOnLightClient)?
self.fetcher().upgrade().ok_or(ClientError::NotAvailableOnLightClient)?
.remote_header(RemoteHeaderRequest {
cht_root: self.storage.header_cht_root(cht::SIZE, number)?,
block: number,
@@ -202,22 +202,22 @@ pub mod tests {
impl BlockchainHeaderBackend<Block> for DummyStorage {
fn header(&self, _id: BlockId<Block>) -> ClientResult<Option<Header>> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn info(&self) -> ClientResult<Info<Block>> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn status(&self, _id: BlockId<Block>) -> ClientResult<BlockStatus> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn number(&self, hash: Hash) -> ClientResult<Option<NumberFor<Block>>> {
if hash == Default::default() {
Ok(Some(Default::default()))
} else {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
}
@@ -225,7 +225,7 @@ pub mod tests {
if number == 0 {
Ok(Some(Default::default()))
} else {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
}
}
@@ -261,26 +261,26 @@ pub mod tests {
}
fn set_head(&self, _block: BlockId<Block>) -> ClientResult<()> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn finalize_header(&self, _block: BlockId<Block>) -> ClientResult<()> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn last_finalized(&self) -> ClientResult<Hash> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn header_cht_root(&self, _cht_size: u64, _block: u64) -> ClientResult<Hash> {
Err(ClientErrorKind::Backend("Test error".into()).into())
Err(ClientError::Backend("Test error".into()))
}
fn changes_trie_cht_root(&self, cht_size: u64, block: u64) -> ClientResult<Hash> {
cht::block_to_cht_number(cht_size, block)
.and_then(|cht_num| self.changes_tries_cht_roots.get(&cht_num))
.cloned()
.ok_or_else(|| ClientErrorKind::Backend(
.ok_or_else(|| ClientError::Backend(
format!("Test error: CHT for block #{} not found", block)
).into())
}