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
+3 -2
View File
@@ -22,7 +22,8 @@ use sc_network::{self, PeerId};
use sc_network::config::Role;
use substrate_test_runtime_client::runtime::Block;
use assert_matches::assert_matches;
use futures::{prelude::*, channel::mpsc};
use futures::prelude::*;
use sp_utils::mpsc::tracing_unbounded;
use std::thread;
struct Status {
@@ -46,7 +47,7 @@ impl Default for Status {
fn api<T: Into<Option<Status>>>(sync: T) -> System<Block> {
let status = sync.into().unwrap_or_default();
let should_have_peers = !status.is_dev;
let (tx, rx) = mpsc::unbounded();
let (tx, rx) = tracing_unbounded("rpc_system_tests");
thread::spawn(move || {
futures::executor::block_on(rx.for_each(move |request| {
match request {