tokens

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddToken    = "store-token"
	DeleteToken = "delete-token"
)

Variables

This section is empty.

Functions

func NewTransaction

func NewTransaction(notifier events.Publisher, tx *tokendb.Transaction, tmsID token.TMSID) (*transaction, error)

func WrapMetadataWithType

func WrapMetadataWithType(typ driver.Type, id driver.Metadata) (driver.Metadata, error)

func WrapWithType

func WrapWithType(typ driver.Type, id driver.Token) (driver.Token, error)

Types

type Cache

type Cache interface {
	Get(key string) (*CacheEntry, bool)
	Add(key string, value *CacheEntry)
	Delete(key string)
}

type CacheEntry

type CacheEntry struct {
	Request  *token.Request
	ToSpend  []*token2.ID
	ToAppend []TokenToAppend
}

type DBProvider

type DBProvider interface {
	DBByTMSId(id token.TMSID) (*tokendb.DB, error)
}

type DBStorage

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

func NewDBStorage

func NewDBStorage(notifier events.Publisher, tokenDB *tokendb.DB, tmsID token.TMSID) (*DBStorage, error)

func (*DBStorage) NewTransaction

func (d *DBStorage) NewTransaction() (*transaction, error)

func (*DBStorage) StorePublicParams

func (d *DBStorage) StorePublicParams(raw []byte) error

func (*DBStorage) TransactionExists

func (d *DBStorage) TransactionExists(ctx context.Context, id string) (bool, error)

type Flags

type Flags struct {
	Mine    bool
	Auditor bool
	Issuer  bool
}

type GetTMSProviderFunc

type GetTMSProviderFunc = func() *token.ManagementServiceProvider

type Manager

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

Manager handles the databases

func GetProvider

func GetProvider(sp token.ServiceProvider) (*Manager, error)

func NewManager

func NewManager(
	tmsProvider TMSProvider,
	dbManager DBProvider,
	notifier events.Publisher,
) *Manager

NewManager creates a new Tokens manager.

func (*Manager) Tokens

func (cm *Manager) Tokens(tmsID token.TMSID) (*Tokens, error)

Tokens returns the Tokens for the given TMS

type MetaData

type MetaData interface {
	SpentTokenID() []*token2.ID
	GetToken(raw []byte) (*token2.Token, token.Identity, []byte, error)
}

type TMSProvider

type TMSProvider interface {
	GetManagementService(opts ...token.ServiceOption) (*token.ManagementService, error)
}

type TokenMessage

type TokenMessage struct {
	TMSID     token.TMSID
	WalletID  string
	TokenType token2.Type
	TxID      string
	Index     uint64
}

type TokenProcessorEvent

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

func NewTokenProcessorEvent

func NewTokenProcessorEvent(topic string, message *TokenMessage) *TokenProcessorEvent

func (*TokenProcessorEvent) Message

func (t *TokenProcessorEvent) Message() interface{}

func (*TokenProcessorEvent) Topic

func (t *TokenProcessorEvent) Topic() string

type TokenToAppend

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

type Tokens

type Tokens struct {
	TMSProvider TMSProvider
	Storage     *DBStorage

	RequestsCache Cache
}

Tokens is the interface for the token service

func GetService

func GetService(sp token.ServiceProvider, tmsID token.TMSID) (*Tokens, error)

GetService returns the Tokens instance for the passed TMS

func (*Tokens) Append

func (t *Tokens) Append(ctx context.Context, tmsID token.TMSID, txID string, request *token.Request) (err error)

func (*Tokens) AppendRaw

func (t *Tokens) AppendRaw(ctx context.Context, tmsID token.TMSID, txID string, requestRaw []byte) (err error)

func (*Tokens) AppendTransaction

func (t *Tokens) AppendTransaction(ctx context.Context, tx Transaction) (err error)

AppendTransaction appends the content of the passed transaction to the token db. If the transaction is already in there, nothing more happens. The operation is atomic.

func (*Tokens) CacheRequest

func (t *Tokens) CacheRequest(tmsID token.TMSID, request *token.Request) error

func (*Tokens) DeleteToken

func (t *Tokens) DeleteToken(deletedBy string, ids ...*token2.ID) (err error)

DeleteToken marks the entries corresponding to the passed token ids as deleted. The deletion is attributed to the passed deletedBy argument.

func (*Tokens) GetCachedTokenRequest

func (t *Tokens) GetCachedTokenRequest(txID string) *token.Request

func (*Tokens) SetSpendableBySupportedTokenTypes

func (t *Tokens) SetSpendableBySupportedTokenTypes(types []token2.Format) error

func (*Tokens) SetSpendableFlag

func (t *Tokens) SetSpendableFlag(value bool, ids ...*token2.ID) error

func (*Tokens) SetSupportedTokenTypes

func (t *Tokens) SetSupportedTokenTypes(tokenTypes []token2.Format) error

func (*Tokens) StorePublicParams

func (t *Tokens) StorePublicParams(raw []byte) error

StorePublicParams stores the passed public parameters in the token db

type Transaction

type Transaction interface {
	ID() string
	Network() string
	Channel() string
	Namespace() string
	Request() *token.Request
}

Transaction models a token transaction

type TypedMetadata

type TypedMetadata struct {
	// Type encodes the metadata type
	Type driver.Type
	// Metadata encodes the metadata itself
	Metadata driver.Metadata
}

TypedMetadata encodes metadata with a type.

func UnmarshalTypedMetadata

func UnmarshalTypedMetadata(metadata driver.Metadata) (*TypedMetadata, error)

func (TypedMetadata) Bytes

func (i TypedMetadata) Bytes() ([]byte, error)

type TypedToken

type TypedToken struct {
	// Type encodes the token's type
	Type driver.Type
	// Token encodes the token itself
	Token driver.Token
}

TypedToken encodes a token with a type.

func UnmarshalTypedToken

func UnmarshalTypedToken(token driver.Token) (*TypedToken, error)

func (TypedToken) Bytes

func (i TypedToken) Bytes() ([]byte, error)

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

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