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:
- Decode only the first 8 event bytes to read the discriminator
- Check filter BEFORE decoding the full event payload
- Decode matching payloads once to a stack buffer; rare large events use heap
- 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).