memdb

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database is an in-memory implementation of HeightIndex. It provides thread-safe height-based key-value storage for testing and high-performance paths.

func New

func New() *Database

New creates a new in-memory HeightIndex database.

func (*Database) Close

func (db *Database) Close() error

Close releases resources and clears all stored data. Subsequent operations will return database.ErrClosed.

func (*Database) Delete

func (db *Database) Delete(height uint64) error

Delete removes the value at the given height. Does not return an error if the height does not exist.

func (*Database) Get

func (db *Database) Get(height uint64) ([]byte, error)

Get retrieves the value at the given height. Returns database.ErrNotFound if the height does not exist. The returned byte slice is safe to read, but cannot be modified.

func (*Database) Has

func (db *Database) Has(height uint64) (bool, error)

Has returns whether a value exists at the given height.

func (*Database) Put

func (db *Database) Put(height uint64, value []byte) error

Put inserts the value at the given height. The value is copied to prevent external mutation.

Jump to

Keyboard shortcuts

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