badger

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBlockCacheSize   = 1610612736 // 1.5GB (increased from 768MB)
	DefaultIndexCacheSize   = 536870912  // 512MB (increased from 256MB)
	DefaultValueLogFileSize = 1073741824 // 1GB (keep large values on disk, write amplification reduction)
	DefaultMemTableSize     = 134217728  // 128MB (increased from 64MB for better write buffering)
	DefaultValueThreshold   = 1048576    // 1MB (keep small values in LSM, large blobs in value log)
)

Default cache sizes for BadgerDB (in bytes)

Variables

This section is empty.

Functions

func NewFromCmdlineOptions added in v0.18.0

func NewFromCmdlineOptions() plugin.Plugin

Types

type BadgerLogger

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

BadgerLogger is a wrapper type to give our logger the expected interface

func NewBadgerLogger

func NewBadgerLogger(logger *slog.Logger) *BadgerLogger

func (*BadgerLogger) Debugf

func (b *BadgerLogger) Debugf(msg string, args ...any)

func (*BadgerLogger) Errorf

func (b *BadgerLogger) Errorf(msg string, args ...any)

func (*BadgerLogger) Infof

func (b *BadgerLogger) Infof(msg string, args ...any)

func (*BadgerLogger) Warningf

func (b *BadgerLogger) Warningf(msg string, args ...any)

type BlobStoreBadger

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

BlobStoreBadger stores all data in badger. Data may not be persisted

func New

New creates a new database

func (*BlobStoreBadger) Close

func (d *BlobStoreBadger) Close() error

Close gets the database handle from our BlobStore and closes it

func (*BlobStoreBadger) DB

func (d *BlobStoreBadger) DB() *badger.DB

DB returns the database handle

func (*BlobStoreBadger) Delete added in v0.19.0

func (d *BlobStoreBadger) Delete(txn types.Txn, key []byte) error

Delete removes a key from badger within a transaction

func (*BlobStoreBadger) DeleteBlock added in v0.20.0

func (d *BlobStoreBadger) DeleteBlock(
	txn types.Txn,
	slot uint64,
	hash []byte,
	id uint64,
) error

DeleteBlock removes a block and its associated data

func (*BlobStoreBadger) DeleteTx added in v0.22.0

func (d *BlobStoreBadger) DeleteTx(
	txn types.Txn,
	txHash []byte,
) error

DeleteTx removes a transaction's offset data

func (*BlobStoreBadger) DeleteUtxo added in v0.20.0

func (d *BlobStoreBadger) DeleteUtxo(
	txn types.Txn,
	txId []byte,
	outputIdx uint32,
) error

DeleteUtxo removes a UTxO's data

func (*BlobStoreBadger) Get added in v0.19.0

func (d *BlobStoreBadger) Get(
	txn types.Txn,
	key []byte,
) ([]byte, error)

Get retrieves a value from badger within a transaction

func (*BlobStoreBadger) GetBlock added in v0.20.0

func (d *BlobStoreBadger) GetBlock(
	txn types.Txn,
	slot uint64,
	hash []byte,
) ([]byte, types.BlockMetadata, error)

GetBlock retrieves a block's CBOR data and metadata

func (*BlobStoreBadger) GetBlockURL added in v0.22.0

func (d *BlobStoreBadger) GetBlockURL(
	ctx context.Context,
	txn types.Txn,
	point ocommon.Point,
) (types.SignedURL, types.BlockMetadata, error)

func (*BlobStoreBadger) GetCommitTimestamp

func (b *BlobStoreBadger) GetCommitTimestamp() (int64, error)

func (*BlobStoreBadger) GetTx added in v0.22.0

func (d *BlobStoreBadger) GetTx(
	txn types.Txn,
	txHash []byte,
) ([]byte, error)

GetTx retrieves a transaction's offset data

func (*BlobStoreBadger) GetUtxo added in v0.20.0

func (d *BlobStoreBadger) GetUtxo(
	txn types.Txn,
	txId []byte,
	outputIdx uint32,
) ([]byte, error)

GetUtxo retrieves a UTxO's CBOR data

