This commit is contained in:
GroovieGermanikus 2024-04-16 15:54:38 +02:00
parent 274dc76125
commit a109037223
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
2 changed files with 25 additions and 21 deletions

View File

@ -6,8 +6,10 @@ use std::{
time::Duration, time::Duration,
}; };
use geyser_grpc_connector::yellowstone_grpc_util::{
connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig,
};
use geyser_grpc_connector::{GeyserGrpcClient, GeyserGrpcClientResult, GrpcSourceConfig}; use geyser_grpc_connector::{GeyserGrpcClient, GeyserGrpcClientResult, GrpcSourceConfig};
use geyser_grpc_connector::yellowstone_grpc_util::{connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig};
use itertools::Itertools; use itertools::Itertools;
use solana_lite_rpc_core::{ use solana_lite_rpc_core::{
commitment_utils::Commitment, commitment_utils::Commitment,
@ -111,9 +113,8 @@ pub fn start_account_streaming_tasks(
ping: None, ping: None,
}; };
let mut client = create_connection(&grpc_config).await?; let mut client = create_connection(&grpc_config).await?;
let account_stream = client.subscribe_once2(program_subscription).await.unwrap(); let account_stream = client.subscribe_once2(program_subscription).await.unwrap();
// each account subscription batch will require individual stream // each account subscription batch will require individual stream
@ -213,7 +214,9 @@ pub fn start_account_streaming_tasks(
}) })
} }
async fn create_connection(grpc_config: &GrpcSourceConfig) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor + Sized>> { async fn create_connection(
grpc_config: &GrpcSourceConfig,
) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor + Sized>> {
connect_with_timeout_with_buffers( connect_with_timeout_with_buffers(
grpc_config.grpc_addr.clone(), grpc_config.grpc_addr.clone(),
grpc_config.grpc_x_token.clone(), grpc_config.grpc_x_token.clone(),
@ -226,7 +229,7 @@ async fn create_connection(grpc_config: &GrpcSourceConfig) -> GeyserGrpcClientRe
stream_window: Some(4194304), stream_window: Some(4194304),
}, },
) )
.await .await
} }
pub fn create_grpc_account_streaming( pub fn create_grpc_account_streaming(

View File

@ -5,6 +5,9 @@ use crate::grpc_multiplex::{
}; };
use anyhow::Context; use anyhow::Context;
use futures::StreamExt; use futures::StreamExt;
use geyser_grpc_connector::yellowstone_grpc_util::{
connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig,
};
use geyser_grpc_connector::GrpcSourceConfig; use geyser_grpc_connector::GrpcSourceConfig;
use itertools::Itertools; use itertools::Itertools;
use log::trace; use log::trace;
@ -36,13 +39,10 @@ use std::cell::OnceCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use geyser_grpc_connector::yellowstone_grpc_util::{connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig};
use tokio::sync::{broadcast, Notify}; use tokio::sync::{broadcast, Notify};
use tracing::trace_span; use tracing::trace_span;
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof; use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
use yellowstone_grpc_proto::geyser::{ use yellowstone_grpc_proto::geyser::{CommitmentLevel, SubscribeRequestFilterBlocks};
CommitmentLevel, SubscribeRequestFilterBlocks
};
use crate::rpc_polling::vote_accounts_and_cluster_info_polling::{ use crate::rpc_polling::vote_accounts_and_cluster_info_polling::{
poll_cluster_info, poll_vote_accounts, poll_cluster_info, poll_vote_accounts,
@ -291,18 +291,19 @@ pub fn create_block_processing_task(
); );
// connect to grpc // connect to grpc
let mut client = let mut client = connect_with_timeout_with_buffers(
connect_with_timeout_with_buffers( grpc_addr.clone(),
grpc_addr.clone(), grpc_x_token.clone(), grpc_x_token.clone(),
None, None,
Some(Duration::from_secs(10)), Some(Duration::from_secs(10)),
Some(Duration::from_secs(10)), Some(Duration::from_secs(10)),
GeyserGrpcClientBufferConfig { GeyserGrpcClientBufferConfig {
buffer_size: Some(65536), buffer_size: Some(65536),
conn_window: Some(5242880), conn_window: Some(5242880),
stream_window: Some(4194304), stream_window: Some(4194304),
}, },
).await?; )
.await?;
let mut stream = tokio::select! { let mut stream = tokio::select! {
res = client res = client
.subscribe_once( .subscribe_once(