Consensus message buffering and more (#114)

* CLI options and keystore integration

* Replace multiqueue with future::mpsc

* BFT gossip

* Revert to app_dirs

* generate_from_seed commented

* Refactor event loop

* Start consensus by timer

* Message buffering

* Minor fixes

* Work around duty-roster issue.

* some more minor fixes

* fix compilation

* more consistent formatting

* make bft input stream never conclude

* Minor fixes

* add timestamp module to executive

* more cleanups and logging

* Fixed message propagation
This commit is contained in:
Arkadiy Paronyan
2018-04-06 19:18:26 +02:00
committed by Gav Wood
parent 633b9f4c0b
commit b3dd4e74fd
34 changed files with 413 additions and 146 deletions
+23
View File
@@ -45,6 +45,12 @@ pub trait BlockchainEvents {
fn import_notification_stream(&self) -> BlockchainEventStream;
}
/// Chain head information.
pub trait ChainHead {
/// Get best block header.
fn best_block_header(&self) -> Result<block::Header, error::Error>;
}
/// Client info
// TODO: split queue info from chain info and amalgamate into single struct.
#[derive(Debug)]
@@ -377,6 +383,12 @@ impl<B, E> Client<B, E> where
pub fn justification(&self, id: &BlockId) -> error::Result<Option<primitives::bft::Justification>> {
self.backend.blockchain().justification(*id)
}
/// Get best block header.
pub fn best_block_header(&self) -> error::Result<block::Header> {
let info = self.backend.blockchain().info().map_err(|e| error::Error::from_blockchain(Box::new(e)))?;
Ok(self.header(&BlockId::Hash(info.best_hash))?.expect("Best block header must always exist"))
}
}
impl<B, E> bft::BlockImport for Client<B, E>
@@ -420,6 +432,17 @@ impl<B, E> BlockchainEvents for Client<B, E>
}
}
impl<B, E> ChainHead for Client<B, E>
where
B: backend::Backend,
E: state_machine::CodeExecutor,
error::Error: From<<B::State as state_machine::backend::Backend>::Error>
{
fn best_block_header(&self) -> error::Result<block::Header> {
Client::best_block_header(self)
}
}
#[cfg(test)]
mod tests {
use super::*;
+1 -1
View File
@@ -44,6 +44,6 @@ pub mod genesis;
pub mod block_builder;
mod client;
pub use client::{Client, ClientInfo, CallResult, ImportResult,
pub use client::{Client, ClientInfo, CallResult, ImportResult, ChainHead,
BlockStatus, BlockOrigin, new_in_mem, BlockchainEventStream, BlockchainEvents};
pub use blockchain::Info as ChainInfo;