Use async/await in build_network_future (#6533)

* Use async/await in build_network_future

* Address concerns

* Fix test
This commit is contained in:
Pierre Krieger
2020-07-07 12:32:30 +02:00
committed by GitHub
parent cccf57a79f
commit 36cf6e7dc4
6 changed files with 257 additions and 170 deletions
+2 -3
View File
@@ -29,7 +29,6 @@ use sp_runtime::traits::{Block as BlockT, Header};
use sp_transaction_pool::TransactionPool;
use sp_utils::{status_sinks, mpsc::tracing_unbounded};
use std::{fmt::Display, sync::Arc, time::Duration, collections::VecDeque};
use parking_lot::Mutex;
mod display;
@@ -82,7 +81,7 @@ impl<T: TransactionPool + MallocSizeOf> TransactionPoolAndMaybeMallogSizeOf for
/// Builds the informant and returns a `Future` that drives the informant.
pub fn build<B: BlockT, C>(
client: Arc<C>,
network_status_sinks: Arc<Mutex<status_sinks::StatusSinks<(NetworkStatus<B>, NetworkState)>>>,
network_status_sinks: Arc<status_sinks::StatusSinks<(NetworkStatus<B>, NetworkState)>>,
pool: Arc<impl TransactionPoolAndMaybeMallogSizeOf>,
format: OutputFormat,
) -> impl futures::Future<Output = ()>
@@ -94,7 +93,7 @@ where
let client_1 = client.clone();
let (network_status_sink, network_status_stream) = tracing_unbounded("mpsc_network_status");
network_status_sinks.lock().push(Duration::from_millis(5000), network_status_sink);
network_status_sinks.push(Duration::from_millis(5000), network_status_sink);
let display_notifications = network_status_stream
.for_each(move |(net_status, _)| {