Fix the metered unbounded sender/recievers (#6246)

* Fix the metered unbounded sender/recievers

* Use a counter instead

* Update client/rpc/src/system/tests.rs

* Add an is_terminated check

* Add FusedStream impl

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Ashley
2020-06-06 13:06:22 +02:00
committed by GitHub
parent 7c051caa42
commit 84cdb02963
5 changed files with 41 additions and 23 deletions
@@ -80,7 +80,7 @@ use sc_client_api::{
KeyIterator, CallExecutor, ExecutorProvider, ProofProvider,
cht, UsageProvider
};
use sp_utils::mpsc::tracing_unbounded;
use sp_utils::mpsc::{TracingUnboundedSender, tracing_unbounded};
use sp_blockchain::Error;
use prometheus_endpoint::Registry;
use super::{
@@ -88,7 +88,6 @@ use super::{
light::{call_executor::prove_execution, fetcher::ChangesProof},
block_rules::{BlockRules, LookupResult as BlockLookupResult},
};
use futures::channel::mpsc;
use rand::Rng;
#[cfg(feature="test-helpers")]
@@ -99,7 +98,7 @@ use {
super::call_executor::LocalCallExecutor,
};
type NotificationSinks<T> = Mutex<Vec<mpsc::UnboundedSender<T>>>;
type NotificationSinks<T> = Mutex<Vec<TracingUnboundedSender<T>>>;
/// Substrate Client
pub struct Client<B, E, Block, RA> where Block: BlockT {
+2 -2
View File
@@ -109,7 +109,7 @@ impl<T> futures::Future for YieldAfter<T> {
mod tests {
use super::StatusSinks;
use futures::prelude::*;
use futures::channel::mpsc;
use sp_utils::mpsc::tracing_unbounded;
use std::time::Duration;
use std::task::Poll;
@@ -120,7 +120,7 @@ mod tests {
let mut status_sinks = StatusSinks::new();
let (tx, rx) = mpsc::unbounded();
let (tx, rx) = tracing_unbounded("status_sink_test");
status_sinks.push(Duration::from_millis(100), tx);
let mut val_order = 5;