adding get signature statuses
This commit is contained in:
parent
e20a2e4257
commit
73f9f0bd3d
|
@ -169,11 +169,6 @@ impl LiteRpcSubsrciptionControl {
|
|||
Ok(notification_type) => {
|
||||
let rpc_notification = match notification_type {
|
||||
NotificationType::Signature(data) => {
|
||||
println!(
|
||||
"getting signature notification {} confirmation {}",
|
||||
data.signature,
|
||||
data.commitment.to_string()
|
||||
);
|
||||
let signature_params = SignatureSubscriptionParams {
|
||||
commitment: CommitmentConfig {
|
||||
commitment: data.commitment,
|
||||
|
|
64
src/rpc.rs
64
src/rpc.rs
|
@ -160,7 +160,6 @@ impl LightRpcRequestProcessor {
|
|||
notification_sender: &crossbeam_channel::Sender<NotificationType>,
|
||||
block_information: &BlockInformation,
|
||||
) {
|
||||
println!("processing blocks for {}", commitment);
|
||||
loop {
|
||||
let block_data = reciever.recv();
|
||||
|
||||
|
@ -196,10 +195,7 @@ impl LightRpcRequestProcessor {
|
|||
for signature in signatures {
|
||||
match signature_status.entry(signature.clone()) {
|
||||
dashmap::mapref::entry::Entry::Occupied(mut x) => {
|
||||
println!(
|
||||
"found signature {} for commitment {}",
|
||||
signature, commitment
|
||||
);
|
||||
|
||||
let signature_notification = SignatureNotification {
|
||||
signature: Signature::from_str(signature.as_str())
|
||||
.unwrap(),
|
||||
|
@ -272,7 +268,9 @@ pub struct RpcPerformanceCounterResults {
|
|||
pub mod lite_rpc {
|
||||
use std::str::FromStr;
|
||||
|
||||
use itertools::Itertools;
|
||||
use solana_sdk::{fee_calculator::FeeCalculator, pubkey::Pubkey};
|
||||
use solana_transaction_status::{TransactionStatus, TransactionConfirmationStatus};
|
||||
|
||||
use super::*;
|
||||
#[rpc]
|
||||
|
@ -323,6 +321,15 @@ pub mod lite_rpc {
|
|||
meta: Self::Metadata,
|
||||
config: Option<RpcContextConfig>,
|
||||
) -> Result<RpcResponse<RpcBlockhash>>;
|
||||
|
||||
#[rpc(meta, name = "getSignatureStatuses")]
|
||||
fn get_signature_statuses(
|
||||
&self,
|
||||
meta: Self::Metadata,
|
||||
signature_strs: Vec<String>,
|
||||
config: Option<RpcSignatureStatusConfig>,
|
||||
) -> Result<RpcResponse<Vec<Option<TransactionStatus>>>>;
|
||||
|
||||
}
|
||||
pub struct LightRpc;
|
||||
impl Lite for LightRpc {
|
||||
|
@ -349,7 +356,6 @@ pub mod lite_rpc {
|
|||
meta.context
|
||||
.signature_status
|
||||
.insert(transaction.signatures[0].to_string(), None);
|
||||
println!("added {} to map", transaction.signatures[0]);
|
||||
meta.tpu_client.send_wire_transaction(wire_transaction);
|
||||
meta.performance_counter.update_sent_transactions_counter();
|
||||
Ok(transaction.signatures[0].to_string())
|
||||
|
@ -456,7 +462,6 @@ pub mod lite_rpc {
|
|||
match k_value {
|
||||
Some(value) => match *value {
|
||||
Some(commitment_for_signature) => {
|
||||
println!("found in cache");
|
||||
Ok(RpcResponse {
|
||||
context: RpcResponseContext::new(slot),
|
||||
value: if commitment.eq(&CommitmentLevel::Finalized) {
|
||||
|
@ -491,6 +496,51 @@ pub mod lite_rpc {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_signature_statuses(
|
||||
&self,
|
||||
meta: Self::Metadata,
|
||||
signature_strs: Vec<String>,
|
||||
_config: Option<RpcSignatureStatusConfig>,
|
||||
) -> Result<RpcResponse<Vec<Option<TransactionStatus>>>> {
|
||||
let confirmed_slot = meta.context.confirmed_block_info.slot.load(Ordering::Relaxed);
|
||||
let status = signature_strs.iter().map(|x| {
|
||||
let singature_status = meta.context.signature_status.get(x);
|
||||
let k_value = singature_status;
|
||||
match k_value {
|
||||
Some(value) => match *value {
|
||||
Some(commitment_for_signature) => {
|
||||
let slot = meta.context
|
||||
.confirmed_block_info
|
||||
.slot
|
||||
.load(Ordering::Relaxed);
|
||||
meta.performance_counter
|
||||
.update_confirm_transaction_counter();
|
||||
|
||||
let status = match commitment_for_signature {
|
||||
CommitmentLevel::Finalized => TransactionConfirmationStatus::Finalized,
|
||||
_ => TransactionConfirmationStatus::Confirmed,
|
||||
};
|
||||
Some(TransactionStatus {
|
||||
slot,
|
||||
confirmations: Some(1),
|
||||
status: Ok(()),
|
||||
err: None,
|
||||
confirmation_status : Some(status)
|
||||
})
|
||||
}
|
||||
None => None,
|
||||
},
|
||||
None => None
|
||||
}
|
||||
}).collect_vec();
|
||||
Ok(
|
||||
RpcResponse {
|
||||
context : RpcResponseContext::new(confirmed_slot),
|
||||
value: status,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn request_airdrop(
|
||||
&self,
|
||||
meta: Self::Metadata,
|
||||
|
|
Loading…
Reference in New Issue