transactions

package
v0.43.2-util-add-execu... Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTransactionNotInBlock = errors.New("transaction not in block")

ErrTransactionNotInBlock represents an error indicating that the transaction is not found in the block.

Functions

This section is empty.

Types

type NoopTxResultCache

type NoopTxResultCache struct{}

NoopTxResultCache is a no-op implementation of the TxResultCache interface.

func NewNoopTxResultCache

func NewNoopTxResultCache() *NoopTxResultCache

NewNoopTxResultCache creates a new no-op implementation of the TxResultCache interface.

func (*NoopTxResultCache) Add

Add adds a transaction result to the cache keyed by its transaction ID, and returns true if an entry was evicted in the process.

This is a no-op implementation which simply ignores the inputs and returns false.

func (*NoopTxResultCache) Get

Get retrieves a cached transaction result by transaction ID, returns true if it exists in the cache, otherwise false.

This is a no-op implementation and always returns nil and false

type Params

type Params struct {
	Log                          zerolog.Logger
	Metrics                      module.TransactionMetrics
	State                        protocol.State
	ChainID                      flow.ChainID
	SystemCollection             *system.SystemCollection
	StaticCollectionRPCClient    accessproto.AccessAPIClient
	HistoricalAccessNodeClients  []accessproto.AccessAPIClient
	NodeCommunicator             node_communicator.Communicator
	ConnFactory                  connection.ConnectionFactory
	EnableRetries                bool
	NodeProvider                 *rpc.ExecutionNodeIdentitiesProvider
	Blocks                       storage.Blocks
	Collections                  storage.Collections
	Transactions                 storage.Transactions
	ScheduledTransactions        storage.ScheduledTransactionsReader
	TxErrorMessageProvider       error_messages.Provider
	TxResultCache                TxResultCache
	TxProvider                   provider.TransactionProvider
	TxValidator                  *validator.TransactionValidator
	TxStatusDeriver              *txstatus.TxStatusDeriver
	EventsIndex                  *index.EventsIndex
	TxResultsIndex               *index.TransactionResultsIndex
	ScheduledTransactionsEnabled bool
}

type Transactions

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

func NewTransactionsBackend

func NewTransactionsBackend(params Params) (*Transactions, error)

func (*Transactions) GetScheduledTransaction

func (t *Transactions) GetScheduledTransaction(ctx context.Context, scheduledTxID uint64) (*flow.TransactionBody, error)

GetScheduledTransaction returns the transaction body of the scheduled transaction by ID.

Expected error returns during normal operation:

func (*Transactions) GetScheduledTransactionResult

func (t *Transactions) GetScheduledTransactionResult(ctx context.Context, scheduledTxID uint64, encodingVersion entities.EventEncodingVersion) (*accessmodel.TransactionResult, error)

GetScheduledTransactionResult returns the transaction result of the scheduled transaction by ID.

Expected error returns during normal operation:

func (*Transactions) GetSystemTransaction

func (t *Transactions) GetSystemTransaction(
	ctx context.Context,
	txID flow.Identifier,
	blockID flow.Identifier,
) (*flow.TransactionBody, error)

GetSystemTransaction returns a system transaction by ID. If no transaction ID is provided, the last system transaction is queried. Note: this function only returns privileged system transactions. It does NOT return user scheduled transactions, which are also contained within the system collection.

func (*Transactions) GetSystemTransactionResult

func (t *Transactions) GetSystemTransactionResult(
	ctx context.Context,
	txID flow.Identifier,
	blockID flow.Identifier,
	encodingVersion entities.EventEncodingVersion,
) (*accessmodel.TransactionResult, error)

GetSystemTransactionResult returns a system transaction result by ID. If no transaction ID is provided, the last system transaction is queried. Note: this function only returns privileged system transactions. It does NOT return user scheduled transactions, which are also contained within the system collection.

func (*Transactions) GetTransaction

func (t *Transactions) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.TransactionBody, error)

func (*Transactions) GetTransactionResult

func (t *Transactions) GetTransactionResult(
	ctx context.Context,
	txID flow.Identifier,
	blockID flow.Identifier,
	collectionID flow.Identifier,
	encodingVersion entities.EventEncodingVersion,
) (txResult *accessmodel.TransactionResult, err error)

func (*Transactions) GetTransactionResultByIndex

func (t *Transactions) GetTransactionResultByIndex(
	ctx context.Context,
	blockID flow.Identifier,
	index uint32,
	encodingVersion entities.EventEncodingVersion,
) (*accessmodel.TransactionResult, error)

GetTransactionResultByIndex returns transactions Results for an index in a block that is executed, pending or finalized transactions return errors

func (*Transactions) GetTransactionResultsByBlockID

func (t *Transactions) GetTransactionResultsByBlockID(
	ctx context.Context,
	blockID flow.Identifier,
	encodingVersion entities.EventEncodingVersion,
) ([]*accessmodel.TransactionResult, error)

func (*Transactions) GetTransactionsByBlockID

func (t *Transactions) GetTransactionsByBlockID(
	ctx context.Context,
	blockID flow.Identifier,
) ([]*flow.TransactionBody, error)

func (*Transactions) ProcessFinalizedBlockHeight

func (t *Transactions) ProcessFinalizedBlockHeight(height uint64) error

ATTENTION: might be a source of problems in future. We run this code on finalization gorotuine, potentially lagging finalization events if operations take long time. We might need to move this logic on dedicated goroutine and provide a way to skip finalization events if they are delivered too often for this engine. An example of similar approach - https://github.com/onflow/flow-go/blob/10b0fcbf7e2031674c00f3cdd280f27bd1b16c47/engine/common/follower/compliance_engine.go#L201.. No errors expected during normal operations.

func (*Transactions) SendRawTransaction

func (t *Transactions) SendRawTransaction(
	ctx context.Context,
	tx *flow.TransactionBody,
) error

SendRawTransaction sends a raw transaction to the collection node

func (*Transactions) SendTransaction

func (t *Transactions) SendTransaction(ctx context.Context, tx *flow.TransactionBody) error

SendTransaction forwards the transaction to the collection node

type TxResultCache

type TxResultCache interface {
	// Get retrieves a cached transaction result by transaction ID,	returns true if it exists in the
	// cache, otherwise false.
	Get(flow.Identifier) (*accessmodel.TransactionResult, bool)

	// Add adds a transaction result to the cache keyed by its transaction ID, and returns true if
	// an entry was evicted in the process.
	Add(flow.Identifier, *accessmodel.TransactionResult) bool
}

TxResultCache is a cache for transaction results used by the API to avoid unnecessary lookups on historical access nodes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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