Skip to content

Commit

Permalink
feat: remove Bandwidthmeter type (#8698)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
kamuik16 and mattsse authored Jun 9, 2024
1 parent 2852893 commit c7fd507
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 330 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/net/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ workspace = true
alloy-primitives.workspace = true

# async
pin-project.workspace = true
tokio = { workspace = true, features = ["full"] }
277 changes: 0 additions & 277 deletions crates/net/common/src/bandwidth_meter.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/net/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod ban_list;
pub mod bandwidth_meter;

/// Traits related to tokio streams
pub mod stream;
Expand Down
10 changes: 0 additions & 10 deletions crates/net/network/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use reth_eth_wire::{
DisconnectReason, EthVersion, Status,
};
use reth_metrics::common::mpsc::UnboundedMeteredSender;
use reth_net_common::bandwidth_meter::BandwidthMeter;
use reth_network_api::ReputationChangeKind;
use reth_network_peers::PeerId;
use reth_primitives::{ForkId, NodeRecord};
Expand Down Expand Up @@ -141,12 +140,6 @@ impl<C> NetworkManager<C> {
&self.handle
}

/// Returns a shareable reference to the [`BandwidthMeter`] stored
/// inside of the [`NetworkHandle`]
pub fn bandwidth_meter(&self) -> &BandwidthMeter {
self.handle.bandwidth_meter()
}

/// Returns the secret key used for authenticating sessions.
pub const fn secret_key(&self) -> SecretKey {
self.swarm.sessions().secret_key()
Expand Down Expand Up @@ -233,7 +226,6 @@ where
let discv4 = discovery.discv4();

let num_active_peers = Arc::new(AtomicUsize::new(0));
let bandwidth_meter: BandwidthMeter = BandwidthMeter::default();

let sessions = SessionManager::new(
secret_key,
Expand All @@ -243,7 +235,6 @@ where
hello_message,
fork_filter,
extra_protocols,
bandwidth_meter.clone(),
);

let state =
Expand All @@ -263,7 +254,6 @@ where
local_peer_id,
peers_handle,
network_mode,
bandwidth_meter,
Arc::new(AtomicU64::new(chain_spec.chain.id())),
tx_gossip_disabled,
discv4,
Expand Down
10 changes: 0 additions & 10 deletions crates/net/network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use enr::Enr;
use parking_lot::Mutex;
use reth_discv4::Discv4;
use reth_eth_wire::{DisconnectReason, NewBlock, NewPooledTransactionHashes, SharedTransactions};
use reth_net_common::bandwidth_meter::BandwidthMeter;
use reth_network_api::{
NetworkError, NetworkInfo, PeerInfo, PeerKind, Peers, PeersInfo, Reputation,
ReputationChangeKind,
Expand Down Expand Up @@ -53,7 +52,6 @@ impl NetworkHandle {
local_peer_id: PeerId,
peers: PeersHandle,
network_mode: NetworkMode,
bandwidth_meter: BandwidthMeter,
chain_id: Arc<AtomicU64>,
tx_gossip_disabled: bool,
discv4: Option<Discv4>,
Expand All @@ -67,7 +65,6 @@ impl NetworkHandle {
local_peer_id,
peers,
network_mode,
bandwidth_meter,
is_syncing: Arc::new(AtomicBool::new(false)),
initial_sync_done: Arc::new(AtomicBool::new(false)),
chain_id,
Expand Down Expand Up @@ -154,11 +151,6 @@ impl NetworkHandle {
rx.await.unwrap()
}

/// Provides a shareable reference to the [`BandwidthMeter`] stored on the `NetworkInner`.
pub fn bandwidth_meter(&self) -> &BandwidthMeter {
&self.inner.bandwidth_meter
}

/// Send message to gracefully shutdown node.
///
/// This will disconnect all active and pending sessions and prevent
Expand Down Expand Up @@ -393,8 +385,6 @@ struct NetworkInner {
peers: PeersHandle,
/// The mode of the network
network_mode: NetworkMode,
/// Used to measure inbound & outbound bandwidth across network streams (currently unused)
bandwidth_meter: BandwidthMeter,
/// Represents if the network is currently syncing.
is_syncing: Arc<AtomicBool>,
/// Used to differentiate between an initial pipeline sync or a live sync
Expand Down
Loading

0 comments on commit c7fd507

Please sign in to comment.