From f6f616d35820059a4cd2735d1e85a1c12b3d7c81 Mon Sep 17 00:00:00 2001 From: Sergei Patrikeev Date: Thu, 23 May 2024 19:54:48 +0100 Subject: [PATCH] feat: allow to customize the bundle result waiting time. --- searcher_client/src/lib.rs | 41 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/searcher_client/src/lib.rs b/searcher_client/src/lib.rs index dc3abb9..4c91dcd 100644 --- a/searcher_client/src/lib.rs +++ b/searcher_client/src/lib.rs @@ -4,18 +4,6 @@ use std::{ }; use futures_util::StreamExt; -use jito_protos::{ - auth::{auth_service_client::AuthServiceClient, Role}, - bundle::{ - bundle_result::Result as BundleResultType, rejected::Reason, Accepted, Bundle, - BundleResult, InternalError, SimulationFailure, StateAuctionBidRejected, - WinningBatchBidRejected, - }, - convert::proto_packet_from_versioned_tx, - searcher::{ - searcher_service_client::SearcherServiceClient, SendBundleRequest, SendBundleResponse, - }, -}; use log::{info, warn}; use solana_client::nonblocking::rpc_client::RpcClient; use solana_sdk::{ @@ -27,9 +15,22 @@ use thiserror::Error; use tokio::time::timeout; use tonic::{ codegen::{Body, Bytes, InterceptedService, StdError}, - transport, - transport::{Channel, Endpoint}, - Response, Status, Streaming, + Response, + Status, + Streaming, transport, transport::{Channel, Endpoint}, +}; + +use jito_protos::{ + auth::{auth_service_client::AuthServiceClient, Role}, + bundle::{ + Accepted, Bundle, bundle_result::Result as BundleResultType, BundleResult, + InternalError, rejected::Reason, SimulationFailure, StateAuctionBidRejected, + WinningBatchBidRejected, + }, + convert::proto_packet_from_versioned_tx, + searcher::{ + searcher_service_client::SearcherServiceClient, SendBundleRequest, SendBundleResponse, + }, }; use crate::token_authenticator::ClientInterceptor; @@ -116,8 +117,14 @@ where let uuid = result.into_inner().uuid; info!("Bundle sent. UUID: {:?}", uuid); - info!("Waiting for 5 seconds to hear results..."); - let mut time_left = 5000; + // Read the environment variable + let wait_seconds = std::env::var("JITO_BUNDLE_RESULT_WAIT_SECONDS") + .unwrap_or_else(|_| "5".to_string()) + .parse::() + .unwrap_or(5); + + info!("Waiting for {wait_seconds} seconds to hear results..."); + let mut time_left = wait_seconds * 1000; while let Ok(Some(Ok(results))) = timeout( Duration::from_millis(time_left), bundle_results_subscription.next(),