Make Proposer instantiation potentially async. (#4630)

* Make Proposer instantiation potentially async.

* fix node-service test

* fix basic-authority doc-test

* only block once on futures in test

* use async/await
This commit is contained in:
Robert Habermeier
2020-01-15 21:09:27 +01:00
committed by GitHub
parent ab1be250bc
commit c7069de044
9 changed files with 63 additions and 43 deletions
@@ -74,13 +74,16 @@ pub enum BlockStatus {
/// Environment producer for a Consensus instance. Creates proposer instance and communication streams.
pub trait Environment<B: BlockT> {
/// The proposer type this creates.
type Proposer: Proposer<B> + 'static;
type Proposer: Proposer<B> + Send + 'static;
/// A future that resolves to the proposer.
type CreateProposer: Future<Output = Result<Self::Proposer, Self::Error>>
+ Send + Unpin + 'static;
/// Error which can occur upon creation.
type Error: From<Error> + std::fmt::Debug + 'static;
/// Initialize the proposal logic on top of a specific header. Provide
/// the authorities at that header.
fn init(&mut self, parent_header: &B::Header) -> Result<Self::Proposer, Self::Error>;
fn init(&mut self, parent_header: &B::Header) -> Self::CreateProposer;
}
/// A proposal that is created by a [`Proposer`].