Surface AccountInUse to JSON RPC users so they know to retry the transaction
This commit is contained in:
parent
4f34822900
commit
7977b97227
|
@ -168,6 +168,7 @@ events.
|
|||
* `Confirmed` - Transaction was successful
|
||||
* `SignatureNotFound` - Unknown transaction
|
||||
* `ProgramRuntimeError` - An error occurred in the program that processed this Transaction
|
||||
* `AccountInUse` - Another Transaction had a write lock one of the Accounts specified in this Transaction. The Transaction may succeed if retried
|
||||
* `GenericFailure` - Some other error occurred. **Note**: In the future new Transaction statuses may be added to this list. It's safe to assume that all new statuses will be more specific error conditions that previously presented as `GenericFailure`
|
||||
|
||||
##### Example:
|
||||
|
|
|
@ -302,6 +302,7 @@ impl Bank {
|
|||
if res[i] != Err(BankError::SignatureNotFound) {
|
||||
let status = match res[i] {
|
||||
Ok(_) => RpcSignatureStatus::Confirmed,
|
||||
Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse,
|
||||
Err(BankError::ProgramRuntimeError(_)) => {
|
||||
RpcSignatureStatus::ProgramRuntimeError
|
||||
}
|
||||
|
|
|
@ -90,10 +90,11 @@ impl Metadata for Meta {}
|
|||
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Debug)]
|
||||
pub enum RpcSignatureStatus {
|
||||
AccountInUse,
|
||||
Confirmed,
|
||||
SignatureNotFound,
|
||||
ProgramRuntimeError,
|
||||
GenericFailure,
|
||||
ProgramRuntimeError,
|
||||
SignatureNotFound,
|
||||
}
|
||||
|
||||
build_rpc_trait! {
|
||||
|
@ -157,6 +158,7 @@ impl RpcSol for RpcSolImpl {
|
|||
Ok(
|
||||
match meta.request_processor.get_signature_status(signature) {
|
||||
Ok(_) => RpcSignatureStatus::Confirmed,
|
||||
Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse,
|
||||
Err(BankError::ProgramRuntimeError(_)) => RpcSignatureStatus::ProgramRuntimeError,
|
||||
Err(BankError::SignatureNotFound) => RpcSignatureStatus::SignatureNotFound,
|
||||
Err(err) => {
|
||||
|
|
Loading…
Reference in New Issue