This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
gossip: futures 03 Receiver #3832
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3870231
gossip: futures 03 receiver
kigawas 44f3bc7
fix gossip test
kigawas 02233f9
use tokio 01
kigawas ab1f19a
add comment
kigawas 29fce83
Update core/finality-grandpa/src/communication/mod.rs
kigawas 65f984f
resolve conflicts
kigawas a8e5039
fix format
kigawas 5ebb09e
rename
kigawas 9fada80
remove tokio 01 runtime
kigawas 98e324e
Merge branch 'master' of https://github.com/paritytech/substrate into…
kigawas cdb61f6
minor fix
kigawas 57e4a92
make stable happy
kigawas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ use std::sync::Arc; | |
|
|
||
| use futures::prelude::*; | ||
| use futures::sync::{oneshot, mpsc}; | ||
| use futures03::stream::{StreamExt, TryStreamExt}; | ||
| use grandpa::Message::{Prevote, Precommit, PrimaryPropose}; | ||
| use grandpa::{voter, voter_set::VoterSet}; | ||
| use log::{debug, trace}; | ||
|
|
@@ -145,12 +146,19 @@ impl<B, S, H> Network<B> for Arc<NetworkService<B, S, H>> where | |
| S: network::specialization::NetworkSpecialization<B>, | ||
| H: network::ExHashT, | ||
| { | ||
| type In = NetworkStream; | ||
| type In = NetworkStream< | ||
| Box<dyn Stream<Item = network_gossip::TopicNotification, Error = ()> + Send + 'static>, | ||
| >; | ||
|
|
||
| #[allow(deprecated)] | ||
| fn messages_for(&self, topic: B::Hash) -> Self::In { | ||
| let (tx, rx) = oneshot::channel(); | ||
| self.with_gossip(move |gossip, _| { | ||
| let inner_rx = gossip.messages_for(GRANDPA_ENGINE_ID, topic); | ||
| let inner_rx = gossip | ||
| .messages_for(GRANDPA_ENGINE_ID, topic) | ||
| .map(|x| Ok(x)) | ||
| .compat() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I have understood correctly, at some point when the call site of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not compile anymore, when message for returns a future03 stream. So, we don't need to have any Todo here. |
||
| .boxed(); // Box::new() will break | ||
|
kigawas marked this conversation as resolved.
Outdated
|
||
| let _ = tx.send(inner_rx); | ||
| }); | ||
| NetworkStream { outer: rx, inner: None } | ||
|
|
@@ -203,12 +211,15 @@ impl<B, S, H> Network<B> for Arc<NetworkService<B, S, H>> where | |
| } | ||
|
|
||
| /// A stream used by NetworkBridge in its implementation of Network. | ||
| pub struct NetworkStream { | ||
| inner: Option<mpsc::UnboundedReceiver<network_gossip::TopicNotification>>, | ||
| outer: oneshot::Receiver<mpsc::UnboundedReceiver<network_gossip::TopicNotification>> | ||
| pub struct NetworkStream<R> { | ||
| inner: Option<R>, | ||
| outer: oneshot::Receiver<R>, | ||
| } | ||
|
|
||
| impl Stream for NetworkStream { | ||
| impl<R> Stream for NetworkStream<R> | ||
| where | ||
| R: Stream<Item = network_gossip::TopicNotification, Error = ()>, | ||
| { | ||
| type Item = network_gossip::TopicNotification; | ||
| type Error = (); | ||
|
|
||
|
|
@@ -221,9 +232,9 @@ impl Stream for NetworkStream { | |
| let poll_result = inner.poll(); | ||
| self.inner = Some(inner); | ||
| poll_result | ||
| }, | ||
| } | ||
| Ok(futures::Async::NotReady) => Ok(futures::Async::NotReady), | ||
| Err(_) => Err(()) | ||
| Err(_) => Err(()), | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.