Documentation ¶
Overview ¶
This file is for grabbing a leveldb instance without cleveldb support
Index ¶
- Constants
- Variables
- func NewCache(name string) *cache
- func NewCacheSafe(name string) *cacheSafe
- type ChainState
- func (state *ChainState) Close()
- func (state *ChainState) Commit() ([]byte, int64)
- func (state *ChainState) Dump()
- func (state *ChainState) Exists(key StoreKey) bool
- func (state *ChainState) FindAll() map[string][]byte
- func (state *ChainState) Get(key StoreKey, lastCommit bool) []byte
- func (state *ChainState) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (stake *ChainState) Remove(key []byte) ([]byte, bool)
- func (state *ChainState) Set(key StoreKey, val []byte) error
- type IterItem
- type Iterator
- type KeyValue
- func (store KeyValue) BeginSession() Session
- func (store KeyValue) Close()
- func (store KeyValue) Dump()
- func (store KeyValue) Errors() string
- func (store KeyValue) Exists(key StoreKey) (bool, error)
- func (store KeyValue) FindAll() []StoreKey
- func (store KeyValue) Get(key StoreKey) ([]byte, error)
- func (store KeyValue) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (store KeyValue) ReadAll() []IterItem
- func (store KeyValue) Reopen()
- type KeyValueSession
- func (session KeyValueSession) Commit() bool
- func (session KeyValueSession) Delete(key StoreKey) (bool, error)
- func (session KeyValueSession) Dump()
- func (session KeyValueSession) Errors() string
- func (session KeyValueSession) Exists(key StoreKey) bool
- func (session KeyValueSession) FindAll() []StoreKey
- func (session KeyValueSession) Get(key StoreKey) ([]byte, error)
- func (session KeyValueSession) GetIterator() *Iterator
- func (session KeyValueSession) Rollback() bool
- func (session KeyValueSession) Set(key StoreKey, dat []byte) error
- type Session
- type SessionedStorage
- type StorageType
- type Store
- type StoreKey
Constants ¶
const ( MEMORY StorageType = iota PERSISTENT CACHE = "cache" CACHE_SAFE = "cache_safe" KEYVALUE = "keyvalue" CHAINKEY_MAXLEN = 20 CHAINSTATE_CACHE_SIZE = 10000 )
Different types
const ( OLDATA = "OLDATA" NODEDATA = "nodedata" )
Variables ¶
var ( ErrNotFound = errors.New("key not found") ErrSetFailed = errors.New("failed to set data") )
var ErrNilData = errors.New("data is nil")
Functions ¶
func NewCacheSafe ¶
func NewCacheSafe(name string) *cacheSafe
Types ¶
type ChainState ¶
type ChainState struct { Name string Type StorageType Delivered *iavl.MutableTree // Build us a new set of transactions // Last committed values LastVersion int64 Version int64 LastHash []byte Hash []byte TreeHeight int8 sync.RWMutex // contains filtered or unexported fields }
Chainstate is a storage for balances on the chain, a snapshot of all accounts
func NewChainState ¶
func NewChainState(name, dbDir, configDB string, newType StorageType) *ChainState
NewChainState generates a new ChainState object
func (*ChainState) Close ¶
func (state *ChainState) Close()
func (*ChainState) Commit ¶
func (state *ChainState) Commit() ([]byte, int64)
TODO: Not sure about this, it seems to be Cosmos-sdk's way of getting arround the immutable copy problem...
func (*ChainState) Dump ¶
func (state *ChainState) Dump()
func (*ChainState) Exists ¶
func (state *ChainState) Exists(key StoreKey) bool
TODO: Should be against the commit tree, not the delivered one!!!
func (*ChainState) FindAll ¶
func (state *ChainState) FindAll() map[string][]byte
Expensive O(n) search through everything...
func (*ChainState) Get ¶
func (state *ChainState) Get(key StoreKey, lastCommit bool) []byte
TODO: Should be against the commit tree, not the delivered one!!!
func (*ChainState) Iterate ¶ added in v0.10.4
func (state *ChainState) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
type KeyValue ¶
type KeyValue struct { Type StorageType Name string File string sync.RWMutex // contains filtered or unexported fields }
KeyValue begins here
KeyValue Wrap the underlying usage
func (KeyValue) BeginSession ¶
BeginSession a new writable session
func (KeyValue) Dump ¶
func (store KeyValue) Dump()
Dump out debugging information from the KeyValue datastore
type KeyValueSession ¶
type KeyValueSession struct {
// contains filtered or unexported fields
}
KeyValueSession begins here
func (KeyValueSession) Commit ¶
func (session KeyValueSession) Commit() bool
Commit the changes to persistence
func (KeyValueSession) Delete ¶
func (session KeyValueSession) Delete(key StoreKey) (bool, error)
Delete a key from the datastore
func (KeyValueSession) Dump ¶
func (session KeyValueSession) Dump()
Dump out the contents of the database
func (KeyValueSession) Exists ¶
func (session KeyValueSession) Exists(key StoreKey) bool
Test to see if a key exists
func (KeyValueSession) FindAll ¶
func (session KeyValueSession) FindAll() []StoreKey
Find all of the keys in the datastore
func (KeyValueSession) Get ¶
func (session KeyValueSession) Get(key StoreKey) ([]byte, error)
Load return the stored value
func (KeyValueSession) GetIterator ¶
func (session KeyValueSession) GetIterator() *Iterator
GetIterator dummy iterator
func (KeyValueSession) Rollback ¶
func (session KeyValueSession) Rollback() bool
Rollback any changes since the last commit
type SessionedStorage ¶
type SessionedStorage interface { Get(StoreKey) ([]byte, error) Exists(StoreKey) (bool, error) BeginSession() Session Close() ReadAll() []IterItem Iterate(fn func(key []byte, value []byte) bool) (stopped bool) }
SessionedStorage wraps objects with option to start a session(db transaction)
func NewStorageDB ¶
func NewStorageDB(flavor, name string, DBDir, DBType string) SessionedStorage
NewStorageSession creates a new SessionStorage