github.com/koko1123/flow-go-1@v0.29.6/storage/blocks.go (about)

     1  // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
     2  
     3  package storage
     4  
     5  import (
     6  	"github.com/koko1123/flow-go-1/model/flow"
     7  	"github.com/koko1123/flow-go-1/storage/badger/transaction"
     8  )
     9  
    10  // Blocks represents persistent storage for blocks.
    11  type Blocks interface {
    12  
    13  	// Store will atomically store a block with all its dependencies.
    14  	Store(block *flow.Block) error
    15  
    16  	// StoreTx allows us to store a new block, including its payload & header, as part of a DB transaction, while
    17  	// still going through the caching layer.
    18  	StoreTx(block *flow.Block) func(*transaction.Tx) error
    19  
    20  	// ByID returns the block with the given hash. It is available for
    21  	// finalized and ambiguous blocks.
    22  	ByID(blockID flow.Identifier) (*flow.Block, error)
    23  
    24  	// ByHeight returns the block at the given height. It is only available
    25  	// for finalized blocks.
    26  	ByHeight(height uint64) (*flow.Block, error)
    27  
    28  	// ByCollectionID returns the block for the given collection ID.
    29  	ByCollectionID(collID flow.Identifier) (*flow.Block, error)
    30  
    31  	// IndexBlockForCollections indexes the block each collection was
    32  	// included in.
    33  	IndexBlockForCollections(blockID flow.Identifier, collIDs []flow.Identifier) error
    34  
    35  	// InsertLastFullBlockHeightIfNotExists inserts the FullBlockHeight index if it does not already exist.
    36  	// Calling this function multiple times is a no-op and returns no expected errors.
    37  	InsertLastFullBlockHeightIfNotExists(height uint64) error
    38  
    39  	// UpdateLastFullBlockHeight updates the FullBlockHeight index
    40  	// The FullBlockHeight index indicates that block for which all collections have been received
    41  	UpdateLastFullBlockHeight(height uint64) error
    42  
    43  	// GetLastFullBlockHeight retrieves the FullBlockHeight
    44  	GetLastFullBlockHeight() (height uint64, err error)
    45  }