diff --git a/core/src/rpc.rs b/core/src/rpc.rs index a196db7e0b..11237d391e 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -397,6 +397,24 @@ impl JsonRpcRequestProcessor { .unwrap_or(None)) } + pub fn get_signature_confirmation_status( + &self, + signature: Signature, + commitment: Option, + ) -> Option { + self.get_transaction_status(signature, &self.bank(commitment)) + .map( + |TransactionStatus { + status, + confirmations, + .. + }| RpcSignatureConfirmation { + confirmations: confirmations.unwrap_or(MAX_LOCKOUT_HISTORY + 1), + status, + }, + ) + } + pub fn get_signature_status( &self, signature: Signature, @@ -417,24 +435,7 @@ impl JsonRpcRequestProcessor { let bank = self.bank(commitment); for signature in signatures { - let status = bank - .get_signature_status_slot(&signature) - .map(|(slot, status)| { - let r_block_commitment_cache = self.block_commitment_cache.read().unwrap(); - - let confirmations = if r_block_commitment_cache.root() >= slot { - None - } else { - r_block_commitment_cache - .get_confirmation_count(slot) - .or(Some(0)) - }; - TransactionStatus { - slot, - status, - confirmations, - } - }); + let status = self.get_transaction_status(signature, &bank); statuses.push(status); } Ok(Response { @@ -442,6 +443,30 @@ impl JsonRpcRequestProcessor { value: statuses, }) } + + fn get_transaction_status( + &self, + signature: Signature, + bank: &Arc, + ) -> Option { + bank.get_signature_status_slot(&signature) + .map(|(slot, status)| { + let r_block_commitment_cache = self.block_commitment_cache.read().unwrap(); + + let confirmations = if r_block_commitment_cache.root() >= slot { + None + } else { + r_block_commitment_cache + .get_confirmation_count(slot) + .or(Some(0)) + }; + TransactionStatus { + slot, + status, + confirmations, + } + }) + } } fn get_tpu_addr(cluster_info: &Arc>) -> Result { @@ -564,6 +589,14 @@ pub trait RpcSol { #[rpc(meta, name = "getFeeRateGovernor")] fn get_fee_rate_governor(&self, meta: Self::Metadata) -> RpcResponse; + #[rpc(meta, name = "getSignatureConfirmation")] + fn get_signature_confirmation( + &self, + meta: Self::Metadata, + signature_str: String, + commitment: Option, + ) -> Result>; + #[rpc(meta, name = "getSignatureStatus")] fn get_signature_status( &self, @@ -903,6 +936,24 @@ impl RpcSol for RpcSolImpl { .get_fee_rate_governor() } + fn get_signature_confirmation( + &self, + meta: Self::Metadata, + signature_str: String, + commitment: Option, + ) -> Result> { + debug!( + "get_signature_confirmation rpc request received: {:?}", + signature_str + ); + let signature = verify_signature(&signature_str)?; + Ok(meta + .request_processor + .read() + .unwrap() + .get_signature_confirmation_status(signature, commitment)) + } + fn get_signature_status( &self, meta: Self::Metadata,