forks

package
v0.22.8-patch-7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2021 License: AGPL-3.0 Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockQC

type BlockQC struct {
	Block *model.Block
	QC    *flow.QuorumCertificate
}

BlockQC is a Block with a QC that pointing to it, meaning a Quorum Certified Block. This implies Block.View == QC.View && Block.BlockID == QC.BlockID

type Finalizer

type Finalizer interface {
	VerifyBlock(*model.Block) error
	IsSafeBlock(*model.Block) bool
	AddBlock(*model.Block) error
	GetBlock(blockID flow.Identifier) (*model.Block, bool)
	GetBlocksForView(view uint64) []*model.Block
	FinalizedBlock() *model.Block
	LockedBlock() *model.Block
}

Finalizer is responsible for block finalization.

type ForkChoice

type ForkChoice interface {

	// AddQC adds a Quorum Certificate to Forks;
	// Errors in case the block referenced by the qc is unknown.
	AddQC(qc *flow.QuorumCertificate) error

	// MakeForkChoice prompts the ForkChoice to generate a fork choice for the
	// current view `curView`. The fork choice is a qc that should be used for
	// building the primaries block.
	//
	// Error return indicates incorrect usage. Processing a QC with view v
	// should result in the PaceMaker being in view v+1 or larger. Hence, given
	// that the current View is curView, all QCs should have view < curView
	MakeForkChoice(curView uint64) (*flow.QuorumCertificate, *model.Block, error)
}

ForkChoice determines the fork-choice. ForkChoice directly interfaces with the Finalizer to query required information (such as finalized View, stored block, etc).

type Forks

type Forks struct {
	// contains filtered or unexported fields
}

Forks implements the hotstuff.Reactor API

func New

func New(finalizer Finalizer, forkchoice ForkChoice) *Forks

New creates a Forks instance

func (*Forks) AddBlock

func (f *Forks) AddBlock(block *model.Block) error

AddBlock passes the block to the finalizer for finalization and gives the QC to forkchoice for updating the preferred parent block

func (*Forks) AddQC

func (f *Forks) AddQC(qc *flow.QuorumCertificate) error

AddQC gives the QC to the forkchoice for updating the preferred parent block

func (*Forks) FinalizedBlock

func (f *Forks) FinalizedBlock() *model.Block

FinalizedBlock returns the latest finalized block

func (*Forks) FinalizedView

func (f *Forks) FinalizedView() uint64

FinalizedView returns the view of the latest finalized block

func (*Forks) GetBlock

func (f *Forks) GetBlock(id flow.Identifier) (*model.Block, bool)

GetBlock returns the block for the given block ID

func (*Forks) GetBlocksForView

func (f *Forks) GetBlocksForView(view uint64) []*model.Block

GetBlocksForView returns all the blocks for a certain view.

func (*Forks) IsSafeBlock

func (f *Forks) IsSafeBlock(block *model.Block) bool

IsSafeBlock returns whether a block is safe to vote for.

func (*Forks) MakeForkChoice

func (f *Forks) MakeForkChoice(curView uint64) (*flow.QuorumCertificate, *model.Block, error)

MakeForkChoice returns the block to build new block proposal from for the current view. the QC is the QC that points to that block.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL