optimism

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

optimism package implements primitives needed for te optimistic read of the chain's state

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RetryOnStateInvalidated

func RetryOnStateInvalidated(fun func() error, timeouts ...time.Duration) error

RetryOnStateInvalidated repeats function while it returns ErrorStateInvalidated Optional parameters:

  • timeouts[0] - overall timeout
  • timeouts[1] - repeat delay

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 (*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) Iterate

func (o *OptimisticKVStoreReader) Iterate(prefix kv.Key, f func(key kv.Key, value []byte) bool) error

func (*OptimisticKVStoreReader) IterateKeys

func (o *OptimisticKVStoreReader) IterateKeys(prefix kv.Key, f func(key kv.Key) bool) error

func (*OptimisticKVStoreReader) IterateKeysSorted

func (o *OptimisticKVStoreReader) IterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool) error

func (*OptimisticKVStoreReader) IterateSorted

func (o *OptimisticKVStoreReader) IterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool) error

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 (o *OptimisticKVStoreReader) MustIterate(prefix kv.Key, f func(key kv.Key, value []byte) bool)

func (*OptimisticKVStoreReader) MustIterateKeys

func (o *OptimisticKVStoreReader) MustIterateKeys(prefix kv.Key, f func(key kv.Key) bool)

func (*OptimisticKVStoreReader) MustIterateKeysSorted

func (o *OptimisticKVStoreReader) MustIterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool)

func (*OptimisticKVStoreReader) MustIterateSorted

func (o *OptimisticKVStoreReader) MustIterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool)

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL