Documentation ¶
Overview ¶
optimism package implements primitives needed for te optimistic read of the chain's state
Index ¶
- func RetryOnStateInvalidated(fun func() error, timeouts ...time.Duration) error
- type OptimisticKVStoreReader
- func (o *OptimisticKVStoreReader) Baseline() coreutil.StateBaseline
- func (o *OptimisticKVStoreReader) Get(key kv.Key) ([]byte, error)
- func (o *OptimisticKVStoreReader) Has(key kv.Key) (bool, error)
- func (o *OptimisticKVStoreReader) IsStateValid() bool
- func (o *OptimisticKVStoreReader) Iterate(prefix kv.Key, f func(key kv.Key, value []byte) bool) error
- func (o *OptimisticKVStoreReader) IterateKeys(prefix kv.Key, f func(key kv.Key) bool) error
- func (o *OptimisticKVStoreReader) IterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool) error
- func (o *OptimisticKVStoreReader) IterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool) error
- func (o *OptimisticKVStoreReader) MustGet(key kv.Key) []byte
- func (o *OptimisticKVStoreReader) MustHas(key kv.Key) bool
- func (o *OptimisticKVStoreReader) MustIterate(prefix kv.Key, f func(key kv.Key, value []byte) bool)
- func (o *OptimisticKVStoreReader) MustIterateKeys(prefix kv.Key, f func(key kv.Key) bool)
- func (o *OptimisticKVStoreReader) MustIterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool)
- func (o *OptimisticKVStoreReader) MustIterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool)
- func (o *OptimisticKVStoreReader) SetBaseline()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type OptimisticKVStoreReader ¶
type OptimisticKVStoreReader struct {
// contains filtered or unexported fields
}
OptimisticKVStoreReader implements KVReader interfaces. It wraps any kv.KVStoreReader together with the baseline of the state index, which, in turn, is linked to the global state index object. The user of the OptimisticKVStoreReader announces it starts reading the state with SetBaseline. Then the user reads the state with Get's. If sequense of Get's is finished without error, it means state wasn't invalidated from the baseline until the last read. If returned error is ErrorStateInvalidated ir means state was invalidated since SetBaseline. In this case read can be repeated. Any other error is a database error
func NewOptimisticKVStoreReader ¶
func NewOptimisticKVStoreReader(store kv.KVStoreReader, baseline coreutil.StateBaseline) *OptimisticKVStoreReader
NewOptimisticKVStoreReader creates an instance of the optimistic reader
func (*OptimisticKVStoreReader) Baseline ¶ added in v0.3.0
func (o *OptimisticKVStoreReader) Baseline() coreutil.StateBaseline
func (*OptimisticKVStoreReader) Get ¶
func (o *OptimisticKVStoreReader) Get(key kv.Key) ([]byte, error)
func (*OptimisticKVStoreReader) Has ¶
func (o *OptimisticKVStoreReader) Has(key kv.Key) (bool, error)
func (*OptimisticKVStoreReader) IsStateValid ¶
func (o *OptimisticKVStoreReader) IsStateValid() bool
IsStateValid check the validity of the baseline
func (*OptimisticKVStoreReader) IterateKeys ¶
func (*OptimisticKVStoreReader) IterateKeysSorted ¶
func (*OptimisticKVStoreReader) IterateSorted ¶
func (*OptimisticKVStoreReader) MustGet ¶
func (o *OptimisticKVStoreReader) MustGet(key kv.Key) []byte
func (*OptimisticKVStoreReader) MustHas ¶
func (o *OptimisticKVStoreReader) MustHas(key kv.Key) bool
func (*OptimisticKVStoreReader) MustIterate ¶
func (*OptimisticKVStoreReader) MustIterateKeys ¶
func (*OptimisticKVStoreReader) MustIterateKeysSorted ¶
func (*OptimisticKVStoreReader) MustIterateSorted ¶
func (*OptimisticKVStoreReader) SetBaseline ¶
func (o *OptimisticKVStoreReader) SetBaseline()
SetBaseline sets the baseline for the read. Each and check if it wasn't invalidated by the global variable (the state manager)