code format
This commit is contained in:
parent
18397eeab7
commit
37e44aa9b3
|
@ -1,3 +1,4 @@
|
||||||
|
use anyhow::Context;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||||
use solana_rpc_client_api::config::RpcBlockConfig;
|
use solana_rpc_client_api::config::RpcBlockConfig;
|
||||||
|
@ -14,7 +15,6 @@ use solana_transaction_status::{
|
||||||
UiTransactionStatusMeta,
|
UiTransactionStatusMeta,
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use anyhow::Context;
|
|
||||||
|
|
||||||
use crate::block_store::{BlockInformation, BlockStore};
|
use crate::block_store::{BlockInformation, BlockStore};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{collections::VecDeque, str::FromStr, sync::Arc};
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use std::{collections::VecDeque, str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
@ -37,7 +37,9 @@ impl LeaderSchedule {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn load_cluster_info(&self, rpc_client: Arc<RpcClient>) -> anyhow::Result<()> {
|
pub async fn load_cluster_info(&self, rpc_client: Arc<RpcClient>) -> anyhow::Result<()> {
|
||||||
let cluster_nodes = rpc_client.get_cluster_nodes().await
|
let cluster_nodes = rpc_client
|
||||||
|
.get_cluster_nodes()
|
||||||
|
.await
|
||||||
.context("failed to get cluster nodes")?;
|
.context("failed to get cluster nodes")?;
|
||||||
cluster_nodes.iter().for_each(|x| {
|
cluster_nodes.iter().for_each(|x| {
|
||||||
if let Ok(pubkey) = Pubkey::from_str(x.pubkey.as_str()) {
|
if let Ok(pubkey) = Pubkey::from_str(x.pubkey.as_str()) {
|
||||||
|
@ -80,7 +82,8 @@ impl LeaderSchedule {
|
||||||
let current_leader = (i - first_slot_to_fetch) as usize;
|
let current_leader = (i - first_slot_to_fetch) as usize;
|
||||||
let leader = leaders[current_leader];
|
let leader = leaders[current_leader];
|
||||||
if !self.cluster_nodes.contains_key(&leader) {
|
if !self.cluster_nodes.contains_key(&leader) {
|
||||||
self.load_cluster_info(rpc_client.clone()).await
|
self.load_cluster_info(rpc_client.clone())
|
||||||
|
.await
|
||||||
.context("failed to load cluster info")?;
|
.context("failed to load cluster info")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,9 @@ impl LiteBridge {
|
||||||
max_retries: usize,
|
max_retries: usize,
|
||||||
) -> anyhow::Result<Self> {
|
) -> anyhow::Result<Self> {
|
||||||
let rpc_client = Arc::new(RpcClient::new(rpc_url.clone()));
|
let rpc_client = Arc::new(RpcClient::new(rpc_url.clone()));
|
||||||
let current_slot = rpc_client.get_slot().await
|
let current_slot = rpc_client
|
||||||
|
.get_slot()
|
||||||
|
.await
|
||||||
.context("failed to get initial slot")?;
|
.context("failed to get initial slot")?;
|
||||||
|
|
||||||
let tx_store = empty_tx_store();
|
let tx_store = empty_tx_store();
|
||||||
|
|
|
@ -238,7 +238,10 @@ impl BlockListener {
|
||||||
// TODO insert if not exists leader_id into accountaddrs
|
// TODO insert if not exists leader_id into accountaddrs
|
||||||
|
|
||||||
// fetch cluster time from rpc
|
// fetch cluster time from rpc
|
||||||
let block_time = self.rpc_client.get_block_time(slot).await
|
let block_time = self
|
||||||
|
.rpc_client
|
||||||
|
.get_block_time(slot)
|
||||||
|
.await
|
||||||
.context("failed to get block time")?;
|
.context("failed to get block time")?;
|
||||||
|
|
||||||
// fetch local time from blockstore
|
// fetch local time from blockstore
|
||||||
|
|
Loading…
Reference in New Issue