Documentation
¶
Index ¶
- Constants
- Variables
- type KVCache
- func (cache *KVCache) ApplyToState()
- func (cache *KVCache) Delete(key []byte)
- func (cache *KVCache) Exists(key []byte) bool
- func (cache *KVCache) Get(key []byte) ([]byte, error)
- func (cache *KVCache) GetCommitted(key []byte) ([]byte, error)
- 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 List
- func (l List) Clear() error
- func (l List) Extend(values [][]byte)
- func (l List) Get(index uint64) ([]byte, error)
- func (l List) IsEmpty() bool
- func (l List) Iterate(fn func(index uint64, value []byte) bool) bool
- func (l List) Len() uint64
- func (l List) Pop() []byte
- func (l List) Push(value []byte)
- func (l List) Set(index uint64, value []byte) error
- func (l List) Truncate(index uint64) error
- type StateStore
- func (st *StateStore) Close()
- func (st *StateStore) Commit() sdk.CommitInfo
- 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) IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
- func (st *StateStore) RefreshCache() sdk.Cache
- func (st *StateStore) Set(key, val []byte)
Constants ¶
const (
// StateDbName is the filename of the kvstore
StateDbName = "mstate"
)
Variables ¶
var ( // ErrOutOfBounds for the list ErrOutOfBounds = errors.New("Index out of bounds") )
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 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 List ¶ added in v0.3.0
type List struct {
// contains filtered or unexported fields
}
List provides an array like structure over a key/value store using composite keys. The following format is used in the realize a list:
/{key}/count => num (where num is the total number of items in a list for a given key)
/{key}/{index} => value (where index is list index pointing to the value )
key: Is a unique key used across the list Example:
Say we want to model that 'Each user has-many public keys'
We can use the List to capture this:
'bob' is our key...maybe an account address. So,
/bob/count => 3 (this means bob has 3 public keys)
/bob/0 => publickey{}
/bob/1 => publickey{}
/bob/2 => publickey{}
Everytime a new publickey{} is added for bob, the count is incremented and we use the count as an index into the list.
func (List) Extend ¶ added in v0.3.0
Extend the list for the given values, increasing the len Ex: if list A = [1,2] then A.extend([3,4,5]) => [1,2,3,4,5]
func (List) Get ¶ added in v0.3.0
Get a value at a given index. Will return an error if the given index is out of bounds.
func (List) Iterate ¶ added in v0.3.0
Iterate over entries in the *committed* list. The callback function will be passed each visited index and value. NOTE: The iterator will not return un-committed entries in the current cache
type StateStore ¶
type StateStore struct {
CommitInfo sdk.CommitInfo
// 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() sdk.CommitInfo
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) 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() sdk.Cache
RefreshCache clears existing k/v from the cache