perf: P0/P1/P2 low-latency and maintainability improvements
P0: - blockhash/nonce: get_transaction_blockhash returns Result; buy/sell entry validation - Bonk sell: remove RPC get_token_balance from build path; require caller to pass input_amount - Hot path: drop redundant dex_type/protocol_params clone; tip via sol_f64_to_lamports (no String) - compute_budget cache uses Arc; extend_compute_budget_instructions avoids SmallVec clone P1: - middleware protocol_name takes &str; executor destructures result once to avoid signatures/submit_timings clone - Error messages include dex context; params use Copy for Pubkey; pumpswap utils clone only Pool for pools[0] P2: - transaction_pool capacity constants; TIP_ACCOUNT_CACHE marked allow(dead_code) - Fix error copy in raydium_amm_v4 / meteora_damm_v2 to correct protocol names Made-with: Cursor
This commit is contained in:
@@ -14,7 +14,7 @@ impl InstructionMiddleware for LoggingMiddleware {
|
||||
fn process_protocol_instructions(
|
||||
&self,
|
||||
protocol_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>> {
|
||||
println!("-------------------[{}]-------------------", self.name());
|
||||
@@ -32,7 +32,7 @@ impl InstructionMiddleware for LoggingMiddleware {
|
||||
fn process_full_instructions(
|
||||
&self,
|
||||
full_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>> {
|
||||
println!("-------------------[{}]-------------------", self.name());
|
||||
|
||||
@@ -20,7 +20,7 @@ pub trait InstructionMiddleware: Send + Sync {
|
||||
fn process_protocol_instructions(
|
||||
&self,
|
||||
protocol_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>>;
|
||||
|
||||
@@ -36,7 +36,7 @@ pub trait InstructionMiddleware: Send + Sync {
|
||||
fn process_full_instructions(
|
||||
&self,
|
||||
full_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>>;
|
||||
|
||||
@@ -72,13 +72,13 @@ impl MiddlewareManager {
|
||||
pub fn apply_middlewares_process_full_instructions(
|
||||
&self,
|
||||
mut full_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>> {
|
||||
for middleware in &self.middlewares {
|
||||
full_instructions = middleware.process_full_instructions(
|
||||
full_instructions,
|
||||
protocol_name.clone(),
|
||||
protocol_name,
|
||||
is_buy,
|
||||
)?;
|
||||
if full_instructions.is_empty() {
|
||||
@@ -92,13 +92,13 @@ impl MiddlewareManager {
|
||||
pub fn apply_middlewares_process_protocol_instructions(
|
||||
&self,
|
||||
mut protocol_instructions: Vec<Instruction>,
|
||||
protocol_name: String,
|
||||
protocol_name: &str,
|
||||
is_buy: bool,
|
||||
) -> Result<Vec<Instruction>> {
|
||||
for middleware in &self.middlewares {
|
||||
protocol_instructions = middleware.process_protocol_instructions(
|
||||
protocol_instructions,
|
||||
protocol_name.clone(),
|
||||
protocol_name,
|
||||
is_buy,
|
||||
)?;
|
||||
if protocol_instructions.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user