badgerdb

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package badgerdb contains ledger store implementation on top of BadgerDB engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashIterator

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

type Store struct {
	// contains filtered or unexported fields
}

Store represents BadgerDB storage implementation.

func NewStore

func NewStore(dir string, opts *badger.Options) (*Store, error)

NewStore returns badgerdb.Store with BadgerDB instance initialized by opts. Creates database in provided dir or in current directory if dir parameter is empty.

func (*Store) Close

func (s *Store) Close() error

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 (*Store) Get

func (s *Store) Get(key []byte) ([]byte, error)

Get gets value by key in BadgerDB storage.

func (*Store) GetClassIndex

func (s *Store) GetClassIndex(ref *record.Reference) (*index.ClassLifeline, error)

GetClassIndex fetches class lifeline's index.

func (*Store) GetCurrentPulse

func (s *Store) GetCurrentPulse() record.PulseNum

GetCurrentPulse returns current pulse number.

func (*Store) GetDrop

func (s *Store) GetDrop(pulse record.PulseNum) (*jetdrop.JetDrop, error)

GetDrop returns jet drop for a given pulse number.

func (*Store) GetEntropy

func (s *Store) GetEntropy(pulse record.PulseNum) ([]byte, error)

GetEntropy returns entropy from storage for given pulse.

Entropy is used for calculating node roles.

func (*Store) GetObjectIndex

func (s *Store) GetObjectIndex(ref *record.Reference) (*index.ObjectLifeline, error)

GetObjectIndex fetches object lifeline index.

func (*Store) GetRecord

func (s *Store) GetRecord(ref *record.Reference) (record.Record, error)

GetRecord returns record from BadgerDB by *record.Reference.

It returns storage.ErrNotFound if the DB does not contain the key.

func (*Store) GetSlotHashes

func (s *Store) GetSlotHashes(n record.PulseNum) ([][]byte, error)

GetSlotHashes returns array of all record's hashes in provided PulseNum.

func (*Store) ProcessSlotHashes

func (s *Store) ProcessSlotHashes(n record.PulseNum, ifn func(it HashIterator) error) error

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 (*Store) Set

func (s *Store) Set(key, value []byte) error

Set stores value by key in BadgerDB.

func (*Store) SetClassIndex

func (s *Store) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error

SetClassIndex stores class lifeline index.

func (*Store) SetCurrentPulse

func (s *Store) SetCurrentPulse(pulse record.PulseNum)

SetCurrentPulse sets current pulse number.

func (*Store) SetDrop

func (s *Store) 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 (*Store) SetEntropy

func (s *Store) SetEntropy(pulse record.PulseNum, entropy []byte) error

SetEntropy stores given entropy for given pulse in storage.

Entropy is used for calculating node roles.

func (*Store) SetObjectIndex

func (s *Store) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error

SetObjectIndex stores object lifeline index.

func (*Store) SetRecord

func (s *Store) SetRecord(rec record.Record) (*record.Reference, error)

SetRecord stores record in BadgerDB and returns *record.Reference of new record.

Directories

Path Synopsis
Package badgertestutils provides sharable utils for testing BadgerDB store implementation.
Package badgertestutils provides sharable utils for testing BadgerDB store implementation.

Jump to

Keyboard shortcuts

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