Skip to main content

parse_log_optimized

Function parse_log_optimized 

Source
pub fn parse_log_optimized(
    log: &str,
    signature: Signature,
    slot: u64,
    tx_index: u64,
    block_time_us: Option<i64>,
    grpc_recv_us: i64,
    event_type_filter: Option<&EventTypeFilter>,
    is_created_buy: bool,
    recent_blockhash: Option<&[u8]>,
) -> Option<DexEvent>
Expand description

Optimized unified log parser with discriminator predecode, decode-on-match strategy

Performance Strategy:

  1. Decode only the first 8 event bytes to read the discriminator
  2. Check filter BEFORE decoding the full event payload
  3. Decode matching payloads once to a stack buffer; rare large events use heap
  4. Parse only the specific event type requested

Key optimization: narrow filters skip full base64 decoding entirely. Old: decode full payload -> check filter -> parse New: decode discriminator prefix -> check filter -> decode matching payload once recent_blockhash: pass as Option<&[u8]>; only cloned when an event is built (low latency).