Skip to content

Commit 34b60b3

Browse files
forester: use indexer_url from config as photon_url in SolanaRpcPoolBuilder
1 parent 69c1204 commit 34b60b3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

forester-utils/src/rpc_pool.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub enum PoolError {
2626

2727
pub struct SolanaConnectionManager<R: Rpc + 'static> {
2828
url: String,
29+
photon_url: Option<String>,
2930
commitment: CommitmentConfig,
3031
// TODO: implement Rpc for SolanaConnectionManager and rate limit requests.
3132
_rpc_rate_limiter: Option<RateLimiter>,
@@ -36,12 +37,14 @@ pub struct SolanaConnectionManager<R: Rpc + 'static> {
3637
impl<R: Rpc + 'static> SolanaConnectionManager<R> {
3738
pub fn new(
3839
url: String,
40+
photon_url: Option<String>,
3941
commitment: CommitmentConfig,
4042
rpc_rate_limiter: Option<RateLimiter>,
4143
send_tx_rate_limiter: Option<RateLimiter>,
4244
) -> Self {
4345
Self {
4446
url,
47+
photon_url,
4548
commitment,
4649
_rpc_rate_limiter: rpc_rate_limiter,
4750
_send_tx_rate_limiter: send_tx_rate_limiter,
@@ -58,7 +61,7 @@ impl<R: Rpc + 'static> bb8::ManageConnection for SolanaConnectionManager<R> {
5861
async fn connect(&self) -> Result<Self::Connection, Self::Error> {
5962
let config = LightClientConfig {
6063
url: self.url.to_string(),
61-
photon_url: None,
64+
photon_url: self.photon_url.clone(),
6265
commitment_config: Some(self.commitment),
6366
fetch_active_tree: false,
6467
};
@@ -86,6 +89,8 @@ pub struct SolanaRpcPool<R: Rpc + 'static> {
8689
#[derive(Debug)]
8790
pub struct SolanaRpcPoolBuilder<R: Rpc> {
8891
url: Option<String>,
92+
photon_url: Option<String>,
93+
8994
commitment: Option<CommitmentConfig>,
9095

9196
max_size: u32,
@@ -110,6 +115,7 @@ impl<R: Rpc> SolanaRpcPoolBuilder<R> {
110115
pub fn new() -> Self {
111116
Self {
112117
url: None,
118+
photon_url: None,
113119
commitment: None,
114120
max_size: 50,
115121
connection_timeout_secs: 15,
@@ -128,6 +134,11 @@ impl<R: Rpc> SolanaRpcPoolBuilder<R> {
128134
self
129135
}
130136

137+
pub fn photon_url(mut self, url: Option<String>) -> Self {
138+
self.photon_url = url;
139+
self
140+
}
141+
131142
pub fn commitment(mut self, commitment: CommitmentConfig) -> Self {
132143
self.commitment = Some(commitment);
133144
self
@@ -183,6 +194,7 @@ impl<R: Rpc> SolanaRpcPoolBuilder<R> {
183194

184195
let manager = SolanaConnectionManager::new(
185196
url,
197+
self.photon_url,
186198
commitment,
187199
self.rpc_rate_limiter,
188200
self.send_tx_rate_limiter,

forester/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub async fn run_pipeline<R: Rpc, I: Indexer + IndexerType<R> + 'static>(
100100
) -> Result<()> {
101101
let mut builder = SolanaRpcPoolBuilder::<R>::default()
102102
.url(config.external_services.rpc_url.to_string())
103+
.photon_url(config.external_services.indexer_url.clone())
103104
.commitment(CommitmentConfig::confirmed())
104105
.max_size(config.rpc_pool_config.max_size)
105106
.connection_timeout_secs(config.rpc_pool_config.connection_timeout_secs)

0 commit comments

Comments
 (0)