Documentation
¶
Index ¶
- Constants
- Variables
- type ActionType
- type HoldingsFilter
- func (f *HoldingsFilter) ByEnrollmentId(id string) *HoldingsFilter
- func (f *HoldingsFilter) ByType(tokenType token.Type) *HoldingsFilter
- func (f *HoldingsFilter) Execute(ctx context.Context) (*HoldingsFilter, error)
- func (f *HoldingsFilter) Sum() *big.Int
- func (f *HoldingsFilter) SumByEnrollmentID() map[string]*big.Int
- type Locker
- type LockerBackend
- type LockerConfig
- type MovementRecord
- type PageTransactionsIterator
- type Pagination
- type PaymentsFilter
- func (f *PaymentsFilter) ByEnrollmentId(id string) *PaymentsFilter
- func (f *PaymentsFilter) ByType(tokenType token.Type) *PaymentsFilter
- func (f *PaymentsFilter) Execute(ctx context.Context) (*PaymentsFilter, error)
- func (f *PaymentsFilter) Last(num int) *PaymentsFilter
- func (f *PaymentsFilter) Sum() *big.Int
- type QueryTokenRequestsParams
- type QueryTransactionsParams
- type RecoveryClaim
- type StoreService
- func (d *StoreService) AcquireLocks(ctx context.Context, anchor string, eIDs ...string) error
- func (d *StoreService) AcquireRecoveryLeadership(ctx context.Context, lockID int64) (dbdriver.RecoveryLeadership, bool, error)
- func (d *StoreService) Append(ctx context.Context, req tokenRequest) error
- func (d *StoreService) ClaimPendingTransactions(ctx context.Context, olderThan time.Duration, leaseDuration time.Duration, ...) ([]*RecoveryClaim, error)
- func (d *StoreService) GetStatus(ctx context.Context, txID string) (TxStatus, string, error)
- func (d *StoreService) GetTokenRequest(ctx context.Context, txID string) ([]byte, error)
- func (d *StoreService) GetTokenRequests(ctx context.Context, txIDs []string) (map[string][]byte, error)
- func (d *StoreService) NewHoldingsFilter() *HoldingsFilter
- func (d *StoreService) NewPaymentsFilter() *PaymentsFilter
- func (d *StoreService) NewTransaction() (dbdriver.TransactionStoreTransaction, error)
- func (d *StoreService) ReleaseLocks(ctx context.Context, anchor string)
- func (d *StoreService) ReleaseRecoveryClaim(ctx context.Context, txID string, owner string, message string) error
- func (d *StoreService) SetStatus(ctx context.Context, txID string, status dbdriver.TxStatus, message string) error
- func (d *StoreService) TokenRequests(ctx context.Context, params QueryTokenRequestsParams) (dbdriver.TokenRequestIterator, error)
- func (d *StoreService) Transactions(ctx context.Context, params QueryTransactionsParams, pagination Pagination) (*PageTransactionsIterator, error)
- type StoreServiceManager
- type StoreServiceOption
- type TransactionRecord
- type TxStatus
- type Wallet
Constants ¶
const ( LockerBackendMemory = locker.BackendMemory LockerBackendPostgres = locker.BackendPostgres )
const ( // Unknown is the status of a transaction that is unknown Unknown = dbdriver.Unknown // Pending is the status of a transaction that has been submitted to the ledger Pending = dbdriver.Pending // Confirmed is the status of a transaction that has been confirmed by the ledger Confirmed = dbdriver.Confirmed // Deleted is the status of a transaction that has been deleted due to a failure to commit Deleted = dbdriver.Deleted // Orphan is the status of a transaction that never reached the ledger Orphan = dbdriver.Orphan )
Variables ¶
var ( ErrLockContention = locker.ErrLockContention ErrLockAcquireTimeout = locker.ErrLockAcquireTimeout ErrLockLost = locker.ErrLockLost ErrLockNotHeld = locker.ErrLockNotHeld )
var TxStatusMessage = dbdriver.TxStatusMessage
TxStatusMessage maps TxStatus to string
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType = dbdriver.ActionType
ActionType is the type of action performed by a transaction.
const ( // Issue is the action type for issuing tokens. Issue ActionType = iota // Transfer is the action type for transferring tokens. Transfer // Redeem is the action type for redeeming tokens. Redeem )
type HoldingsFilter ¶
type HoldingsFilter struct {
// contains filtered or unexported fields
}
func (*HoldingsFilter) ByEnrollmentId ¶
func (f *HoldingsFilter) ByEnrollmentId(id string) *HoldingsFilter
func (*HoldingsFilter) ByType ¶
func (f *HoldingsFilter) ByType(tokenType token.Type) *HoldingsFilter
func (*HoldingsFilter) Execute ¶
func (f *HoldingsFilter) Execute(ctx context.Context) (*HoldingsFilter, error)
func (*HoldingsFilter) Sum ¶
func (f *HoldingsFilter) Sum() *big.Int
func (*HoldingsFilter) SumByEnrollmentID ¶ added in v0.14.2
func (f *HoldingsFilter) SumByEnrollmentID() map[string]*big.Int
SumByEnrollmentID returns the sum of the loaded records grouped by enrollment id. Enrollment ids with no records are absent from the returned map.
type LockerBackend ¶
LockerBackend identifies which Locker implementation to use.
type LockerConfig ¶
LockerConfig is the top-level configuration for the auditor EID locker.
func DefaultLockerConfig ¶
func DefaultLockerConfig() LockerConfig
DefaultLockerConfig returns the default auditor locker configuration.
type MovementRecord ¶
type MovementRecord = dbdriver.MovementRecord
MovementRecord is a record of a movement of assets. Given a Token Transaction, a movement record is created for each enrollment ID that participated in the transaction and each token type that was transferred. The movement record contains the total amount of the token type that was transferred to/from the enrollment ID in a given token transaction.
type PageTransactionsIterator ¶
type PageTransactionsIterator = cdriver.PageIterator[*TransactionRecord]
PageTransactionsIterator iterator defines the pagination iterator for movements query results
type Pagination ¶
type Pagination = cdriver.Pagination
Pagination defines the pagination for querying movements
type PaymentsFilter ¶
type PaymentsFilter struct {
// contains filtered or unexported fields
}
PaymentsFilter is a filter for payments.
func (*PaymentsFilter) ByEnrollmentId ¶
func (f *PaymentsFilter) ByEnrollmentId(id string) *PaymentsFilter
ByEnrollmentId add an enrollment id to the filter.
func (*PaymentsFilter) ByType ¶
func (f *PaymentsFilter) ByType(tokenType token.Type) *PaymentsFilter
func (*PaymentsFilter) Execute ¶
func (f *PaymentsFilter) Execute(ctx context.Context) (*PaymentsFilter, error)
func (*PaymentsFilter) Last ¶
func (f *PaymentsFilter) Last(num int) *PaymentsFilter
func (*PaymentsFilter) Sum ¶
func (f *PaymentsFilter) Sum() *big.Int
type QueryTokenRequestsParams ¶
type QueryTokenRequestsParams = dbdriver.QueryTokenRequestsParams
QueryTokenRequestsParams defines the parameters for querying token requests
type QueryTransactionsParams ¶
type QueryTransactionsParams = dbdriver.QueryTransactionsParams
QueryTransactionsParams defines the parameters for querying movements
type RecoveryClaim ¶
type RecoveryClaim = dbdriver.RecoveryClaim
RecoveryClaim is the minimal projection of a pending transaction row returned by ClaimPendingTransactions for recovery processing.
type StoreService ¶
type StoreService struct {
*common.StatusSupport
// contains filtered or unexported fields
}
StoreService is a database that stores token transactions related information
func GetByTMSID ¶
func GetByTMSID(sp token.ServiceProvider, tmsID token.TMSID) (*StoreService, error)
func NewStoreService ¶
func NewStoreService(p dbdriver.AuditTransactionStore, opts ...StoreServiceOption) (*StoreService, error)
func (*StoreService) AcquireLocks ¶
AcquireLocks acquires locks for the passed anchor and enrollment ids. This can be used to prevent concurrent read/write access to the audit records of the passed enrollment ids. The function respects context cancellation and deadlines, returning an error if the context is cancelled or times out before all locks can be acquired. This prevents indefinite blocking and enables fast failure in case of lock contention or deadlock scenarios. The implementation provides deadlock prevention through deterministic lock ordering (sorted by enrollment ID). Livelock prevention is handled by the caller through retry logic with exponential backoff.
func (*StoreService) AcquireRecoveryLeadership ¶
func (d *StoreService) AcquireRecoveryLeadership(ctx context.Context, lockID int64) (dbdriver.RecoveryLeadership, bool, error)
AcquireRecoveryLeadership tries to acquire the DB-backed recovery leadership lease.
func (*StoreService) Append ¶
func (d *StoreService) Append(ctx context.Context, req tokenRequest) error
Append appends send and receive movements, and transaction records corresponding to the passed token request
func (*StoreService) ClaimPendingTransactions ¶
func (d *StoreService) ClaimPendingTransactions(ctx context.Context, olderThan time.Duration, leaseDuration time.Duration, limit int, owner string) ([]*RecoveryClaim, error)
ClaimPendingTransactions returns a claimed batch of Pending transactions older than the given duration. Each returned RecoveryClaim carries the TxID and StoredAt timestamp the recovery loop needs; the rest of the row is intentionally not projected from SQL.
func (*StoreService) GetStatus ¶
GetStatus return the status of the given transaction id. It returns an error if no transaction with that id is found
func (*StoreService) GetTokenRequest ¶
GetTokenRequest returns the token request bound to the passed transaction id, if available.
func (*StoreService) GetTokenRequests ¶
func (d *StoreService) GetTokenRequests(ctx context.Context, txIDs []string) (map[string][]byte, error)
GetTokenRequests returns the token requests bound to the given tx ids in a single query. See driver.TransactionStore.GetTokenRequests for details about missing-key semantics.
func (*StoreService) NewHoldingsFilter ¶
func (d *StoreService) NewHoldingsFilter() *HoldingsFilter
NewHoldingsFilter returns a programmable filter over the holdings owned by enrollment IDs.
func (*StoreService) NewPaymentsFilter ¶
func (d *StoreService) NewPaymentsFilter() *PaymentsFilter
NewPaymentsFilter returns a programmable filter over the payments sent or received by enrollment IDs.
func (*StoreService) NewTransaction ¶
func (d *StoreService) NewTransaction() (dbdriver.TransactionStoreTransaction, error)
func (*StoreService) ReleaseLocks ¶
func (d *StoreService) ReleaseLocks(ctx context.Context, anchor string)
ReleaseLocks releases the locks associated to the passed anchor
func (*StoreService) ReleaseRecoveryClaim ¶
func (d *StoreService) ReleaseRecoveryClaim(ctx context.Context, txID string, owner string, message string) error
ReleaseRecoveryClaim clears the recovery claim for the passed transaction if owned by owner. The message parameter is stored for audit/debugging purposes.
func (*StoreService) SetStatus ¶
func (d *StoreService) SetStatus(ctx context.Context, txID string, status dbdriver.TxStatus, message string) error
SetStatus sets the status of the audit records with the passed transaction id to the passed status
func (*StoreService) TokenRequests ¶
func (d *StoreService) TokenRequests(ctx context.Context, params QueryTokenRequestsParams) (dbdriver.TokenRequestIterator, error)
TokenRequests returns an iterator over the token requests matching the passed params
func (*StoreService) Transactions ¶
func (d *StoreService) Transactions(ctx context.Context, params QueryTransactionsParams, pagination Pagination) (*PageTransactionsIterator, error)
Transactions returns an iterators of transaction records filtered by the given params.
type StoreServiceManager ¶
type StoreServiceManager db.StoreServiceManager[*StoreService]
func NewStoreServiceManager ¶
func NewStoreServiceManager(cp db.ConfigService, drivers multiplexed.Driver, replicaID locker.ReplicaIDProvider) StoreServiceManager
type StoreServiceOption ¶
type StoreServiceOption func(*StoreService)
StoreServiceOption configures a StoreService at construction time.
func WithLocker ¶
func WithLocker(l Locker) StoreServiceOption
WithLocker replaces the default in-memory Locker.
type TransactionRecord ¶
type TransactionRecord = dbdriver.TransactionRecord
TransactionRecord is a more finer-grained version of a movement record. Given a Token Transaction, for each token action in the Token Request, a transaction record is created for each unique enrollment ID found in the outputs. The transaction record contains the total amount of the token type that was transferred to/from that enrollment ID in that action.
type Wallet ¶
type Wallet interface {
// ID returns the wallet ID
ID() string
// TMS returns the TMS of the wallet
TMS() *token.ManagementService
}
Wallet models a wallet