feat: optimize RPC polling and remove data size limit

Significantly reduce RPC pressure and fix MaxLoadedAccountsDataSizeExceeded errors.

Major improvements:
1. Add wait_confirmation parameter to all swqos clients
   - Skip polling entirely when wait_transaction_confirmed=false (100% RPC reduction)
   - Optimize getTransaction calls to only execute on errors or after 10s (50% reduction)
   - Update all 13 swqos client implementations

2. Remove LoadedAccountsDataSize instruction and data_size_limit parameter
   - Eliminate MaxLoadedAccountsDataSizeExceeded errors reported by users
   - Clean up gas_fee_strategy, params, and transaction builder
   - Simplify compute budget instruction generation

Results:
- Single channel: 30 RPC calls → 0-15 calls (50-100% reduction)
- Multi-channel (3x): 90 RPC calls → 0-45 calls (50-100% reduction)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Wood
2025-12-28 13:15:16 +08:00
co-authored by Claude Sonnet 4.5
parent 710de8a92a
commit 321f4c4a25
22 changed files with 183 additions and 179 deletions
+12 -10
View File
@@ -29,12 +29,12 @@ pub struct AstralaneClient {
#[async_trait::async_trait]
impl SwqosClientTrait for AstralaneClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -146,7 +146,7 @@ impl AstralaneClient {
Ok(())
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -183,7 +183,7 @@ impl AstralaneClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -191,15 +191,17 @@ impl AstralaneClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [astralane] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [astralane] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -29,12 +29,12 @@ pub struct BlockRazorClient {
#[async_trait::async_trait]
impl SwqosClientTrait for BlockRazorClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -153,7 +153,7 @@ impl BlockRazorClient {
Ok(())
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -185,7 +185,7 @@ impl BlockRazorClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -193,15 +193,17 @@ impl BlockRazorClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [blockrazor] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [blockrazor] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+11 -9
View File
@@ -24,12 +24,12 @@ pub struct BloxrouteClient {
#[async_trait::async_trait]
impl SwqosClientTrait for BloxrouteClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -61,7 +61,7 @@ impl BloxrouteClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -95,7 +95,7 @@ impl BloxrouteClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -103,13 +103,15 @@ impl BloxrouteClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [bloxroute] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [bloxroute] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let body = serde_json::json!({
+29 -1
View File
@@ -56,16 +56,25 @@ impl FormatBase64VersionedTransaction for VersionedTransaction {
pub async fn poll_transaction_confirmation(
rpc: &SolanaRpcClient,
txt_sig: Signature,
wait_confirmation: bool,
) -> Result<Signature> {
// 如果不需要等待确认,立即返回签名
if !wait_confirmation {
return Ok(txt_sig);
}
let timeout: Duration = Duration::from_secs(15); // 🔧 增加到15秒,避免网络拥堵时超时
let interval: Duration = Duration::from_millis(1000);
let start: Instant = Instant::now();
let mut poll_count = 0u32;
loop {
if start.elapsed() >= timeout {
return Err(anyhow::anyhow!("Transaction {}'s confirmation timed out", txt_sig));
}
poll_count += 1;
let status = rpc.get_signature_statuses(&[txt_sig]).await?;
match status.value[0].clone() {
Some(status) => {
@@ -77,8 +86,27 @@ pub async fn poll_transaction_confirmation(
{
return Ok(txt_sig);
}
// 如果 getSignatureStatuses 返回了错误,立即获取详细信息
if status.err.is_some() {
// 直接跳转到获取交易详情
}
}
None => {}
None => {
// 交易还未上链,继续等待,不调用 getTransaction
sleep(interval).await;
continue;
}
}
// 优化:只在以下情况调用 getTransaction
// 1. getSignatureStatuses 返回了错误
// 2. 或者已经轮询了较长时间(超过10次,即10秒)
let should_get_transaction = status.value[0].as_ref().map(|s| s.err.is_some()).unwrap_or(false)
|| poll_count >= 10;
if !should_get_transaction {
sleep(interval).await;
continue;
}
let tx_details = match rpc
+12 -10
View File
@@ -25,12 +25,12 @@ pub struct FlashBlockClient {
#[async_trait::async_trait]
impl SwqosClientTrait for FlashBlockClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -62,7 +62,7 @@ impl FlashBlockClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -97,7 +97,7 @@ impl FlashBlockClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -105,15 +105,17 @@ impl FlashBlockClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [FlashBlock] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [FlashBlock] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -25,12 +25,12 @@ pub struct JitoClient {
#[async_trait::async_trait]
impl SwqosClientTrait for JitoClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction_impl(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions_impl(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -65,13 +65,13 @@ impl JitoClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction_impl(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
let request_body = serde_json::to_string(&json!({
"id": 1,
"jsonrpc": "2.0",
"jsonrpc": "2.0",
"method": "sendTransaction",
"params": [
content,
@@ -111,7 +111,7 @@ impl JitoClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -119,13 +119,15 @@ impl JitoClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [jito] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [jito] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions_impl(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, _wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let txs_base64 = transactions.iter().map(|tx| tx.to_base64_string()).collect::<Vec<String>>();
let body = serde_json::json!({
+12 -10
View File
@@ -24,12 +24,12 @@ pub struct LightspeedClient {
#[async_trait::async_trait]
impl SwqosClientTrait for LightspeedClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -63,7 +63,7 @@ impl LightspeedClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -102,7 +102,7 @@ impl LightspeedClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -110,15 +110,17 @@ impl LightspeedClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [lightspeed] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [lightspeed] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+2 -2
View File
@@ -126,8 +126,8 @@ pub type SwqosClient = dyn SwqosClientTrait + Send + Sync + 'static;
#[async_trait::async_trait]
pub trait SwqosClientTrait {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()>;
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()>;
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()>;
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()>;
fn get_tip_account(&self) -> Result<String>;
fn get_swqos_type(&self) -> SwqosType;
}
+12 -10
View File
@@ -24,12 +24,12 @@ pub struct NextBlockClient {
#[async_trait::async_trait]
impl SwqosClientTrait for NextBlockClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -67,7 +67,7 @@ impl NextBlockClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -98,7 +98,7 @@ impl NextBlockClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -106,15 +106,17 @@ impl NextBlockClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [nextblock] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [nextblock] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -29,12 +29,12 @@ pub struct Node1Client {
#[async_trait::async_trait]
impl SwqosClientTrait for Node1Client {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -140,7 +140,7 @@ impl Node1Client {
Ok(())
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -176,7 +176,7 @@ impl Node1Client {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -184,15 +184,17 @@ impl Node1Client {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [node1] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [node1] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+8 -4
View File
@@ -23,6 +23,7 @@ impl SwqosClientTrait for SolRpcClient {
&self,
trade_type: TradeType,
transaction: &VersionedTransaction,
wait_confirmation: bool,
) -> Result<()> {
let signature = self
.rpc_client
@@ -39,7 +40,7 @@ impl SwqosClientTrait for SolRpcClient {
.await?;
let start_time = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -47,8 +48,10 @@ impl SwqosClientTrait for SolRpcClient {
return Err(e);
}
}
println!(" signature: {:?}", signature);
println!(" [rpc] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [rpc] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
@@ -57,9 +60,10 @@ impl SwqosClientTrait for SolRpcClient {
&self,
trade_type: TradeType,
transactions: &Vec<VersionedTransaction>,
wait_confirmation: bool,
) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+8 -4
View File
@@ -102,6 +102,7 @@ impl SwqosClientTrait for SoyasClient {
&self,
trade_type: TradeType,
transaction: &VersionedTransaction,
wait_confirmation: bool,
) -> Result<()> {
let signature = transaction.get_signature();
let serialized_tx = bincode::serialize(transaction)?;
@@ -115,7 +116,7 @@ impl SwqosClientTrait for SoyasClient {
Self::try_send_bytes(&connection, &serialized_tx).await?;
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, *signature).await {
match poll_transaction_confirmation(&self.rpc_client, *signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -123,8 +124,10 @@ impl SwqosClientTrait for SoyasClient {
return Err(e);
}
}
println!(" signature: {:?}", signature);
println!(" [soyas] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [soyas] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
@@ -132,9 +135,10 @@ impl SwqosClientTrait for SoyasClient {
&self,
trade_type: TradeType,
transactions: &Vec<VersionedTransaction>,
wait_confirmation: bool,
) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -27,12 +27,12 @@ pub struct StelliumClient {
#[async_trait::async_trait]
impl SwqosClientTrait for StelliumClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -114,7 +114,7 @@ impl StelliumClient {
});
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -155,7 +155,7 @@ impl StelliumClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -163,15 +163,17 @@ impl StelliumClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [Stellium] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [Stellium] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -44,12 +44,12 @@ pub struct TemporalClient {
#[async_trait::async_trait]
impl SwqosClientTrait for TemporalClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -166,7 +166,7 @@ impl TemporalClient {
Ok(())
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -205,7 +205,7 @@ impl TemporalClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -213,15 +213,17 @@ impl TemporalClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [nozomi] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [nozomi] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}
+12 -10
View File
@@ -25,12 +25,12 @@ pub struct ZeroSlotClient {
#[async_trait::async_trait]
impl SwqosClientTrait for ZeroSlotClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
self.send_transaction(trade_type, transaction).await
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
self.send_transaction(trade_type, transaction, wait_confirmation).await
}
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
self.send_transactions(trade_type, transactions).await
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
self.send_transactions(trade_type, transactions, wait_confirmation).await
}
fn get_tip_account(&self) -> Result<String> {
@@ -62,7 +62,7 @@ impl ZeroSlotClient {
Self { rpc_client: Arc::new(rpc_client), endpoint, auth_token, http_client }
}
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<()> {
pub async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
let start_time = Instant::now();
let (content, signature) = serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64).await?;
@@ -102,7 +102,7 @@ impl ZeroSlotClient {
}
let start_time: Instant = Instant::now();
match poll_transaction_confirmation(&self.rpc_client, signature).await {
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
Ok(_) => (),
Err(e) => {
println!(" signature: {:?}", signature);
@@ -110,15 +110,17 @@ impl ZeroSlotClient {
return Err(e);
},
}
println!(" signature: {:?}", signature);
println!(" [0slot] {} confirmed: {:?}", trade_type, start_time.elapsed());
if wait_confirmation {
println!(" signature: {:?}", signature);
println!(" [0slot] {} confirmed: {:?}", trade_type, start_time.elapsed());
}
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<()> {
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, wait_confirmation: bool) -> Result<()> {
for transaction in transactions {
self.send_transaction(trade_type, transaction).await?;
self.send_transaction(trade_type, transaction, wait_confirmation).await?;
}
Ok(())
}