github.com/onflow/flow-go@v0.33.17/storage/headers.go (about)

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