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
+2 -2
View File
@@ -59,7 +59,7 @@ impl error::Error for Void {
/// In-memory backend. Fully recomputes tries on each commit but useful for
/// tests.
#[derive(Default)]
#[derive(Default, Clone)]
pub struct InMemory {
inner: MemoryState, // keeps all the state in memory.
}
@@ -67,7 +67,7 @@ pub struct InMemory {
impl Backend for InMemory {
type Error = Void;
fn storage(&self, key: &[u8]) -> Result<&[u8], Void> {
fn storage(&self, key: &[u8]) -> Result<&[u8], Self::Error> {
Ok(self.inner.storage(key).unwrap_or(&[]))
}
+2 -2
View File
@@ -43,7 +43,7 @@ pub enum Update {
}
// in-memory section of the state.
#[derive(Default)]
#[derive(Default, Clone)]
struct MemoryState {
storage: HashMap<Vec<u8>, Vec<u8>>,
}
@@ -152,7 +152,7 @@ pub trait Externalities {
}
/// Code execution engine.
pub trait CodeExecutor: Sized {
pub trait CodeExecutor: Sized + Send + Sync {
/// Externalities error type.
type Error: Error;