query

package
v0.37.12-add-verify-ex... Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLogTimeThreshold    = 1 * time.Second
	DefaultExecutionTimeLimit  = 10 * time.Second
	DefaultMaxErrorMessageSize = 1000 // 1000 chars
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EntropyProviderPerBlock added in v0.32.0

type EntropyProviderPerBlock interface {
	// AtBlockID returns an entropy provider at the given block ID.
	AtBlockID(blockID flow.Identifier) environment.EntropyProvider
}

EntropyProviderPerBlock is an abstraction for entropy providers that can be used in `QueryExecutor`.

`EntropyProvider` is defined in `fvm/environment` and abstracts the distributed random source used by the protocol.

For a full-protocol node implementation , `EntropyProvider` is implemented by the protocol `Snapshot`, while `EntropyProviderPerBlock` is implemented by the protocol `State`. For nodes answering script queries that do not participate in the protocol, `EntropyProvider` and `EntropyProviderPerBlock` can be implemented by other components that provide the source of randomness for each block.

func NewProtocolStateWrapper added in v0.32.0

func NewProtocolStateWrapper(s protocol.State) EntropyProviderPerBlock

NewProtocolStateWrapper wraps a protocol.State input as an `EntropyProviderPerBlock`

type Executor

type Executor interface {
	ExecuteScript(
		ctx context.Context,
		script []byte,
		arguments [][]byte,
		blockHeader *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		[]byte,
		uint64,
		error,
	)

	GetAccount(
		ctx context.Context,
		addr flow.Address,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		*flow.Account,
		error,
	)

	GetAccountBalance(
		ctx context.Context,
		addr flow.Address,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		uint64,
		error,
	)

	GetAccountAvailableBalance(
		ctx context.Context,
		addr flow.Address,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		uint64,
		error,
	)

	GetAccountKeys(
		ctx context.Context,
		addr flow.Address,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		[]flow.AccountPublicKey,
		error,
	)

	GetAccountKey(
		ctx context.Context,
		addr flow.Address,
		keyIndex uint32,
		header *flow.Header,
		snapshot snapshot.StorageSnapshot,
	) (
		*flow.AccountPublicKey,
		error,
	)
}

type QueryConfig

type QueryConfig struct {
	LogTimeThreshold    time.Duration
	ExecutionTimeLimit  time.Duration
	ComputationLimit    uint64
	MaxErrorMessageSize int
}

func NewDefaultConfig

func NewDefaultConfig() QueryConfig

type QueryExecutor

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

func NewQueryExecutor

func NewQueryExecutor(
	config QueryConfig,
	logger zerolog.Logger,
	metrics module.ExecutionMetrics,
	vm fvm.VM,
	vmCtx fvm.Context,
	derivedChainData *derived.DerivedChainData,
	entropyPerBlock EntropyProviderPerBlock,
) *QueryExecutor

func (*QueryExecutor) ExecuteScript

func (e *QueryExecutor) ExecuteScript(
	ctx context.Context,
	script []byte,
	arguments [][]byte,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (
	encodedValue []byte,
	computationUsed uint64,
	err error,
)

func (*QueryExecutor) GetAccount

func (e *QueryExecutor) GetAccount(
	_ context.Context,
	address flow.Address,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (
	*flow.Account,
	error,
)

func (*QueryExecutor) GetAccountAvailableBalance added in v0.36.1

func (e *QueryExecutor) GetAccountAvailableBalance(
	_ context.Context,
	address flow.Address,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (uint64, error)

func (*QueryExecutor) GetAccountBalance added in v0.35.17

func (e *QueryExecutor) GetAccountBalance(
	_ context.Context,
	address flow.Address,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (uint64, error)

func (*QueryExecutor) GetAccountKey added in v0.36.1

func (e *QueryExecutor) GetAccountKey(
	_ context.Context,
	address flow.Address,
	keyIndex uint32,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) (*flow.AccountPublicKey, error)

func (*QueryExecutor) GetAccountKeys added in v0.35.17

func (e *QueryExecutor) GetAccountKeys(
	_ context.Context,
	address flow.Address,
	blockHeader *flow.Header,
	snapshot snapshot.StorageSnapshot,
) ([]flow.AccountPublicKey, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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