github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/headers.go (about)

     1  package storage
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  )
     6  
     7  // Headers represents persistent storage for blocks.
     8  type Headers interface {
     9  
    10  	// Store will store a header.
    11  	Store(header *flow.Header) error
    12  
    13  	// ByBlockID returns the header with the given ID. It is available for finalized and ambiguous blocks.
    14  	// Error returns:
    15  	//  - ErrNotFound if no block header with the given ID exists
    16  	ByBlockID(blockID flow.Identifier) (*flow.Header, error)
    17  
    18  	// ByHeight returns the block with the given number. It is only available for finalized blocks.
    19  	ByHeight(height uint64) (*flow.Header, error)
    20  
    21  	// Exists returns true if a header with the given ID has been stored.
    22  	// No errors are expected during normal operation.
    23  	Exists(blockID flow.Identifier) (bool, error)
    24  
    25  	// BlockIDByHeight returns the block ID that is finalized at the given height. It is an optimized
    26  	// version of `ByHeight` that skips retrieving the block. Expected errors during normal operations:
    27  	//  * `storage.ErrNotFound` if no finalized block is known at given height
    28  	BlockIDByHeight(height uint64) (flow.Identifier, error)
    29  
    30  	// ByParentID finds all children for the given parent block. The returned headers
    31  	// might be unfinalized; if there is more than one, at least one of them has to
    32  	// be unfinalized.
    33  	ByParentID(parentID flow.Identifier) ([]*flow.Header, error)
    34  }