Skip to content

Commit 9dba9d0

Browse files
authored
fix(fortuna): remove wss related code (#2648)
1 parent 578741c commit 9dba9d0

File tree

3 files changed

+4
-57
lines changed

3 files changed

+4
-57
lines changed

apps/fortuna/src/config.rs

-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ pub struct EthereumConfig {
110110
/// TODO: Change type from String to Url
111111
pub geth_rpc_addr: String,
112112

113-
/// URL of a Geth RPC wss endpoint to use for subscribing to blockchain events.
114-
pub geth_rpc_wss: Option<String>,
115-
116113
/// Address of a Pyth Randomness contract to interact with.
117114
pub contract_addr: Address,
118115

apps/fortuna/src/keeper.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,7 @@ pub async fn run_keeper_threads(
9999

100100
let (tx, rx) = mpsc::channel::<BlockRange>(1000);
101101
// Spawn a thread to watch for new blocks and send the range of blocks for which events has not been handled to the `tx` channel.
102-
spawn(
103-
watch_blocks_wrapper(
104-
chain_state.clone(),
105-
latest_safe_block,
106-
tx,
107-
chain_eth_config.geth_rpc_wss.clone(),
108-
)
109-
.in_current_span(),
110-
);
102+
spawn(watch_blocks_wrapper(chain_state.clone(), latest_safe_block, tx).in_current_span());
111103

112104
// Spawn a thread for block processing with configured delays
113105
spawn(

apps/fortuna/src/keeper/block.rs

+3-45
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ use {
66
keeper::keeper_metrics::KeeperMetrics,
77
keeper::process_event::process_event_with_backoff,
88
},
9-
anyhow::{anyhow, Result},
10-
ethers::{
11-
providers::{Middleware, Provider, Ws},
12-
types::U256,
13-
},
14-
futures::StreamExt,
9+
anyhow::Result,
10+
ethers::types::U256,
1511
std::{collections::HashSet, sync::Arc},
1612
tokio::{
1713
spawn,
@@ -176,15 +172,13 @@ pub async fn watch_blocks_wrapper(
176172
chain_state: BlockchainState,
177173
latest_safe_block: BlockNumber,
178174
tx: mpsc::Sender<BlockRange>,
179-
geth_rpc_wss: Option<String>,
180175
) {
181176
let mut last_safe_block_processed = latest_safe_block;
182177
loop {
183178
if let Err(e) = watch_blocks(
184179
chain_state.clone(),
185180
&mut last_safe_block_processed,
186181
tx.clone(),
187-
geth_rpc_wss.clone(),
188182
)
189183
.in_current_span()
190184
.await
@@ -203,47 +197,11 @@ pub async fn watch_blocks(
203197
chain_state: BlockchainState,
204198
last_safe_block_processed: &mut BlockNumber,
205199
tx: mpsc::Sender<BlockRange>,
206-
geth_rpc_wss: Option<String>,
207200
) -> Result<()> {
208201
tracing::info!("Watching blocks to handle new events");
209202

210-
let provider_option = match geth_rpc_wss {
211-
Some(wss) => Some(match Provider::<Ws>::connect(wss.clone()).await {
212-
Ok(provider) => provider,
213-
Err(e) => {
214-
tracing::error!("Error while connecting to wss: {}. error: {:?}", wss, e);
215-
return Err(e.into());
216-
}
217-
}),
218-
None => {
219-
tracing::info!("No wss provided");
220-
None
221-
}
222-
};
223-
224-
let mut stream_option = match provider_option {
225-
Some(ref provider) => Some(match provider.subscribe_blocks().await {
226-
Ok(client) => client,
227-
Err(e) => {
228-
tracing::error!("Error while subscribing to blocks. error {:?}", e);
229-
return Err(e.into());
230-
}
231-
}),
232-
None => None,
233-
};
234-
235203
loop {
236-
match stream_option {
237-
Some(ref mut stream) => {
238-
if stream.next().await.is_none() {
239-
tracing::error!("Error blocks subscription stream ended");
240-
return Err(anyhow!("Error blocks subscription stream ended"));
241-
}
242-
}
243-
None => {
244-
time::sleep(POLL_INTERVAL).await;
245-
}
246-
}
204+
time::sleep(POLL_INTERVAL).await;
247205

248206
let latest_safe_block = get_latest_safe_block(&chain_state).in_current_span().await;
249207
if latest_safe_block > *last_safe_block_processed {

0 commit comments

Comments
 (0)