leveldb

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package leveldb contains ledger implementation on top of Go's LevelDB engine

Index

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) Close

func (ll *LevelLedger) Close() error

Close terminates db connection

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) GetDrop added in v0.0.3

func (ll *LevelLedger) GetDrop(pulse record.PulseNum) (*jetdrop.JetDrop, error)

GetDrop returns jet drop for a given pulse number.

func (*LevelLedger) GetObjectIndex

func (ll *LevelLedger) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)

GetObjectIndex fetches lifeline index from leveldb

func (*LevelLedger) GetRecord

func (ll *LevelLedger) GetRecord(ref *record.Reference) (record.Record, error)

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.

func (*LevelLedger) SetRecord

func (ll *LevelLedger) SetRecord(rec record.Record) (*record.Reference, error)

SetRecord stores record in leveldb

type PulseFn added in v0.0.4

type PulseFn func() record.PulseNum

The PulseFn type is an adapter to allow set function produces pulses for storage.

Directories

Path Synopsis
Package leveltestutils provides sharable utils for testing LevelDB ledger implementation.
Package leveltestutils provides sharable utils for testing LevelDB ledger implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL