Documentation ¶
Index ¶
- Variables
- func ReadUserConfigValue[T any](db UserConfigReader, key string, defaultValue ...T) T
- type DB
- func (db *DB[Tx]) CountTransactions(matchers ...q.Matcher) (int, error)
- func (db *DB[T]) DeleteUserConfigValue(key string) error
- func (db *DB[T]) DeleteWalletConfigValue(key string) error
- func (db *DB[Tx]) FindTransaction(fieldName string, fieldValue interface{}) (*Tx, error)
- func (db *DB[Tx]) FindTransactions(offset, limit int, sort *SORT, matchers ...q.Matcher) ([]*Tx, error)
- func (db *DB[Tx]) IndexTransaction(tx *Tx) (bool, error)
- func (db *DB[T]) ReadUserConfigValue(key string, valueOut interface{}) error
- func (db *DB[T]) ReadWalletConfigValue(key string, valueOut interface{}) error
- func (db *DB[Tx]) RollbackTxIndexLastBlock(height int32) error
- func (db *DB[Tx]) SaveTxIndexLastBlock(height int32) error
- func (db *DB[T]) SaveUserConfigValue(key string, value interface{}) error
- func (db *DB[T]) SaveWalletConfigValue(key string, value interface{}) error
- func (db *DB[Tx]) TxIndexLastBlock() (int32, error)
- type SORT
- type TxIndexDB
- type TxIndexDBConfig
- type UserConfigDB
- type UserConfigReader
- type WalletConfigDB
Constants ¶
This section is empty.
Variables ¶
var ErrTxIndexNotSupported = fmt.Errorf("database isn't configured for tx indexing")
Functions ¶
func ReadUserConfigValue ¶
func ReadUserConfigValue[T any](db UserConfigReader, key string, defaultValue ...T) T
Types ¶
type DB ¶
type DB[Tx any] struct { // contains filtered or unexported fields }
DB is a storm-backed database for storing simple information in key-value pairs for a wallet. It can also be optionally used to index a wallet's transactions for subsequent quick querying and filtering.
func Initialize ¶
func Initialize[Tx any](dbPath string, txIndexCfg *TxIndexDBConfig[Tx]) (*DB[Tx], error)
Initialize creates or open a database at the specified path. txIndexCfg is optional but must be provided if the database will be used for transaction indexing. If txIndexCfg.txVersion is different from the version last used by this database, the transactions index will be dropped and the wallet's transactions will need to be re-indexed.
func (*DB[Tx]) CountTransactions ¶
CountTransactions returns the number of transactions that match the specified criteria.
func (*DB[T]) DeleteUserConfigValue ¶
DeleteUserConfigValue deletes the user config data with the specified key.
func (*DB[T]) DeleteWalletConfigValue ¶
DeleteWalletConfigValue deletes the wallet config data with the specified key.
func (*DB[Tx]) FindTransaction ¶
FindTransaction looks up a transaction that has the specified value in the specified field. It's not an error if no transaction is found to match this criteria, instead a nil tx and a nil error are returned.
func (*DB[Tx]) FindTransactions ¶
func (db *DB[Tx]) FindTransactions(offset, limit int, sort *SORT, matchers ...q.Matcher) ([]*Tx, error)
FindTransactions looks up and returns transactions that match the specified criteria and in the order specified by the sort argument. It is not an error if no transaction is found to match the provided criteria, instead an empty tx list and a nil error are returned. If no matcher is passed, all indexed transactions will be returned.
func (*DB[Tx]) IndexTransaction ¶
IndexTransaction saves a transaction to the indexed transactions db. Returns true if the tx was previously saved.
func (*DB[T]) ReadUserConfigValue ¶
ReadUserConfigValue reads user configuration data from the database.
func (*DB[T]) ReadWalletConfigValue ¶
ReadWalletConfigValue reads wallet configuration data from the database.
func (*DB[Tx]) RollbackTxIndexLastBlock ¶
RollbackTxIndexLastBlock is like SaveTxIndexLastBlock but it also deletes all previously indexed transactions whose block heights are above the specified height to allow subsequent re-indexing from the specified height+1.
func (*DB[Tx]) SaveTxIndexLastBlock ¶
SaveTxIndexLastBlock saves the specified height as the last block height for which transactions are indexed. Subsequent tx indexing should start from this height+1.
func (*DB[T]) SaveUserConfigValue ¶
SaveUserConfigValue saves user configuration data as a key-value pair.
func (*DB[T]) SaveWalletConfigValue ¶
SaveWalletConfigValue saves wallet configuration data as a key-value pair.
func (*DB[Tx]) TxIndexLastBlock ¶
TxIndexLastBlock returns the highest block height for which transactions are indexed.
type SORT ¶
type SORT struct {
// contains filtered or unexported fields
}
func SortAscending ¶
func SortDescending ¶
type TxIndexDB ¶
type TxIndexDB[T any] interface { TxIndexLastBlock() (int32, error) SaveTxIndexLastBlock(height int32) error RollbackTxIndexLastBlock(height int32) error IndexTransaction(tx *T) (bool, error) FindTransaction(fieldName string, fieldValue interface{}) (*T, error) FindTransactions(offset, limit int, sort *SORT, matchers ...q.Matcher) ([]*T, error) CountTransactions(matchers ...q.Matcher) (int, error) }
TxIndexDB defines methods for saving and reading transactions to/from an indexed database.
type TxIndexDBConfig ¶
type TxIndexDBConfig[Tx any] struct { // contains filtered or unexported fields }
TxIndexDBConfig contains properties that are necessary for transaction indexing.
func NewTxIndexDBConfig ¶
func NewTxIndexDBConfig[Tx any](txVersion uint32, txIDField, txBlockHeightField string, makeEmptyTx func() *Tx, txUpdateHook func(oldTx, newTx *Tx) (*Tx, error)) *TxIndexDBConfig[Tx]
NewTxIndexDBConfig creates a TxIndexDBConfig.
type UserConfigDB ¶
type UserConfigDB interface { SaveUserConfigValue(key string, value interface{}) error ReadUserConfigValue(key string, valueOut interface{}) error DeleteUserConfigValue(key string) error }
UserConfigDB defines methods for writing and reading user config information to/from a persistent data store.
type UserConfigReader ¶
type WalletConfigDB ¶
type WalletConfigDB interface { SaveWalletConfigValue(key string, value interface{}) error ReadWalletConfigValue(key string, valueOut interface{}) error DeleteWalletConfigValue(key string) error }
WalletConfigDB defines methods for writing and reading wallet config information to/from a persistent data store.