Documentation
¶
Index ¶
Constants ¶
View Source
const ( EnvironmentInstanceSolanaMainnet = "mainnet" EnvironmentInstanceSolanaDevnet = "devnet" EnvironmentInstanceSolanaTestnet = "testnet" )
Variables ¶
View Source
var ( ErrStaleVersion = errors.New("nonce version is stale") ErrNonceNotFound = errors.New("no nonce could be found") )
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment uint8
const ( EnvironmentUnknown Environment = iota EnvironmentSolana // Environment instance is the cluster name (ie. mainnet, devnet, testnet, etc) EnvironmentCvm // Environment instance is the VM public key )
func (Environment) String ¶
func (e Environment) String() string
type Purpose ¶
type Purpose uint8
Split nonce pool across different use cases. This has an added benefit of:.
- 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 Record struct {
Id uint64
Address string
Authority string
Blockhash string
Environment Environment
EnvironmentInstance string
Purpose Purpose
State State
Signature string
ClaimNodeID *string
ClaimExpiresAt *time.Time
Version uint64
}
func (*Record) CanReserveWithSignature ¶
func (*Record) IsAvailableToClaim ¶
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 fulfillment for a virtual instruction or transaction. StateReserved // The nonce is reserved by a fulfillment for a virtual instruction or transaction. StateInvalid // The nonce account is invalid (e.g. insufficient funds, etc). StateClaimed // The nonce is claimed by a process for future use (identified by a node ID) )
type Store ¶
type Store interface {
// Count returns the total count of nonce accounts within an environment instance
Count(ctx context.Context, env Environment, instance string) (uint64, error)
// CountByState returns the total count of nonce accounts in the provided state within
// an environment instance
CountByState(ctx context.Context, env Environment, instance string, state State) (uint64, error)
// CountByStateAndPurpose returns the total count of nonce accounts in the provided
// state and use case within an environment instance
CountByStateAndPurpose(ctx context.Context, env Environment, instance string, 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
// within an environment intance.
//
// Returns ErrNotFound if no records are found.
GetAllByState(ctx context.Context, env Environment, instance string, state State, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)
// BatchClaimAvailableByPurpose batch claims up to the specified limit.
//
// The returned nonces will be marked as claimed by the current node, with
// the specified expiry date.
//
// Note: Implementations need not randomize the results/selection.
// The transactional nature of the call means that any contention exists
// on the tx level (which always occurs), and not around fighting over
// individual nonces.
BatchClaimAvailableByPurpose(ctx context.Context, env Environment, instance string, purpose Purpose, limit int, nodeID string, minExpireAt, maxExpireAt time.Time) ([]*Record, error)
}
Click to show internal directories.
Click to hide internal directories.