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
|
* `Confirmed` - Transaction was successful
|
||||||
* `SignatureNotFound` - Unknown transaction
|
* `SignatureNotFound` - Unknown transaction
|
||||||
* `ProgramRuntimeError` - An error occurred in the program that processed this 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`
|
* `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:
|
##### Example:
|
||||||
|
|
|
@ -302,6 +302,7 @@ impl Bank {
|
||||||
if res[i] != Err(BankError::SignatureNotFound) {
|
if res[i] != Err(BankError::SignatureNotFound) {
|
||||||
let status = match res[i] {
|
let status = match res[i] {
|
||||||
Ok(_) => RpcSignatureStatus::Confirmed,
|
Ok(_) => RpcSignatureStatus::Confirmed,
|
||||||
|
Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse,
|
||||||
Err(BankError::ProgramRuntimeError(_)) => {
|
Err(BankError::ProgramRuntimeError(_)) => {
|
||||||
RpcSignatureStatus::ProgramRuntimeError
|
RpcSignatureStatus::ProgramRuntimeError
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,11 @@ impl Metadata for Meta {}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Serialize, Debug)]
|
#[derive(Copy, Clone, PartialEq, Serialize, Debug)]
|
||||||
pub enum RpcSignatureStatus {
|
pub enum RpcSignatureStatus {
|
||||||
|
AccountInUse,
|
||||||
Confirmed,
|
Confirmed,
|
||||||
SignatureNotFound,
|
|
||||||
ProgramRuntimeError,
|
|
||||||
GenericFailure,
|
GenericFailure,
|
||||||
|
ProgramRuntimeError,
|
||||||
|
SignatureNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
build_rpc_trait! {
|
build_rpc_trait! {
|
||||||
|
@ -157,6 +158,7 @@ impl RpcSol for RpcSolImpl {
|
||||||
Ok(
|
Ok(
|
||||||
match meta.request_processor.get_signature_status(signature) {
|
match meta.request_processor.get_signature_status(signature) {
|
||||||
Ok(_) => RpcSignatureStatus::Confirmed,
|
Ok(_) => RpcSignatureStatus::Confirmed,
|
||||||
|
Err(BankError::AccountInUse) => RpcSignatureStatus::AccountInUse,
|
||||||
Err(BankError::ProgramRuntimeError(_)) => RpcSignatureStatus::ProgramRuntimeError,
|
Err(BankError::ProgramRuntimeError(_)) => RpcSignatureStatus::ProgramRuntimeError,
|
||||||
Err(BankError::SignatureNotFound) => RpcSignatureStatus::SignatureNotFound,
|
Err(BankError::SignatureNotFound) => RpcSignatureStatus::SignatureNotFound,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Reference in New Issue