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 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
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 timestamp(&self) -> i64
pub fn timestamp(&self) -> i64
Get the timestamp, falling back to current system time if not set
Sourcepub fn with_metadata(self, key: String, value: Value) -> Self
pub fn with_metadata(self, key: String, value: Value) -> Self
Add custom metadata
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