Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNonceNotFound = errors.New("no records could be found") ErrInvalidNonce = errors.New("invalid nonce") )
Functions ¶
This section is empty.
Types ¶
type Purpose ¶
type Purpose uint8
Split nonce pool across different use cases. This has an added benefit of:
- Solving for race conditions without distributed locks.
- Avoiding different use cases from starving each other and ending up in a deadlocked state. Concretely, it would be really bad if clients could starve internal processes from creating transactions that would allow us to progress and submit existing transactions.
type Record ¶
type State ¶
type State uint8
const ( StateUnknown State = iota StateReleased // The nonce is almost ready but we don't know its blockhash yet. StateAvailable // The nonce is available to be used by a payment intent, subscription, or other nonce-related transaction. StateReserved // The nonce is reserved by a payment intent, subscription, or other nonce-related transaction. StateInvalid // The nonce account is invalid (e.g. insufficient funds, etc). )
type Store ¶
type Store interface { // Count returns the total count of nonce accounts. Count(ctx context.Context) (uint64, error) // CountByState returns the total count of nonce accounts in the provided state. CountByState(ctx context.Context, state State) (uint64, error) // CountByStateAndPurpose returns the total count of nonce accounts in the provided // state and use case CountByStateAndPurpose(ctx context.Context, state State, purpose Purpose) (uint64, error) // Save creates or updates nonce metadata in the store. Save(ctx context.Context, record *Record) error // Get finds the nonce record for a given address. // // Returns ErrNotFound if no record is found. Get(ctx context.Context, address string) (*Record, error) // GetAllByState returns nonce records in the store for a given // confirmation state. // // Returns ErrNotFound if no records are found. GetAllByState(ctx context.Context, state State, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error) // GetRandomAvailableByPurpose gets a random available nonce for a purpose. // // Returns ErrNotFound if no records are found. GetRandomAvailableByPurpose(ctx context.Context, purpose Purpose) (*Record, error) }
Click to show internal directories.
Click to hide internal directories.