Documentation
¶
Index ¶
- Constants
- Variables
- type Cache
- type CommitData
- func (*CommitData) Descriptor() ([]byte, []int)
- func (m *CommitData) GetHash() []byte
- func (m *CommitData) GetVersion() int64
- func (*CommitData) ProtoMessage()
- func (m *CommitData) Reset()
- func (m *CommitData) String() string
- func (m *CommitData) XXX_DiscardUnknown()
- func (m *CommitData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CommitData) XXX_Merge(src proto.Message)
- func (m *CommitData) XXX_Size() int
- func (m *CommitData) XXX_Unmarshal(b []byte) error
- type KVCache
- func (cache *KVCache) ApplyToState()
- func (cache *KVCache) Delete(key []byte)
- func (cache *KVCache) Get(key []byte) ([]byte, error)
- func (cache *KVCache) GetCommitted(key []byte) ([]byte, error)
- func (cache *KVCache) Has(key []byte) bool
- func (cache *KVCache) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
- func (cache *KVCache) Set(key, val []byte)
- type KVStore
- type StateStore
- func (st *StateStore) Close()
- func (st *StateStore) Commit() CommitData
- func (st *StateStore) Delete(key []byte)
- func (st *StateStore) Get(key []byte) ([]byte, error)
- func (st *StateStore) GetCommitted(key []byte) ([]byte, error)
- func (st *StateStore) Has(key []byte) bool
- func (st *StateStore) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
- func (st *StateStore) RefreshCache() Cache
- func (st *StateStore) Set(key, val []byte)
- type Store
Constants ¶
const (
// StateDbName is the filename of the kvstore
StateDbName = "mstate"
)
Variables ¶
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) GetCommitted ¶ added in v0.3.0
GetCommitted only returns committed data, nothing cached
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) 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
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