Skip to content

Commit

Permalink
fix(executor): handle bad blockhash
Browse files Browse the repository at this point in the history
  • Loading branch information
00nktk committed Nov 19, 2024
1 parent d63f965 commit f0e347a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions executor/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ impl TransactionBuilder {
TxErrorKind::BadExternalCall | TxErrorKind::Other => {
self.handle_preflight_error(tx).await
}
TxErrorKind::BlockhashNotFound => Ok(tx), // Tx is ok, just need to re-sign it
TxErrorKind::AlreadyProcessed => bail!("must be handled before"),
}
}
Expand Down
12 changes: 7 additions & 5 deletions executor/src/transactions/preflight_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum TxErrorKind {
BadExternalCall,
AlreadyProcessed,
MissingAccount(Pubkey),
BlockhashNotFound,
Other,
}

Expand All @@ -37,11 +38,11 @@ impl TxErrorKind {
_ => (),
};

if matches!(
extract_transaction_err(&err.kind),
Some(TransactionError::AlreadyProcessed)
) {
return Some(Self::AlreadyProcessed);
let tx_err = extract_transaction_err(&err.kind);
match tx_err {
Some(TransactionError::AlreadyProcessed) => return Some(Self::AlreadyProcessed),
Some(TransactionError::BlockhashNotFound) => return Some(Self::BlockhashNotFound),
_ => (),
}

if tx.is_alt() {
Expand Down Expand Up @@ -77,6 +78,7 @@ fn extract_transaction_err(err: &ClientErrorKind) -> Option<&TransactionError> {
),
..
}) => err.as_ref(),
ClientErrorKind::TransactionError(ref err) => Some(err),
_ => None,
}
}
Expand Down

0 comments on commit f0e347a

Please sign in to comment.