db

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIO indicates the generic error of DB I/O operation
	ErrIO = errors.New("DB I/O operation error")
	// ErrNotExist defines an error that the query has no return value in db
	ErrNotExist = errors.New("key does not exist")
	// NextHeightKey defines the constant key of next height
	NextHeightKey = []byte("next-height")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	NumOfRetries uint8  `yaml:"numOfRetries"`
	DBPath       string `yaml:"dbPath"`
}

Config defines the config of db

type KVStore

type KVStore interface {
	Start(context.Context) error
	Stop(context.Context) error
	Get([]byte) ([]byte, error)
	Put([]byte, []byte) error
}

KVStore defines the db interface using in committee

func NewInMemKVStore

func NewInMemKVStore() KVStore

NewInMemKVStore creates a new in memory kv store

func NewKVStoreWithNamespaceWrapper

func NewKVStoreWithNamespaceWrapper(namespace string, store KVStoreWithNamespace) KVStore

NewKVStoreWithNamespaceWrapper create a kvstore with specified namespace and a KVStoreWithNamespace

type KVStoreWithNamespace

type KVStoreWithNamespace interface {
	Start(context.Context) error
	Stop(context.Context) error
	Get(string, []byte) ([]byte, error)
	Put(string, []byte, []byte) error
}

KVStoreWithNamespace defines the db interface with namesapce

func NewBoltDB

func NewBoltDB(dbPath string, numOfRetries uint8) KVStoreWithNamespace

NewBoltDB creates a new boltDB

func NewInMemStoreWithNamespace added in v0.2.0

func NewInMemStoreWithNamespace(_ Config) KVStoreWithNamespace

NewInMemStoreWithNamespace defines a wrapper to convert memStore to KVStoreWithNamespace

type KVStoreWithNamespaceWrapper

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

KVStoreWithNamespaceWrapper defines a wrapper to convert KVStoreWithNamespace to KVStore

func (*KVStoreWithNamespaceWrapper) Get

func (w *KVStoreWithNamespaceWrapper) Get(key []byte) ([]byte, error)

Get gets the value by key from kv store

func (*KVStoreWithNamespaceWrapper) Put

func (w *KVStoreWithNamespaceWrapper) Put(key []byte, value []byte) error

Put puts key-value pair into kv store

func (*KVStoreWithNamespaceWrapper) Start

Start starts the kv store

func (*KVStoreWithNamespaceWrapper) Stop

Stop stops the kv store

Jump to

Keyboard shortcuts

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