Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Switch consensus crates to new futures #3146

Merged
merged 11 commits into from
Jul 25, 2019

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Jul 19, 2019

I had this PR almost ready for a long time, was just waiting for #3117 to be merged.

Switches consensus/* to new futures.
Most notably, however, start_aura and start_babe still return an old future (by building a new future and putting the compatibility layer around), so that we avoid breaking everything.

cc #3099

@tomaka tomaka added A0-please_review Pull request needs code review. B2-breaksapi labels Jul 19, 2019
@@ -75,7 +75,7 @@ pub trait Proposer<B: BlockT> {
/// Error type which can occur when proposing or evaluating.
type Error: From<Error> + ::std::fmt::Debug + 'static;
/// Future that resolves to a committed proposal.
type Create: IntoFuture<Item=B, Error=Self::Error>;
type Create: Future<Output = Result<B, Self::Error>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this change is because the IntoFuture trait no longer exists.

if let Some(pool) = &mut pool {
// TODO: this expect() can be removed once
// https://github.com/rust-lang-nursery/futures-rs/pull/1750 is merged and deployed
pool.spawn(future).expect("ThreadPool can never fail to spawn tasks; QED");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it is unfortunately no longer possible to properly recover from task spawning errors.
I went for creating a local ThreadPool here so that we are guaranteed to never have any error (as in: if creating the pool succeeds, then spawning the task will also succeed).
In the future, we should probably pass some task spawning utility by parameter, but the idiomatic way to do that remains to be discovered.

This was referenced Jul 22, 2019
@rphmeier rphmeier added A8-looksgood and removed A0-please_review Pull request needs code review. labels Jul 23, 2019
@rphmeier
Copy link
Contributor

I'd prefer to merge the BABE PRs first, if that's OK.

@gavofyork gavofyork merged commit 31942f4 into paritytech:master Jul 25, 2019
@tomaka tomaka deleted the tmp-new-fut-common branch July 25, 2019 06:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants