Expand description
Per-(account_index, api_key_index) sequential nonce manager.
Mirrors the optimistic strategy lighter-python’s OptimisticNonceManager
uses: each call to NonceManager::next_nonce hands out the next monotonic
integer for the requested key without waiting for the venue to confirm the
prior one. The caller bounds the number of unconfirmed allocations through
the NonceManager::skip_window argument; once the window is exhausted,
NonceManager::next_nonce errors so the caller can drain or refresh
before issuing further transactions.
The window bounds local unconfirmed allocations, not venue acceptance of
out-of-order transactions. With skip_nonce=0, the venue requires consecutive
nonces per API key; callers must preserve submission order.
The module is lock-free per key: a [DashMap] keys an Arc holding two
AtomicI64s (last_issued and baseline). NonceManager::next_nonce
is a CAS loop bounded by skip_window; NonceManager::ack_success
monotonically advances the baseline when the venue confirms a tx;
NonceManager::ack_failure_if_latest rolls back the most recent
allocation when the failed nonce is still the latest issuance.
Structs§
- Nonce
Manager - Thread-safe sequential nonce allocator keyed by
(account_index, api_key_index).
Enums§
- Nonce
Error - Errors raised by
NonceManager.
Constants§
- DEFAULT_
SKIP_ WINDOW - Default skip-window used when the caller does not specify one.