aztec-nr - noir_aztec::protocol::delayed_public_mutable::scheduled_value_change

Struct ScheduledValueChange

pub struct ScheduledValueChange<T>
{ /* private fields */ }

Implementations

impl<T> ScheduledValueChange<T>

pub fn new(pre: T, post: T, timestamp_of_change: u64) -> Self pub fn get_current_at(self, timestamp: u64) -> T

Returns the value stored in the data structure at a given timestamp. This function can be called both in public (where timestamp is simply the current timestamp, i.e. the timestamp at which the current transaction will be included) and in private (where timestamp is the anchor block's timestamp). Reading in private is only safe if the transaction's include_by_timestamp property is set to a value lower or equal to the time horizon (see get_time_horizon()).

pub fn get_scheduled(self) -> (T, u64)

Returns the scheduled change, i.e. the post-change value and the timestamp at which it will become the current value. Note that this timestamp may be in the past if the change has already taken place. Additionally, further changes might be later scheduled, potentially canceling the one returned by this function.

pub fn get_previous(self) -> (T, u64) pub fn get_time_horizon(self, anchor_timestamp: u64, minimum_delay: u64) -> u64

Returns the largest timestamp at which the value returned by get_current_at is known to remain the current value. This value is only meaningful in private where the proof is constructed against an anchor block, since due to its asynchronous nature private execution cannot know about any later scheduled changes. The caller of this function must know how quickly the value can change due to a scheduled change in the form of minimum_delay. If the delay itself is immutable, then this is just its duration. If the delay is mutable however, then this value is the 'effective minimum delay' (obtained by calling ScheduledDelayChange.get_effective_minimum_delay_at), which equals the minimum time in seconds that needs to elapse from the next block's timestamp until the value changes, regardless of further delay changes. The value returned by get_current_at in private when called with a anchor block's timestamp is only safe to use if the transaction's include_by_timestamp property is set to a value lower or equal to the time horizon computed using the same anchor timestamp.

pub fn schedule_change( &mut self, new_value: T, current_timestamp: u64, minimum_delay: u64, timestamp_of_change: u64, )

Mutates the value by scheduling a change at the current timestamp. This function is only meaningful when called in public with the current timestamp.

Trait implementations

impl<T> Empty for ScheduledValueChange<T>
where T: Empty

pub fn empty() -> Self pub fn is_empty(self) -> bool pub fn assert_empty<let S: u32>(self, msg: str<S>)

impl<T> Eq for ScheduledValueChange<T>
where T: Eq

pub fn eq(self, other: Self) -> bool