Clean up the public API of sc-network-gossip (#5001)

This commit is contained in:
Pierre Krieger
2020-02-20 13:27:36 +01:00
committed by GitHub
parent 8cdf98c773
commit 5bf644b768
5 changed files with 13 additions and 24 deletions
@@ -44,20 +44,12 @@ pub(crate) struct TestNetwork {
sender: mpsc::UnboundedSender<Event>,
}
impl TestNetwork {
fn event_stream_03(&self) -> Pin<Box<dyn futures::Stream<Item = NetworkEvent> + Send>> {
impl sc_network_gossip::Network<Block> for TestNetwork {
fn event_stream(&self) -> Pin<Box<dyn Stream<Item = NetworkEvent> + Send>> {
let (tx, rx) = mpsc::unbounded();
let _ = self.sender.unbounded_send(Event::EventStream(tx));
Box::pin(rx)
}
}
impl sc_network_gossip::Network<Block> for TestNetwork {
fn event_stream(&self) -> Box<dyn futures01::Stream<Item = NetworkEvent, Error = ()> + Send> {
Box::new(
self.event_stream_03().map(Ok::<_, ()>).compat()
)
}
fn report_peer(&self, who: sc_network::PeerId, cost_benefit: sc_network::ReputationChange) {
let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit));