store

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StateDbName is the filename of the kvstore
	StateDbName = "mstate"
)

Variables

View Source
var (

	// ErrValueNotFound returned when the value for a key is nil
	ErrValueNotFound = errors.New("Store get: nil value for given key")
)

Functions

This section is empty.

Types

type Cache added in v0.4.0

type Cache interface {
	KVStore
	// Dump the cache to the tree
	ApplyToState()
}

Cache extends KVStore adding an additional method to implement on a cache

type CommitData added in v0.4.0

type CommitData struct {
	Hash                 []byte   `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	Version              int64    `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

State commit information

func (*CommitData) Descriptor added in v0.4.0

func (*CommitData) Descriptor() ([]byte, []int)

func (*CommitData) GetHash added in v0.4.0

func (m *CommitData) GetHash() []byte

func (*CommitData) GetVersion added in v0.4.0

func (m *CommitData) GetVersion() int64

func (*CommitData) ProtoMessage added in v0.4.0

func (*CommitData) ProtoMessage()

func (*CommitData) Reset added in v0.4.0

func (m *CommitData) Reset()

func (*CommitData) String added in v0.4.0

func (m *CommitData) String() string

func (*CommitData) XXX_DiscardUnknown added in v0.4.0

func (m *CommitData) XXX_DiscardUnknown()

func (*CommitData) XXX_Marshal added in v0.4.0

func (m *CommitData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CommitData) XXX_Merge added in v0.4.0

func (m *CommitData) XXX_Merge(src proto.Message)

func (*CommitData) XXX_Size added in v0.4.0

func (m *CommitData) XXX_Size() int

func (*CommitData) XXX_Unmarshal added in v0.4.0

func (m *CommitData) XXX_Unmarshal(b []byte) error

type KVCache

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

KVCache used by the app. It wraps a simple cache and access to the State Store

func NewCache

func NewCache(store *StateStore) *KVCache

NewCache return a fresh empty cache with ref to the State Store

func (*KVCache) ApplyToState

func (cache *KVCache) ApplyToState()

ApplyToState is called during abci.commit(). It sorts all keys in the cache for determinism, then writes the set to the tree

func (*KVCache) Delete added in v0.3.0

func (cache *KVCache) Delete(key []byte)

Delete a key/value

func (*KVCache) Get

func (cache *KVCache) Get(key []byte) ([]byte, error)

Get a value for a given key. Try the cache first and then the state db

func (*KVCache) GetCommitted added in v0.3.0

func (cache *KVCache) GetCommitted(key []byte) ([]byte, error)

GetCommitted only returns committed data, nothing cached

func (*KVCache) Has added in v0.4.0

func (cache *KVCache) Has(key []byte) bool

Exists - checks for a given key

func (*KVCache) IterateKeyRange

func (cache *KVCache) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool

IterateKeyRange returns results that are processed via the callback func

func (*KVCache) Set

func (cache *KVCache) Set(key, val []byte)

Set a key in the cache

type KVStore added in v0.4.0

type KVStore interface {
	// Get from the cache or tree
	Get(key []byte) ([]byte, error)
	// Does the store contain the given key
	Has(key []byte) bool
	// Get only from committed data
	GetCommitted(key []byte) ([]byte, error)
	// Set to the cache or tree
	Set(key, value []byte)
	// Delete a key/value pair
	Delete(key []byte)
	// IterateKeyRange over the tree
	IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
}

KVStore is the base interface for all methods related to a store. See the store package

type StateStore

type StateStore struct {
	CommitInfo CommitData
	// contains filtered or unexported fields
}

StateStore provides access the the levelDb and Tree

func NewStateStore

func NewStateStore(dbdir string) *StateStore

NewStateStore creates a new instance. If 'dbdir' == "", it'll return an in-memory database

func (*StateStore) Close

func (st *StateStore) Close()

Close the underlying db

func (*StateStore) Commit

func (st *StateStore) Commit() CommitData

Commit information about the current state to the db

func (*StateStore) Delete added in v0.3.0

func (st *StateStore) Delete(key []byte)

Delete a k/v from the tree

func (*StateStore) Get

func (st *StateStore) Get(key []byte) ([]byte, error)

Get returns committed data from the tree

func (*StateStore) GetCommitted added in v0.3.0

func (st *StateStore) GetCommitted(key []byte) ([]byte, error)

GetCommitted returns only committed data, nothing cached ** Implemented here to satisfy the KVStore interface. Need to improve this

func (*StateStore) Has added in v0.4.0

func (st *StateStore) Has(key []byte) bool

func (*StateStore) IterateKeyRange

func (st *StateStore) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool

IterateKeyRange - iterator non-inclusive

func (*StateStore) RefreshCache

func (st *StateStore) RefreshCache() Cache

RefreshCache clears existing k/v from the cache

func (*StateStore) Set

func (st *StateStore) Set(key, val []byte)

Set a k/v in the tree

type Store added in v0.4.0

type Store interface {
	KVStore
	// Commit is called on Abci commit to commit the tree to storage and update the hash
	Commit() CommitData
	// Close the store
	Close()
	// Refresh the check/deliver caches
	RefreshCache() Cache
}

Store extends KVStore

Jump to

Keyboard shortcuts

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