state

package
v0.0.5-beta2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutputValueTypeInt64    = "int64"
	OutputValueTypeFloat64  = "float64"
	OutputValueTypeBigInt   = "bigInt"
	OutputValueTypeBigFloat = "bigFloat"
	OutputValueTypeString   = "string"
)
View Source
const WaiterSleepInterval = 5 * time.Second

Variables

View Source
var NotFound = errors.New("state key not found")

Functions

func FilePrefix

func FilePrefix(storeName string, endBlockNum uint64) string

func PartialFileName

func PartialFileName(storeName string, startBlockNum, endBlockNum uint64) string

func StateFileName

func StateFileName(storeName string, startBlockNum, endBlockNum uint64) string

func StateFilePrefix

func StateFilePrefix(storeName string, blockNum uint64) string

func WaitKV

func WaitKV(ctx context.Context, storeName string, store dstore.Store, moduleStartBlock, endBlock uint64) <-chan error

func WaitPartial

func WaitPartial(ctx context.Context, storeName string, store dstore.Store, startBlock, endBlock uint64) <-chan error

Types

type Builder

type Builder struct {
	Name  string
	Store *Store

	ModuleStartBlock uint64
	ModuleHash       string

	KV              map[string][]byte          // KV is the state, and assumes all Deltas were already applied to it.
	Deltas          []*pbsubstreams.StoreDelta // Deltas are always deltas for the given block.
	DeletedPrefixes []string
	// contains filtered or unexported fields
}

func BuilderFromFile

func BuilderFromFile(ctx context.Context, filename string, store dstore.Store) (*Builder, error)

func NewBuilder

func NewBuilder(name string, moduleStartBlock uint64, updatePolicy pbsubstreams.Module_KindStore_UpdatePolicy, valueType string, store *Store, opts ...BuilderOption) *Builder

func (*Builder) Del

func (b *Builder) Del(ord uint64, key string)

func (*Builder) DeletePrefix

func (b *Builder) DeletePrefix(ord uint64, prefix string)

func (*Builder) Flush

func (b *Builder) Flush()

func (*Builder) GetAt

func (b *Builder) GetAt(ord uint64, key string) (out []byte, found bool)

GetAt returns the key for the state that includes the processing of `ord`.

func (*Builder) GetFirst

func (b *Builder) GetFirst(key string) ([]byte, bool)

func (*Builder) GetLast

func (b *Builder) GetLast(key string) ([]byte, bool)

func (*Builder) Merge

func (b *Builder) Merge(previous *Builder) error

func (*Builder) Print

func (b *Builder) Print()

func (*Builder) PrintDelta

func (b *Builder) PrintDelta(delta *pbsubstreams.StoreDelta)

func (*Builder) ReadState

func (b *Builder) ReadState(ctx context.Context, requestedStartBlock uint64) error

func (*Builder) Set

func (b *Builder) Set(ord uint64, key string, value string)

func (*Builder) SetBytes

func (b *Builder) SetBytes(ord uint64, key string, value []byte)

func (*Builder) SetBytesIfNotExists

func (b *Builder) SetBytesIfNotExists(ord uint64, key string, value []byte)

func (*Builder) SetIfNotExists

func (b *Builder) SetIfNotExists(ord uint64, key string, value string)

func (*Builder) SetMaxBigFloat

func (b *Builder) SetMaxBigFloat(ord uint64, key string, value *big.Float)

func (*Builder) SetMaxBigInt

func (b *Builder) SetMaxBigInt(ord uint64, key string, value *big.Int)

func (*Builder) SetMaxFloat64

func (b *Builder) SetMaxFloat64(ord uint64, key string, value float64)

func (*Builder) SetMaxInt64

func (b *Builder) SetMaxInt64(ord uint64, key string, value int64)

func (*Builder) SetMinBigFloat

func (b *Builder) SetMinBigFloat(ord uint64, key string, value *big.Float)

func (*Builder) SetMinBigInt

func (b *Builder) SetMinBigInt(ord uint64, key string, value *big.Int)

func (*Builder) SetMinFloat64

func (b *Builder) SetMinFloat64(ord uint64, key string, value float64)

func (*Builder) SetMinInt64

func (b *Builder) SetMinInt64(ord uint64, key string, value int64)

func (*Builder) Squash

func (b *Builder) Squash(ctx context.Context, baseStore dstore.Store, upToBlock uint64) error

func (*Builder) SumBigFloat

func (b *Builder) SumBigFloat(ord uint64, key string, value *big.Float)

