pub struct DiscoveryBatchEvent {
pub slot: u64,
pub batch_index: u32,
pub matched: Vec<DiscoveryFilter>,
pub transactions: Vec<EncodedBinary>,
pub transaction_indices: Vec<u32>,
}Expand description
Payload emitted when the session has discovered an upcoming batch that
matches one or more registered DiscoveryFilters from session creation
(for example, a batch containing a transaction that invokes a program of
interest). The (slot, batch_index) pair can be fed directly to
BacktestRequest::ContinueTo to pause immediately before the batch
executes. After each Continue / ContinueTo, the session emits the
next DiscoveryBatchEvent ahead of the next matching batch, enabling a
reactive “pause on every discovery” driver loop.
use simulator_api::{BacktestRequest, BacktestResponse, ContinueToParams};
/// On a discovery, inspect the matching transactions and pause just before their batch.
fn on_response(
response: &BacktestResponse,
) -> Result<Option<BacktestRequest>, Box<dyn std::error::Error>> {
let BacktestResponse::DiscoveryBatch(event) = response else {
return Ok(None);
};
for (encoded, index) in event.transactions.iter().zip(&event.transaction_indices) {
// Raw wincode bytes; `simulator_client::decode_transaction(encoded)` parses them.
let bytes = encoded.decode()?;
println!("slot {} transaction {index}: {} bytes", event.slot, bytes.len());
}
Ok(Some(BacktestRequest::ContinueTo(ContinueToParams {
slot: event.slot,
batch_index: Some(event.batch_index),
})))
}Fields§
§slot: u64The slot the matching batch is in.
batch_index: u32Wire name batchIndex: the matching batch’s index within slot.
matched: Vec<DiscoveryFilter>Filters that matched this batch (always non-empty).
transactions: Vec<EncodedBinary>Encoded transactions in this batch that triggered the match. Decode each
with simulator_client::decode_transaction (base64 wincode of VersionedTransaction).
transaction_indices: Vec<u32>Each of transactions’ index in its slot’s block, the index Solana reports for it. Empty
from a session that predates it.