storage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockIndexer

type BlockIndexer interface {
	// Store provided EVM block with the matching Cadence height and Cadence Block ID.
	// Batch is required to batch multiple indexer operations, skipped if nil.
	// Expected errors:
	// - errors.Duplicate if the block already exists
	Store(cadenceHeight uint64, cadenceID flow.Identifier, block *models.Block, batch *pebble.Batch) error

	// GetByHeight returns an EVM block stored by EVM height.
	// Expected errors:
	// - errors.NotFound if the block is not found
	GetByHeight(height uint64) (*models.Block, error)

	// GetByID returns an EVM block stored by ID.
	// Expected errors:
	// - errors.NotFound if the block is not found
	GetByID(ID common.Hash) (*models.Block, error)

	// GetHeightByID returns the EVM block height for the given ID.
	// Expected errors:
	// - errors.NotFound if the block is not found
	GetHeightByID(ID common.Hash) (uint64, error)

	// LatestEVMHeight returns the latest stored EVM block height.
	// Expected errors:
	// - errors.NotInitialized if the storage was not initialized
	LatestEVMHeight() (uint64, error)

	// LatestCadenceHeight return the latest stored Cadence height.
	// Expected errors:
	// - errors.NotInitialized if the storage was not initialized
	LatestCadenceHeight() (uint64, error)

	// SetLatestCadenceHeight sets the latest Cadence height.
	SetLatestCadenceHeight(cadenceHeight uint64, batch *pebble.Batch) error

	// GetCadenceHeight returns the Cadence height that matches the
	// provided EVM height. Each EVM block indexed contains a link
	// to the Cadence height.
	// - errors.NotFound if the height is not found
	GetCadenceHeight(height uint64) (uint64, error)

	// GetCadenceID returns the Cadence block ID that matches the
	// provided EVM height. Each EVM block indexed contains a link to the
	// Cadence block ID. Multiple EVM heights can point to the same
	// Cadence block ID.
	// - errors.NotFound if the height is not found
	GetCadenceID(height uint64) (flow.Identifier, error)
}

type ReceiptIndexer

type ReceiptIndexer interface {
	// Store provided receipt.
	// Batch is required to batch multiple indexer operations, skipped if nil.
	Store(receipts []*models.Receipt, batch *pebble.Batch) error

	// GetByTransactionID returns the receipt for the transaction ID.
	// Expected errors:
	// - errors.NotFound if the receipt is not found
	GetByTransactionID(ID common.Hash) (*models.Receipt, error)

	// GetByBlockHeight returns the receipt for the block height.
	// Expected errors:
	// - errors.NotFound if the receipt is not found
	GetByBlockHeight(height uint64) ([]*models.Receipt, error)

	// BloomsForBlockRange returns slice of bloom values and a slice of block heights
	// corresponding to each item in the bloom slice. It only matches the blooms between
	// inclusive start and end block height.
	// Expected errors:
	// - errors.InvalidRange if the block by the height was not indexed or if the end and start values are invalid.
	BloomsForBlockRange(start, end uint64) ([]*models.BloomsHeight, error)
}

type RegisterDelta added in v1.0.0

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

func NewRegisterDelta added in v1.0.0

func NewRegisterDelta(
	registers types.BackendStorageSnapshot,
) *RegisterDelta

NewRegisterDelta creates a new instance of RegisterDelta. It is not concurrency safe. This allows for the caller to build new state on top of the provided snapshot. The new state is not persisted. The caller is responsible for persisting the state using the `GetUpdates` method.

func (*RegisterDelta) AllocateSlabIndex added in v1.0.0

func (r *RegisterDelta) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)

func (*RegisterDelta) GetUpdates added in v1.0.0

func (r *RegisterDelta) GetUpdates() flow.RegisterEntries

GetUpdates returns the register updates from the delta to be applied to storage.

func (*RegisterDelta) GetValue added in v1.0.0

func (r *RegisterDelta) GetValue(owner []byte, key []byte) ([]byte, error)

GetValue gets the value for the given register ID. If the value was set, it returns that value. If the value was not set, it reads the value from the snapshot.

func (*RegisterDelta) SetValue added in v1.0.0

func (r *RegisterDelta) SetValue(owner, key, value []byte) error

SetValue sets the value for the given register ID. It sets it in the delta, not in the storage.

func (*RegisterDelta) ValueExists added in v1.0.0

func (r *RegisterDelta) ValueExists(owner []byte, key []byte) (bool, error)

type TraceIndexer added in v0.16.0

type TraceIndexer interface {
	// StoreTransaction will index transaction trace by the transaction ID.
	// Batch is required to batch multiple indexer operations, skipped if nil.
	StoreTransaction(ID common.Hash, trace json.RawMessage, batch *pebble.Batch) error

	// GetTransaction will retrieve transaction trace by the transaction ID.
	GetTransaction(ID common.Hash) (json.RawMessage, error)
}

type TransactionIndexer

type TransactionIndexer interface {
	// Store provided transaction.
	// Batch is required to batch multiple indexer operations, skipped if nil.
	// Expected errors:
	// - errors.Duplicate if the transaction with the ID already exists.
	Store(tx models.Transaction, batch *pebble.Batch) error

	// Get transaction by the ID.
	// Expected errors:
	// - errors.NotFound if the transaction with the ID is not found.
	Get(ID common.Hash) (models.Transaction, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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