storage

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyLength = 32 // Total bytes used for keys
)

Variables

View Source
var ErrNotFound = errors.NotFound

ErrNotFound is returned by KeyValueDB.Get if the key is not found.

View Source
var ErrNotOpen = errors.InternalError.With("not open")

ErrNotOpen is returned by KeyValueDB.Get, .Put, and .Close if the database is not open.

Functions

func AsBytes

func AsBytes(v interface{}) []byte

func DisableKeyNameTracking

func DisableKeyNameTracking()

func EnableKeyNameTracking

func EnableKeyNameTracking()

Types

type Beginner

type Beginner interface {
	// Begin begins a transaction or sub-transaction.
	Begin(writable bool) KeyValueTxn

	// Begin begins a transaction or sub-transaction with the given prefix
	// applied to keys.
	BeginWithPrefix(writable bool, prefix string) KeyValueTxn
}

type DebugBatch

type DebugBatch struct {
	Batch  KeyValueTxn
	Logger Logger

	Writable bool
	// contains filtered or unexported fields
}

func (*DebugBatch) Begin

func (b *DebugBatch) Begin(writable bool) KeyValueTxn

func (*DebugBatch) BeginWithPrefix

func (b *DebugBatch) BeginWithPrefix(writable bool, prefix string) KeyValueTxn

func (*DebugBatch) Commit

func (b *DebugBatch) Commit() error

func (*DebugBatch) Discard

func (b *DebugBatch) Discard()

func (*DebugBatch) Get

func (b *DebugBatch) Get(key Key) (v []byte, err error)

func (*DebugBatch) PretendWrite

func (b *DebugBatch) PretendWrite()

func (*DebugBatch) Put

func (b *DebugBatch) Put(key Key, value []byte) error

func (*DebugBatch) PutAll

func (b *DebugBatch) PutAll(values map[Key][]byte) error

type Key

type Key [KeyLength]byte

func MakeKey

func MakeKey(keys ...interface{}) Key

func (Key) Append

func (k Key) Append(key ...interface{}) Key

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

MarshalJSON is implemented for JSON-based logging

func (Key) String

func (k Key) String() string

String hex encodes the key. If debugging is enabled, String looks up the original composite key.

type KeyValueStore

type KeyValueStore interface {
	Beginner

	// Close closes the store.
	Close() error
}

type KeyValueTxn

type KeyValueTxn interface {
	Beginner

	// Get gets a value.
	Get(key Key) ([]byte, error)
	// Put puts a value.
	Put(key Key, value []byte) error
	// PutAll puts many values.
	PutAll(map[Key][]byte) error
	// Commit commits the transaction.
	Commit() error
	// Discard discards the transaction.
	Discard()
}

type Logger

type Logger interface {
	Debug(msg string, keyVals ...interface{})
	Info(msg string, keyVals ...interface{})
	Error(msg string, keyVals ...interface{})
}

Logger defines a generic logging interface compatible with Tendermint (stolen from Tendermint).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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