Surface AccountInUse to JSON RPC users so they know to retry the transaction

This commit is contained in:
Michael Vines
2018-10-23 13:11:29 -07:00
parent 4f34822900
commit 7977b97227
3 changed files with 6 additions and 2 deletions

View File

@@ -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
}

View File

@@ -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) => {