badger

package
v0.39.0-stable-cadence-3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 20 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
	// Allow git snapshots.
	Snapshot bool
	// Badger options to open DB
	BadgerOptions badger.Options
	// In Memory
	InMemory 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 WithPersist added in v0.38.0

func WithPersist(persist bool) Opt

func WithSnapshot added in v0.34.1

func WithSnapshot(enabled bool) 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) JumpToContext added in v0.27.0

func (s *Store) JumpToContext(context string) 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