Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
m30m committed Jul 17, 2024
1 parent d69312a commit c0ed513
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/fortuna/src/chain/nonce_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
Ok(nonce)
} // guard dropped here

pub async fn reset(&self) {
pub fn reset(&self) {
self.initialized.store(false, Ordering::SeqCst);
}

Expand Down
31 changes: 14 additions & 17 deletions apps/fortuna/src/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,28 +493,25 @@ pub async fn process_event(
))
})?;

let optional_receipt = pending_tx.await.map_err(|e| {
backoff::Error::transient(anyhow!(
"Error waiting for transaction receipt. Tx:{:?} Error:{:?}",
transaction,
e
))
})?;


let receipt = match optional_receipt {
Some(receipt) => receipt,
None => {
let receipt = pending_tx
.await
.map_err(|e| {
backoff::Error::transient(anyhow!(
"Error waiting for transaction receipt. Tx:{:?} Error:{:?}",
transaction,
e
))
})?
.ok_or_else(|| {
// RPC may not return an error on tx submission if the nonce is too high.
// But we will never get a receipt. So we reset the nonce manager to get the correct nonce.
let nonce_manager = contract.client_ref().inner().inner();
nonce_manager.reset().await;
return Err(backoff::Error::transient(anyhow!(
nonce_manager.reset();
backoff::Error::transient(anyhow!(
"Can't verify the reveal, probably dropped from mempool Tx:{:?}",
transaction
)));
}
};
))
})?;

tracing::info!(
sequence_number = &event.sequence_number,
Expand Down

0 comments on commit c0ed513

Please sign in to comment.