Adding notify channel to stop tasks
This commit is contained in:
parent
e9eb3ecdc5
commit
7f115fb8b5
|
@ -1249,7 +1249,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "geyser-grpc-connector"
|
name = "geyser-grpc-connector"
|
||||||
version = "0.10.1+yellowstone.1.12"
|
version = "0.10.4+yellowstone.1.13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-stream",
|
"async-stream",
|
||||||
|
|
|
@ -2,6 +2,8 @@ use log::info;
|
||||||
use solana_sdk::clock::Slot;
|
use solana_sdk::clock::Slot;
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tokio::sync::Notify;
|
||||||
|
|
||||||
use geyser_grpc_connector::channel_plugger::spawn_broadcast_channel_plug;
|
use geyser_grpc_connector::channel_plugger::spawn_broadcast_channel_plug;
|
||||||
use geyser_grpc_connector::grpc_subscription_autoreconnect_tasks::create_geyser_autoconnection_task;
|
use geyser_grpc_connector::grpc_subscription_autoreconnect_tasks::create_geyser_autoconnection_task;
|
||||||
|
@ -87,9 +89,12 @@ pub async fn main() {
|
||||||
|
|
||||||
info!("Write Block stream..");
|
info!("Write Block stream..");
|
||||||
|
|
||||||
|
let exit_notify = Arc::new(Notify::new());
|
||||||
|
|
||||||
let (jh_geyser_task, message_channel) = create_geyser_autoconnection_task(
|
let (jh_geyser_task, message_channel) = create_geyser_autoconnection_task(
|
||||||
green_config.clone(),
|
green_config.clone(),
|
||||||
GeyserFilter(CommitmentConfig::confirmed()).blocks_and_txs(),
|
GeyserFilter(CommitmentConfig::confirmed()).blocks_and_txs(),
|
||||||
|
exit_notify,
|
||||||
);
|
);
|
||||||
let mut message_channel =
|
let mut message_channel =
|
||||||
spawn_broadcast_channel_plug(tokio::sync::broadcast::channel(8), message_channel);
|
spawn_broadcast_channel_plug(tokio::sync::broadcast::channel(8), message_channel);
|
||||||
|
|
|
@ -2,6 +2,8 @@ use log::{info, warn};
|
||||||
use solana_sdk::clock::Slot;
|
use solana_sdk::clock::Slot;
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tokio::sync::Notify;
|
||||||
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
@ -20,12 +22,8 @@ use solana_sdk::transaction::TransactionError;
|
||||||
use tokio::sync::mpsc::Receiver;
|
use tokio::sync::mpsc::Receiver;
|
||||||
use yellowstone_grpc_proto::geyser::SubscribeUpdateBlock;
|
use yellowstone_grpc_proto::geyser::SubscribeUpdateBlock;
|
||||||
|
|
||||||
use geyser_grpc_connector::grpc_subscription_autoreconnect_tasks::{
|
use geyser_grpc_connector::grpc_subscription_autoreconnect_tasks::create_geyser_autoconnection_task_with_mpsc;
|
||||||
create_geyser_autoconnection_task_with_mpsc,
|
use geyser_grpc_connector::grpcmultiplex_fastestwins::FromYellowstoneExtractor;
|
||||||
};
|
|
||||||
use geyser_grpc_connector::grpcmultiplex_fastestwins::{
|
|
||||||
FromYellowstoneExtractor,
|
|
||||||
};
|
|
||||||
use geyser_grpc_connector::{GeyserFilter, GrpcConnectionTimeouts, GrpcSourceConfig, Message};
|
use geyser_grpc_connector::{GeyserFilter, GrpcConnectionTimeouts, GrpcSourceConfig, Message};
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
|
use yellowstone_grpc_proto::geyser::subscribe_update::UpdateOneof;
|
||||||
|
@ -122,6 +120,7 @@ pub async fn main() {
|
||||||
subscribe_timeout: Duration::from_secs(5),
|
subscribe_timeout: Duration::from_secs(5),
|
||||||
receive_timeout: Duration::from_secs(5),
|
receive_timeout: Duration::from_secs(5),
|
||||||
};
|
};
|
||||||
|
let exit_notify = Arc::new(Notify::new());
|
||||||
|
|
||||||
let green_config =
|
let green_config =
|
||||||
GrpcSourceConfig::new(grpc_addr_green, grpc_x_token_green, None, timeouts.clone());
|
GrpcSourceConfig::new(grpc_addr_green, grpc_x_token_green, None, timeouts.clone());
|
||||||
|
@ -135,16 +134,19 @@ pub async fn main() {
|
||||||
green_config.clone(),
|
green_config.clone(),
|
||||||
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
||||||
autoconnect_tx.clone(),
|
autoconnect_tx.clone(),
|
||||||
|
exit_notify.clone(),
|
||||||
);
|
);
|
||||||
let _blue_stream_ah = create_geyser_autoconnection_task_with_mpsc(
|
let _blue_stream_ah = create_geyser_autoconnection_task_with_mpsc(
|
||||||
blue_config.clone(),
|
blue_config.clone(),
|
||||||
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
||||||
autoconnect_tx.clone(),
|
autoconnect_tx.clone(),
|
||||||
|
exit_notify.clone(),
|
||||||
);
|
);
|
||||||
let _toxiproxy_stream_ah = create_geyser_autoconnection_task_with_mpsc(
|
let _toxiproxy_stream_ah = create_geyser_autoconnection_task_with_mpsc(
|
||||||
toxiproxy_config.clone(),
|
toxiproxy_config.clone(),
|
||||||
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
GeyserFilter(CommitmentConfig::confirmed()).blocks_meta(),
|
||||||
autoconnect_tx.clone(),
|
autoconnect_tx.clone(),
|
||||||
|
exit_notify.clone(),
|
||||||
);
|
);
|
||||||
start_example_blockmeta_consumer(blockmeta_rx);
|
start_example_blockmeta_consumer(blockmeta_rx);
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
use crate::{Attempt, GrpcSourceConfig, Message};
|
use crate::{yellowstone_grpc_util, Attempt, GrpcSourceConfig, Message};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
use log::{debug, error, info, log, trace, warn, Level};
|
use log::{debug, error, info, log, trace, warn, Level};
|
||||||
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::mpsc::error::SendTimeoutError;
|
use tokio::sync::mpsc::error::SendTimeoutError;
|
||||||
use tokio::sync::mpsc::Receiver;
|
use tokio::sync::mpsc::Receiver;
|
||||||
use tokio::task::AbortHandle;
|
use tokio::sync::Notify;
|
||||||
|
use tokio::task::JoinHandle;
|
||||||
use tokio::time::{sleep, timeout, Instant};
|
use tokio::time::{sleep, timeout, Instant};
|
||||||
use yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientError};
|
use yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientError};
|
||||||
use yellowstone_grpc_proto::geyser::{SubscribeRequest, SubscribeUpdate};
|
use yellowstone_grpc_proto::geyser::{SubscribeRequest, SubscribeUpdate};
|
||||||
use yellowstone_grpc_proto::tonic::service::Interceptor;
|
use yellowstone_grpc_proto::tonic::service::Interceptor;
|
||||||
use yellowstone_grpc_proto::tonic::Status;
|
use yellowstone_grpc_proto::tonic::Status;
|
||||||
use crate::yellowstone_grpc_util::{connect_with_timeout_with_buffers, GeyserGrpcClientBufferConfig};
|
use crate::yellowstone_grpc_util::connect_with_timeout_with_buffers;
|
||||||
|
|
||||||
enum ConnectionState<S: Stream<Item = Result<SubscribeUpdate, Status>>, F: Interceptor> {
|
enum ConnectionState<S: Stream<Item = Result<SubscribeUpdate, Status>>, F: Interceptor> {
|
||||||
NotConnected(Attempt),
|
NotConnected(Attempt),
|
||||||
|
@ -34,13 +36,18 @@ enum FatalErrorReason {
|
||||||
pub fn create_geyser_autoconnection_task(
|
pub fn create_geyser_autoconnection_task(
|
||||||
grpc_source: GrpcSourceConfig,
|
grpc_source: GrpcSourceConfig,
|
||||||
subscribe_filter: SubscribeRequest,
|
subscribe_filter: SubscribeRequest,
|
||||||
) -> (AbortHandle, Receiver<Message>) {
|
exit_notify: Arc<Notify>,
|
||||||
|
) -> (JoinHandle<()>, Receiver<Message>) {
|
||||||
let (sender, receiver_channel) = tokio::sync::mpsc::channel::<Message>(1);
|
let (sender, receiver_channel) = tokio::sync::mpsc::channel::<Message>(1);
|
||||||
|
|
||||||
let abort_handle =
|
let join_handle = create_geyser_autoconnection_task_with_mpsc(
|
||||||
create_geyser_autoconnection_task_with_mpsc(grpc_source, subscribe_filter, sender);
|
grpc_source,
|
||||||
|
subscribe_filter,
|
||||||
|
sender,
|
||||||
|
exit_notify,
|
||||||
|
);
|
||||||
|
|
||||||
(abort_handle, receiver_channel)
|
(join_handle, receiver_channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// connect to grpc source performing autoconnect if required,
|
/// connect to grpc source performing autoconnect if required,
|
||||||
|
@ -50,7 +57,8 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
grpc_source: GrpcSourceConfig,
|
grpc_source: GrpcSourceConfig,
|
||||||
subscribe_filter: SubscribeRequest,
|
subscribe_filter: SubscribeRequest,
|
||||||
mpsc_downstream: tokio::sync::mpsc::Sender<Message>,
|
mpsc_downstream: tokio::sync::mpsc::Sender<Message>,
|
||||||
) -> AbortHandle {
|
exit_notify: Arc<Notify>,
|
||||||
|
) -> JoinHandle<()> {
|
||||||
// read this for argument: http://www.randomhacks.net/2019/03/08/should-rust-channels-panic-on-send/
|
// read this for argument: http://www.randomhacks.net/2019/03/08/should-rust-channels-panic-on-send/
|
||||||
|
|
||||||
// task will be aborted when downstream receiver gets dropped
|
// task will be aborted when downstream receiver gets dropped
|
||||||
|
@ -58,7 +66,7 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
let mut state = ConnectionState::NotConnected(1);
|
let mut state = ConnectionState::NotConnected(1);
|
||||||
let mut messages_forwarded = 0;
|
let mut messages_forwarded = 0;
|
||||||
|
|
||||||
loop {
|
'main_loop: loop {
|
||||||
state = match state {
|
state = match state {
|
||||||
ConnectionState::NotConnected(attempt) => {
|
ConnectionState::NotConnected(attempt) => {
|
||||||
let addr = grpc_source.grpc_addr.clone();
|
let addr = grpc_source.grpc_addr.clone();
|
||||||
|
@ -77,15 +85,23 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
addr
|
addr
|
||||||
);
|
);
|
||||||
|
|
||||||
let connect_result = connect_with_timeout_with_buffers(
|
let buffer_config = yellowstone_grpc_util::GeyserGrpcClientBufferConfig::optimize_for_subscription(&subscribe_filter);
|
||||||
|
debug!("Using Grpc Buffer config {:?}", buffer_config);
|
||||||
|
let connect_result = tokio::select! {
|
||||||
|
res = connect_with_timeout_with_buffers(
|
||||||
addr,
|
addr,
|
||||||
token,
|
token,
|
||||||
config,
|
config,
|
||||||
connect_timeout,
|
connect_timeout,
|
||||||
request_timeout,
|
request_timeout,
|
||||||
GeyserGrpcClientBufferConfig::optimize_for_subscription(&subscribe_filter),
|
buffer_config,
|
||||||
)
|
) => {
|
||||||
.await;
|
res
|
||||||
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
match connect_result {
|
match connect_result {
|
||||||
Ok(client) => ConnectionState::Connecting(attempt, client),
|
Ok(client) => ConnectionState::Connecting(attempt, client),
|
||||||
|
@ -134,11 +150,17 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
let subscribe_filter = subscribe_filter.clone();
|
let subscribe_filter = subscribe_filter.clone();
|
||||||
debug!("Subscribe with filter {:?}", subscribe_filter);
|
debug!("Subscribe with filter {:?}", subscribe_filter);
|
||||||
|
|
||||||
let subscribe_result_timeout = timeout(
|
let subscribe_result_timeout = tokio::select! {
|
||||||
|
res = timeout(
|
||||||
subscribe_timeout.unwrap_or(Duration::MAX),
|
subscribe_timeout.unwrap_or(Duration::MAX),
|
||||||
client.subscribe_once2(subscribe_filter),
|
client.subscribe_once2(subscribe_filter),
|
||||||
)
|
) => {
|
||||||
.await;
|
res
|
||||||
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
match subscribe_result_timeout {
|
match subscribe_result_timeout {
|
||||||
Ok(subscribe_result) => {
|
Ok(subscribe_result) => {
|
||||||
|
@ -194,7 +216,14 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
"waiting {} seconds, then reconnect to {}",
|
"waiting {} seconds, then reconnect to {}",
|
||||||
backoff_secs, grpc_source
|
backoff_secs, grpc_source
|
||||||
);
|
);
|
||||||
sleep(Duration::from_secs_f32(backoff_secs)).await;
|
tokio::select! {
|
||||||
|
_ = sleep(Duration::from_secs_f32(backoff_secs)) => {
|
||||||
|
//slept
|
||||||
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
ConnectionState::NotConnected(attempt)
|
ConnectionState::NotConnected(attempt)
|
||||||
}
|
}
|
||||||
ConnectionState::FatalError(_attempt, reason) => match reason {
|
ConnectionState::FatalError(_attempt, reason) => match reason {
|
||||||
|
@ -221,18 +250,31 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
"waiting {} seconds, then reconnect to {}",
|
"waiting {} seconds, then reconnect to {}",
|
||||||
backoff_secs, grpc_source
|
backoff_secs, grpc_source
|
||||||
);
|
);
|
||||||
sleep(Duration::from_secs_f32(backoff_secs)).await;
|
tokio::select! {
|
||||||
|
_ = sleep(Duration::from_secs_f32(backoff_secs)) => {
|
||||||
|
//slept
|
||||||
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
ConnectionState::NotConnected(attempt)
|
ConnectionState::NotConnected(attempt)
|
||||||
}
|
}
|
||||||
ConnectionState::Ready(mut geyser_stream) => {
|
ConnectionState::Ready(mut geyser_stream) => {
|
||||||
let receive_timeout = grpc_source.timeouts.as_ref().map(|t| t.receive_timeout);
|
let receive_timeout = grpc_source.timeouts.as_ref().map(|t| t.receive_timeout);
|
||||||
'recv_loop: loop {
|
'recv_loop: loop {
|
||||||
match timeout(
|
let geyser_stream_res = tokio::select! {
|
||||||
|
res = timeout(
|
||||||
receive_timeout.unwrap_or(Duration::MAX),
|
receive_timeout.unwrap_or(Duration::MAX),
|
||||||
geyser_stream.next(),
|
geyser_stream.next(),
|
||||||
)
|
) => {
|
||||||
.await
|
res
|
||||||
{
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
match geyser_stream_res {
|
||||||
Ok(Some(Ok(update_message))) => {
|
Ok(Some(Ok(update_message))) => {
|
||||||
trace!("> recv update message from {}", grpc_source);
|
trace!("> recv update message from {}", grpc_source);
|
||||||
// note: first send never blocks as the mpsc channel has capacity 1
|
// note: first send never blocks as the mpsc channel has capacity 1
|
||||||
|
@ -242,13 +284,21 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
Duration::from_millis(500)
|
Duration::from_millis(500)
|
||||||
};
|
};
|
||||||
let started_at = Instant::now();
|
let started_at = Instant::now();
|
||||||
match mpsc_downstream
|
|
||||||
|
let mpsc_downstream_result = tokio::select! {
|
||||||
|
res = mpsc_downstream
|
||||||
.send_timeout(
|
.send_timeout(
|
||||||
Message::GeyserSubscribeUpdate(Box::new(update_message)),
|
Message::GeyserSubscribeUpdate(Box::new(update_message)),
|
||||||
warning_threshold,
|
warning_threshold,
|
||||||
)
|
) => {
|
||||||
.await
|
res
|
||||||
{
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match mpsc_downstream_result {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
messages_forwarded += 1;
|
messages_forwarded += 1;
|
||||||
if messages_forwarded == 1 {
|
if messages_forwarded == 1 {
|
||||||
|
@ -266,7 +316,16 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
Err(SendTimeoutError::Timeout(the_message)) => {
|
Err(SendTimeoutError::Timeout(the_message)) => {
|
||||||
warn!("downstream receiver did not pick up message for {}ms - keep waiting", warning_threshold.as_millis());
|
warn!("downstream receiver did not pick up message for {}ms - keep waiting", warning_threshold.as_millis());
|
||||||
|
|
||||||
match mpsc_downstream.send(the_message).await {
|
let mpsc_downstream_result = tokio::select! {
|
||||||
|
res = mpsc_downstream.send(the_message)=> {
|
||||||
|
res
|
||||||
|
},
|
||||||
|
_ = exit_notify.notified() => {
|
||||||
|
break 'main_loop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match mpsc_downstream_result {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
messages_forwarded += 1;
|
messages_forwarded += 1;
|
||||||
trace!(
|
trace!(
|
||||||
|
@ -313,7 +372,7 @@ pub fn create_geyser_autoconnection_task_with_mpsc(
|
||||||
} // -- endless state loop
|
} // -- endless state loop
|
||||||
});
|
});
|
||||||
|
|
||||||
jh_geyser_task.abort_handle()
|
jh_geyser_task
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -5,12 +5,11 @@ use yellowstone_grpc_proto::geyser::geyser_client::GeyserClient;
|
||||||
use yellowstone_grpc_proto::geyser::SubscribeRequest;
|
use yellowstone_grpc_proto::geyser::SubscribeRequest;
|
||||||
use yellowstone_grpc_proto::prost::bytes::Bytes;
|
use yellowstone_grpc_proto::prost::bytes::Bytes;
|
||||||
use yellowstone_grpc_proto::tonic;
|
use yellowstone_grpc_proto::tonic;
|
||||||
use yellowstone_grpc_proto::tonic::metadata::AsciiMetadataValue;
|
|
||||||
use yellowstone_grpc_proto::tonic::metadata::errors::InvalidMetadataValue;
|
use yellowstone_grpc_proto::tonic::metadata::errors::InvalidMetadataValue;
|
||||||
|
use yellowstone_grpc_proto::tonic::metadata::AsciiMetadataValue;
|
||||||
use yellowstone_grpc_proto::tonic::service::Interceptor;
|
use yellowstone_grpc_proto::tonic::service::Interceptor;
|
||||||
use yellowstone_grpc_proto::tonic::transport::ClientTlsConfig;
|
use yellowstone_grpc_proto::tonic::transport::ClientTlsConfig;
|
||||||
|
|
||||||
|
|
||||||
pub async fn connect_with_timeout<E, T>(
|
pub async fn connect_with_timeout<E, T>(
|
||||||
endpoint: E,
|
endpoint: E,
|
||||||
x_token: Option<T>,
|
x_token: Option<T>,
|
||||||
|
@ -19,15 +18,21 @@ pub async fn connect_with_timeout<E, T>(
|
||||||
request_timeout: Option<Duration>,
|
request_timeout: Option<Duration>,
|
||||||
connect_lazy: bool,
|
connect_lazy: bool,
|
||||||
) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor>>
|
) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor>>
|
||||||
where
|
where
|
||||||
E: Into<Bytes>,
|
E: Into<Bytes>,
|
||||||
T: TryInto<AsciiMetadataValue, Error = InvalidMetadataValue>,
|
T: TryInto<AsciiMetadataValue, Error = InvalidMetadataValue>,
|
||||||
{
|
{
|
||||||
GeyserGrpcClient::connect_with_timeout(
|
GeyserGrpcClient::connect_with_timeout(
|
||||||
endpoint, x_token, tls_config, connect_timeout, request_timeout, connect_lazy).await
|
endpoint,
|
||||||
|
x_token,
|
||||||
|
tls_config,
|
||||||
|
connect_timeout,
|
||||||
|
request_timeout,
|
||||||
|
connect_lazy,
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// see https://github.com/hyperium/tonic/blob/v0.10.2/tonic/src/transport/channel/mod.rs
|
// see https://github.com/hyperium/tonic/blob/v0.10.2/tonic/src/transport/channel/mod.rs
|
||||||
const DEFAULT_BUFFER_SIZE: usize = 1024;
|
const DEFAULT_BUFFER_SIZE: usize = 1024;
|
||||||
// see https://github.com/hyperium/hyper/blob/v0.14.28/src/proto/h2/client.rs#L45
|
// see https://github.com/hyperium/hyper/blob/v0.14.28/src/proto/h2/client.rs#L45
|
||||||
|
@ -52,7 +57,6 @@ impl Default for GeyserGrpcClientBufferConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GeyserGrpcClientBufferConfig {
|
impl GeyserGrpcClientBufferConfig {
|
||||||
|
|
||||||
pub fn optimize_for_subscription(filter: &SubscribeRequest) -> GeyserGrpcClientBufferConfig {
|
pub fn optimize_for_subscription(filter: &SubscribeRequest) -> GeyserGrpcClientBufferConfig {
|
||||||
if !filter.blocks.is_empty() {
|
if !filter.blocks.is_empty() {
|
||||||
GeyserGrpcClientBufferConfig {
|
GeyserGrpcClientBufferConfig {
|
||||||
|
@ -64,10 +68,8 @@ impl GeyserGrpcClientBufferConfig {
|
||||||
GeyserGrpcClientBufferConfig::default()
|
GeyserGrpcClientBufferConfig::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn connect_with_timeout_with_buffers<E, T>(
|
pub async fn connect_with_timeout_with_buffers<E, T>(
|
||||||
endpoint: E,
|
endpoint: E,
|
||||||
x_token: Option<T>,
|
x_token: Option<T>,
|
||||||
|
@ -76,9 +78,10 @@ pub async fn connect_with_timeout_with_buffers<E, T>(
|
||||||
request_timeout: Option<Duration>,
|
request_timeout: Option<Duration>,
|
||||||
buffer_config: GeyserGrpcClientBufferConfig,
|
buffer_config: GeyserGrpcClientBufferConfig,
|
||||||
) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor>>
|
) -> GeyserGrpcClientResult<GeyserGrpcClient<impl Interceptor>>
|
||||||
where
|
where
|
||||||
E: Into<Bytes>,
|
E: Into<Bytes>,
|
||||||
T: TryInto<AsciiMetadataValue, Error = InvalidMetadataValue>, {
|
T: TryInto<AsciiMetadataValue, Error = InvalidMetadataValue>,
|
||||||
|
{
|
||||||
// see https://github.com/blockworks-foundation/geyser-grpc-connector/issues/10
|
// see https://github.com/blockworks-foundation/geyser-grpc-connector/issues/10
|
||||||
let mut endpoint = tonic::transport::Endpoint::from_shared(endpoint)?
|
let mut endpoint = tonic::transport::Endpoint::from_shared(endpoint)?
|
||||||
.buffer_size(buffer_config.buffer_size)
|
.buffer_size(buffer_config.buffer_size)
|
||||||
|
|
Loading…
Reference in New Issue