Skip to content

Commit

Permalink
refactor: invert the hash check conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs committed Nov 4, 2024
1 parent 5180af2 commit eab77aa
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions engine/src/sol/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,30 @@ impl SolRpcClient {
let mut poll_interval = make_periodic_tick(RPC_RETRY_CONNECTION_INTERVAL, true);
loop {
poll_interval.tick().await;
match get_genesis_hash(&client, &endpoint).await {
Ok(genesis_hash) => match expected_genesis_hash {
None => {
warn!("Skipping Solana genesis hash check");
break;
},
Some(expected_hash) if expected_hash == genesis_hash => {
break;
},
Some(_) => {
error!(
"Connected to Solana node at {0} but the genesis hash {genesis_hash} does not match the expected genesis hash. Please check your CFE configuration file.", endpoint
)
match expected_genesis_hash {
None => {
warn!("Skipping Solana genesis hash check");
break;
},
Some(expected_hash) => match get_genesis_hash(&client, &endpoint).await {
Ok(genesis_hash) =>
if expected_hash == genesis_hash {
break;
} else {
error!(
"Connected to Solana node at {0} but the genesis hash {genesis_hash} does not match the expected genesis hash. Please check your CFE configuration file.",
endpoint
)
},
Err(e) => {
tracing::error!(
"Cannot connect to Solana node at {1} with error: {e}. \
Please check your CFE configuration file. Retrying in {:?}...",
poll_interval.period(),
endpoint
)
},
},
Err(e) => tracing::error!(
"Cannot connect to Solana node at {1} with error: {e}. \
Please check your CFE configuration file. Retrying in {:?}...",
poll_interval.period(),
endpoint
),
}
}
Self { client, endpoint }
Expand Down

0 comments on commit eab77aa

Please sign in to comment.