Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to customize the bundle result waiting time. #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions searcher_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down Expand Up @@ -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::<u64>()
.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(),
Expand Down