simple

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string) (any, bool)
	Add(key string, value any)
}

type ConfigProvider

type ConfigProvider interface {
	UnmarshalKey(key string, rawVal any) error
}

type Locker

type Locker interface {
	// Lock locks the token id for the consumer transaction txID on behalf of the given
	// owner (the wallet the tokens are selected for, ownerFilter.ID()).
	// owner lets a Locker implementation apply per-wallet policies such as rate limiting.
	// To deny a lock for policy reasons, return an error wrapping token.SelectorRateLimited:
	// the selector then aborts immediately instead of retrying.
	Lock(ctx context.Context, owner string, id *token2.ID, txID string, reclaim bool) (string, error)
	// UnlockIDs unlocks the passed IDs for the given owner. It returns the list of tokens
	// that were not locked in the first place among those passed.
	UnlockIDs(ctx context.Context, owner string, ids ...*token2.ID) []*token2.ID
	UnlockByTxID(ctx context.Context, txID string)
	IsLocked(id *token2.ID) bool
}

type LockerProvider

type LockerProvider interface {
	New(network, channel, namespace string) (Locker, error)
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(
	locker Locker,
	newQueryEngine NewQueryEngineFunc,
	numRetry int,
	timeout time.Duration,
	requestCertification bool,
	precision uint64,
) *Manager

func (*Manager) Close

func (m *Manager) Close(txID string) error

func (*Manager) NewSelector

func (m *Manager) NewSelector(id string) (token.Selector, error)

func (*Manager) SetPrecision added in v0.27.0

func (m *Manager) SetPrecision(precision uint64)

SetPrecision sets the precision of the selectors this manager creates from now on. The selector service calls it when the public parameters of the TMS change. Selectors that already exist keep the precision they were created with.

func (*Manager) Unlock

func (m *Manager) Unlock(ctx context.Context, txID string) error

type NewQueryEngineFunc

type NewQueryEngineFunc func() QueryService

type QueryService

type QueryService interface {
	UnspentTokensIterator(ctx context.Context) (*token.UnspentTokensIterator, error)
	UnspentTokensIteratorBy(ctx context.Context, id string, tokenType token2.Type) (driver.UnspentTokensIterator, error)
	GetTokens(ctx context.Context, inputs ...*token2.ID) ([]*token2.Token, error)
}

type SelectorService

type SelectorService struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(lockerProvider LockerProvider, c ConfigProvider, metricsProvider metrics.Provider, opts ...ratelimit.Option) *SelectorService

NewService returns a SelectorService for the simple driver.

By default, selection is not rate limited. Passing ratelimit options, or enabling the token.selector.rateLimit* configuration keys, meters every selection request per wallet.

func (*SelectorService) SelectorManager

func (s *SelectorService) SelectorManager(tms *token.ManagementService) (token.SelectorManager, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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