storage

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

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

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

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

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

Functions

This section is empty.

Types

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 {
	Close() error                                // Returns an error if the close fails
	InitDB(filepath string, logger Logger) error // Sets up the database, returns error if it fails
	Get(key Key) (value []byte, err error)       // Get key from database, returns ErrNotFound if the key is not found
	Put(key Key, value []byte) error             // Put the value in the database, throws an error if fails
	EndBatch(map[Key][]byte) error               // End and commit a batch of transactions
	Begin() KeyValueTxn
}

type KeyValueTxn

type KeyValueTxn interface {
	Get(key Key) ([]byte, error)
	Put(key Key, value []byte)
	PutAll(map[Key][]byte)
	Commit() error
	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