pub struct NonceManager { /* private fields */ }Expand description
Thread-safe sequential nonce allocator keyed by (wallet, subaccount_id).
Implementations§
Source§impl NonceManager
impl NonceManager
Sourcepub fn next_nonce(
&self,
wallet: &str,
subaccount_id: u64,
) -> Result<u64, NonceError>
pub fn next_nonce( &self, wallet: &str, subaccount_id: u64, ) -> Result<u64, NonceError>
Allocates the next nonce for (wallet, subaccount_id) using the
system clock as the millisecond reference.
§Errors
Returns NonceError::ClockBeforeEpoch when the system clock is
invalid.
Sourcepub fn next_nonce_at(
&self,
wallet: &str,
subaccount_id: u64,
now_ms: u64,
) -> u64
pub fn next_nonce_at( &self, wallet: &str, subaccount_id: u64, now_ms: u64, ) -> u64
Allocates the next nonce for (wallet, subaccount_id) with an
injected now_ms, suitable for deterministic testing.
Sourcepub fn refresh(&self, wallet: &str, subaccount_id: u64, last_seen_nonce: u64)
pub fn refresh(&self, wallet: &str, subaccount_id: u64, last_seen_nonce: u64)
Aligns the local last-issued state with a venue-reported nextNonce,
monotonically. The stored value advances to last_seen_nonce only
when it is strictly greater than the current state, otherwise the
call is a no-op.
Monotonicity matters because rewinding would re-issue nonces already dispatched on the wire, which the venue rejects as replays. A stale or out-of-date venue snapshot must never clobber more recent local allocations.
Trait Implementations§
Source§impl Debug for NonceManager
impl Debug for NonceManager
Source§impl Default for NonceManager
impl Default for NonceManager
Source§fn default() -> NonceManager
fn default() -> NonceManager
Auto Trait Implementations§
impl !RefUnwindSafe for NonceManager
impl Freeze for NonceManager
impl Send for NonceManager
impl Sync for NonceManager
impl Unpin for NonceManager
impl UnsafeUnpin for NonceManager
impl UnwindSafe for NonceManager
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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