miden_client/transaction/observer.rs
1//! Side-effect-only observer trait for committed transactions.
2//!
3//! Analogous to [`crate::sync::NoteObserver`] but scoped to `Client::apply_transaction`. Lets
4//! feature subsystems (e.g. PSWAP chain tracking) hook into the post-apply pipeline without
5//! `apply_transaction` knowing about them by name.
6
7use alloc::boxed::Box;
8
9use async_trait::async_trait;
10
11use crate::ClientError;
12use crate::transaction::TransactionResult;
13
14/// Side-effect-only observer of committed transactions. `apply()` runs once per `apply_transaction`
15/// AFTER the standard updates land. Errors are logged (tagged with [`Self::name`]) and never abort
16/// sync.
17#[async_trait(?Send)]
18pub trait TransactionObserver: Send + Sync {
19 /// Short identifier for `tracing::warn!` events on `apply()` errors.
20 fn name(&self) -> &'static str;
21
22 /// Return `Ok(())` for "not interested"; reserve `Err(_)` for genuine internal failures.
23 async fn apply(&self, tx_result: &TransactionResult) -> Result<(), ClientError>;
24}