mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add metrics for already seen txs and hashes (#2467)
This commit is contained in:
@ -45,6 +45,10 @@ pub struct TransactionsManagerMetrics {
|
||||
pub(crate) propagated_transactions: Counter,
|
||||
/// Total number of reported bad transactions
|
||||
pub(crate) reported_bad_transactions: Counter,
|
||||
/// Total number of messages with already seen hashes
|
||||
pub(crate) messages_with_already_seen_hashes: Counter,
|
||||
/// Total number of messages with already seen full transactions
|
||||
pub(crate) messages_with_already_seen_transactions: Counter,
|
||||
}
|
||||
|
||||
/// Metrics for Disconnection types
|
||||
|
||||
@ -32,7 +32,7 @@ use std::{
|
||||
};
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio_stream::wrappers::{ReceiverStream, UnboundedReceiverStream};
|
||||
use tracing::trace;
|
||||
use tracing::{debug, trace};
|
||||
|
||||
/// Cache limit of transactions to keep track of for a single peer.
|
||||
const PEER_TRANSACTION_CACHE_LIMIT: usize = 1024 * 10;
|
||||
@ -311,9 +311,15 @@ where
|
||||
if peer.request_tx.try_send(req).is_ok() {
|
||||
self.inflight_requests.push(GetPooledTxRequest { peer_id, response: rx })
|
||||
}
|
||||
|
||||
if num_already_seen > 0 {
|
||||
self.metrics.messages_with_already_seen_hashes.increment(1);
|
||||
debug!(target: "net::tx", num_hashes=%num_already_seen, ?peer_id, client=?peer.client_version, "Peer sent already seen hashes");
|
||||
}
|
||||
}
|
||||
|
||||
if num_already_seen > 0 {
|
||||
self.metrics.messages_with_already_seen_hashes.increment(1);
|
||||
self.report_bad_message(peer_id);
|
||||
}
|
||||
}
|
||||
@ -447,6 +453,11 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if num_already_seen > 0 {
|
||||
self.metrics.messages_with_already_seen_transactions.increment(1);
|
||||
debug!(target: "net::tx", num_txs=%num_already_seen, ?peer_id, client=?peer.client_version, "Peer sent already seen transactions");
|
||||
}
|
||||
}
|
||||
|
||||
if has_bad_transactions || num_already_seen > 0 {
|
||||
|
||||
Reference in New Issue
Block a user