From 2efa91987e28fa3cecf48e35b6636cd00ed4525a Mon Sep 17 00:00:00 2001 From: boqiu <82121246@qq.com> Date: Thu, 26 Sep 2024 13:56:29 +0800 Subject: [PATCH] stat only 10 mins --- node/router/src/libp2p_event_handler.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/node/router/src/libp2p_event_handler.rs b/node/router/src/libp2p_event_handler.rs index 7135a3a..23149cc 100644 --- a/node/router/src/libp2p_event_handler.rs +++ b/node/router/src/libp2p_event_handler.rs @@ -99,6 +99,8 @@ pub struct Libp2pEventHandler { file_batcher: RwLock>, /// Announcements to publish in batch announcement_batcher: RwLock>, + + since: Instant, } impl Libp2pEventHandler { @@ -138,6 +140,7 @@ impl Libp2pEventHandler { peers, file_batcher, announcement_batcher, + since: Instant::now(), } } @@ -325,14 +328,17 @@ impl Libp2pEventHandler { self.on_find_chunks(msg).await } PubsubMessage::AnnounceFile(msgs) => { - let txs = msgs - .iter() - .map(|file| file.tx_ids.iter().map(|x| x.seq).collect::>()) - .collect::>>(); - info!( - "qbit: received file announcement, propagation={}, source={}, txs={:?}", - propagation_source, source, txs - ); + let elapsed = self.since.elapsed().as_secs(); + if elapsed > 600 && elapsed < 1200 { + let txs = msgs + .iter() + .map(|file| file.tx_ids.iter().map(|x| x.seq).collect::>()) + .collect::>>(); + info!( + "qbit: received file announcement, propagation={}, source={}, txs={:?}", + propagation_source, source, txs + ); + } metrics::LIBP2P_HANDLE_PUBSUB_ANNOUNCE_FILE.mark(1);