Documentation ¶
Index ¶
- Constants
- func Drivers() []string
- func Register(name string, driver driver.Driver)
- type ActionType
- type DB
- func (db *DB) AcquireLocks(anchor string, eIDs ...string) error
- func (db *DB) Append(req *token.Request) error
- func (db *DB) AppendTransactionRecord(req *token.Request) error
- func (db *DB) AppendValidationRecord(txID string, tr []byte, meta map[string][]byte) error
- func (db *DB) GetStatus(txID string) (TxStatus, error)
- func (db *DB) GetTokenRequest(txID string) ([]byte, error)
- func (db *DB) NewQueryExecutor() *QueryExecutor
- func (db *DB) ReleaseLocks(anchor string)
- func (db *DB) SetStatus(txID string, status TxStatus) error
- type HoldingsFilter
- type Manager
- type MovementRecord
- type PaymentsFilter
- type QueryExecutor
- func (qe *QueryExecutor) Done()
- func (qe *QueryExecutor) NewHoldingsFilter() *HoldingsFilter
- func (qe *QueryExecutor) NewPaymentsFilter() *PaymentsFilter
- func (qe *QueryExecutor) Transactions(params QueryTransactionsParams) (*TransactionIterator, error)
- func (qe *QueryExecutor) ValidationRecords(params QueryValidationRecordsParams) (*ValidationRecordsIterator, error)
- type QueryTransactionsParams
- type QueryValidationRecordsParams
- type TransactionIterator
- type TransactionRecord
- type TxStatus
- type ValidationRecord
- type ValidationRecordsIterator
- type Wallet
Constants ¶
const ( // Unknown is the status of a transaction that is unknown Unknown = driver.Unknown // Pending is the status of a transaction that has been submitted to the ledger Pending = driver.Pending // Confirmed is the status of a transaction that has been confirmed by the ledger Confirmed = driver.Confirmed // Deleted is the status of a transaction that has been deleted due to a failure to commit Deleted = driver.Deleted )
const (
// PersistenceTypeConfigKey is the key for the persistence type in the config.
PersistenceTypeConfigKey = "token.ttxdb.persistence.type"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionType ¶
type ActionType = driver.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 DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a database that stores token transactions related information
func Get ¶
func Get(sp view.ServiceProvider, w Wallet) *DB
Get returns the DB for the given wallet. Nil might be returned if the wallet is not found or an error occurred.
func (*DB) 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.
func (*DB) Append ¶
Append appends send and receive movements, and transaction records corresponding to the passed token request
func (*DB) AppendTransactionRecord ¶
AppendTransactionRecord appends the transaction records corresponding to the passed token request.
func (*DB) AppendValidationRecord ¶ added in v0.3.0
AppendValidationRecord appends the given validation metadata related to the given token request and transaction id
func (*DB) GetStatus ¶ added in v0.3.0
GetStatus return the status of the given transaction id. It returns an error if no transaction with that id is found
func (*DB) GetTokenRequest ¶ added in v0.3.0
GetTokenRequest returns the token request bound to the passed transaction id, if available.
func (*DB) NewQueryExecutor ¶
func (db *DB) NewQueryExecutor() *QueryExecutor
NewQueryExecutor returns a new query executor
func (*DB) ReleaseLocks ¶ added in v0.2.0
ReleaseLocks releases the locks associated to the passed anchor
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 string) *HoldingsFilter
func (*HoldingsFilter) Execute ¶
func (f *HoldingsFilter) Execute() (*HoldingsFilter, error)
func (*HoldingsFilter) Sum ¶
func (f *HoldingsFilter) Sum() *big.Int
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the databases
func NewManager ¶
func NewManager(sp view.ServiceProvider, driver string) *Manager
NewManager creates a new DB manager. The driver is the name of the driver to use. If the driver is not supported, an error is returned. If the driver is not specified, the driver is taken from the configuration. If the configuration is not specified, the default driver is used.
type MovementRecord ¶
type MovementRecord = driver.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 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 string) *PaymentsFilter
func (*PaymentsFilter) Execute ¶
func (f *PaymentsFilter) Execute() (*PaymentsFilter, error)
func (*PaymentsFilter) Last ¶
func (f *PaymentsFilter) Last(num int) *PaymentsFilter
func (*PaymentsFilter) Sum ¶
func (f *PaymentsFilter) Sum() *big.Int
type QueryExecutor ¶
type QueryExecutor struct {
// contains filtered or unexported fields
}
QueryExecutor executors queries against the DB
func (*QueryExecutor) Done ¶
func (qe *QueryExecutor) Done()
Done closes the query executor. It must be called when the query executor is no longer needed.s
func (*QueryExecutor) NewHoldingsFilter ¶
func (qe *QueryExecutor) NewHoldingsFilter() *HoldingsFilter
NewHoldingsFilter returns a programmable filter over the holdings owned by enrollment IDs.
func (*QueryExecutor) NewPaymentsFilter ¶
func (qe *QueryExecutor) NewPaymentsFilter() *PaymentsFilter
NewPaymentsFilter returns a programmable filter over the payments sent or received by enrollment IDs.
func (*QueryExecutor) Transactions ¶
func (qe *QueryExecutor) Transactions(params QueryTransactionsParams) (*TransactionIterator, error)
Transactions returns an iterators of transaction records filtered by the given params.
func (*QueryExecutor) ValidationRecords ¶ added in v0.3.0
func (qe *QueryExecutor) ValidationRecords(params QueryValidationRecordsParams) (*ValidationRecordsIterator, error)
ValidationRecords returns an iterators of validation records filtered by the given params.
type QueryTransactionsParams ¶
type QueryTransactionsParams = driver.QueryTransactionsParams
QueryTransactionsParams defines the parameters for querying movements
type QueryValidationRecordsParams ¶ added in v0.3.0
type QueryValidationRecordsParams = driver.QueryValidationRecordsParams
QueryValidationRecordsParams defines the parameters for querying movements
type TransactionIterator ¶
type TransactionIterator struct {
// contains filtered or unexported fields
}
TransactionIterator is an iterator over transaction records
func (*TransactionIterator) Close ¶
func (t *TransactionIterator) Close()
Close closes the iterator. It must be called when done with the iterator.
func (*TransactionIterator) Next ¶
func (t *TransactionIterator) Next() (*TransactionRecord, error)
Next returns the next transaction record, if any. It returns nil, nil if there are no more records.
type TransactionRecord ¶
type TransactionRecord = driver.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 ValidationRecord ¶ added in v0.3.0
type ValidationRecord = driver.ValidationRecord
ValidationRecord 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 ValidationRecordsIterator ¶ added in v0.3.0
type ValidationRecordsIterator struct {
// contains filtered or unexported fields
}
ValidationRecordsIterator is an iterator over validation records
func (*ValidationRecordsIterator) Close ¶ added in v0.3.0
func (t *ValidationRecordsIterator) Close()
Close closes the iterator. It must be called when done with the iterator.
func (*ValidationRecordsIterator) Next ¶ added in v0.3.0
func (t *ValidationRecordsIterator) Next() (*ValidationRecord, error)
Next returns the next validation record, if any. It returns nil, nil if there are no more records.
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