From 1b9926fc1b019f152f423c26837e8d2627cd4318 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Tue, 23 Jan 2024 14:48:47 +0100 Subject: [PATCH] slots --- src/lib.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index a31d646..dd3f2ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ use solana_sdk::commitment_config::CommitmentConfig; use std::collections::HashMap; use std::fmt::{Debug, Display}; use std::time::Duration; -use yellowstone_grpc_proto::geyser::{CommitmentLevel, SubscribeRequest, SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta, SubscribeUpdate}; +use yellowstone_grpc_proto::geyser::{CommitmentLevel, SubscribeRequest, SubscribeRequestFilterBlocks, SubscribeRequestFilterBlocksMeta, SubscribeRequestFilterSlots, SubscribeUpdate}; use yellowstone_grpc_proto::tonic::transport::ClientTlsConfig; pub mod channel_plugger; @@ -124,6 +124,26 @@ impl GeyserFilter { ping: None, } } + + pub fn slots(&self) -> SubscribeRequest { + let mut slots_subs = HashMap::new(); + slots_subs.insert("client".to_string(), + SubscribeRequestFilterSlots { + filter_by_commitment: Some(true), + }); + + SubscribeRequest { + slots: slots_subs, + accounts: Default::default(), + transactions: HashMap::new(), + entry: Default::default(), + blocks: HashMap::new(), + blocks_meta: HashMap::new(), + commitment: Some(map_commitment_level(self.0) as i32), + accounts_data_slice: Default::default(), + ping: None, + } + } } fn map_commitment_level(commitment_config: CommitmentConfig) -> CommitmentLevel {