- Enable quinn feature runtime-tokio so QUIC clients (Speedlanding/Soyas) initialize instead of failing with "no async runtime found". - Align Speedlanding with the official client: use solana_tls_utils new_dummy_x509_certificate and SkipServerVerification; use fixed TLS SNI "speed-landing" (not the PoP hostname). - Raise per-SWQoS init timeout to 15s; always log init failures/timeouts; if every SWQoS client fails, fall back to Default RPC and print active channel labels. - Improve SWQoS submission visibility (Default RPC path and related logging); adjust Soyas TLS credential handling where applicable. Made-with: Cursor
88 lines
2.6 KiB
Rust
Executable File
88 lines
2.6 KiB
Rust
Executable File
use std::{sync::Arc, time::Instant};
|
|
|
|
use solana_client::rpc_config::RpcSendTransactionConfig;
|
|
use solana_commitment_config::CommitmentLevel;
|
|
use solana_sdk::transaction::VersionedTransaction;
|
|
use solana_transaction_status::UiTransactionEncoding;
|
|
|
|
use crate::swqos::SwqosClientTrait;
|
|
use crate::{
|
|
common::{sdk_log, SolanaRpcClient},
|
|
swqos::{common::poll_transaction_confirmation, SwqosType, TradeType},
|
|
};
|
|
use anyhow::Result;
|
|
|
|
#[derive(Clone)]
|
|
pub struct SolRpcClient {
|
|
pub rpc_client: Arc<SolanaRpcClient>,
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl SwqosClientTrait for SolRpcClient {
|
|
async fn send_transaction(
|
|
&self,
|
|
trade_type: TradeType,
|
|
transaction: &VersionedTransaction,
|
|
wait_confirmation: bool,
|
|
) -> Result<()> {
|
|
let submit_start = Instant::now();
|
|
let signature = self
|
|
.rpc_client
|
|
.send_transaction_with_config(
|
|
transaction,
|
|
RpcSendTransactionConfig {
|
|
skip_preflight: true,
|
|
preflight_commitment: Some(CommitmentLevel::Processed),
|
|
encoding: Some(UiTransactionEncoding::Base64),
|
|
max_retries: Some(3),
|
|
min_context_slot: Some(0),
|
|
},
|
|
)
|
|
.await?;
|
|
|
|
sdk_log::log_swqos_submitted("Default", trade_type, submit_start.elapsed());
|
|
|
|
let start_time = Instant::now();
|
|
match poll_transaction_confirmation(&self.rpc_client, signature, wait_confirmation).await {
|
|
Ok(_) => (),
|
|
Err(e) => {
|
|
println!(" signature: {:?}", signature);
|
|
println!(" [rpc] {} confirmation failed: {:?}", trade_type, start_time.elapsed());
|
|
return Err(e);
|
|
}
|
|
}
|
|
if wait_confirmation {
|
|
println!(" signature: {:?}", signature);
|
|
println!(" [rpc] {} confirmed: {:?}", trade_type, start_time.elapsed());
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
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, wait_confirmation).await?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn get_tip_account(&self) -> Result<String> {
|
|
Ok("".to_string())
|
|
}
|
|
|
|
fn get_swqos_type(&self) -> SwqosType {
|
|
SwqosType::Default
|
|
}
|
|
}
|
|
|
|
impl SolRpcClient {
|
|
pub fn new(rpc_client: Arc<SolanaRpcClient>) -> Self {
|
|
Self { rpc_client }
|
|
}
|
|
}
|