Documentation ¶
Index ¶
- Constants
- type BTCBucket
- func (b *BTCBucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error)
- func (b *BTCBucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error)
- func (b *BTCBucket) Delete(key []byte) error
- func (b *BTCBucket) DeleteNestedBucket(key []byte) error
- func (b *BTCBucket) ForEach(fn func(k, v []byte) error) error
- func (b *BTCBucket) Get(key []byte) []byte
- func (b *BTCBucket) NestedReadBucket(key []byte) walletdb.ReadBucket
- func (b *BTCBucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket
- func (b *BTCBucket) NextSequence() (uint64, error)
- func (b *BTCBucket) Put(key, value []byte) error
- func (b *BTCBucket) ReadCursor() walletdb.ReadCursor
- func (b *BTCBucket) ReadWriteCursor() walletdb.ReadWriteCursor
- func (b *BTCBucket) Sequence() uint64
- func (b *BTCBucket) SetSequence(v uint64) error
- func (b *BTCBucket) Tx() walletdb.ReadWriteTx
- type BTCDB
- func (db *BTCDB) BeginReadTx() (walletdb.ReadTx, error)
- func (db *BTCDB) BeginReadWriteTx() (walletdb.ReadWriteTx, error)
- func (db *BTCDB) Close() error
- func (db *BTCDB) Copy(w io.Writer) error
- func (db *BTCDB) PrintStats() string
- func (db *BTCDB) Update(f func(tx walletdb.ReadWriteTx) error, reset func()) error
- func (db *BTCDB) View(f func(tx walletdb.ReadTx) error, reset func()) error
- type BTCTX
- func (tx *BTCTX) Commit() error
- func (tx *BTCTX) CreateTopLevelBucket(key []byte) (walletdb.ReadWriteBucket, error)
- func (tx *BTCTX) DeleteTopLevelBucket(key []byte) error
- func (tx *BTCTX) ForEachBucket(fn func(key []byte) error) error
- func (tx *BTCTX) OnCommit(f func())
- func (tx *BTCTX) ReadBucket(key []byte) walletdb.ReadBucket
- func (tx *BTCTX) ReadWriteBucket(key []byte) walletdb.ReadWriteBucket
- func (tx *BTCTX) Rollback() error
- type DB
- func (db *DB) ClearSavedTransactions(emptyTxPointer interface{}) error
- func (db *DB) Close() error
- func (db *DB) Count(txFilter int32, requiredConfirmations, bestBlock int32, txObj interface{}) (int, error)
- func (db *DB) Find(matcher q.Matcher, transactions interface{}) error
- func (db *DB) FindAll(fieldName string, value interface{}, txObj interface{}) error
- func (db *DB) FindLast(fieldName string, value interface{}, txObj interface{}) error
- func (db *DB) FindOne(fieldName string, value interface{}, obj interface{}) error
- func (db *DB) LastIndexPoint() (int32, error)
- func (db *DB) Read(offset, limit, txFilter int32, newestFirst bool, ...) error
- func (db *DB) ReadIndexingStartBlock() (int32, error)
- func (db *DB) SaveLastIndexPoint(endBlockHeight int32) error
- func (db *DB) SaveOrUpdate(emptyTxPointer, record interface{}) (overwritten bool, err error)
- func (db *DB) SaveOrUpdateVspdRecord(emptyTxPointer, record interface{}) (updated bool, err error)
- func (db *DB) SetTicketExpiry(val int32) *DB
- func (db *DB) SetTicketMaturity(val int32) *DB
- type LTCBucket
- func (b *LTCBucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error)
- func (b *LTCBucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error)
- func (b *LTCBucket) Delete(key []byte) error
- func (b *LTCBucket) DeleteNestedBucket(key []byte) error
- func (b *LTCBucket) ForEach(fn func(k, v []byte) error) error
- func (b *LTCBucket) Get(key []byte) []byte
- func (b *LTCBucket) NestedReadBucket(key []byte) walletdb.ReadBucket
- func (b *LTCBucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket
- func (b *LTCBucket) NextSequence() (uint64, error)
- func (b *LTCBucket) Put(key, value []byte) error
- func (b *LTCBucket) ReadCursor() walletdb.ReadCursor
- func (b *LTCBucket) ReadWriteCursor() walletdb.ReadWriteCursor
- func (b *LTCBucket) Sequence() uint64
- func (b *LTCBucket) SetSequence(v uint64) error
- func (b *LTCBucket) Tx() walletdb.ReadWriteTx
- type LTCDB
- func (db *LTCDB) BeginReadTx() (walletdb.ReadTx, error)
- func (db *LTCDB) BeginReadWriteTx() (walletdb.ReadWriteTx, error)
- func (db *LTCDB) Close() error
- func (db *LTCDB) Copy(w io.Writer) error
- func (db *LTCDB) PrintStats() string
- func (db *LTCDB) Update(f func(tx walletdb.ReadWriteTx) error, reset func()) error
- func (db *LTCDB) View(f func(tx walletdb.ReadTx) error, reset func()) error
- type LTCTX
- func (tx *LTCTX) Commit() error
- func (tx *LTCTX) CreateTopLevelBucket(key []byte) (walletdb.ReadWriteBucket, error)
- func (tx *LTCTX) DeleteTopLevelBucket(key []byte) error
- func (tx *LTCTX) ForEachBucket(fn func(key []byte) error) error
- func (tx *LTCTX) OnCommit(f func())
- func (tx *LTCTX) ReadBucket(key []byte) walletdb.ReadBucket
- func (tx *LTCTX) ReadWriteBucket(key []byte) walletdb.ReadWriteBucket
- func (tx *LTCTX) Rollback() error
Constants ¶
const ( DCRDbName = "walletData.db" BTCDBName = "neutrino.db" LTCDBName = "neutrino.db" OldDbName = "tx.db" TxBucketName = "TxIndexInfo" KeyDbVersion = "DbVersion" // TxDbVersion is necessary to force re-indexing if changes are made to the structure of data being stored. // Increment this version number if db structure changes such that client apps need to re-index. TxDbVersion uint32 = 3 )
const KeyEndBlock = "EndBlock"
const MaxReOrgBlocks = 6
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BTCBucket ¶
type BTCBucket struct {
// contains filtered or unexported fields
}
func (*BTCBucket) CreateBucket ¶
func (b *BTCBucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error)
CreateBucket creates and returns a new nested bucket with the given key. Returns ErrBucketExists if the bucket already exists, ErrBucketNameRequired if the key is empty, or ErrIncompatibleValue if the key value is otherwise invalid for the particular database implementation. Other errors are possible depending on the implementation.
func (*BTCBucket) CreateBucketIfNotExists ¶
func (b *BTCBucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error)
CreateBucketIfNotExists creates and returns a new nested bucket with the given key if it does not already exist. Returns ErrBucketNameRequired if the key is empty or ErrIncompatibleValue if the key value is otherwise invalid for the particular database backend. Other errors are possible depending on the implementation.
func (*BTCBucket) Delete ¶
Delete removes the specified key from the bucket. Deleting a key that does not exist does not return an error. Returns ErrTxNotWritable if attempted against a read-only transaction.
func (*BTCBucket) DeleteNestedBucket ¶
DeleteNestedBucket removes a nested bucket with the given key. Returns ErrTxNotWritable if attempted against a read-only transaction and ErrBucketNotFound if the specified bucket does not exist.
func (*BTCBucket) ForEach ¶
ForEach invokes the passed function with every key/value pair in the bucket. This includes nested buckets, in which case the value is nil, but it does not include the key/value pairs within those nested buckets.
NOTE: The values returned by this function are only valid during a transaction. Attempting to access them after a transaction has ended results in undefined behavior. This constraint prevents additional data copies and allows support for memory-mapped database implementations.
func (*BTCBucket) Get ¶
Get returns the value for the given key. Returns nil if the key does not exist in this bucket (or nested buckets).
NOTE: The value returned by this function is only valid during a transaction. Attempting to access it after a transaction has ended results in undefined behavior. This constraint prevents additional data copies and allows support for memory-mapped database implementations.
func (*BTCBucket) NestedReadBucket ¶
func (b *BTCBucket) NestedReadBucket(key []byte) walletdb.ReadBucket
NestedReadBucket retrieves a nested bucket with the given key. Returns nil if the bucket does not exist.
func (*BTCBucket) NestedReadWriteBucket ¶
func (b *BTCBucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket
NestedReadWriteBucket retrieves a nested bucket with the given key. Returns nil if the bucket does not exist.
func (*BTCBucket) NextSequence ¶
NextSequence returns an autoincrementing integer for the bucket.
func (*BTCBucket) Put ¶
Put saves the specified key/value pair to the bucket. Keys that do not already exist are added and keys that already exist are overwritten. Returns ErrTxNotWritable if attempted against a read-only transaction.
func (*BTCBucket) ReadCursor ¶
func (b *BTCBucket) ReadCursor() walletdb.ReadCursor
func (*BTCBucket) ReadWriteCursor ¶
func (b *BTCBucket) ReadWriteCursor() walletdb.ReadWriteCursor
ReadWriteCursor returns a new cursor, allowing for iteration over the bucket's key/value pairs and nested buckets in forward or backward order.
func (*BTCBucket) Sequence ¶
Sequence returns the current integer for the bucket without incrementing it.
func (*BTCBucket) SetSequence ¶
SetSequence updates the sequence number for the bucket.
func (*BTCBucket) Tx ¶
func (b *BTCBucket) Tx() walletdb.ReadWriteTx
Tx returns the bucket's transaction.
type BTCDB ¶
func (*BTCDB) BeginReadTx ¶
BeginReadTx opens a database read transaction.
func (*BTCDB) BeginReadWriteTx ¶
func (db *BTCDB) BeginReadWriteTx() (walletdb.ReadWriteTx, error)
BeginReadWriteTx opens a database read+write transaction.
func (*BTCDB) Copy ¶
Copy writes a copy of the database to the provided writer. This call will start a read-only transaction to perform all operations.
func (*BTCDB) PrintStats ¶
PrintStats returns all collected stats pretty printed into a string.
func (*BTCDB) Update ¶
func (db *BTCDB) Update(f func(tx walletdb.ReadWriteTx) error, reset func()) error
Update opens a database read/write transaction and executes the function f with the transaction passed as a parameter. After f exits, if f did not error, the transaction is committed. Otherwise, if f did error, the transaction is rolled back. If the rollback fails, the original error returned by f is still returned. If the commit fails, the commit error is returned. As callers may expect retries of the f closure (depending on the database backend used), the reset function will be called before each retry respectively.
NOTE: For new code, this method should be used directly instead of the package level Update() function.
func (*BTCDB) View ¶
View opens a database read transaction and executes the function f with the transaction passed as a parameter. After f exits, the transaction is rolled back. If f errors, its error is returned, not a rollback error (if any occur). The passed reset function is called before the start of the transaction and can be used to reset intermediate state. As callers may expect retries of the f closure (depending on the database backend used), the reset function will be called before each retry respectively.
NOTE: For new code, this method should be used directly instead of the package level View() function.
type BTCTX ¶
type BTCTX struct {
// contains filtered or unexported fields
}
func (*BTCTX) Commit ¶
Commit commits all changes that have been on the transaction's root buckets and all of their sub-buckets to persistent storage.
func (*BTCTX) CreateTopLevelBucket ¶
func (tx *BTCTX) CreateTopLevelBucket(key []byte) (walletdb.ReadWriteBucket, error)
CreateTopLevelBucket creates the top level bucket for a key if it does not exist. The newly-created bucket it returned.
func (*BTCTX) DeleteTopLevelBucket ¶
DeleteTopLevelBucket deletes the top level bucket for a key. This errors if the bucket can not be found or the key keys a single value instead of a bucket.
func (*BTCTX) ForEachBucket ¶
ForEachBucket will iterate through all top level buckets.
func (*BTCTX) OnCommit ¶
func (tx *BTCTX) OnCommit(f func())
OnCommit takes a function closure that will be executed when the transaction successfully gets committed.
func (*BTCTX) ReadBucket ¶
func (tx *BTCTX) ReadBucket(key []byte) walletdb.ReadBucket
ReadBucket opens the root bucket for read only access. If the bucket described by the key does not exist, nil is returned.
func (*BTCTX) ReadWriteBucket ¶
func (tx *BTCTX) ReadWriteBucket(key []byte) walletdb.ReadWriteBucket
ReadWriteBucket opens the root bucket for read/write access. If the bucket described by the key does not exist, nil is returned.
type DB ¶
func Initialize ¶
Initialize opens the existing storm db at `dbPath` and checks the database version for compatibility. If there is a version mismatch or the db does not exist at `dbPath`, a new db is created and the current db version number saved to the db.
func (*DB) ClearSavedTransactions ¶
func (*DB) Count ¶
func (db *DB) Count(txFilter int32, requiredConfirmations, bestBlock int32, txObj interface{}) (int, error)
Count queries the db for transactions of the `txObj` type to return the number of records matching the specified `txFilter`.
func (*DB) LastIndexPoint ¶
func (*DB) Read ¶
func (db *DB) Read(offset, limit, txFilter int32, newestFirst bool, requiredConfirmations, bestBlock int32, transactions interface{}) error
Read queries the db for `limit` count transactions that match the specified `txFilter` starting from the specified `offset`; and saves the transactions found to the received `transactions` object. `transactions` should be a pointer to a slice of Transaction objects.
func (*DB) ReadIndexingStartBlock ¶
ReadIndexingStartBlock checks if the end block height was saved from last indexing operation. If so, the end block height - MaxReOrgBlocks is returned. Otherwise, 0 is returned to begin indexing from height 0.
func (*DB) SaveLastIndexPoint ¶
func (*DB) SaveOrUpdate ¶
SaveOrUpdate saves a transaction to the database and would overwrite if a transaction with same hash exists
func (*DB) SaveOrUpdateVspdRecord ¶
func (*DB) SetTicketExpiry ¶
SetTicketExpiry sets the ticket expiry value required when filtering txs
func (*DB) SetTicketMaturity ¶
SetTicketMaturity sets the ticket maturity value required when filterig txs.
type LTCBucket ¶
type LTCBucket struct {
// contains filtered or unexported fields
}
func (*LTCBucket) CreateBucket ¶
func (b *LTCBucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error)
CreateBucket creates and returns a new nested bucket with the given key. Returns ErrBucketExists if the bucket already exists, ErrBucketNameRequired if the key is empty, or ErrIncompatibleValue if the key value is otherwise invalid for the particular database implementation. Other errors are possible depending on the implementation.
func (*LTCBucket) CreateBucketIfNotExists ¶
func (b *LTCBucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error)
CreateBucketIfNotExists creates and returns a new nested bucket with the given key if it does not already exist. Returns ErrBucketNameRequired if the key is empty or ErrIncompatibleValue if the key value is otherwise invalid for the particular database backend. Other errors are possible depending on the implementation.
func (*LTCBucket) Delete ¶
Delete removes the specified key from the bucket. Deleting a key that does not exist does not return an error. Returns ErrTxNotWritable if attempted against a read-only transaction.
func (*LTCBucket) DeleteNestedBucket ¶
DeleteNestedBucket removes a nested bucket with the given key. Returns ErrTxNotWritable if attempted against a read-only transaction and ErrBucketNotFound if the specified bucket does not exist.
func (*LTCBucket) ForEach ¶
ForEach invokes the passed function with every key/value pair in the bucket. This includes nested buckets, in which case the value is nil, but it does not include the key/value pairs within those nested buckets.
NOTE: The values returned by this function are only valid during a transaction. Attempting to access them after a transaction has ended results in undefined behavior. This constraint prevents additional data copies and allows support for memory-mapped database implementations.
func (*LTCBucket) Get ¶
Get returns the value for the given key. Returns nil if the key does not exist in this bucket (or nested buckets).
NOTE: The value returned by this function is only valid during a transaction. Attempting to access it after a transaction has ended results in undefined behavior. This constraint prevents additional data copies and allows support for memory-mapped database implementations.
func (*LTCBucket) NestedReadBucket ¶
func (b *LTCBucket) NestedReadBucket(key []byte) walletdb.ReadBucket
NestedReadBucket retrieves a nested bucket with the given key. Returns nil if the bucket does not exist.
func (*LTCBucket) NestedReadWriteBucket ¶
func (b *LTCBucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket
NestedReadWriteBucket retrieves a nested bucket with the given key. Returns nil if the bucket does not exist.
func (*LTCBucket) NextSequence ¶
NextSequence returns an autoincrementing integer for the bucket.
func (*LTCBucket) Put ¶
Put saves the specified key/value pair to the bucket. Keys that do not already exist are added and keys that already exist are overwritten. Returns ErrTxNotWritable if attempted against a read-only transaction.
func (*LTCBucket) ReadCursor ¶
func (b *LTCBucket) ReadCursor() walletdb.ReadCursor
func (*LTCBucket) ReadWriteCursor ¶
func (b *LTCBucket) ReadWriteCursor() walletdb.ReadWriteCursor
ReadWriteCursor returns a new cursor, allowing for iteration over the bucket's key/value pairs and nested buckets in forward or backward order.
func (*LTCBucket) Sequence ¶
Sequence returns the current integer for the bucket without incrementing it.
func (*LTCBucket) SetSequence ¶
SetSequence updates the sequence number for the bucket.
func (*LTCBucket) Tx ¶
func (b *LTCBucket) Tx() walletdb.ReadWriteTx
Tx returns the bucket's transaction.
type LTCDB ¶
func (*LTCDB) BeginReadTx ¶
BeginReadTx opens a database read transaction.
func (*LTCDB) BeginReadWriteTx ¶
func (db *LTCDB) BeginReadWriteTx() (walletdb.ReadWriteTx, error)
BeginReadWriteTx opens a database read+write transaction.
func (*LTCDB) Copy ¶
Copy writes a copy of the database to the provided writer. This call will start a read-only transaction to perform all operations.
func (*LTCDB) PrintStats ¶
PrintStats returns all collected stats pretty printed into a string.
func (*LTCDB) Update ¶
func (db *LTCDB) Update(f func(tx walletdb.ReadWriteTx) error, reset func()) error
Update opens a database read/write transaction and executes the function f with the transaction passed as a parameter. After f exits, if f did not error, the transaction is committed. Otherwise, if f did error, the transaction is rolled back. If the rollback fails, the original error returned by f is still returned. If the commit fails, the commit error is returned. As callers may expect retries of the f closure (depending on the database backend used), the reset function will be called before each retry respectively.
NOTE: For new code, this method should be used directly instead of the package level Update() function.
func (*LTCDB) View ¶
View opens a database read transaction and executes the function f with the transaction passed as a parameter. After f exits, the transaction is rolled back. If f errors, its error is returned, not a rollback error (if any occur). The passed reset function is called before the start of the transaction and can be used to reset intermediate state. As callers may expect retries of the f closure (depending on the database backend used), the reset function will be called before each retry respectively.
NOTE: For new code, this method should be used directly instead of the package level View() function.
type LTCTX ¶
type LTCTX struct {
// contains filtered or unexported fields
}
func (*LTCTX) Commit ¶
Commit commits all changes that have been on the transaction's root buckets and all of their sub-buckets to persistent storage.
func (*LTCTX) CreateTopLevelBucket ¶
func (tx *LTCTX) CreateTopLevelBucket(key []byte) (walletdb.ReadWriteBucket, error)
CreateTopLevelBucket creates the top level bucket for a key if it does not exist. The newly-created bucket it returned.
func (*LTCTX) DeleteTopLevelBucket ¶
DeleteTopLevelBucket deletes the top level bucket for a key. This errors if the bucket can not be found or the key keys a single value instead of a bucket.
func (*LTCTX) ForEachBucket ¶
ForEachBucket will iterate through all top level buckets.
func (*LTCTX) OnCommit ¶
func (tx *LTCTX) OnCommit(f func())
OnCommit takes a function closure that will be executed when the transaction successfully gets committed.
func (*LTCTX) ReadBucket ¶
func (tx *LTCTX) ReadBucket(key []byte) walletdb.ReadBucket
ReadBucket opens the root bucket for read only access. If the bucket described by the key does not exist, nil is returned.
func (*LTCTX) ReadWriteBucket ¶
func (tx *LTCTX) ReadWriteBucket(key []byte) walletdb.ReadWriteBucket
ReadWriteBucket opens the root bucket for read/write access. If the bucket described by the key does not exist, nil is returned.