Documentation
¶
Index ¶
- Constants
- func NewFromCmdlineOptions() plugin.Plugin
- type BadgerLogger
- type BlobStoreBadger
- func (d *BlobStoreBadger) Close() error
- func (d *BlobStoreBadger) DB() *badger.DB
- func (d *BlobStoreBadger) Delete(txn types.Txn, key []byte) error
- func (d *BlobStoreBadger) DeleteBlock(txn types.Txn, slot uint64, hash []byte, id uint64) error
- func (d *BlobStoreBadger) DeleteTx(txn types.Txn, txHash []byte) error
- func (d *BlobStoreBadger) DeleteUtxo(txn types.Txn, txId []byte, outputIdx uint32) error
- func (d *BlobStoreBadger) DiskSize() (int64, error)
- func (d *BlobStoreBadger) Get(txn types.Txn, key []byte) ([]byte, error)
- func (d *BlobStoreBadger) GetBlock(txn types.Txn, slot uint64, hash []byte) ([]byte, types.BlockMetadata, error)
- func (d *BlobStoreBadger) GetBlockURL(ctx context.Context, txn types.Txn, point ocommon.Point) (types.SignedURL, types.BlockMetadata, error)
- func (b *BlobStoreBadger) GetCommitTimestamp() (int64, error)
- func (d *BlobStoreBadger) GetTx(txn types.Txn, txHash []byte) ([]byte, error)
- func (d *BlobStoreBadger) GetUtxo(txn types.Txn, txId []byte, outputIdx uint32) ([]byte, error)
- func (d *BlobStoreBadger) NewIterator(txn types.Txn, opts types.BlobIteratorOptions) (iter types.BlobIterator)
- func (d *BlobStoreBadger) NewTransaction(update bool) types.Txn
- func (d *BlobStoreBadger) Set(txn types.Txn, key, val []byte) error
- func (d *BlobStoreBadger) SetBlock(txn types.Txn, slot uint64, hash []byte, cborData []byte, id uint64, ...) error
- func (b *BlobStoreBadger) SetCommitTimestamp(timestamp int64, txn types.Txn) error
- func (d *BlobStoreBadger) SetLogger(logger *slog.Logger)
- func (d *BlobStoreBadger) SetTx(txn types.Txn, txHash []byte, offsetData []byte) error
- func (d *BlobStoreBadger) SetUtxo(txn types.Txn, txId []byte, outputIdx uint32, cborData []byte) error
- func (d *BlobStoreBadger) Start() error
- func (d *BlobStoreBadger) Stop() error
- func (d *BlobStoreBadger) TombstoneBlock(txn types.Txn, slot uint64, hash []byte) error
- type BlobStoreBadgerOptionFunc
- func WithBlockCacheSize(size uint64) BlobStoreBadgerOptionFunc
- func WithCompactBlockMetadata(enabled bool) BlobStoreBadgerOptionFunc
- func WithCompressionEnabled(enabled bool) BlobStoreBadgerOptionFunc
- func WithCompressionLevel(level int) BlobStoreBadgerOptionFunc
- func WithDataDir(dataDir string) BlobStoreBadgerOptionFunc
- func WithDeferOpen() BlobStoreBadgerOptionFunc
- func WithGc(enabled bool) BlobStoreBadgerOptionFunc
- func WithIndexCacheSize(size uint64) BlobStoreBadgerOptionFunc
- func WithLogger(logger *slog.Logger) BlobStoreBadgerOptionFunc
- func WithMemTableSize(size int64) BlobStoreBadgerOptionFunc
- func WithPromRegistry(registry prometheus.Registerer) BlobStoreBadgerOptionFunc
- func WithValueLogFileSize(size int64) BlobStoreBadgerOptionFunc
- func WithValueThreshold(threshold int64) BlobStoreBadgerOptionFunc
Constants ¶
const ( DefaultBlockCacheSize = 268435456 // 256 MB DefaultIndexCacheSize = 0 // 0 = unlimited DefaultValueLogFileSize = 1073741824 // 1 GB DefaultMemTableSize = 134217728 // 128 MB DefaultValueThreshold = 1048576 // 1 MB DefaultCoreBlockCacheSize = 0 DefaultCoreIndexCacheSize = 0 DefaultCoreCompressionEnabled = false DefaultAPIBlockCacheSize = DefaultBlockCacheSize DefaultAPIIndexCacheSize = DefaultIndexCacheSize DefaultAPICompressionEnabled = true // DefaultCompressionLevel is the ZSTD compression level used when // compression is enabled. Badger recommends level 1, which gives a good // compression ratio without the throughput penalty of higher levels. DefaultCompressionLevel = 1 )
Default cache sizes for BadgerDB (in bytes).
Block cache is needed when Snappy compression is enabled. Badger's own default is 256 MB block cache and 0 (unlimited) index cache. Set compression=false and block-cache-size=0 for mmap-only mode. Setting IndexCacheSize to 0 lets Badger memory-map the full index without eviction, which is preferable to capping it.
Operators can override via block-cache-size / index-cache-size CLI flags or YAML config.
Variables ¶
This section is empty.
Functions ¶
func NewFromCmdlineOptions ¶ added in v0.18.0
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 ¶
func New(opts ...BlobStoreBadgerOptionFunc) (*BlobStoreBadger, error)
New creates a new database. When deferOpen is set (via WithDeferOpen), Badger is not opened until Start() is called, allowing an injected logger (via SetLogger) to be used for Badger's startup logging.
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
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
DeleteUtxo removes a UTxO's data
func (*BlobStoreBadger) DiskSize ¶ added in v0.29.0
func (d *BlobStoreBadger) DiskSize() (int64, error)
DiskSize returns the on-disk size of the Badger database in bytes (LSM tree size + value log size).
func (*BlobStoreBadger) Get ¶ added in v0.19.0
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 (*BlobStoreBadger) GetCommitTimestamp ¶
func (b *BlobStoreBadger) GetCommitTimestamp() (int64, error)
func (*BlobStoreBadger) NewIterator ¶ added in v0.19.0
func (d *BlobStoreBadger) NewIterator( txn types.Txn, opts types.BlobIteratorOptions, ) (iter 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) SetLogger ¶ added in v0.24.0
func (d *BlobStoreBadger) SetLogger(logger *slog.Logger)
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. When the database was created with WithDeferOpen, Start opens Badger using the logger that was injected via SetLogger after construction.
func (*BlobStoreBadger) Stop ¶ added in v0.18.0
func (d *BlobStoreBadger) Stop() error
Stop implements the plugin.Plugin interface
func (*BlobStoreBadger) TombstoneBlock ¶ added in v0.39.1
TombstoneBlock overwrites a block's CBOR with an expired-history marker. GetBlock reads the bp value, sees the marker, and returns types.ErrHistoryExpired so an archive proxy can intercept it.
What stays:
bi<id>: required by BlockByIndex (the chain iterator translates id→key here; no equivalent index exists in metadata).
bh<hash>: BlockByHash resolves only through this index and treats a missing entry as a hard miss (ErrBlockNotFound), so the entry must survive tombstoning to keep the block reachable by hash.
bp_metadata: kept so bark can populate models.Block.ID (and the other small metadata fields) when surfacing a CBOR fetched from the archive. Without this the chain iterator's BlockByIndex path gets ID=0 and immediately returns ErrIteratorChainTip.
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 WithCompactBlockMetadata ¶ added in v0.27.0
func WithCompactBlockMetadata(enabled bool) BlobStoreBadgerOptionFunc
WithCompactBlockMetadata enables a compact binary metadata format for blocks.
func WithCompressionEnabled ¶ added in v0.27.7
func WithCompressionEnabled(enabled bool) BlobStoreBadgerOptionFunc
WithCompressionEnabled controls ZSTD compression of SSTable blocks. Disabling compression allows block cache size 0 (pure mmap).
func WithCompressionLevel ¶ added in v0.51.0
func WithCompressionLevel(level int) BlobStoreBadgerOptionFunc
WithCompressionLevel sets the ZSTD compression level used when compression is enabled. Higher levels yield better compression ratios at the cost of throughput. Has no effect when compression is disabled.
func WithDataDir ¶ added in v0.18.0
func WithDataDir(dataDir string) BlobStoreBadgerOptionFunc
WithDataDir specifies the data directory to use for storage
func WithDeferOpen ¶ added in v0.24.0
func WithDeferOpen() BlobStoreBadgerOptionFunc
WithDeferOpen defers opening Badger until Start() is called. This allows a logger to be injected via SetLogger before Badger emits any startup logs.
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