Documentation
¶
Index ¶
- Constants
- func NewTransaction(notifier events.Publisher, tx *tokendb.Transaction, tmsID token.TMSID) (*transaction, error)
- func WrapMetadataWithType(typ driver.Type, id driver.Metadata) (driver.Metadata, error)
- func WrapWithType(typ driver.Type, id driver.Token) (driver.Token, error)
- type Cache
- type CacheEntry
- type DBStorage
- type Flags
- type GetTMSProviderFunc
- type MetaData
- type NetworkProvider
- type Service
- func (t *Service) Append(ctx context.Context, tmsID token.TMSID, txID token.RequestAnchor, ...) (err error)
- func (t *Service) AppendRaw(ctx context.Context, tmsID token.TMSID, txID token.RequestAnchor, ...) (err error)
- func (t *Service) AppendTransaction(ctx context.Context, tx Transaction) (err error)
- func (t *Service) CacheRequest(ctx context.Context, tmsID token.TMSID, request *token.Request) error
- func (t *Service) DeleteTokens(ctx context.Context, ids ...*token2.ID) (err error)
- func (t *Service) DeleteTokensBy(ctx context.Context, deletedBy string, ids ...*token2.ID) (err error)
- func (t *Service) GetCachedTokenRequest(txID string) *token.Request
- func (t *Service) PruneInvalidUnspentTokens(ctx context.Context) ([]*token2.ID, error)
- func (t *Service) SetSpendableBySupportedTokenTypes(types []token2.Format) error
- func (t *Service) SetSpendableFlag(value bool, ids ...*token2.ID) error
- func (t *Service) SetSupportedTokenFormats(tokenTypes []token2.Format) error
- func (t *Service) StorePublicParams(ctx context.Context, raw []byte) error
- func (t *Service) UnsupportedTokensIteratorBy(ctx context.Context, walletID string, typ token2.Type) (driver.UnsupportedTokensIterator, error)
- type ServiceManager
- type StoreServiceManager
- type TMSProvider
- type TokenMessage
- type TokenProcessorEvent
- type TokenToAppend
- type Transaction
- type TypedMetadata
- type TypedToken
- type UnspendableTokensIterator
Constants ¶
const ( AddToken = "store-token" DeleteToken = "delete-token" )
Variables ¶
This section is empty.
Functions ¶
func NewTransaction ¶
func WrapMetadataWithType ¶
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 DBStorage ¶
type DBStorage struct {
// contains filtered or unexported fields
}
func NewDBStorage ¶
func (*DBStorage) NewTransaction ¶
func (*DBStorage) StorePublicParams ¶
type GetTMSProviderFunc ¶
type GetTMSProviderFunc = func() *token.ManagementServiceProvider
type NetworkProvider ¶ added in v0.5.0
type Service ¶ added in v0.5.0
type Service struct { TMSProvider TMSProvider NetworkProvider NetworkProvider Storage *DBStorage RequestsCache Cache }
Service is the interface for the token service
func GetService ¶
GetService returns the Service instance for the passed TMS
func (*Service) AppendTransaction ¶ added in v0.5.0
func (t *Service) 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 (*Service) CacheRequest ¶ added in v0.5.0
func (*Service) DeleteTokens ¶ added in v0.5.0
DeleteTokens marks the entries corresponding to the passed token ids as deleted. The deletion is attributed to the caller of this function.
func (*Service) DeleteTokensBy ¶ added in v0.5.0
func (t *Service) DeleteTokensBy(ctx context.Context, deletedBy string, ids ...*token2.ID) (err error)
DeleteTokensBy marks the entries corresponding to the passed token ids as deleted. The deletion is attributed to the passed deletedBy argument.
func (*Service) GetCachedTokenRequest ¶ added in v0.5.0
func (*Service) PruneInvalidUnspentTokens ¶ added in v0.5.0
PruneInvalidUnspentTokens checks that each unspent token is actually available on the ledger. Those that are not available are deleted. The function returns the list of deleted token ids
func (*Service) SetSpendableBySupportedTokenTypes ¶ added in v0.5.0
func (*Service) SetSpendableFlag ¶ added in v0.5.0
func (*Service) SetSupportedTokenFormats ¶ added in v0.5.0
func (*Service) StorePublicParams ¶ added in v0.5.0
StorePublicParams stores the passed public parameters in the token db
func (*Service) UnsupportedTokensIteratorBy ¶ added in v0.5.0
func (t *Service) UnsupportedTokensIteratorBy(ctx context.Context, walletID string, typ token2.Type) (driver.UnsupportedTokensIterator, error)
UnsupportedTokensIteratorBy returns the minimum information for upgrade about the tokens that are not supported
type ServiceManager ¶ added in v0.5.0
type ServiceManager struct {
// contains filtered or unexported fields
}
ServiceManager handles the services
func NewServiceManager ¶ added in v0.5.0
func NewServiceManager( tmsProvider TMSProvider, storeServiceManager StoreServiceManager, networkProvider NetworkProvider, notifier events.Publisher, ) *ServiceManager
NewServiceManager creates a new Service manager.
func (*ServiceManager) ServiceByTMSId ¶ added in v0.5.0
func (cm *ServiceManager) ServiceByTMSId(tmsID token.TMSID) (*Service, error)
ServiceByTMSId returns the Service for the given TMS
type StoreServiceManager ¶ added in v0.5.0
type StoreServiceManager db.StoreServiceManager[*tokendb.StoreService]
type TMSProvider ¶
type TMSProvider interface {
GetManagementService(opts ...token.ServiceOption) (*token.ManagementService, error)
}
type TokenMessage ¶
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 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)
type UnspendableTokensIterator ¶ added in v0.5.0
type UnspendableTokensIterator = driver.UnsupportedTokensIterator