diff --git a/yellowstone-grpc-geyser/src/grpc.rs b/yellowstone-grpc-geyser/src/grpc.rs index 7931f4f..3602abb 100644 --- a/yellowstone-grpc-geyser/src/grpc.rs +++ b/yellowstone-grpc-geyser/src/grpc.rs @@ -58,6 +58,7 @@ use { }, }, }; +use crate::THROTTLE_ACCOUNT_LOGGING; #[derive(Debug, Clone)] pub struct MessageAccountInfo { @@ -1184,15 +1185,18 @@ impl GrpcService { for message in messages.iter() { for message in filter.get_update(message, Some(commitment)) { + match message.update_oneof.as_ref().unwrap() { UpdateOneof::Account(update) => { // message is put in bounded queue which gets consumed by GRPC receiver if let Some(ref account_info) = update.account { - let now = SystemTime::now(); - let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); + if account_info.write_version % THROTTLE_ACCOUNT_LOGGING == 0 { + let now = SystemTime::now(); + let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); - info!("account update inspect before sending to buffer channel: write_version={};timestamp_us={};slot={}", - account_info.write_version, since_the_epoch.as_micros(), update.slot); + info!("account update inspect before sending to buffer channel: write_version={};timestamp_us={};slot={}", + account_info.write_version, since_the_epoch.as_micros(), update.slot); + } } } _ => {} @@ -1458,11 +1462,13 @@ fn spawn_plugger_mpcs( UpdateOneof::Account(update) => { if let Some(ref account_info) = update.account { - let now = SystemTime::now(); - let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); + if account_info.write_version % THROTTLE_ACCOUNT_LOGGING == 0 { + let now = SystemTime::now(); + let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); - info!("account update inspect before sending to grpc stream: write_version={};timestamp_us={};slot={}", - account_info.write_version, since_the_epoch.as_micros(), update.slot); + info!("account update inspect before sending to grpc stream: write_version={};timestamp_us={};slot={}", + account_info.write_version, since_the_epoch.as_micros(), update.slot); + } } // message is put in bounded queue which gets consumed by GRPC receiver diff --git a/yellowstone-grpc-geyser/src/lib.rs b/yellowstone-grpc-geyser/src/lib.rs index 192cc6e..7a57f18 100644 --- a/yellowstone-grpc-geyser/src/lib.rs +++ b/yellowstone-grpc-geyser/src/lib.rs @@ -8,3 +8,6 @@ pub mod grpc; pub mod plugin; pub mod prom; pub mod version; + +// log every X account write +pub const THROTTLE_ACCOUNT_LOGGING: u64 = 50; diff --git a/yellowstone-grpc-geyser/src/plugin.rs b/yellowstone-grpc-geyser/src/plugin.rs index 2518200..29b0dbd 100644 --- a/yellowstone-grpc-geyser/src/plugin.rs +++ b/yellowstone-grpc-geyser/src/plugin.rs @@ -30,6 +30,7 @@ use { }, }; use crate::grpc::{MessageAccount, MessageAccountInfo}; +use crate::THROTTLE_ACCOUNT_LOGGING; #[derive(Debug)] pub struct PluginInner { @@ -170,11 +171,13 @@ impl GeyserPlugin for Plugin { // Message::Account((account, slot, is_startup).into()) // }; - let now = SystemTime::now(); - let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); + if account.write_version % THROTTLE_ACCOUNT_LOGGING == 0 { + let now = SystemTime::now(); + let since_the_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards"); - info!("account update inspect from geyser: write_version={};timestamp_us={};slot={}", - account.write_version, since_the_epoch.as_micros(), slot); + info!("account update inspect from geyser: write_version={};timestamp_us={};slot={}", + account.write_version, since_the_epoch.as_micros(), slot); + } let message = Message::Account((account, slot, is_startup).into());