func (*BlobStoreBadger) NewIterator added in v0.19.0

func (d *BlobStoreBadger) NewIterator(
	txn types.Txn,
	opts types.BlobIteratorOptions,
) types.BlobIterator

NewIterator creates an iterator for badger within a transaction.

Important: items returned by the iterator's `Item()` must only be accessed while the transaction used to create the iterator is still active. Implementations may validate transaction state at access time (for example `ValueCopy` may fail if the transaction has been committed or rolled back). Typical usage iterates and accesses item values within the same transaction scope.

func (*BlobStoreBadger) NewTransaction

func (d *BlobStoreBadger) NewTransaction(update bool) types.Txn

NewTransaction creates a new badger transaction

func (*BlobStoreBadger) Set added in v0.19.0

func (d *BlobStoreBadger) Set(txn types.Txn, key, val []byte) error

Set stores a key-value pair in badger within a transaction

func (*BlobStoreBadger) SetBlock added in v0.20.0

func (d *BlobStoreBadger) SetBlock(
	txn types.Txn,
	slot uint64,
	hash []byte,
	cborData []byte,
	id uint64,
	blockType uint,
	height uint64,
	prevHash []byte,
) error

SetBlock stores a block with its metadata and index

func (*BlobStoreBadger) SetCommitTimestamp

func (b *BlobStoreBadger) SetCommitTimestamp(
	timestamp int64,
	txn types.Txn,
) error

func (*BlobStoreBadger) SetTx added in v0.22.0

func (d *BlobStoreBadger) SetTx(
	txn types.Txn,
	txHash []byte,
	offsetData []byte,
) error

SetTx stores a transaction's offset data

func (*BlobStoreBadger) SetUtxo added in v0.20.0

func (d *BlobStoreBadger) SetUtxo(
	txn types.Txn,
	txId []byte,
	outputIdx uint32,
	cborData []byte,
) error

SetUtxo stores a UTxO's CBOR data

func (*BlobStoreBadger) Start added in v0.18.0

func (d *BlobStoreBadger) Start() error

Start implements the plugin.Plugin interface

func (*BlobStoreBadger) Stop added in v0.18.0

func (d *BlobStoreBadger) Stop() error

Stop implements the plugin.Plugin interface

type BlobStoreBadgerOptionFunc added in v0.18.0

type BlobStoreBadgerOptionFunc func(*BlobStoreBadger)

func WithBlockCacheSize added in v0.18.0

func WithBlockCacheSize(size uint64) BlobStoreBadgerOptionFunc

WithBlockCacheSize specifies the block cache size

func WithDataDir added in v0.18.0

func WithDataDir(dataDir string) BlobStoreBadgerOptionFunc

WithDataDir specifies the data directory to use for storage

func WithGc added in v0.18.0

func WithGc(enabled bool) BlobStoreBadgerOptionFunc

WithGc specifies whether garbage collection is enabled

func WithIndexCacheSize added in v0.18.0

func WithIndexCacheSize(size uint64) BlobStoreBadgerOptionFunc

WithIndexCacheSize specifies the index cache size

func WithLogger added in v0.18.0

func WithLogger(logger *slog.Logger) BlobStoreBadgerOptionFunc

WithLogger specifies the logger object to use for logging messages

func WithMemTableSize added in v0.20.0

func WithMemTableSize(size int64) BlobStoreBadgerOptionFunc

WithMemTableSize specifies the memtable size in bytes

func WithPromRegistry added in v0.18.0

func WithPromRegistry(
	registry prometheus.Registerer,
) BlobStoreBadgerOptionFunc

WithPromRegistry specifies the prometheus registry to use for metrics

func WithValueLogFileSize added in v0.20.0

func WithValueLogFileSize(size int64) BlobStoreBadgerOptionFunc

WithValueLogFileSize specifies the value log file size in bytes

func WithValueThreshold added in v0.20.0

func WithValueThreshold(threshold int64) BlobStoreBadgerOptionFunc

WithValueThreshold specifies the value threshold for keeping values in LSM tree

Jump to

Keyboard shortcuts

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