Documentation ¶
Overview ¶
Package leveldb contains ledger implementation on top of Go's LevelDB engine
Index ¶
- type HashIterator
- type LevelLedger
- func (ll *LevelLedger) Close() error
- func (ll *LevelLedger) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)
- func (ll *LevelLedger) GetCurrentPulse() record.PulseNum
- func (ll *LevelLedger) GetDrop(pulse record.PulseNum) (*jetdrop.JetDrop, error)
- func (ll *LevelLedger) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)
- func (ll *LevelLedger) GetRecord(ref *record.Reference) (record.Record, error)
- func (ll *LevelLedger) GetSlotHashes(n record.PulseNum) ([][]byte, error)
- func (ll *LevelLedger) ProcessSlotRecords(n record.PulseNum, ifn func(it HashIterator) error) error
- func (ll *LevelLedger) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error
- func (ll *LevelLedger) SetDrop(pulse record.PulseNum, prevdrop *jetdrop.JetDrop) (*jetdrop.JetDrop, error)
- func (ll *LevelLedger) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error
- func (ll *LevelLedger) SetPulseFn(fn PulseFn)
- func (ll *LevelLedger) SetRecord(rec record.Record) (*record.Reference, error)
- type PulseFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashIterator ¶ added in v0.0.4
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 overs a DB's keys. An iterator provides methods for record hash extraction.
HashIterator supposed to be used only in functions like ProcessSlotRecords. Any release of iterator's resources like in native leveldb iterators (see github.com/syndtr/goleveldb/leveldb/iterator) not needed.
type LevelLedger ¶
type LevelLedger struct {
// contains filtered or unexported fields
}
LevelLedger represents ledger's LevelDB storage.
func InitDB ¶
func InitDB(dir string, opts *opt.Options) (*LevelLedger, error)
InitDB returns LevelDB ledger implementation.
func (*LevelLedger) GetClassIndex ¶
func (ll *LevelLedger) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)
GetClassIndex fetches lifeline index from leveldb
func (*LevelLedger) GetCurrentPulse ¶ added in v0.0.3
func (ll *LevelLedger) GetCurrentPulse() record.PulseNum
GetCurrentPulse return currently stored pulse.
func (*LevelLedger) GetObjectIndex ¶
func (ll *LevelLedger) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)
GetObjectIndex fetches lifeline index from leveldb
func (*LevelLedger) GetRecord ¶
GetRecord returns record from leveldb by *record.Reference.
It returns ErrNotFound if the DB does not contains the key.
func (*LevelLedger) GetSlotHashes ¶ added in v0.0.4
func (ll *LevelLedger) GetSlotHashes(n record.PulseNum) ([][]byte, error)
GetSlotHashes returns array of all record's hashes in provided PulseNum.
func (*LevelLedger) ProcessSlotRecords ¶ added in v0.0.4
func (ll *LevelLedger) ProcessSlotRecords(n record.PulseNum, ifn func(it HashIterator) error) error
ProcessSlotRecords executes a iteration function and provides HashIterator to iterate all records with the same record.PulseNum.
Error returned by the ProcessSlotRecords is based on iteration function result or leveldb iterator error if any.
func (*LevelLedger) SetClassIndex ¶
func (ll *LevelLedger) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error
SetClassIndex stores lifeline index into leveldb
func (*LevelLedger) SetDrop ¶ added in v0.0.3
func (ll *LevelLedger) SetDrop(pulse record.PulseNum, prevdrop *jetdrop.JetDrop) (*jetdrop.JetDrop, error)
SetDrop stores jet drop for given pulse number. Previous JetDrop should be provided. On success returns saved drop hash.
func (*LevelLedger) SetObjectIndex ¶
func (ll *LevelLedger) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error
SetObjectIndex stores lifeline index into leveldb
func (*LevelLedger) SetPulseFn ¶ added in v0.0.4
func (ll *LevelLedger) SetPulseFn(fn PulseFn)
SetPulseFn allows redefine pulse function.
Directories ¶
Path | Synopsis |
---|---|
Package leveltestutils provides sharable utils for testing LevelDB ledger implementation.
|
Package leveltestutils provides sharable utils for testing LevelDB ledger implementation. |