Skip to content

Commit

Permalink
chore: remove unused check (#1837)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19-cw authored Nov 1, 2024
1 parent 8f3dff6 commit f95d139
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/eth/follower/importer/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,39 +301,33 @@ impl Importer {
// in case of failure, re-subscribe because current subscription may have been closed in the server.
if let Some(sub) = &mut sub_new_heads {
tracing::info!("{} awaiting block number from newHeads subscription", TASK_NAME);
let resubscribe_ws = match timeout(TIMEOUT_NEW_HEADS, sub.next()).await {
match timeout(TIMEOUT_NEW_HEADS, sub.next()).await {
Ok(Some(Ok(block))) => {
tracing::info!(block_number = %block.number(), "{} received newHeads event", TASK_NAME);
set_external_rpc_current_block(block.number());
continue;
}
Ok(None) => {
Ok(None) =>
if !Self::should_shutdown(TASK_NAME) {
tracing::error!("{} newHeads subscription closed by the other side", TASK_NAME);
}
true
}
Ok(Some(Err(e))) => {
},
Ok(Some(Err(e))) =>
if !Self::should_shutdown(TASK_NAME) {
tracing::error!(reason = ?e, "{} failed to read newHeads subscription event", TASK_NAME);
}
true
}
Err(_) => {
},
Err(_) =>
if !Self::should_shutdown(TASK_NAME) {
tracing::error!("{} timed-out waiting for newHeads subscription event", TASK_NAME);
}
true
}
};
},
}

if Self::should_shutdown(TASK_NAME) {
return Ok(());
}

// resubscribe if necessary.
// only update the existing subscription if succedeed, otherwise we will try again in the next iteration.
if chain.supports_ws() && resubscribe_ws {
if chain.supports_ws() {
tracing::info!("{} resubscribing to newHeads event", TASK_NAME);
match chain.subscribe_new_heads().await {
Ok(sub) => {
Expand Down

0 comments on commit f95d139

Please sign in to comment.