pub struct RetryableState<'a, D> {
pub timeout_queue: Queue,
pub arbos_version: u64,
/* private fields */
}Expand description
Manages the collection of retryable tickets.
Fields§
§timeout_queue: Queue§arbos_version: u64Implementations§
Source§impl<'a, D> RetryableState<'a, D>
impl<'a, D> RetryableState<'a, D>
pub fn open(sto: Storage<'a, D>, arbos_version: u64) -> Self
Sourcepub fn create_retryable<B: StorageBackend>(
&self,
backend: &mut B,
id: B256,
timeout: u64,
from: Address,
to: Option<Address>,
callvalue: U256,
beneficiary: Address,
calldata: &[u8],
) -> Result<Retryable<'a, D>, RetryableError>
pub fn create_retryable<B: StorageBackend>( &self, backend: &mut B, id: B256, timeout: u64, from: Address, to: Option<Address>, callvalue: U256, beneficiary: Address, calldata: &[u8], ) -> Result<Retryable<'a, D>, RetryableError>
Creates a new retryable ticket. The id must be unique.
Sourcepub fn open_retryable<B: SystemStateBackend>(
&self,
backend: &mut B,
id: B256,
current_timestamp: u64,
) -> Result<Option<Retryable<'a, D>>, RetryableError>
pub fn open_retryable<B: SystemStateBackend>( &self, backend: &mut B, id: B256, current_timestamp: u64, ) -> Result<Option<Retryable<'a, D>>, RetryableError>
Opens an existing retryable if it is still live.
Past the raw timeout at ArbOS v60+, a kept-alive ticket survives while its windowed timeout has not yet elapsed.
Sourcepub fn open_retryable_metered<B: SystemStateBackend>(
&self,
backend: &mut B,
id: B256,
current_timestamp: u64,
) -> Result<(Option<Retryable<'a, D>>, u64), RetryableError>
pub fn open_retryable_metered<B: SystemStateBackend>( &self, backend: &mut B, id: B256, current_timestamp: u64, ) -> Result<(Option<Retryable<'a, D>>, u64), RetryableError>
Like [open_retryable], additionally returning the extra storage-read
gas the open consumed consulting the lifetime-window slot past the raw
timeout. Callers that meter storage access by hand fold this in.
Sourcepub fn retryable_size_bytes<B: SystemStateBackend>(
&self,
backend: &mut B,
id: B256,
current_time: u64,
) -> Result<u64, RetryableError>
pub fn retryable_size_bytes<B: SystemStateBackend>( &self, backend: &mut B, id: B256, current_time: u64, ) -> Result<u64, RetryableError>
Gets the size in bytes a retryable occupies in storage.
Sourcepub fn delete_retryable<F, G, B>(
&self,
backend: &mut B,
id: B256,
transfer_fn: F,
balance_of: G,
) -> Result<bool, RetryableError>where
F: FnMut(Address, Address, U256) -> Result<(), BalanceError>,
G: FnMut(Address) -> U256,
B: StorageBackend,
pub fn delete_retryable<F, G, B>(
&self,
backend: &mut B,
id: B256,
transfer_fn: F,
balance_of: G,
) -> Result<bool, RetryableError>where
F: FnMut(Address, Address, U256) -> Result<(), BalanceError>,
G: FnMut(Address) -> U256,
B: StorageBackend,
Deletes a retryable and returns whether it existed. Moves the escrow’s entire balance to the beneficiary via the provided closures.
Sourcepub fn get_timeout<B: SystemStateBackend>(
&self,
backend: &mut B,
ticket_id: B256,
current_timestamp: u64,
) -> Result<RetryableLookup<u64>, RetryableError>
pub fn get_timeout<B: SystemStateBackend>( &self, backend: &mut B, ticket_id: B256, current_timestamp: u64, ) -> Result<RetryableLookup<u64>, RetryableError>
Reads the effective timeout of an open retryable.
Returns NoTicketWithId if the ticket does not exist or has expired.
Sourcepub fn get_beneficiary<B: SystemStateBackend>(
&self,
backend: &mut B,
ticket_id: B256,
current_timestamp: u64,
) -> Result<RetryableLookup<Address>, RetryableError>
pub fn get_beneficiary<B: SystemStateBackend>( &self, backend: &mut B, ticket_id: B256, current_timestamp: u64, ) -> Result<RetryableLookup<Address>, RetryableError>
Reads the beneficiary of an open retryable.
Returns NoTicketWithId if the ticket does not exist or has expired.
Sourcepub fn calldata_size_for<B: SystemStateBackend>(
&self,
backend: &mut B,
ticket_id: B256,
current_timestamp: u64,
) -> Result<(u64, u64), RetryableError>
pub fn calldata_size_for<B: SystemStateBackend>( &self, backend: &mut B, ticket_id: B256, current_timestamp: u64, ) -> Result<(u64, u64), RetryableError>
Returns the calldata size of an open retryable, or zero if it has
expired. The lookup never fails the way get_timeout does so the
precompile can use it to size its gas reservation regardless of
liveness.
Sourcepub fn increment_num_tries_for<B: StorageBackend>(
&self,
backend: &mut B,
ticket_id: B256,
current_timestamp: u64,
) -> Result<RetryableLookup<u64>, RetryableError>
pub fn increment_num_tries_for<B: StorageBackend>( &self, backend: &mut B, ticket_id: B256, current_timestamp: u64, ) -> Result<RetryableLookup<u64>, RetryableError>
Increments num_tries on an open retryable and returns the previous
value (i.e. the nonce used by the retry transaction).
Returns NoTicketWithId if the ticket is missing or expired.
Sourcepub fn keepalive<B: StorageBackend>(
&self,
backend: &mut B,
ticket_id: B256,
current_timestamp: u64,
limit_before_add: u64,
_time_to_add: u64,
) -> Result<RetryableLookup<u64>, RetryableError>
pub fn keepalive<B: StorageBackend>( &self, backend: &mut B, ticket_id: B256, current_timestamp: u64, limit_before_add: u64, _time_to_add: u64, ) -> Result<RetryableLookup<u64>, RetryableError>
Extends the lifetime of a retryable ticket.
Sourcepub fn cancel<B: StorageBackend>(
&self,
backend: &mut B,
ticket_id: B256,
caller: Address,
current_timestamp: u64,
) -> Result<CancelLookup, RetryableError>
pub fn cancel<B: StorageBackend>( &self, backend: &mut B, ticket_id: B256, caller: Address, current_timestamp: u64, ) -> Result<CancelLookup, RetryableError>
Verifies caller is the beneficiary of an open retryable and clears
the ticket’s storage. Returns the calldata size that was cleared so
the precompile can derive its gas reservation.
Returns NoTicketWithId for missing/expired tickets and
NotBeneficiary when the caller is unauthorised.
Sourcepub fn try_to_reap_one_retryable<F, G, B>(
&self,
backend: &mut B,
current_timestamp: u64,
transfer_fn: F,
balance_of: G,
) -> Result<(), RetryableError>where
F: FnMut(Address, Address, U256) -> Result<(), BalanceError>,
G: FnMut(Address) -> U256,
B: StorageBackend,
pub fn try_to_reap_one_retryable<F, G, B>(
&self,
backend: &mut B,
current_timestamp: u64,
transfer_fn: F,
balance_of: G,
) -> Result<(), RetryableError>where
F: FnMut(Address, Address, U256) -> Result<(), BalanceError>,
G: FnMut(Address) -> U256,
B: StorageBackend,
Tries to reap one expired retryable from the timeout queue.
Sourcepub fn queue_size<B: SystemStateBackend>(
&self,
backend: &mut B,
) -> Result<u64, RetryableError>
pub fn queue_size<B: SystemStateBackend>( &self, backend: &mut B, ) -> Result<u64, RetryableError>
Total number of pending retryables in the timeout queue.
Sourcepub fn snapshot_queue<B: SystemStateBackend>(
&self,
backend: &mut B,
current_time: u64,
max_entries: usize,
) -> Result<Vec<(B256, u64)>, RetryableError>
pub fn snapshot_queue<B: SystemStateBackend>( &self, backend: &mut B, current_time: u64, max_entries: usize, ) -> Result<Vec<(B256, u64)>, RetryableError>
Walk the timeout queue and yield (ticket_id, timeout_seconds)
for each non-expired retryable.
Source§impl<D: Database> RetryableState<'_, D>
impl<D: Database> RetryableState<'_, D>
pub fn initialize(sto: &Storage<'_, D>) -> Result<(), RetryableError>
Auto Trait Implementations§
impl<'a, D> Freeze for RetryableState<'a, D>
impl<'a, D> RefUnwindSafe for RetryableState<'a, D>where
D: RefUnwindSafe,
impl<'a, D> Send for RetryableState<'a, D>where
D: Send,
impl<'a, D> Sync for RetryableState<'a, D>where
D: Sync,
impl<'a, D> Unpin for RetryableState<'a, D>
impl<'a, D> !UnwindSafe for RetryableState<'a, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
§fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
TxEnv] from a transaction and a sender address.§impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
§fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
TxEnv] from a transaction, its sender, and encoded transaction bytes.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.