Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove metered_channel::name
1. we don't provide good names
2. these names are never used anywhere
  • Loading branch information
rphmeier committed Mar 27, 2021
commit c4a7a8e44ce1c94874dfd46093459bb609ea251c
3 changes: 1 addition & 2 deletions node/metered-channel/src/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ use super::Meter;


/// Create a wrapped `mpsc::channel` pair of `MeteredSender` and `MeteredReceiver`.
pub fn channel<T>(capacity: usize, name: &'static str) -> (MeteredSender<T>, MeteredReceiver<T>) {
pub fn channel<T>(capacity: usize) -> (MeteredSender<T>, MeteredReceiver<T>) {
let (tx, rx) = mpsc::channel(capacity);
let mut shared_meter = Meter::default();
shared_meter.name = name;
let tx = MeteredSender { meter: shared_meter.clone(), inner: tx };
let rx = MeteredReceiver { meter: shared_meter, inner: rx };
(tx, rx)
Expand Down
17 changes: 5 additions & 12 deletions node/metered-channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ pub use self::unbounded::*;
/// A peek into the inner state of a meter.
#[derive(Debug, Clone, Default)]
pub struct Meter {
/// Name of the receiver and sender pair.
name: &'static str,
// Number of sends on this channel.
sent: Arc<AtomicUsize>,
// Number of receives on this channel.
Expand Down Expand Up @@ -60,11 +58,6 @@ impl Meter {
}
}

/// Obtain the name of the channel `Sender` and `Receiver` pair.
pub fn name(&self) -> &'static str {
self.name
}

fn note_sent(&self) {
self.sent.fetch_add(1, Ordering::Relaxed);
}
Expand Down Expand Up @@ -92,7 +85,7 @@ mod tests {
#[test]
fn try_send_try_next() {
block_on(async move {
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);
let msg = Msg::default();
assert_eq!(rx.meter().read(), Readout { sent: 0, received: 0 });
tx.try_send(msg).unwrap();
Expand All @@ -116,7 +109,7 @@ mod tests {
fn with_tasks() {
let (ready, go) = futures::channel::oneshot::channel();

let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);
block_on(async move {
futures::join!(
async move {
Expand Down Expand Up @@ -149,7 +142,7 @@ mod tests {

#[test]
fn stream_and_sink() {
let (mut tx, mut rx) = channel::<Msg>(5, "goofy");
let (mut tx, mut rx) = channel::<Msg>(5);

block_on(async move {
futures::join!(
Expand All @@ -175,8 +168,8 @@ mod tests {

#[test]
fn failed_send_does_not_inc_sent() {
let (mut bounded, _) = channel::<Msg>(5, "pluto");
let (mut unbounded, _) = unbounded::<Msg>("pluto");
let (mut bounded, _) = channel::<Msg>(5);
let (mut unbounded, _) = unbounded::<Msg>();

block_on(async move {
assert!(bounded.send(Msg::default()).await.is_err());
Expand Down
3 changes: 1 addition & 2 deletions node/metered-channel/src/unbounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ use super::Meter;


/// Create a wrapped `mpsc::channel` pair of `MeteredSender` and `MeteredReceiver`.
pub fn unbounded<T>(name: &'static str) -> (UnboundedMeteredSender<T>, UnboundedMeteredReceiver<T>) {
pub fn unbounded<T>() -> (UnboundedMeteredSender<T>, UnboundedMeteredReceiver<T>) {
let (tx, rx) = mpsc::unbounded();
let mut shared_meter = Meter::default();
shared_meter.name = name;
let tx = UnboundedMeteredSender { meter: shared_meter.clone(), inner: tx };
let rx = UnboundedMeteredReceiver { meter: shared_meter, inner: rx };
(tx, rx)
Expand Down
2 changes: 1 addition & 1 deletion node/network/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ mod tests {
TestAuthorityDiscovery,
) {
let (net_tx, net_rx) = polkadot_node_subsystem_test_helpers::single_item_sink();
let (action_tx, action_rx) = metered::unbounded("test_action");
let (action_tx, action_rx) = metered::unbounded();

(
TestNetwork {
Expand Down
92 changes: 46 additions & 46 deletions node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1909,97 +1909,97 @@ where
ApV: Subsystem<OverseerSubsystemContext<ApprovalVotingMessage>> + Send,
GS: Subsystem<OverseerSubsystemContext<GossipSupportMessage>> + Send,
{
let (events_tx, events_rx) = metered::channel(CHANNEL_CAPACITY, "overseer_events");
let (events_tx, events_rx) = metered::channel(CHANNEL_CAPACITY);

let handler = OverseerHandler {
events_tx: events_tx.clone(),
};

let metrics = <Metrics as metrics::Metrics>::register(prometheus_registry)?;

let (to_overseer_tx, to_overseer_rx) = metered::unbounded("to_overseer");
let (to_overseer_tx, to_overseer_rx) = metered::unbounded();

let mut running_subsystems = FuturesUnordered::new();

let mut seed = 0x533d; // arbitrary

let (candidate_validation_bounded_tx, candidate_validation_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (candidate_backing_bounded_tx, candidate_backing_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (candidate_selection_bounded_tx, candidate_selection_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (statement_distribution_bounded_tx, statement_distribution_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (availability_distribution_bounded_tx, availability_distribution_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (availability_recovery_bounded_tx, availability_recovery_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (bitfield_signing_bounded_tx, bitfield_signing_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (bitfield_distribution_bounded_tx, bitfield_distribution_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (provisioner_bounded_tx, provisioner_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (pov_distribution_bounded_tx, pov_distribution_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (runtime_api_bounded_tx, runtime_api_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (availability_store_bounded_tx, availability_store_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (network_bridge_bounded_tx, network_bridge_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (chain_api_bounded_tx, chain_api_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (collator_protocol_bounded_tx, collator_protocol_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (collation_generation_bounded_tx, collation_generation_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (approval_distribution_bounded_tx, approval_distribution_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (approval_voting_bounded_tx, approval_voting_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);
let (gossip_support_bounded_tx, gossip_support_bounded_rx)
= metered::channel(CHANNEL_CAPACITY, "subsystem-comms-bounded");
= metered::channel(CHANNEL_CAPACITY);

let (candidate_validation_unbounded_tx, candidate_validation_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (candidate_backing_unbounded_tx, candidate_backing_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (candidate_selection_unbounded_tx, candidate_selection_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (statement_distribution_unbounded_tx, statement_distribution_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (availability_distribution_unbounded_tx, availability_distribution_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (availability_recovery_unbounded_tx, availability_recovery_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (bitfield_signing_unbounded_tx, bitfield_signing_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (bitfield_distribution_unbounded_tx, bitfield_distribution_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (provisioner_unbounded_tx, provisioner_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (pov_distribution_unbounded_tx, pov_distribution_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (runtime_api_unbounded_tx, runtime_api_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (availability_store_unbounded_tx, availability_store_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (network_bridge_unbounded_tx, network_bridge_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (chain_api_unbounded_tx, chain_api_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (collator_protocol_unbounded_tx, collator_protocol_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (collation_generation_unbounded_tx, collation_generation_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (approval_distribution_unbounded_tx, approval_distribution_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (approval_voting_unbounded_tx, approval_voting_unbounded_rx)
= metered::unbounded("subsystem-comms-unbounded");
= metered::unbounded();
let (gossip_support_unbounded_tx, gossip_support_unbounded_rx)
= metered::unbounded("subsystem-comms-bounded");
= metered::unbounded();

let channels_out = ChannelsOut {
candidate_validation: candidate_validation_bounded_tx.clone(),
Expand Down Expand Up @@ -2719,7 +2719,7 @@ fn spawn<S: SpawnNamed, M: Send + 'static>(
futures: &mut FuturesUnordered<BoxFuture<'static, SubsystemResult<()>>>,
task_kind: TaskKind,
) -> SubsystemResult<OverseenSubsystem<M>> {
let (signal_tx, signal_rx) = metered::channel(CHANNEL_CAPACITY, "subsystem-spawn");
let (signal_tx, signal_rx) = metered::channel(CHANNEL_CAPACITY);
let ctx = OverseerSubsystemContext::new(
signal_rx,
message_rx,
Expand Down Expand Up @@ -3115,8 +3115,8 @@ mod tests {
number: 3,
};

let (tx_5, mut rx_5) = metered::channel(64, "overseer_test");
let (tx_6, mut rx_6) = metered::channel(64, "overseer_test");
let (tx_5, mut rx_5) = metered::channel(64);
let (tx_6, mut rx_6) = metered::channel(64);
let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_validation(TestSubsystem5(tx_5))
.replace_candidate_backing(TestSubsystem6(tx_6));
Expand Down Expand Up @@ -3217,8 +3217,8 @@ mod tests {
number: 3,
};

let (tx_5, mut rx_5) = metered::channel(64, "overseer_test");
let (tx_6, mut rx_6) = metered::channel(64, "overseer_test");
let (tx_5, mut rx_5) = metered::channel(64);
let (tx_6, mut rx_6) = metered::channel(64);

let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_validation(TestSubsystem5(tx_5))
Expand Down Expand Up @@ -3317,7 +3317,7 @@ mod tests {
number: 1,
};

let (tx_5, mut rx_5) = metered::channel(64, "overseer_test");
let (tx_5, mut rx_5) = metered::channel(64);

let all_subsystems = AllSubsystems::<()>::dummy()
.replace_candidate_backing(TestSubsystem6(tx_5));
Expand Down