executor

package
v1.0.1-beta-6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockScope

type BlockScope interface {
	// ExecuteTxnEvents executes atomically all the events in an EVM-transaction, returning the TableID where
	// changes were applied. Changes aren't fully committed to the database until Commit(...) is called.
	// If the execution of events in the transaction fails, the client should distinguish between errors of type
	// ErrQueryExecution which aren't recoverable, and infrastructure errors which are recoverable.
	ExecuteTxnEvents(context.Context, eventfeed.TxnEvents) (TxnExecutionResult, error)

	// SetLastprocessedHeight sets a new processed height.
	SetLastProcessedHeight(ctx context.Context, height int64) error

	// SaveTxnReceipts saves a set of transaction receipts.
	SaveTxnReceipts(ctx context.Context, rs []eventprocessor.Receipt) error

	// TxnReceiptExists return true if the provided transaction hash was already processed, and false otherwise.
	TxnReceiptExists(ctx context.Context, txnHash common.Hash) (bool, error)

	// StateHash calculates the hash of some state of the database.
	StateHash(ctx context.Context, chainID tableland.ChainID) (StateHash, error)

	// Commit commits all the changes that happened in  previously successful ExecuteTxnEvents(...) calls.
	Commit() error

	// Close gracefully closes the block scope. If Commit(...) called before, it's a noop. If Commit(...) wasn't called,
	// then it will rollback any changes done in previous ExecuteTxnEvents(...) calls.
	Close() error
}

BlockScope provides a sandbox to execute events generated by each EVM transaction in the block. It provides an all or nothing execution at the block level, while allowing each transaction processing to also be an all or nothing execution of all the events contained in that transaction.

type Executor

type Executor interface {
	// NewBlockScope returns a new block scope which can execute events generated by EVM-transactions.
	NewBlockScope(context.Context, int64) (BlockScope, error)

	// GetLastExecutedBlockNumber returns the last executed block number.
	GetLastExecutedBlockNumber(ctx context.Context) (int64, error)

	// Close gracefully closes the executor, waiting for any block scope to be gracefully closed or force closing
	// if the provided context gets canceled.
	Close(context.Context) error
}

Executor provides a safe way of executing events contained in an EVM blockchain block.

type StateHash

type StateHash struct {
	ChainID     tableland.ChainID
	BlockNumber int64
	Hash        string
}

StateHash represents the state of the database at given block number for a particular chain id.

func NewStateHash

func NewStateHash(chainID tableland.ChainID, blockNumber int64, hash string) StateHash

NewStateHash creates a new state hash.

type TxnExecutionResult

type TxnExecutionResult struct {
	TableID *tables.TableID

	Error         *string
	ErrorEventIdx *int
}

TxnExecutionResult contains the result of executing a txn with all contained events.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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