pub struct UpdateContext {
pub slot: Option<u64>,
pub signature: Option<String>,
pub timestamp: Option<i64>,
pub write_version: Option<u64>,
pub txn_index: Option<u64>,
pub skip_resolvers: bool,
pub metadata: HashMap<String, Value>,
}Expand description
Context metadata for blockchain updates (accounts and instructions) This structure is designed to be extended over time with additional metadata
Fields§
§slot: Option<u64>Blockchain slot number
signature: Option<String>Transaction signature
timestamp: Option<i64>Unix timestamp (seconds since epoch) If not provided, will default to current system time when accessed
write_version: Option<u64>Write version for account updates (monotonically increasing per account within a slot) Used for staleness detection to reject out-of-order updates
txn_index: Option<u64>Transaction index for instruction updates (orders transactions within a slot) Used for staleness detection to reject out-of-order updates
skip_resolvers: boolWhen true, QueueResolver opcodes are skipped during handler execution. Set for reprocessed cached data from PDA mapping changes to prevent stale data from triggering resolvers or locking in wrong values via SetOnce.
metadata: HashMap<String, Value>Additional custom metadata that can be added without breaking changes
Implementations§
Source§impl UpdateContext
impl UpdateContext
Sourcepub fn new(slot: u64, signature: String) -> Self
pub fn new(slot: u64, signature: String) -> Self
Create a new UpdateContext with slot and signature
Sourcepub fn with_timestamp(slot: u64, signature: String, timestamp: i64) -> Self
pub fn with_timestamp(slot: u64, signature: String, timestamp: i64) -> Self
Create a new UpdateContext with slot, signature, and timestamp
Sourcepub fn new_account(slot: u64, signature: String, write_version: u64) -> Self
pub fn new_account(slot: u64, signature: String, write_version: u64) -> Self
Create context for account updates with write_version for staleness detection
Sourcepub fn new_instruction(slot: u64, signature: String, txn_index: u64) -> Self
pub fn new_instruction(slot: u64, signature: String, txn_index: u64) -> Self
Create context for instruction updates with txn_index for staleness detection
Sourcepub fn new_reprocessed(slot: u64, write_version: u64) -> Self
pub fn new_reprocessed(slot: u64, write_version: u64) -> Self
Create context for reprocessed cached account data from PDA mapping changes.
Uses empty signature to prevent when guards from matching stale instructions,
and sets skip_resolvers to prevent stale scheduling/SetOnce lock-in.
Sourcepub fn timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Get the timestamp, falling back to current system time if not set
Sourcepub fn is_account_update(&self) -> bool
pub fn is_account_update(&self) -> bool
Add custom metadata Returns true if this is an account update context (has write_version, no txn_index)
Sourcepub fn is_instruction_update(&self) -> bool
pub fn is_instruction_update(&self) -> bool
Returns true if this is an instruction update context (has txn_index, no write_version)
pub fn with_metadata(self, key: String, value: Value) -> Self
Sourcepub fn get_metadata(&self, key: &str) -> Option<&Value>
pub fn get_metadata(&self, key: &str) -> Option<&Value>
Get metadata value
Trait Implementations§
Source§impl Clone for UpdateContext
impl Clone for UpdateContext
Source§fn clone(&self) -> UpdateContext
fn clone(&self) -> UpdateContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more