After groovies review
This commit is contained in:
parent
72026d5a58
commit
f8995cbdfc
|
@ -11,7 +11,6 @@ pub fn poll_cluster_info(
|
|||
) -> AnyhowJoinHandle {
|
||||
// task MUST not terminate but might be aborted from outside
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
loop {
|
||||
match rpc_client.get_cluster_nodes().await {
|
||||
Ok(cluster_nodes) => {
|
||||
|
|
|
@ -6,13 +6,13 @@ use tokio::time::{timeout, Instant};
|
|||
|
||||
use crate::{structures::block_info::BlockInfo, types::BlockInfoStream};
|
||||
|
||||
pub async fn get_latest_block_info(
|
||||
pub async fn wait_till_block_of_commitment_is_recieved(
|
||||
mut blockinfo_stream: BlockInfoStream,
|
||||
commitment_config: CommitmentConfig,
|
||||
) -> BlockInfo {
|
||||
let started = Instant::now();
|
||||
loop {
|
||||
match timeout(Duration::from_millis(500), blockinfo_stream.recv()).await {
|
||||
match timeout(Duration::from_millis(1000), blockinfo_stream.recv()).await {
|
||||
Ok(Ok(block_info)) => {
|
||||
if block_info.commitment_config == commitment_config {
|
||||
return block_info;
|
||||
|
@ -25,8 +25,8 @@ pub async fn get_latest_block_info(
|
|||
started.elapsed().as_secs_f32() * 1000.0
|
||||
);
|
||||
}
|
||||
Ok(Err(_error)) => {
|
||||
panic!("Did not recv block info");
|
||||
Ok(Err(error)) => {
|
||||
panic!("Did not recv block info : {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use solana_lite_rpc_core::{
|
|||
epoch::EpochCache, identity_stakes::IdentityStakes, leaderschedule::CalculatedSchedule,
|
||||
transaction_sent_info::SentTransactionInfo,
|
||||
},
|
||||
utils::get_latest_block_info,
|
||||
utils::wait_till_block_of_commitment_is_recieved,
|
||||
};
|
||||
use solana_lite_rpc_services::{
|
||||
data_caching_service::DataCachingService,
|
||||
|
@ -280,7 +280,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
create_json_rpc_polling_subscription(rpc_client.clone(), 100)?
|
||||
};
|
||||
|
||||
let finalized_block_information = get_latest_block_info(
|
||||
let finalized_block_information = wait_till_block_of_commitment_is_recieved(
|
||||
endpoints.blockinfo_notifier.resubscribe(),
|
||||
CommitmentConfig::finalized(),
|
||||
)
|
||||
|
|
|
@ -45,7 +45,7 @@ use solana_lite_rpc_core::structures::{
|
|||
};
|
||||
use solana_lite_rpc_core::traits::address_lookup_table_interface::AddressLookupTableInterface;
|
||||
use solana_lite_rpc_core::types::BlockStream;
|
||||
use solana_lite_rpc_core::utils::get_latest_block_info;
|
||||
use solana_lite_rpc_core::utils::wait_till_block_of_commitment_is_recieved;
|
||||
use solana_lite_rpc_core::AnyhowJoinHandle;
|
||||
use solana_lite_rpc_prioritization_fees::account_prio_service::AccountPrioService;
|
||||
use solana_lite_rpc_services::data_caching_service::DataCachingService;
|
||||
|
@ -228,7 +228,7 @@ pub async fn start_lite_rpc(args: Config, rpc_client: Arc<RpcClient>) -> anyhow:
|
|||
};
|
||||
|
||||
info!("Waiting for first finalized block info...");
|
||||
let finalized_block_info = get_latest_block_info(
|
||||
let finalized_block_info = wait_till_block_of_commitment_is_recieved(
|
||||
blockinfo_notifier.resubscribe(),
|
||||
CommitmentConfig::finalized(),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue