Skip to content

Commit 5bf3eb8

Browse files
feat: add logging for RPC subscription notifications
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.
1 parent 69d157e commit 5bf3eb8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/eth/rpc/rpc_subscriptions.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ impl RpcSubscriptions {
172172

173173
let interested_subs = subs.pending_txs.read().await;
174174
let interested_subs = interested_subs.values().collect_vec();
175+
176+
tracing::info!(
177+
tx_hash = ?tx_hash,
178+
subscribers_count = interested_subs.len(),
179+
"notifying subscribers about new pending transaction"
180+
);
181+
175182
Self::notify(interested_subs, tx_hash.to_string());
176183
}
177184
warn_task_rx_closed(TASK_NAME);
@@ -196,6 +203,14 @@ impl RpcSubscriptions {
196203

197204
let interested_subs = subs.new_heads.read().await;
198205
let interested_subs = interested_subs.values().collect_vec();
206+
207+
tracing::info!(
208+
block_number = ?block_header.number,
209+
block_hash = ?block_header.hash,
210+
subscribers_count = interested_subs.len(),
211+
"notifying subscribers about new block"
212+
);
213+
199214
Self::notify(interested_subs, block_header);
200215
}
201216
warn_task_rx_closed(TASK_NAME);
@@ -225,6 +240,13 @@ impl RpcSubscriptions {
225240
.filter_map(|s| if_else!(s.filter.matches(&log), Some(&s.inner), None))
226241
.collect_vec();
227242

243+
tracing::info!(
244+
log_block_number = ?log.block_number,
245+
log_tx_hash = ?log.transaction_hash,
246+
subscribers_count = interested_subs.len(),
247+
"notifying subscribers about new logs"
248+
);
249+
228250
Self::notify(interested_subs, log);
229251
}
230252
warn_task_rx_closed(TASK_NAME);

0 commit comments

Comments
 (0)