Update counters only if transactions are sent by literpc

This commit is contained in:
godmodegalactus 2023-10-04 17:29:12 +02:00
parent 3210d6a1e1
commit 53fc6b482a
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
3 changed files with 17 additions and 28 deletions

View File

@ -1,22 +1,14 @@
use std::sync::Arc;
use dashmap::DashMap;
use solana_transaction_status::TransactionStatus;
use std::sync::Arc;
/// Transaction Properties
#[derive(Debug, Clone)]
pub struct TxProps {
pub status: Option<TransactionStatus>,
pub last_valid_blockheight: u64,
}
impl TxProps {
pub fn new(last_valid_blockheight: u64) -> Self {
Self {
status: Default::default(),
last_valid_blockheight,
}
}
pub sent_by_lite_rpc: bool,
}
#[derive(Clone, Debug)]
@ -28,22 +20,24 @@ pub struct TxStore {
impl TxStore {
pub fn update_status(
&self,
signature: &str,
status: TransactionStatus,
signature: &String,
transaction_status: TransactionStatus,
last_valid_blockheight: u64,
) -> bool {
if let Some(mut meta) = self.store.get_mut(signature) {
meta.status = Some(status);
meta.status = Some(transaction_status);
meta.value().sent_by_lite_rpc
} else {
self.store.insert(
signature.to_string(),
signature.clone(),
TxProps {
status: Some(status),
status: Some(transaction_status),
last_valid_blockheight,
sent_by_lite_rpc: false,
},
);
false
}
true
}
pub fn insert(&self, signature: String, props: TxProps) -> Option<TxProps> {

View File

@ -282,6 +282,7 @@ impl LiteRpcServer for LiteBridge {
TxProps {
status: None,
last_valid_blockheight: block_height,
sent_by_lite_rpc: true,
},
);
}

View File

@ -72,27 +72,21 @@ impl TxSender {
let tpu_client = self.tpu_service.clone();
let txs_sent = self.data_cache.txs.clone();
let forwarded_slot = self.data_cache.slot_cache.get_current_slot();
let forwarded_local_time = Utc::now();
for transaction_info in &transaction_infos {
let mut quic_responses = vec![];
for transaction_info in transaction_infos.iter() {
trace!("sending transaction {}", transaction_info.signature);
txs_sent.insert(
transaction_info.signature.clone(),
TxProps {
status: None,
last_valid_blockheight: transaction_info.last_valid_block_height,
sent_by_lite_rpc: true,
},
);
}
let forwarded_slot = self.data_cache.slot_cache.get_current_slot();
let forwarded_local_time = Utc::now();
let mut quic_responses = vec![];
for transaction_info in transaction_infos.iter() {
txs_sent.insert(
transaction_info.signature.clone(),
TxProps::new(transaction_info.last_valid_block_height),
);
let quic_response = match tpu_client.send_transaction(transaction_info) {
Ok(_) => {
TXS_SENT.inc_by(1);