Skip to content

Commit

Permalink
fix faithful request
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Jul 1, 2024
1 parent 9f3a8d8 commit 031ee43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::bail;
use log::warn;
use log::{info, warn};
use solana_lite_rpc_cluster_endpoints::rpc_polling;
use solana_lite_rpc_core::structures::produced_block::ProducedBlock;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
Expand Down Expand Up @@ -32,10 +32,10 @@ impl FaithfulBlockStore {
// TODO check what parameters we want
let faithful_config = RpcBlockConfig {
encoding: Some(UiTransactionEncoding::Base58),
transaction_details: Some(TransactionDetails::Full),
rewards: None,
commitment: None,
max_supported_transaction_version: None,
transaction_details: Some(TransactionDetails::None),
rewards: Some(false),
commitment: Some(CommitmentConfig::finalized()),
max_supported_transaction_version: Some(0),
};

match self
Expand Down
17 changes: 11 additions & 6 deletions blockstore/src/block_stores/multiple_strategy_block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use solana_lite_rpc_core::structures::produced_block::ProducedBlock;

use solana_sdk::slot_history::Slot;
use std::ops::{Deref, RangeInclusive};
use std::sync::Arc;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;

#[derive(Debug, Clone)]
pub enum BlockSource {
Expand Down Expand Up @@ -46,11 +48,14 @@ impl MultipleStrategyBlockStorage {
"without"
);

let faithful_rpc_client = Some(Arc::new(RpcClient::new("http://rpc.old-faithful.net".to_string())));


Self {
block_storage_query,
// faithful_history not used ATM
faithful_block_storage: None,
// faithful_block_storage: faithful_rpc_client.map(|rpc| FaithfulBlockStore::new(rpc)),
// faithful_block_storage: None,
faithful_block_storage: faithful_rpc_client.map(|rpc| FaithfulBlockStore::new(rpc)),
}
}

Expand Down Expand Up @@ -100,6 +105,7 @@ impl MultipleStrategyBlockStorage {
// 2.1. if yes; fetch from Postgres
// 2.2. if not: try to fetch from faithful_history

// TODO what to do if slot is newer than what we have in the database?
match self.block_storage_query.is_block_in_range(slot).await {
true => {
debug!(
Expand Down Expand Up @@ -138,11 +144,10 @@ impl MultipleStrategyBlockStorage {
result_source: BlockSource::FaithfulArchive,
})
}
Err(_) => {
Err(rpc_err) => {
debug!(
"Block {} not found in faithful_history storage - giving up",
slot
);
"Block {} not found in faithful_history storage - giving up: {}",
slot, rpc_err);
bail!(format!("Block {} not found in faithful_history", slot));
}
}
Expand Down

0 comments on commit 031ee43

Please sign in to comment.