Skip to content

Commit

Permalink
chore: address naming issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Aug 29, 2024
1 parent 3fd23e3 commit 22f7693
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/metrics/src/p2p_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn p2p_metrics() -> &'static P2PMetrics {
P2P_METRICS.get_or_init(P2PMetrics::new)
}

pub fn inc_unique_peers() {
pub fn increment_unique_peers() {
p2p_metrics().unique_peers.inc();
}

Expand Down
8 changes: 4 additions & 4 deletions crates/services/p2p/src/p2p_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::{
},
TryPeerId,
};
use fuel_core_metrics::p2p_metrics::inc_unique_peers;
use fuel_core_metrics::p2p_metrics::increment_unique_peers;
use fuel_core_types::{
fuel_types::BlockHeight,
services::p2p::peer_reputation::AppScore,
Expand Down Expand Up @@ -271,12 +271,12 @@ impl FuelP2PService {
}
}

pub fn log_metrics<T>(&self, cb: T)
pub fn update_metrics<T>(&self, update_fn: T)
where
T: FnOnce(),
{
if self.metrics {
cb();
update_fn();
}
}

Expand Down Expand Up @@ -653,7 +653,7 @@ impl FuelP2PService {
fn handle_identify_event(&mut self, event: identify::Event) -> Option<FuelP2PEvent> {
match event {
identify::Event::Received { peer_id, info } => {
self.log_metrics(inc_unique_peers);
self.update_metrics(increment_unique_peers);

let mut addresses = info.listen_addrs;
let agent_version = info.agent_version;
Expand Down
14 changes: 7 additions & 7 deletions crates/services/p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ pub trait TaskP2PService: Send {

fn update_block_height(&mut self, height: BlockHeight) -> anyhow::Result<()>;

fn log_metrics<T>(&self, cb: T)
fn update_metrics<T>(&self, update_fn: T)
where
T: FnOnce();
}

impl TaskP2PService for FuelP2PService {
fn log_metrics<T>(&self, cb: T)
fn update_metrics<T>(&self, update_fn: T)
where
T: FnOnce(),
{
FuelP2PService::log_metrics(self, cb)
FuelP2PService::update_metrics(self, update_fn)
}

fn get_all_peer_info(&self) -> Vec<(&PeerId, &PeerInfo)> {
Expand Down Expand Up @@ -439,11 +439,11 @@ where
V: AtomicView + 'static,
V::LatestView: P2pDb,
{
fn log_metrics<T>(&self, cb: T)
fn update_metrics<T>(&self, update_fn: T)
where
T: FnOnce(),
{
self.p2p_service.log_metrics(cb)
self.p2p_service.update_metrics(update_fn)
}

fn process_request(
Expand Down Expand Up @@ -485,7 +485,7 @@ where
let max_len = self.max_headers_per_request;
let range_len = range.len();

self.log_metrics(|| set_blocks_requested(range_len));
self.update_metrics(|| set_blocks_requested(range_len));

if range_len > max_len {
tracing::error!(
Expand Down Expand Up @@ -1053,7 +1053,7 @@ pub mod tests {
}

impl TaskP2PService for FakeP2PService {
fn log_metrics<T>(&self, _: T)
fn update_metrics<T>(&self, _: T)
where
T: FnOnce(),
{
Expand Down

0 comments on commit 22f7693

Please sign in to comment.