Documentation ¶
Index ¶
- Constants
- Variables
- func AssertValidKey(key []byte)
- func AssertValidValue(value []byte)
- func Cp(bz []byte) (ret []byte)
- func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvA cmn.KVPair, kvB cmn.KVPair, count int64, equal bool)
- func InclusiveEndBytes(inclusiveBytes []byte) (exclusiveBytes []byte)
- func PrefixEndBytes(prefix []byte) []byte
- type CacheKVStore
- type CacheMultiStore
- type CacheWrap
- type CacheWrapper
- type CommitID
- type CommitKVStore
- type CommitMultiStore
- type CommitStore
- type Committer
- type ErrorGasOverflow
- type ErrorOutOfGas
- type Gas
- type GasConfig
- type GasMeter
- type Iterator
- type KVPair
- type KVStore
- type KVStoreKey
- type MultiStore
- type PruningOptions
- type Queryable
- type Store
- type StoreKey
- type StoreType
- type TraceContext
- type TransientStoreKey
Constants ¶
const ( GasIterNextCostFlatDesc = "IterNextFlat" GasValuePerByteDesc = "ValuePerByte" GasWritePerByteDesc = "WritePerByte" GasReadPerByteDesc = "ReadPerByte" GasWriteCostFlatDesc = "WriteFlat" GasReadCostFlatDesc = "ReadFlat" GasHasDesc = "Has" GasDeleteDesc = "Delete" )
Gas consumption descriptors.
Variables ¶
var ( // PruneEverything means all saved states will be deleted, storing only the current state PruneEverything = NewPruningOptions(0, 0) // PruneNothing means all historic states will be saved, nothing will be deleted PruneNothing = NewPruningOptions(0, 1) // PruneSyncable means only those states not needed for state syncing will be deleted (keeps last 100 + every 10000th) PruneSyncable = NewPruningOptions(100, 10000) )
default pruning strategies
Functions ¶
func AssertValidValue ¶
func AssertValidValue(value []byte)
Check if the value is valid(value is not nil)
func DiffKVStores ¶
func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvA cmn.KVPair, kvB cmn.KVPair, count int64, equal bool)
Compare two KVstores, return either the first key/value pair at which they differ and whether or not they are equal, skipping value comparison for a set of provided prefixes
func InclusiveEndBytes ¶
InclusiveEndBytes returns the []byte that would end a range query such that the input would be included
func PrefixEndBytes ¶
PrefixEndBytes returns the []byte that would end a range query for all []byte with a certain prefix Deals with last byte of prefix being FF without overflowing
Types ¶
type CacheKVStore ¶
type CacheKVStore interface { KVStore // Writes operations to underlying KVStore Write() }
CacheKVStore cache-wraps a KVStore. After calling .Write() on the CacheKVStore, all previously created CacheKVStores on the object expire.
type CacheMultiStore ¶
type CacheMultiStore interface { MultiStore Write() // Writes operations to underlying KVStore }
From MultiStore.CacheMultiStore()....
type CacheWrap ¶
type CacheWrap interface { // Write syncs with the underlying store. Write() // CacheWrap recursively wraps again. CacheWrap() CacheWrap // CacheWrapWithTrace recursively wraps again with tracing enabled. CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap }
CacheWrap makes the most appropriate cache-wrap. For example, IAVLStore.CacheWrap() returns a CacheKVStore. CacheWrap should not return a Committer, since Commit cache-wraps make no sense. It can return KVStore, HeapStore, SpaceStore, etc.
type CacheWrapper ¶
type CacheWrapper interface { // CacheWrap cache wraps. CacheWrap() CacheWrap // CacheWrapWithTrace cache wraps with tracing enabled. CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap }
type CommitKVStore ¶
Stores of MultiStore must implement CommitStore.
type CommitMultiStore ¶
type CommitMultiStore interface { Committer MultiStore // Mount a store of type using the given db. // If db == nil, the new store will use the CommitMultiStore db. MountStoreWithDB(key StoreKey, typ StoreType, db dbm.DB) // Panics on a nil key. GetCommitStore(key StoreKey) CommitStore // Panics on a nil key. GetCommitKVStore(key StoreKey) CommitKVStore // Load the latest persisted version. Called once after all // calls to Mount*Store() are complete. LoadLatestVersion() error // Load a specific persisted version. When you load an old // version, or when the last commit attempt didn't complete, // the next commit after loading must be idempotent (return the // same commit id). Otherwise the behavior is undefined. LoadVersion(ver int64) error }
A non-cache MultiStore.
type CommitStore ¶
Stores of MultiStore must implement CommitStore.
type Committer ¶
type Committer interface { Commit() CommitID LastCommitID() CommitID SetPruning(PruningOptions) }
something that can persist to disk
type ErrorGasOverflow ¶
type ErrorGasOverflow struct {
Descriptor string
}
ErrorGasOverflow defines an error thrown when an action results gas consumption unsigned integer overflow.
type ErrorOutOfGas ¶
type ErrorOutOfGas struct {
Descriptor string
}
ErrorOutOfGas defines an error thrown when an action results in out of gas.
type GasConfig ¶
type GasConfig struct { HasCost Gas DeleteCost Gas ReadCostFlat Gas ReadCostPerByte Gas WriteCostFlat Gas WriteCostPerByte Gas IterNextCostFlat Gas }
GasConfig defines gas cost for each operation on KVStores
func KVGasConfig ¶
func KVGasConfig() GasConfig
KVGasConfig returns a default gas config for KVStores.
func TransientGasConfig ¶
func TransientGasConfig() GasConfig
TransientGasConfig returns a default gas config for TransientStores.
type GasMeter ¶
type GasMeter interface { GasConsumed() Gas GasConsumedToLimit() Gas Limit() Gas ConsumeGas(amount Gas, descriptor string) IsPastLimit() bool IsOutOfGas() bool }
GasMeter interface to track gas consumption
func NewGasMeter ¶
NewGasMeter returns a reference to a new basicGasMeter.
func NewInfiniteGasMeter ¶
func NewInfiniteGasMeter() GasMeter
NewInfiniteGasMeter returns a reference to a new infiniteGasMeter.
type Iterator ¶
Alias iterator to db's Iterator for convenience.
func KVStorePrefixIterator ¶
Iterator over all the keys with a certain prefix in ascending order
func KVStoreReversePrefixIterator ¶
Iterator over all the keys with a certain prefix in descending order.
type KVStore ¶
type KVStore interface { Store // Get returns nil iff key doesn't exist. Panics on nil key. Get(key []byte) []byte // Has checks if a key exists. Panics on nil key. Has(key []byte) bool // Set sets the key. Panics on nil key or value. Set(key, value []byte) // Delete deletes the key. Panics on nil key. Delete(key []byte) // Iterator over a domain of keys in ascending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. // To iterate over entire domain, use store.Iterator(nil, nil) // CONTRACT: No writes may happen within a domain while an iterator exists over it. // Exceptionally allowed for cachekv.Store, safe to write in the modules. Iterator(start, end []byte) Iterator // Iterator over a domain of keys in descending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. // CONTRACT: No writes may happen within a domain while an iterator exists over it. // Exceptionally allowed for cachekv.Store, safe to write in the modules. ReverseIterator(start, end []byte) Iterator }
KVStore is a simple interface to get/set data TODO cosmos 的存储抽象定义 应用程序的基本存储层是KVStore
type KVStoreKey ¶
type KVStoreKey struct {
// contains filtered or unexported fields
}
KVStoreKey is used for accessing substores. Only the pointer value should ever be used - it functions as a capabilities key. * KVStoreKey用于访问 substores。 应该只使用指针值 - 它用来做功能键。
func NewKVStoreKey ¶
func NewKVStoreKey(name string) *KVStoreKey
NewKVStoreKey returns a new pointer to a KVStoreKey. Use a pointer so keys don't collide. * NewKVStoreKey返回一个指向KVStoreKey的新指针。 使用指针,以便键不会发生碰撞
func (*KVStoreKey) Name ¶
func (key *KVStoreKey) Name() string
func (*KVStoreKey) String ¶
func (key *KVStoreKey) String() string
type MultiStore ¶
type MultiStore interface { Store // Cache wrap MultiStore. // NOTE: Caller should probably not call .Write() on each, but // call CacheMultiStore.Write(). CacheMultiStore() CacheMultiStore // Convenience for fetching substores. // If the store does not exist, panics. GetStore(StoreKey) Store GetKVStore(StoreKey) KVStore // TracingEnabled returns if tracing is enabled for the MultiStore. TracingEnabled() bool // SetTracer sets the tracer for the MultiStore that the underlying // stores will utilize to trace operations. The modified MultiStore is // returned. SetTracer(w io.Writer) MultiStore // SetTracingContext sets the tracing context for a MultiStore. It is // implied that the caller should update the context when necessary between // tracing operations. The modified MultiStore is returned. SetTracingContext(TraceContext) MultiStore }
type PruningOptions ¶
type PruningOptions struct {
// contains filtered or unexported fields
}
PruningStrategy specifies how old states will be deleted over time where keepRecent can be used with keepEvery to create a pruning "strategy".
func NewPruningOptions ¶
func NewPruningOptions(keepRecent, keepEvery int64) PruningOptions
func (PruningOptions) KeepEvery ¶
func (po PruningOptions) KeepEvery() int64
Keeps every N stated, deleting others.
func (PruningOptions) KeepRecent ¶
func (po PruningOptions) KeepRecent() int64
How much recent state will be kept. Older state will be deleted.
type Queryable ¶
type Queryable interface {
Query(abci.RequestQuery) abci.ResponseQuery
}
Queryable allows a Store to expose internal state to the abci.Query interface. Multistore can route requests to the proper Store.
This is an optional, but useful extension to any CommitStore
type Store ¶
type Store interface { GetStoreType() StoreType CacheWrapper }
type TraceContext ¶
type TraceContext map[string]interface{}
TraceContext contains TraceKVStore context data. It will be written with every trace operation.
type TransientStoreKey ¶
type TransientStoreKey struct {
// contains filtered or unexported fields
}
TransientStoreKey is used for indexing transient stores in a MultiStore * TransientStoreKey用于索引MultiStore中的临时存储
func NewTransientStoreKey ¶
func NewTransientStoreKey(name string) *TransientStoreKey
Constructs new TransientStoreKey Must return a pointer according to the ocap principle
func (*TransientStoreKey) String ¶
func (key *TransientStoreKey) String() string
Implements StoreKey