procedure

package
v0.43.1-rc.1.access-me... Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FinalizeClusterBlock

func FinalizeClusterBlock(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier) error

FinalizeClusterBlock finalizes a block in cluster consensus.

func IndexNewBlock

func IndexNewBlock(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier, parentID flow.Identifier) error

IndexNewBlock will add parent-child index for the new block.

  • Each block that we ingest has a parent, we use this parent-child relationship to build a reverse index for looking up children blocks for a given block. This is useful for forks recovery where we want to find all the pending children blocks for the lastest finalized block.

When adding parent-child index for a new block, we will update two indexes:

  1. Per protocol convention, blocks must be ingested in "ancestors-first" order. Hence, if a block is new (needs to be verified, to avoid state corruption in case of repeated calls), its set of persisted children is empty at the time of insertion.
  2. Since the parent block has this new block as a child, we add to the parent block's children. There are two special cases for (2): - If the parent block is zero (i.e. genesis block), then we don't need to add this index. - If the parent block doesn't exist, then we will index the new block as the only child of the parent anyway. This is useful for bootstrapping nodes with truncated history.

func IndexNewClusterBlock

func IndexNewClusterBlock(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier, parentID flow.Identifier) error

IndexNewClusterBlock will add parent-child index for the new block.

  • Each block that we ingest has a parent, we use this parent-child relationship to build a reverse index for looking up children blocks for a given block. This is useful for forks recovery where we want to find all the pending children blocks for the lastest finalized block.

When adding parent-child index for a new block, we will update two indexes:

  1. Per protocol convention, blocks must be ingested in "ancestors-first" order. Hence, if a block is new (needs to be verified, to avoid state corruption in case of repeated calls), its set of persisted children is empty at the time of insertion.
  2. Since the parent block has this new block as a child, we add to the parent block's children. There are two special cases for (2): - If the parent block is zero (i.e. genesis block), then we don't need to add this index. - If the parent block doesn't exist, then we will index the new block as the only child of the parent anyway. This is useful for bootstrapping nodes with truncated history.

func InsertClusterBlock

func InsertClusterBlock(lctx lockctx.Proof, rw storage.ReaderBatchWriter, proposal *cluster.Proposal) error

InsertClusterBlock inserts a cluster consensus block, updating all associated indexes.

CAUTION:

  • The caller must acquire the lock storage.LockInsertOrFinalizeClusterBlock and hold it until the database write has been committed. This lock allows `InsertClusterBlock` to verify that this block has not yet been indexed. In order to protect against accidental mutation of existing data, this read and subsequent writes must be performed as one atomic operation. Hence, the requirement to hold the lock until the write is committed.

We return storage.ErrAlreadyExists if the block has already been persisted before, i.e. we only insert a block once. This error allows the caller to detect duplicate inserts. No other errors are expected during normal operation.

func InsertClusterPayload

func InsertClusterPayload(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier, payload *cluster.Payload) error

InsertClusterPayload inserts the payload for a cluster block. It inserts both the collection and all constituent transactions, allowing duplicates.

func InsertIndex

func InsertIndex(lctx lockctx.Proof, rw storage.ReaderBatchWriter, blockID flow.Identifier, index *flow.Index) error

InsertIndex persists the given index keyed by the block ID

CAUTION:

  • The caller must acquire the storage.LockInsertBlock and hold it until the database write has been committed.
  • OVERWRITES existing data (potential for data corruption): This method silently overrides existing data without any sanity checks whether data for the same key already exits. Note that the Flow protocol mandates that for a previously persisted key, the data is never changed to a different value. Changing data could cause the node to publish inconsistent data and to be slashed, or the protocol to be compromised as a whole. This method does not contain any safeguards to prevent such data corruption. The lock proof serves as a reminder that the CALLER is responsible to ensure that the DEDUPLICATION CHECK is done elsewhere ATOMICALLY with this write operation.

No errors expected during normal operations.

func LookupBlockChildren

func LookupBlockChildren(r storage.Reader, blockID flow.Identifier, childrenIDs *flow.IdentifierList) error

LookupBlockChildren looks up the IDs of all child blocks of the given parent block.

func RetrieveClusterBlock

func RetrieveClusterBlock(r storage.Reader, blockID flow.Identifier, block *cluster.Block) error

RetrieveClusterBlock retrieves a cluster consensus block by block ID.

func RetrieveClusterPayload

func RetrieveClusterPayload(r storage.Reader, blockID flow.Identifier, payload *cluster.Payload) error

RetrieveClusterPayload retrieves a cluster consensus block payload by block ID.

func RetrieveIndex

func RetrieveIndex(r storage.Reader, blockID flow.Identifier, index *flow.Index) error

func RetrieveLatestFinalizedClusterHeader

func RetrieveLatestFinalizedClusterHeader(r storage.Reader, clusterID flow.ChainID, final *flow.Header) error

RetrieveLatestFinalizedClusterHeader retrieves the latest finalized cluster block header from the specified cluster.

Types

This section is empty.

Jump to

Keyboard shortcuts

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