indexes

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountTransactions

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

AccountTransactions implements storage.AccountTransactions using Pebble. It provides an index mapping accounts to their transactions, ordered by block height in descending order (newest first).

Key format: [prefix][address][~block_height][tx_index] - prefix: 1 byte (codeAccountTransactions) - address: 8 bytes (flow.Address) - ~block_height: 8 bytes (one's complement for descending sort) - tx_index: 4 bytes (uint32, big-endian)

Value format: storedAccountTransaction - tx_id: 32 bytes (flow.Identifier) - roles: variable length ([]access.TransactionRole)

All read methods are safe for concurrent access. Write methods (Store) must be called sequentially with consecutive heights.

func BootstrapAccountTransactions

func BootstrapAccountTransactions(lctx lockctx.Proof, rw storage.ReaderBatchWriter, db storage.DB, initialStartHeight uint64, txData []access.AccountTransaction) (*AccountTransactions, error)

BootstrapAccountTransactions initializes the account transactions index with data from the first block, and returns a new AccountTransactions instance. The caller must hold the storage.LockIndexAccountTransactions lock until the batch is committed.

Expected error returns during normal operations:

func NewAccountTransactions

func NewAccountTransactions(db storage.DB) (*AccountTransactions, error)

NewAccountTransactions creates a new AccountTransactions backed by the given database.

If the index has not been initialized, constuction will fail with storage.ErrNotBootstrapped. The caller should retry with `BootstrapAccountTransactions` passing the required initialization data.

Expected error returns during normal operations:

func (*AccountTransactions) FirstIndexedHeight

func (idx *AccountTransactions) FirstIndexedHeight() uint64

FirstIndexedHeight returns the first (oldest) block height that has been indexed.

func (*AccountTransactions) LatestIndexedHeight

func (idx *AccountTransactions) LatestIndexedHeight() uint64

LatestIndexedHeight returns the latest block height that has been indexed.

func (*AccountTransactions) Store

func (idx *AccountTransactions) Store(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockHeight uint64, txData []access.AccountTransaction) error

Store indexes all account-transaction associations for a block. Repeated calls at the latest height are a no-op. Must be called sequentially with consecutive heights (latestHeight + 1). The caller must hold the storage.LockIndexAccountTransactions lock until the batch is committed.

Expected error returns during normal operations:

func (*AccountTransactions) TransactionsByAddress

func (idx *AccountTransactions) TransactionsByAddress(
	account flow.Address,
	startHeight uint64,
	endHeight uint64,
) ([]access.AccountTransaction, error)

TransactionsByAddress retrieves transaction references for an account within the specified block height range (inclusive). Results are returned in descending order (newest first).

If `endHeight` is greater than the latest indexed height, the latest indexed height will be used.

Expected error returns during normal operations:

type AccountTransactionsBootstrapper

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

AccountTransactionsBootstrapper wraps an AccountTransactions and performs just-in-time initialization of the index when the initial block is provided.

Account transactions are indexed from execution data which may not be available for the root block during bootstrapping. This module acts as a proxy for the underlying AccountTransactions and encapsulates the complexity of initializing the index when the initial block is eventually provided.

func NewAccountTransactionsBootstrapper

func NewAccountTransactionsBootstrapper(db storage.DB, initialStartHeight uint64) (*AccountTransactionsBootstrapper, error)

func (*AccountTransactionsBootstrapper) FirstIndexedHeight

func (b *AccountTransactionsBootstrapper) FirstIndexedHeight() (uint64, error)

FirstIndexedHeight returns the first (oldest) block height that has been indexed.

Expected error returns during normal operations:

func (*AccountTransactionsBootstrapper) LatestIndexedHeight

func (b *AccountTransactionsBootstrapper) LatestIndexedHeight() (uint64, error)

LatestIndexedHeight returns the latest block height that has been indexed.

Expected error returns during normal operations:

func (*AccountTransactionsBootstrapper) Store

Store indexes all account-transaction associations for a block. Must be called sequentially with consecutive heights (latestHeight + 1). Calling with the last height is a no-op. The caller must hold the storage.LockIndexAccountTransactions lock until the batch is committed.

Expected error returns during normal operations:

func (*AccountTransactionsBootstrapper) TransactionsByAddress

func (b *AccountTransactionsBootstrapper) TransactionsByAddress(account flow.Address, startHeight uint64, endHeight uint64) ([]access.AccountTransaction, error)

TransactionsByAddress retrieves transaction references for an account within the specified block height range (inclusive). Results are returned in descending order (newest first).

Expected error returns during normal operations:

func (*AccountTransactionsBootstrapper) UninitializedFirstHeight

func (b *AccountTransactionsBootstrapper) UninitializedFirstHeight() (uint64, bool)

UninitializedFirstHeight returns the height the index will accept as the first height, and a boolean indicating if the index is initialized. If the index is not initialized, the first call to `Store` must include data for this height.

Jump to

Keyboard shortcuts

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