aztec-nr - noir_aztec::protocol::delayed_public_mutable::scheduled_delay_change

Struct ScheduledDelayChange

pub struct ScheduledDelayChange<let INITIAL_DELAY: u64>
{ /* private fields */ }

Implementations

impl<let INITIAL_DELAY: u64> ScheduledDelayChange<INITIAL_DELAY>

pub fn new(pre: Option<u64>, post: Option<u64>, timestamp_of_change: u64) -> Self pub fn get_current(self, current_timestamp: u64) -> u64

Returns the current value of the delay stored in the data structure. WARNING: This function only returns a meaningful value when called in public with the current timestamp - for historical private reads use get_effective_minimum_delay_at instead.

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

Returns the scheduled change, i.e. the post-change delay and the timestamp at which it will become the current delay. 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 schedule_change(&mut self, new: u64, current_timestamp: u64)

Schedules a change to the delay, given the current_timestamp and the current delay. This function is only meaningful when called in public with the current timestamp. The timestamp at which the new delay will become effective is determined automatically:

  • when increasing the delay, the change is effective immediately
  • when reducing the delay, the change will take effect after a delay equal to the difference between old and new delay. For example, if reducing from 3 days to 1 day, the reduction will be scheduled to happen after 2 days.
pub fn get_effective_minimum_delay_at(self, historical_timestamp: u64) -> u64

Returns the minimum delay before a value might mutate due to a scheduled change, from the perspective of some historical timestamp. It only returns a meaningful value when called in private with historical timestamps. The output of this function can be passed into ScheduledValueChange.get_time_horizon to properly constrain the include_by_timestamp when reading delayed mutable state. This value typically equals the current delay at the timestamp following the historical one (the earliest one in which a value change could be scheduled), but it also considers scenarios in which a delay reduction is scheduled to happen in the near future, resulting in a way to schedule a change with an overall delay lower than the current one.

Alternative explanation: returns the maximum amount of time (from the historical timestamp) that a state read (as at the historical timestamp) will remain valid. A read might end up being valid for less time in the case where a svc.timestamp_of_change has already been set and if it's sooner than the output of this function. In that case, the scheduled_value_change.nr's get_time_horizon function will realize this.

Trait implementations

impl<let INITIAL_DELAY: u64> Empty for ScheduledDelayChange<INITIAL_DELAY>

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

impl<let INITIAL_DELAY: u64> Eq for ScheduledDelayChange<INITIAL_DELAY>

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