storage

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 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

type Cache interface {
	// Get from the cache or tree
	Get(key []byte) ([]byte, error)
	// Does the store contain the given key
	Has(key []byte) bool
	// Put to the cache or tree
	Put(key, value []byte)
	// Delete a key/value pair
	Remove(key []byte)
	// ToBatch returns the cache storage
	ToBatch() map[string]CacheOp
}

Cache is the used to batch writes for commit

type CacheOp

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

type CommitData

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

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

func (*CommitData) GetHash

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

func (*CommitData) GetVersion

func (m *CommitData) GetVersion() int64

func (*CommitData) ProtoMessage

func (*CommitData) ProtoMessage()

func (*CommitData) Reset

func (m *CommitData) Reset()

func (*CommitData) String

func (m *CommitData) String() string

func (*CommitData) XXX_DiscardUnknown

func (m *CommitData) XXX_DiscardUnknown()

func (*CommitData) XXX_Marshal

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

func (*CommitData) XXX_Merge

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

func (*CommitData) XXX_Size

func (m *CommitData) XXX_Size() int

func (*CommitData) XXX_Unmarshal

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

type KVCache

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

KVCache provides a cached used for r/w access to storage

func NewCache

func NewCache(snap TreeReader) *KVCache

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

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) Has

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

Has - checks for a given key

func (*KVCache) Put

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

Put a key in the cache

func (*KVCache) Remove

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

Remove a key/value

func (*KVCache) ToBatch

func (cache *KVCache) ToBatch() map[string]CacheOp

ToBatch returns the cached entries

type Snapshot

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

func NewSnaphot

func NewSnaphot(tree *iavl.MutableTree) Snapshot

func (Snapshot) Get

func (snap Snapshot) Get(key []byte) ([]byte, error)

func (Snapshot) IterateKeyRange

func (snap Snapshot) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool

type Store

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

Store provides access the the levelDb and Tree

func NewStore

func NewStore(dbdir string) *Store

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

func (*Store) Close

func (st *Store) Close()

Close the DB

func (*Store) Commit

func (st *Store) Commit(batch map[string]CacheOp) CommitData

Commit information about the current state to storage

func (*Store) Snapshot

func (st *Store) Snapshot() TreeReader

type TreeReader

type TreeReader interface {
	// Get from committed state in the tree
	Get(key []byte) ([]byte, error)
	// IterateKeyRange over committed state
	IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
}

TreeReader provides read access to committed state

type TreeWriter

type TreeWriter interface {
	Commit(batch map[string]CacheOp) CommitData
	Snapshot() TreeReader
}

TreeWriter writes to state and provides a snapshot of committed state

Jump to

Keyboard shortcuts

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