reserve

package
v1.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package reserve defines a focused store for currency creator mint reserve states.

Records are keyed per mint (the number of mints is unbounded), so every record is a single item — there is no map-of-all-mints row.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store interface {
	// PutHistoricalReserve puts a currency creator mint reserve record into the
	// store.
	//
	// currency.ErrExists is returned if a record already exists for the mint at the
	// provided time.
	PutHistoricalReserve(ctx context.Context, record *currency.ReserveRecord) error

	// GetReserveAtTime gets reserve state for a given currency creator mint at a
	// point in time. The most recent record at or before the requested time is
	// returned.
	//
	// currency.ErrNotFound is returned if no reserve data exists at or before the
	// provided time.
	GetReserveAtTime(ctx context.Context, mint string, t time.Time) (*currency.ReserveRecord, error)

	// GetReservesInRange gets the reserve records for a range of time given a
	// currency creator mint and interval.
	//
	// currency.ErrNotFound is returned if the mint or the reserves for the mint cannot be found
	// currency.ErrInvalidRange is returned if the range is not valid
	// currency.ErrInvalidInterval is returned if the interval is not valid
	GetReservesInRange(ctx context.Context, mint string, interval query.Interval, start time.Time, end time.Time, ordering query.Ordering) ([]*currency.ReserveRecord, error)

	// PutLiveReserve upserts the latest reserve record for a currency creator mint.
	// An upsert is only performed if the provided slot is greater than the slot
	// currently stored.
	//
	// currency.ErrStaleReserveState is returned if the provided slot is not greater
	// than the stored slot.
	PutLiveReserve(ctx context.Context, record *currency.ReserveRecord) error

	// GetLiveReserve gets the latest live reserve record for a currency creator mint.
	//
	// currency.ErrNotFound is returned if no live reserve record exists for the provided mint.
	GetLiveReserve(ctx context.Context, mint string) (*currency.ReserveRecord, error)

	// GetAllLiveReserves gets the latest live reserve records for all currency
	// creator mints.
	//
	// currency.ErrNotFound is returned if no live reserve records exist.
	GetAllLiveReserves(ctx context.Context) (map[string]*currency.ReserveRecord, error)
}

Directories

Path Synopsis
Package cache provides a reserve.Store decorator that caches point-in-time reserve lookups in front of a wrapped store.
Package cache provides a reserve.Store decorator that caches point-in-time reserve lookups in front of a wrapped store.
Package dynamodb implements the reserve.Store interface on top of DynamoDB.
Package dynamodb implements the reserve.Store interface on top of DynamoDB.
Package memory provides an in-memory reserve.Store implementation for fast unit tests.
Package memory provides an in-memory reserve.Store implementation for fast unit tests.
Package tests holds the shared conformance suite run against every reserve.Store implementation.
Package tests holds the shared conformance suite run against every reserve.Store implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL