Documentation ¶
Overview ¶
Package storage contains ledger storage implementation on top of BadgerDB engine.
Index ¶
- Variables
- type DB
- func (db *DB) BeginTransaction(update bool) *TransactionManager
- func (db *DB) Bootstrap() error
- func (db *DB) Close() error
- func (db *DB) Get(key []byte) ([]byte, error)
- func (db *DB) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)
- func (db *DB) GetCurrentPulse() record.PulseNum
- func (db *DB) GetDrop(pulse record.PulseNum) (*jetdrop.JetDrop, error)
- func (db *DB) GetEntropy(pulse record.PulseNum) ([]byte, error)
- func (db *DB) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)
- func (db *DB) GetRecord(ref *record.Reference) (record.Record, error)
- func (db *DB) GetSlotHashes(n record.PulseNum) ([][]byte, error)
- func (db *DB) ProcessSlotHashes(n record.PulseNum, ifn func(it HashIterator) error) error
- func (db *DB) RootRef() *record.Reference
- func (db *DB) Set(key, value []byte) error
- func (db *DB) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error
- func (db *DB) SetCurrentPulse(pulse record.PulseNum)
- func (db *DB) SetDrop(pulse record.PulseNum, prevdrop *jetdrop.JetDrop) (*jetdrop.JetDrop, error)
- func (db *DB) SetEntropy(pulse record.PulseNum, entropy []byte) error
- func (db *DB) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error
- func (db *DB) SetRecord(rec record.Record) (ref *record.Reference, err error)
- func (db *DB) SetTxRetiries(n int)
- func (db *DB) Update(fn func(*TransactionManager) error) error
- func (db *DB) View(fn func(*TransactionManager) error) error
- type HashIterator
- type Store
- type TransactionManager
- func (m *TransactionManager) Commit() error
- func (m *TransactionManager) Discard()
- func (m *TransactionManager) Get(key []byte) ([]byte, error)
- func (m *TransactionManager) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)
- func (m *TransactionManager) GetEntropy(pulse record.PulseNum) ([]byte, error)
- func (m *TransactionManager) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)
- func (m *TransactionManager) GetRecord(ref *record.Reference) (record.Record, error)
- func (m *TransactionManager) Set(key, value []byte) error
- func (m *TransactionManager) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error
- func (m *TransactionManager) SetEntropy(pulse record.PulseNum, entropy []byte) error
- func (m *TransactionManager) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error
- func (m *TransactionManager) SetRecord(rec record.Record) (*record.Reference, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound returns if record/index not found in storage. ErrNotFound = errors.New("storage object not found") // ErrConflictRetriesOver is returned if Update transaction fails on all retry attempts. ErrConflictRetriesOver = errors.New("Transaction Conflict retries exceeded") // ErrConflict is the alias for badger.ErrConflict. ErrConflict = badger.ErrConflict )
Functions ¶
This section is empty.
Types ¶
type DB ¶ added in v0.0.6
type DB struct {
// contains filtered or unexported fields
}
DB represents BadgerDB storage implementation.
func NewDB ¶ added in v0.0.6
NewDB returns storage.DB with BadgerDB instance initialized by opts. Creates database in provided dir or in current directory if dir parameter is empty.
func (*DB) BeginTransaction ¶ added in v0.0.6
func (db *DB) BeginTransaction(update bool) *TransactionManager
BeginTransaction opens a new transaction. All methods called on returned transaction manager will persist changes only after success on "Commit" call.
func (*DB) Close ¶ added in v0.0.6
Close wraps BadgerDB Close method.
From https://godoc.org/github.com/dgraph-io/badger#DB.Close: «It's crucial to call it to ensure all the pending updates make their way to disk. Calling DB.Close() multiple times is not safe and wouldcause panic.»
func (*DB) GetClassIndex ¶ added in v0.0.6
GetClassIndex wraps matching transaction manager method.
func (*DB) GetCurrentPulse ¶ added in v0.0.6
GetCurrentPulse returns current pulse number.
func (*DB) GetEntropy ¶ added in v0.0.6
GetEntropy wraps matching transaction manager method.
func (*DB) GetObjectIndex ¶ added in v0.0.6
GetObjectIndex wraps matching transaction manager method.
func (*DB) GetSlotHashes ¶ added in v0.0.6
GetSlotHashes returns array of all record's hashes in provided PulseNum.
func (*DB) ProcessSlotHashes ¶ added in v0.0.6
ProcessSlotHashes executes a iteration function ifn and provides HashIterator inside it to iterate over all records hashes with the same record.PulseNum.
Error returned by the ProcessSlotRecords is based on iteration function result or BadgerDB iterator error if any.
func (*DB) RootRef ¶ added in v0.0.6
RootRef returns the root record reference.
Root record is the parent for all top-level records.
func (*DB) SetClassIndex ¶ added in v0.0.6
SetClassIndex wraps matching transaction manager method.
func (*DB) SetCurrentPulse ¶ added in v0.0.6
SetCurrentPulse sets current pulse number.
func (*DB) SetDrop ¶ added in v0.0.6
SetDrop stores jet drop for given pulse number.
Previous JetDrop should be provided. On success returns saved drop hash.
func (*DB) SetEntropy ¶ added in v0.0.6
SetEntropy wraps matching transaction manager method.
func (*DB) SetObjectIndex ¶ added in v0.0.6
SetObjectIndex wraps matching transaction manager method.
func (*DB) SetTxRetiries ¶ added in v0.0.6
SetTxRetiries sets number of retries on conflict in Update
type HashIterator ¶ added in v0.0.6
type HashIterator interface { // Next moves the iterator to the next key/value pair. // It returns false then iterator is exhausted. Next() bool // Hash returns record's hash copy. That allows use returned value // on any iteration step or outside of iteration function. Hash() []byte // ShallowHash returns unsafe record's hash, that could be used only // in current iteration step. It could be useful for processing hashes // on the fly to avoid unnecessary copy and memory allocations. ShallowHash() []byte }
HashIterator iterates over a database record's hashes. An iterator provides methods for record's hash access.
HashIterator supposed to be used only in functions like ProcessSlotHashes. Any release of iterator resources not needed.
type Store ¶ added in v0.0.5
type Store interface { GetRecord(ref *record.Reference) (record.Record, error) SetRecord(rec record.Record) (*record.Reference, error) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error }
Store is used by context unaware clients who can work inside transactions as well as outside.
type TransactionManager ¶ added in v0.0.6
type TransactionManager struct {
// contains filtered or unexported fields
}
TransactionManager is used to ensure persistent writes to disk.
func (*TransactionManager) Commit ¶ added in v0.0.6
func (m *TransactionManager) Commit() error
Commit tries to write transaction on disk. Returns error on fail.
func (*TransactionManager) Discard ¶ added in v0.0.6
func (m *TransactionManager) Discard()
Discard terminates transaction without disk writes.
func (*TransactionManager) Get ¶ added in v0.0.6
func (m *TransactionManager) Get(key []byte) ([]byte, error)
Get returns value by key.
func (*TransactionManager) GetClassIndex ¶ added in v0.0.6
func (m *TransactionManager) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)
GetClassIndex fetches class lifeline's index.
func (*TransactionManager) GetEntropy ¶ added in v0.0.6
func (m *TransactionManager) GetEntropy(pulse record.PulseNum) ([]byte, error)
GetEntropy returns entropy from storage for given pulse.
Entropy is used for calculating node roles.
func (*TransactionManager) GetObjectIndex ¶ added in v0.0.6
func (m *TransactionManager) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)
GetObjectIndex fetches object lifeline index.
func (*TransactionManager) GetRecord ¶ added in v0.0.6
GetRecord returns record from BadgerDB by *record.Reference.
It returns ErrNotFound if the DB does not contain the key.
func (*TransactionManager) Set ¶ added in v0.0.6
func (m *TransactionManager) Set(key, value []byte) error
Set stores value by key.
func (*TransactionManager) SetClassIndex ¶ added in v0.0.6
func (m *TransactionManager) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error
SetClassIndex stores class lifeline index.
func (*TransactionManager) SetEntropy ¶ added in v0.0.6
func (m *TransactionManager) SetEntropy(pulse record.PulseNum, entropy []byte) error
SetEntropy stores given entropy for given pulse in storage.
Entropy is used for calculating node roles.
func (*TransactionManager) SetObjectIndex ¶ added in v0.0.6
func (m *TransactionManager) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error
SetObjectIndex stores object lifeline index.
Directories ¶
Path | Synopsis |
---|---|
Package storagetest contains high level API tests and test utils for other modules.
|
Package storagetest contains high level API tests and test utils for other modules. |