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