kvstore

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a pre-image cannot be found in the KV store.

Functions

This section is empty.

Types

type FileKV added in v1.9.2

type FileKV struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

FileKV is a disk-backed key-value store, every key-value pair is a hex-encoded .txt file, with the value as content. FileKV is safe for concurrent use with a single FileKV instance. FileKV is safe for concurrent use between different FileKV instances of the same disk directory as long as the file system supports atomic renames.

func NewFileKV added in v1.9.2

func NewFileKV(path string) *FileKV

NewFileKV creates a FileKV that puts/gets pre-images as files in the given directory path. The path must exist, or subsequent Put/Get calls will error when it does not.

func (*FileKV) Close added in v1.9.2

func (d *FileKV) Close() error

func (*FileKV) Get added in v1.9.2

func (d *FileKV) Get(k common.Hash) ([]byte, error)

func (*FileKV) Put added in v1.9.2

func (d *FileKV) Put(k common.Hash, v []byte) error

type KV

type KV interface {
	// Put puts the pre-image value v in the key-value store with key k.
	// KV store implementations may return additional errors specific to the KV storage.
	Put(k common.Hash, v []byte) error

	// Get retrieves the pre-image with key k from the key-value store.
	// It returns ErrNotFound when the pre-image cannot be found.
	// KV store implementations may return additional errors specific to the KV storage.
	Get(k common.Hash) ([]byte, error)

	// Closes the KV store.
	Close() error
}

KV is a Key-Value store interface for pre-image data.

type LocalPreimageSource added in v1.0.5

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

func NewLocalPreimageSource added in v1.0.5

func NewLocalPreimageSource(config *config.Config) *LocalPreimageSource

func (*LocalPreimageSource) Get added in v1.0.5

func (s *LocalPreimageSource) Get(key common.Hash) ([]byte, error)

type MemKV

type MemKV struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemKV implements the KV store interface in memory, backed by a regular Go map. This should only be used in testing, as large programs may require more pre-image data than available memory. MemKV is safe for concurrent use.

func NewMemKV

func NewMemKV() *MemKV

func (*MemKV) Close added in v1.9.2

func (m *MemKV) Close() error

func (*MemKV) Get

func (m *MemKV) Get(k common.Hash) ([]byte, error)

func (*MemKV) Put

func (m *MemKV) Put(k common.Hash, v []byte) error

type PebbleKV added in v1.9.2

type PebbleKV struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PebbleKV is a disk-backed key-value store, with PebbleDB as the underlying DBMS. PebbleKV is safe for concurrent use with a single PebbleKV instance.

func NewPebbleKV added in v1.9.2

func NewPebbleKV(path string) *PebbleKV

NewPebbleKV creates a PebbleKV that puts/gets pre-images as files in the given directory path. The path must exist, or subsequent Put/Get calls will error when it does not.

func (*PebbleKV) Close added in v1.9.2

func (d *PebbleKV) Close() error

func (*PebbleKV) Get added in v1.9.2

func (d *PebbleKV) Get(k common.Hash) ([]byte, error)

func (*PebbleKV) Put added in v1.9.2

func (d *PebbleKV) Put(k common.Hash, v []byte) error

type PreimageSource added in v1.0.5

type PreimageSource func(key common.Hash) ([]byte, error)

type PreimageSourceSplitter added in v1.0.5

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

func NewPreimageSourceSplitter added in v1.0.5

func NewPreimageSourceSplitter(local PreimageSource, global PreimageSource) *PreimageSourceSplitter

func (*PreimageSourceSplitter) Get added in v1.0.5

func (s *PreimageSourceSplitter) Get(key [32]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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