badger

package
v0.14.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Logger is where Badger system logs will go.
	Logger badger.Logger
	// DBPath the path to the database directory.
	DBPath string
	// Truncate whether to truncate the write log to remove corrupt data.
	Truncate bool
}

Config defines the configurable parameters of the Badger storage implementation.

type Opt

type Opt func(*Config)

func WithLogger

func WithLogger(logger badger.Logger) Opt

func WithPath

func WithPath(path string) Opt

func WithTruncate

func WithTruncate(trunc bool) Opt

type Store

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

Store is an embedded storage implementation using Badger as the underlying persistent key-value store.

func New

func New(opts ...Opt) (*Store, error)

New returns a new Badger Store.

func (*Store) BlockByHeight

func (s *Store) BlockByHeight(blockHeight uint64) (block *flowgo.Block, err error)

func (*Store) BlockByID

func (s *Store) BlockByID(blockID flowgo.Identifier) (block *flowgo.Block, err error)

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying Badger database. It is necessary to close a Store before exiting to ensure all writes are persisted to disk.

func (*Store) CollectionByID

func (s *Store) CollectionByID(colID flowgo.Identifier) (col flowgo.LightCollection, err error)

func (*Store) CommitBlock

func (s *Store) CommitBlock(
	block flowgo.Block,
	collections []*flowgo.LightCollection,
	transactions map[flowgo.Identifier]*flowgo.TransactionBody,
	transactionResults map[flowgo.Identifier]*types.StorableTransactionResult,
	delta delta.Delta,
	events []flowgo.Event,
) error

func (*Store) EventsByHeight

func (s *Store) EventsByHeight(blockHeight uint64, eventType string) (events []flowgo.Event, err error)

func (*Store) InsertCollection

func (s *Store) InsertCollection(col flowgo.LightCollection) error

func (*Store) InsertEvents

func (s *Store) InsertEvents(blockHeight uint64, events []flowgo.Event) error

func (*Store) InsertLedgerDelta

func (s *Store) InsertLedgerDelta(blockHeight uint64, delta delta.Delta) error

func (*Store) InsertTransaction

func (s *Store) InsertTransaction(tx flowgo.TransactionBody) error

func (*Store) InsertTransactionResult

func (s *Store) InsertTransactionResult(txID flowgo.Identifier, result types.StorableTransactionResult) error

func (*Store) LatestBlock

func (s *Store) LatestBlock() (block flowgo.Block, err error)

func (*Store) LedgerViewByHeight

func (s *Store) LedgerViewByHeight(blockHeight uint64) *delta.View

func (*Store) RunValueLogGC

func (s *Store) RunValueLogGC(discardRatio float64) error

func (*Store) StoreBlock

func (s *Store) StoreBlock(block *flowgo.Block) error

func (*Store) Sync

func (s *Store) Sync() error

Sync syncs database content to disk.

func (*Store) TransactionByID

func (s *Store) TransactionByID(txID flowgo.Identifier) (tx flowgo.TransactionBody, err error)

func (*Store) TransactionResultByID

func (s *Store) TransactionResultByID(txID flowgo.Identifier) (result types.StorableTransactionResult, err error)

Jump to

Keyboard shortcuts

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