pub async fn subscribe_program_diffs<F, Fut>(
rpc_endpoint: &str,
program_id: &str,
on_notification: F,
) -> Result<AccountDiffSubscriptionHandle, SubscriptionError>Expand description
Subscribe to the changes of every account a program owns.
rpc_endpoint is the session’s RPC endpoint. The callback receives one
AccountDiffNotification per changed account, with account set; callbacks run one at a
time, in order. Never reconnects: a dropped WebSocket ends the stream with
SubscriptionRuntimeError::Closed.
§Errors
SubscriptionError if the subscription cannot be started.
§Example
use simulator_client::{ManagedBacktestSession, subscribe_program_diffs};
let handle = subscribe_program_diffs(
&session.session_info().rpc_endpoint,
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
|notification| async move {
let account = notification.account.unwrap_or_default();
println!("account={account} slot={}", notification.context.slot);
},
)
.await?;
handle.shutdown().await?;