feat: add transaction confirmation wait option and parallel execution optimization

- Add wait_transaction_confirmed parameter to all trading methods
- Support async transaction sending without waiting for confirmation for better performance
- Optimize parallel execution logic to return on first successful transaction
- Fix direct priority_fee modification issue
- Improve error handling and resource management
- Update all example code to support new parameter
This commit is contained in:
ysq
2025-08-21 21:32:53 +08:00
parent 9fa0f6ad6b
commit 5a9238a741
5 changed files with 92 additions and 25 deletions
+6
View File
@@ -36,6 +36,7 @@ pub struct BuyParams {
pub lookup_table_key: Option<Pubkey>,
pub recent_blockhash: Hash,
pub data_size_limit: u32,
pub wait_transaction_confirmed: bool,
pub protocol_params: Box<dyn ProtocolParams>,
}
@@ -54,6 +55,7 @@ pub struct BuyWithTipParams {
pub lookup_table_key: Option<Pubkey>,
pub recent_blockhash: Hash,
pub data_size_limit: u32,
pub wait_transaction_confirmed: bool,
pub protocol_params: Box<dyn ProtocolParams>,
}
@@ -70,6 +72,7 @@ pub struct SellParams {
pub priority_fee: PriorityFee,
pub lookup_table_key: Option<Pubkey>,
pub recent_blockhash: Hash,
pub wait_transaction_confirmed: bool,
pub protocol_params: Box<dyn ProtocolParams>,
}
@@ -87,6 +90,7 @@ pub struct SellWithTipParams {
pub priority_fee: PriorityFee,
pub lookup_table_key: Option<Pubkey>,
pub recent_blockhash: Hash,
pub wait_transaction_confirmed: bool,
pub protocol_params: Box<dyn ProtocolParams>,
}
@@ -456,6 +460,7 @@ impl BuyParams {
lookup_table_key: self.lookup_table_key,
recent_blockhash: self.recent_blockhash,
data_size_limit: self.data_size_limit,
wait_transaction_confirmed: self.wait_transaction_confirmed,
protocol_params: self.protocol_params,
}
}
@@ -476,6 +481,7 @@ impl SellParams {
priority_fee: self.priority_fee,
lookup_table_key: self.lookup_table_key,
recent_blockhash: self.recent_blockhash,
wait_transaction_confirmed: self.wait_transaction_confirmed,
protocol_params: self.protocol_params,
}
}