func (*Builder) SumBigInt

func (b *Builder) SumBigInt(ord uint64, key string, value *big.Int)

func (*Builder) SumFloat64

func (b *Builder) SumFloat64(ord uint64, key string, value float64)

func (*Builder) SumInt64

func (b *Builder) SumInt64(ord uint64, key string, value int64)

func (*Builder) WriteState

func (b *Builder) WriteState(ctx context.Context, blockNum uint64, partialMode bool) (filename string, err error)

type BuilderOption

type BuilderOption func(b *Builder)

func WithPartialMode

func WithPartialMode(startBlock uint64) BuilderOption

type ConditionalKeySetter

type ConditionalKeySetter interface {
	SetIfNotExists(ord uint64, key string, value string)
	SetBytesIfNotExists(ord uint64, key string, value []byte)
}

type Deleter

type Deleter interface {
	DeletePrefix(ord uint64, prefix string)
}

type FileInfo

type FileInfo struct {
	ModuleName string
	StartBlock uint64
	EndBlock   uint64
	Partial    bool
}

func ParseFileName

func ParseFileName(filename string) (*FileInfo, bool)

type FileWaiter

type FileWaiter struct {
	// contains filtered or unexported fields
}

func NewFileWaiter

func NewFileWaiter(targetStartBlock uint64, stores []*Store) *FileWaiter

func (*FileWaiter) Wait

func (w *FileWaiter) Wait(ctx context.Context, requestStartBlock uint64, moduleStartBlock uint64) error

type MaxBigFloatSetter

type MaxBigFloatSetter interface {
	SetMaxBigFloat(ord uint64, key string, value *big.Float)
}

type MaxBigIntSetter

type MaxBigIntSetter interface {
	SetMaxBigInt(ord uint64, key string, value *big.Int)
}

type MaxFloat64Setter

type MaxFloat64Setter interface {
	SetMaxFloat64(ord uint64, key string, value float64)
}

type MaxInt64Setter

type MaxInt64Setter interface {
	SetMaxInt64(ord uint64, key string, value int64)
}

type Mergeable

type Mergeable interface {
	Merge(other *Builder) error
}

type MinBigFloatSetter

type MinBigFloatSetter interface {
	SetMinBigFloat(ord uint64, key string, value *big.Float)
}

type MinBigIntSetter

type MinBigIntSetter interface {
	SetMinBigInt(ord uint64, key string, value *big.Int)
}

type MinFloat64Setter

type MinFloat64Setter interface {
	SetMinFloat64(ord uint64, key string, value float64)
}

type MinInt64Setter

type MinInt64Setter interface {
	SetMinInt64(ord uint64, key string, value int64)
}

type Reader

type Reader interface {
	GetFirst(key string) ([]byte, bool)
	GetLast(key string) ([]byte, bool)
	GetAt(ord uint64, key string) ([]byte, bool)
}

type Store

type Store struct {
	dstore.Store

	Name             string
	ModuleHash       string
	ModuleStartBlock uint64
}

func NewStore added in v0.0.19

func NewStore(name string, moduleHash string, moduleStartBlock uint64, baseStore dstore.Store) (*Store, error)

func (*Store) PartialFileName

func (s *Store) PartialFileName(startBlockNum, endBlockNum uint64) string

func (*Store) StateFileName

func (s *Store) StateFileName(blockNum uint64) string

func (*Store) StateFilePrefix

func (s *Store) StateFilePrefix(blockNum uint64) string

func (*Store) WritePartialState

func (s *Store) WritePartialState(ctx context.Context, content []byte, startBlockNum, endBlockNum uint64) (string, error)

func (*Store) WriteState

func (s *Store) WriteState(ctx context.Context, content []byte, blockNum uint64) (string, error)

type SumBigFloatSetter

type SumBigFloatSetter interface {
	SumBigFloat(ord uint64, key string, value *big.Float)
}

type SumBigIntSetter

type SumBigIntSetter interface {
	SumBigInt(ord uint64, key string, value *big.Int)
}

type SumFloat64Setter

type SumFloat64Setter interface {
	SumFloat64(ord uint64, key string, value float64)
}

type SumInt64Setter

type SumInt64Setter interface {
	SumInt64(ord uint64, key string, value int64)
}

type UpdateKeySetter

type UpdateKeySetter interface {
	Set(ord uint64, key string, value string)
	SetBytes(ord uint64, key string, value []byte)
}

Jump to

Keyboard shortcuts

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