github.com/koko1123/flow-go-1@v0.29.6/module/finalizer.go (about)

     1  // (c) 2019 Dapper Labs - ALL RIGHTS RESERVED
     2  
     3  package module
     4  
     5  import (
     6  	"github.com/koko1123/flow-go-1/model/flow"
     7  )
     8  
     9  // Finalizer is used by the consensus algorithm to inform other components for (such
    10  // as the protocol state) about validity of block headers and finalization of blocks.
    11  //
    12  // Since we have two different protocol states: one for the main consensus,
    13  // the other for the collection cluster consensus, the Finalizer interface
    14  // allows the two different protocol states to provide different implementations
    15  // for updating its state when a block has been validated or finalized.
    16  //
    17  // Why MakeValid and MakeFinal need to return an error?
    18  // Updating the protocol state should always succeed when the data is consistent.
    19  // However, in case the protocol state is corrupted, error should be returned and
    20  // the consensus algorithm should halt. So the error returned from MakeValid and
    21  // MakeFinal is for the protocol state to report exceptions.
    22  type Finalizer interface {
    23  
    24  	// MakeValid will mark a block as having passed the consensus algorithm's
    25  	// internal validation.
    26  	MakeValid(blockID flow.Identifier) error
    27  
    28  	// MakeFinal will declare a block and all of its ancestors as finalized, which
    29  	// makes it an immutable part of the blockchain. Returning an error indicates
    30  	// some fatal condition and will cause the finalization logic to terminate.
    31  	MakeFinal(blockID flow.Identifier) error
    32  }