style: run rustfmt

This commit is contained in:
hookenful
2026-03-14 18:16:55 +02:00
parent 0ec826fcbd
commit 2abcf3839e
76 changed files with 1763 additions and 1352 deletions
+46 -15
View File
@@ -6,17 +6,16 @@ use rand::seq::IndexedRandom;
use reqwest::Client;
use std::{sync::Arc, time::Instant};
use std::time::Duration;
use solana_transaction_status::UiTransactionEncoding;
use std::time::Duration;
use crate::swqos::SwqosClientTrait;
use crate::swqos::{SwqosType, TradeType};
use anyhow::Result;
use solana_sdk::transaction::VersionedTransaction;
use crate::swqos::{SwqosType, TradeType};
use crate::swqos::SwqosClientTrait;
use crate::{common::SolanaRpcClient, constants::swqos::BLOX_TIP_ACCOUNTS};
#[derive(Clone)]
pub struct BloxrouteClient {
pub endpoint: String,
@@ -27,16 +26,29 @@ pub struct BloxrouteClient {
#[async_trait::async_trait]
impl SwqosClientTrait for BloxrouteClient {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction, wait_confirmation: bool) -> Result<()> {
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>, wait_confirmation: bool) -> Result<()> {
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> {
let tip_account = *BLOX_TIP_ACCOUNTS.choose(&mut rand::rng()).or_else(|| BLOX_TIP_ACCOUNTS.first()).unwrap();
let tip_account = *BLOX_TIP_ACCOUNTS
.choose(&mut rand::rng())
.or_else(|| BLOX_TIP_ACCOUNTS.first())
.unwrap();
Ok(tip_account.to_string())
}
@@ -56,9 +68,15 @@ 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, wait_confirmation: bool) -> 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)?;
let (content, signature) =
serialize_transaction_and_encode(transaction, UiTransactionEncoding::Base64)?;
// Single format! for body to avoid json! + to_string() double allocation
let body = format!(
@@ -67,7 +85,9 @@ impl BloxrouteClient {
);
let endpoint = format!("{}/api/v2/submit", self.endpoint);
let response_text = self.http_client.post(&endpoint)
let response_text = self
.http_client
.post(&endpoint)
.body(body)
.header("Content-Type", "application/json")
.header("Authorization", self.auth_token.as_str())
@@ -95,10 +115,14 @@ impl BloxrouteClient {
Err(e) => {
if crate::common::sdk_log::sdk_log_enabled() {
println!(" signature: {:?}", signature);
println!(" [bloxroute] {} confirmation failed: {:?}", trade_type, start_time.elapsed());
println!(
" [bloxroute] {} confirmation failed: {:?}",
trade_type,
start_time.elapsed()
);
}
return Err(e);
},
}
}
if wait_confirmation && crate::common::sdk_log::sdk_log_enabled() {
println!(" signature: {:?}", signature);
@@ -108,7 +132,12 @@ impl BloxrouteClient {
Ok(())
}
pub async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>, _wait_confirmation: bool) -> Result<()> {
pub async fn send_transactions(
&self,
trade_type: TradeType,
transactions: &Vec<VersionedTransaction>,
_wait_confirmation: bool,
) -> Result<()> {
let start_time = Instant::now();
let contents = serialization::serialize_transactions_batch_sync(
@@ -123,7 +152,9 @@ impl BloxrouteClient {
let body = format!(r#"{{"entries":[{}]}}"#, entries);
let endpoint = format!("{}/api/v2/submit-batch", self.endpoint);
let response_text = self.http_client.post(&endpoint)
let response_text = self
.http_client
.post(&endpoint)
.body(body)
.header("Content-Type", "application/json")
.header("Authorization", self.auth_token.as_str())
@@ -144,4 +175,4 @@ impl BloxrouteClient {
Ok(())
}
}
}