ethdb

package
v0.0.0-...-7833c67 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EndSuffix = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
View Source
var ErrKeyNotFound = errors.New("db: key not found")

ErrKeyNotFound is returned when key isn't found in the database.

Functions

func Bytesmask

func Bytesmask(fixedbits int) (fixedbytes int, mask byte)

func GetOneWrapper

func GetOneWrapper(dat []byte, err error) ([]byte, error)

func NewSplitCursor

func NewSplitCursor(c kv.Cursor, startkey []byte, matchBits int, part1end, part2start, part3start int) *splitCursor

func Walk

func Walk(c kv.Cursor, startkey []byte, fixedbits int, walker func(k, v []byte) (bool, error)) error

Types

type BucketsMigrator

type BucketsMigrator interface {
	BucketExists(bucket string) (bool, error) // makes them empty
	ClearBuckets(buckets ...string) error     // makes them empty
	DropBuckets(buckets ...string) error      // drops them, use of them after drop will panic
}

type DBGetter

type DBGetter interface {
	kv.Getter

	// Get returns the value for a given key if it's present.
	Get(bucket string, key []byte) ([]byte, error)
}

DBGetter wraps the database read operations.

type Database

type Database interface {
	DBGetter
	kv.Putter
	kv.Deleter
	kv.Closer

	Begin(ctx context.Context, flags TxFlags) (DbWithPendingMutations, error) // starts db transaction
	Last(bucket string) ([]byte, []byte, error)

	IncrementSequence(bucket string, amount uint64) (uint64, error)
	ReadSequence(bucket string) (uint64, error)
	RwKV() kv.RwDB
}

Database wraps all database operations. All methods are safe for concurrent use.

type DbWithPendingMutations

type DbWithPendingMutations interface {
	Database

	// Commit - commits transaction (or flush data into underlying db object in case of `mutation`)
	//
	// Common pattern:
	//
	// tx := db.Begin()
	// defer tx.Rollback()
	// ... some calculations on `tx`
	// tx.Commit()
	//
	Commit() error

	Rollback()
	BatchSize() int
}

DbWithPendingMutations is an extended version of the Database, where all changes are first made in memory. Later they can either be committed to the database or rolled back.

type HasRwKV

type HasRwKV interface {
	RwKV() kv.RwDB
	SetRwKV(kv kv.RwDB)
}

type HasTx

type HasTx interface {
	Tx() kv.Tx
}

type MinDatabase

type MinDatabase interface {
	Get(bucket string, key []byte) ([]byte, error)
	Put(table string, k, v []byte) error
	Delete(table string, k []byte) error
}

MinDatabase is a minimalistic version of the Database interface.

type TxFlags

type TxFlags uint
const (
	RW TxFlags = 0x00 // default
	RO TxFlags = 0x02
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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