transactions

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: AGPL-3.0 Imports: 27 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 added in v0.44.0

type NoopTxResultCache struct{}

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

func NewNoopTxResultCache added in v0.44.0

func NewNoopTxResultCache() *NoopTxResultCache

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

func (*NoopTxResultCache) Add added in v0.44.0

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 added in v0.44.0

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
	SystemCollections            *systemcollection.Versioned
	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 added in v0.44.0

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 added in v0.44.0

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) 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 added in v0.44.0

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