Networking and in-memory client (#38)

* Networking crate draft

* Started work on syncing algo

* Fixed query range

* BlockCollection tests

* In-mem client backend

* Fixed tests

* Renamed Transaction

* Removed stray println

* Docs
This commit is contained in:
Arkadiy Paronyan
2018-01-30 18:49:52 +01:00
committed by Robert Habermeier
parent 8e554129ec
commit 44499550d9
31 changed files with 2689 additions and 154 deletions
+22 -2
View File
@@ -16,8 +16,9 @@
//! Polkadot client possible errors.
use primitives::block;
use std;
use state_machine;
use blockchain;
error_chain! {
errors {
@@ -28,7 +29,7 @@ error_chain! {
}
/// Unknown block.
UnknownBlock(h: block::HeaderHash) {
UnknownBlock(h: blockchain::BlockId) {
description("unknown block"),
display("UnknownBlock: {}", h),
}
@@ -38,6 +39,12 @@ error_chain! {
description("execution error"),
display("Execution: {}", e),
}
/// Blockchain error.
Blockchain(e: Box<std::error::Error + Send>) {
description("Blockchain error"),
display("Blockchain: {}", e),
}
}
}
@@ -47,3 +54,16 @@ impl From<Box<state_machine::Error>> for Error {
ErrorKind::Execution(e).into()
}
}
impl From<state_machine::backend::Void> for Error {
fn from(_e: state_machine::backend::Void) -> Self {
unreachable!()
}
}
impl Error {
/// Chain a blockchain error.
pub fn from_blockchain(e: Box<std::error::Error + Send>) -> Self {
ErrorKind::Blockchain(e).into()
}
}