Skip to content

Commit

Permalink
feat: add logging for RPC subscription notifications
Browse files Browse the repository at this point in the history
Add detailed tracing logs for RPC subscription events, including:
- Pending transaction notifications
- New block header notifications
- Log event notifications

The logs now include relevant context such as transaction hash, block number, and the number of subscribers being notified.
  • Loading branch information
pedro-pelicioni-cw committed Feb 19, 2025
1 parent 69d157e commit 5bf3eb8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/eth/rpc/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ impl RpcSubscriptions {

let interested_subs = subs.pending_txs.read().await;
let interested_subs = interested_subs.values().collect_vec();

tracing::info!(
tx_hash = ?tx_hash,
subscribers_count = interested_subs.len(),
"notifying subscribers about new pending transaction"
);

Self::notify(interested_subs, tx_hash.to_string());
}
warn_task_rx_closed(TASK_NAME);
Expand All @@ -196,6 +203,14 @@ impl RpcSubscriptions {

let interested_subs = subs.new_heads.read().await;
let interested_subs = interested_subs.values().collect_vec();

tracing::info!(
block_number = ?block_header.number,
block_hash = ?block_header.hash,
subscribers_count = interested_subs.len(),
"notifying subscribers about new block"
);

Self::notify(interested_subs, block_header);
}
warn_task_rx_closed(TASK_NAME);
Expand Down Expand Up @@ -225,6 +240,13 @@ impl RpcSubscriptions {
.filter_map(|s| if_else!(s.filter.matches(&log), Some(&s.inner), None))
.collect_vec();

tracing::info!(
log_block_number = ?log.block_number,
log_tx_hash = ?log.transaction_hash,
subscribers_count = interested_subs.len(),
"notifying subscribers about new logs"
);

Self::notify(interested_subs, log);
}
warn_task_rx_closed(TASK_NAME);
Expand Down

0 comments on commit 5bf3eb8

Please sign in to comment.