Documentation ¶
Overview ¶
This file is for grabbing a leveldb instance without cleveldb support
Index ¶
- Constants
- Variables
- func GetDatabase(name, dbDir, configDB string) (db.DB, error)
- func NewCache(name string) *cache
- func NewCacheSafe(name string) *cacheSafe
- func NewSessionCache(name string) *sessionCache
- func Prefix(prefix string) []byte
- func Rangefix(prefix string) []byte
- type ChainState
- func (state *ChainState) ClearFrom(version int64) error
- func (state *ChainState) Commit() ([]byte, int64)
- func (state *ChainState) Delete(key StoreKey) (bool, error)
- func (state *ChainState) Exists(key StoreKey) bool
- func (state *ChainState) FindAll() map[string][]byte
- func (state *ChainState) Get(key StoreKey) ([]byte, error)
- func (state *ChainState) GetIterable() Iterable
- func (state *ChainState) GetLatestVersioned(key StoreKey) (int64, []byte)
- func (state *ChainState) GetVersioned(version int64, key StoreKey) (int64, []byte)
- func (state *ChainState) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (state *ChainState) IterateRange(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stop bool)
- func (state *ChainState) LoadVersion(version int64) (int64, error)
- func (state *ChainState) Set(key StoreKey, val []byte) error
- func (state *ChainState) SetupRotation(chainStateRotationCfg config.ChainStateRotationCfg) error
- type ChainStateRotationSetting
- type Gas
- type GasCalculator
- type GasStore
- type IGasStore
- type Iterable
- type KeyValue
- func (store KeyValue) BeginSession() Session
- func (store KeyValue) Close() error
- func (store KeyValue) Delete(StoreKey) (bool, error)
- 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) GetIterable() Iterable
- func (store KeyValue) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (store KeyValue) Set(StoreKey, []byte) error
- type KeyValueIterator
- 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) GetIterable() Iterable
- func (session KeyValueSession) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (session KeyValueSession) IterateRange(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stop bool)
- func (session KeyValueSession) Rollback() bool
- func (session KeyValueSession) Set(key StoreKey, dat []byte) error
- type NoGasStore
- type Session
- type SessionedDirectStorage
- type SessionedStorage
- type State
- func (s *State) BeginTxSession()
- func (s *State) Commit() (hash []byte, version int64)
- func (s *State) CommitTxSession()
- func (s *State) ConsumeContractGas(gas Gas) bool
- func (s *State) ConsumeStorageGas(gas Gas) bool
- func (s *State) ConsumeUpfront(gas Gas) bool
- func (s *State) ConsumeVerifySigGas(gas Gas) bool
- func (s *State) ConsumedGas() Gas
- func (s *State) Delete(key StoreKey) (bool, error)
- func (s *State) DiscardTxSession()
- func (s *State) DumpState()
- func (s *State) Exists(key StoreKey) bool
- func (s *State) Get(key StoreKey) ([]byte, error)
- func (s *State) GetAtHeight(version int64, key StoreKey) ([]byte, error)
- func (s *State) GetCalculator() GasCalculator
- func (s *State) GetGasStore() IGasStore
- func (s *State) GetIterable() Iterable
- func (s *State) GetPrevious(num int64, key StoreKey) []byte
- func (s *State) GetVersioned(version int64, key StoreKey) []byte
- func (s *State) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
- func (s *State) IterateRange(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stop bool)
- func (s *State) LoadVersion(version int64) (int64, error)
- func (s State) RootHash() []byte
- func (s *State) Set(key StoreKey, value []byte) error
- func (s State) Version() int64
- func (s *State) WithGas(gc GasCalculator) *State
- func (s *State) WithGasStore(gs IGasStore)
- func (s *State) WithoutGas() *State
- func (s State) Write() bool
- type StorageType
- type Store
- type StoreKey
Constants ¶
const ( MEMORY StorageType = iota PERSISTENT CACHE = "cache" CACHE_SAFE = "cache_safe" KEYVALUE = "keyvalue" SESSION_CACHE = "session_cache" CHAINKEY_MAXLEN = 20 CHAINSTATE_CACHE_SIZE = 10000 DB_PREFIX = "_" DB_RANGEFIX = "~" TOMBSTONE = "⛼" )
Different types
const ( OLDATA = "OLDATA" NODEDATA = "nodedata" )
Variables ¶
var ( ErrNotFound = errors.New("key not found") ErrSetFailed = errors.New("failed to set data") ErrExceedGasLimit = errors.New("gas exceeds limit") )
var ErrNilData = errors.New("data is nil")
Functions ¶
func NewCacheSafe ¶
func NewCacheSafe(name string) *cacheSafe
func NewSessionCache ¶ added in v0.14.0
func NewSessionCache(name string) *sessionCache
Types ¶
type ChainState ¶
type ChainState struct { Name string Delivered *iavl.MutableTree // Build us a new set of transactions // Last committed values LastVersion int64 Version int64 LastHash []byte Hash []byte TreeHeight int8 ChainStateRotation ChainStateRotationSetting sync.RWMutex }
Chainstate is a storage for balances on the chain, a snapshot of all accounts
func NewChainState ¶
func NewChainState(name string, db tmdb.DB) *ChainState
NewChainState generates a new ChainState object
func (*ChainState) ClearFrom ¶ added in v0.13.0
func (state *ChainState) ClearFrom(version int64) error
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) Delete ¶ added in v0.12.0
func (state *ChainState) Delete(key StoreKey) (bool, error)
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) ([]byte, error)
TODO: Should be against the commit tree, not the delivered one!!!
func (*ChainState) GetIterable ¶ added in v0.14.0
func (state *ChainState) GetIterable() Iterable
func (*ChainState) GetLatestVersioned ¶ added in v0.12.0
func (state *ChainState) GetLatestVersioned(key StoreKey) (int64, []byte)
func (*ChainState) GetVersioned ¶ added in v0.12.0
func (state *ChainState) GetVersioned(version int64, key StoreKey) (int64, []byte)
func (*ChainState) Iterate ¶ added in v0.10.4
func (state *ChainState) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
func (*ChainState) IterateRange ¶ added in v0.12.0
func (*ChainState) LoadVersion ¶ added in v0.14.0
func (state *ChainState) LoadVersion(version int64) (int64, error)
func (*ChainState) Set ¶
func (state *ChainState) Set(key StoreKey, val []byte) error
Do this only for the Delivery side
func (*ChainState) SetupRotation ¶ added in v0.12.0
func (state *ChainState) SetupRotation(chainStateRotationCfg config.ChainStateRotationCfg) error
Setup the rotation configuration for ChainState, "recent" : latest number of version to persist "every" : every X number of version to persist "cycles" : number of latest every version to persist
type ChainStateRotationSetting ¶ added in v0.14.0
type ChainStateRotationSetting struct {
// contains filtered or unexported fields
}
type GasCalculator ¶ added in v0.12.0
type GasCalculator interface { // Consume amount of Gas for the Category Consume(amount, category Gas, allowOverflow bool) bool // Get the max amount of Gas the GasCalculator accept GetLimit() Gas // Get the current consumed Gas GetConsumed() Gas // Check if the block has fullfill the Gas Limit IsEnough() bool // GetLeft return total gas left, used right now in olvm (frankenstein update) GetLeft() uint64 }
Calculate the gas used for each action, will be embedded with GasStore.
func NewGasCalculator ¶ added in v0.12.0
func NewGasCalculator(limit Gas) GasCalculator
type GasStore ¶ added in v0.12.0
type GasStore struct { SessionedDirectStorage GasCalculator }
func NewGasStore ¶ added in v0.12.0
func NewGasStore(store SessionedDirectStorage, gc GasCalculator) *GasStore
type Iterable ¶ added in v0.14.0
type Iterable interface { Iterate(fn func(key, value []byte) bool) (stop bool) IterateRange(start, end []byte, ascending bool, fn func(key, value []byte) bool) (stop bool) }
The Iterable interface include the function for iteration Iterable function only be implemented for persistent data, doesn't guaranteed in the cache storage
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
func (KeyValue) GetIterable ¶ added in v0.14.0
type KeyValueIterator ¶ added in v0.13.0
type KeyValueIterator struct {
// contains filtered or unexported fields
}
func (*KeyValueIterator) Iterate ¶ added in v0.13.0
func (kvi *KeyValueIterator) Iterate(fn func(key, value []byte) bool) (stop bool)
func (*KeyValueIterator) IterateRange ¶ added in v0.13.0
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) GetIterable ¶ added in v0.14.0
func (session KeyValueSession) GetIterable() Iterable
func (KeyValueSession) Iterate ¶ added in v0.12.0
func (session KeyValueSession) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
GetIterable dummy iterator
func (KeyValueSession) IterateRange ¶ added in v0.12.0
func (KeyValueSession) Rollback ¶
func (session KeyValueSession) Rollback() bool
Rollback any changes since the last commit
type NoGasStore ¶ added in v0.18.15
type NoGasStore struct { SessionedDirectStorage GasCalculator }
NoGasStore skip gas consume because EVM will calculate it and apply at fee processor
func NewNoGasStore ¶ added in v0.18.15
func NewNoGasStore(store SessionedDirectStorage) *NoGasStore
func (*NoGasStore) Delete ¶ added in v0.18.15
func (g *NoGasStore) Delete(key StoreKey) (bool, error)
func (*NoGasStore) Exists ¶ added in v0.18.15
func (g *NoGasStore) Exists(key StoreKey) bool
type SessionedDirectStorage ¶ added in v0.14.0
SessionedDirectStorage
func NewSessionedDirectStorage ¶ added in v0.14.0
func NewSessionedDirectStorage(flavor, name string) SessionedDirectStorage
NewSessionedDirectStorage initializes a non sessioned storage
type SessionedStorage ¶
type SessionedStorage interface { Get(StoreKey) ([]byte, error) Exists(StoreKey) (bool, error) BeginSession() Session Close() error }
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
type State ¶ added in v0.12.0
type State struct {
// contains filtered or unexported fields
}
func NewState ¶ added in v0.12.0
func NewState(state *ChainState) *State
func (*State) BeginTxSession ¶ added in v0.14.0
func (s *State) BeginTxSession()
func (*State) CommitTxSession ¶ added in v0.14.0
func (s *State) CommitTxSession()
func (*State) ConsumeContractGas ¶ added in v0.17.0
func (*State) ConsumeStorageGas ¶ added in v0.12.0
func (*State) ConsumeUpfront ¶ added in v0.13.0
func (*State) ConsumeVerifySigGas ¶ added in v0.12.0
func (*State) ConsumedGas ¶ added in v0.12.0
func (*State) DiscardTxSession ¶ added in v0.14.0
func (s *State) DiscardTxSession()
func (*State) GetAtHeight ¶ added in v0.18.15
func (*State) GetCalculator ¶ added in v0.18.15
func (s *State) GetCalculator() GasCalculator
func (*State) GetGasStore ¶ added in v0.18.15
func (*State) GetIterable ¶ added in v0.14.0
This only Iterate for the ChainState
func (*State) GetPrevious ¶ added in v0.12.0
func (*State) GetVersioned ¶ added in v0.12.0
func (*State) IterateRange ¶ added in v0.12.0
func (*State) LoadVersion ¶ added in v0.14.0
func (*State) WithGas ¶ added in v0.12.0
func (s *State) WithGas(gc GasCalculator) *State