hotstuff

package
v0.0.0-...-169a2f2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmpBlockHeight

func CmpBlockHeight(b1, b2 Block) int

CmpBlockHeight compares two blocks by height

func IsThreeChain

func IsThreeChain(b, b1, b2 Block) bool

IsThreeChain checks whether the blocks satisfy three chain rule

Types

type Block

type Block interface {
	Height() uint64
	Parent() Block
	Equal(blk Block) bool
	Justify() QC
}

Block type

func GetJustifyBlocks

func GetJustifyBlocks(bNew Block) (b, b1, b2 Block)

GetJustifyBlocks returns justify referenced blocks

type Driver

type Driver interface {
	MajorityCount() int
	CreateLeaf(parent Block, qc QC, height uint64) Block
	CreateQC(votes []Vote) QC
	BroadcastProposal(blk Block)
	VoteBlock(blk Block)
	Commit(blk Block)
}

Driver godoc

type Hotstuff

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

Hotstuff consensus engine

func New

func New(driver Driver, b0 Block, q0 QC) *Hotstuff

func (*Hotstuff) CanVote

func (hs *Hotstuff) CanVote(bNew Block) bool

CanVote returns true if the hotstuff instance can vote the given block

func (*Hotstuff) CheckLivenessRule

func (hs *Hotstuff) CheckLivenessRule(bNew Block) bool

CheckLivenessRule returns true if the qc referenced block of the given block is higher than b_Lock

func (*Hotstuff) CheckSafetyRule

func (hs *Hotstuff) CheckSafetyRule(bNew Block) bool

CheckSafetyRule returns true if the given block extends from b_Lock

func (Hotstuff) GetBExec

func (s Hotstuff) GetBExec() Block

func (Hotstuff) GetBLeaf

func (s Hotstuff) GetBLeaf() Block

func (Hotstuff) GetBLock

func (s Hotstuff) GetBLock() Block

func (Hotstuff) GetBVote

func (s Hotstuff) GetBVote() Block

func (Hotstuff) GetQCHigh

func (s Hotstuff) GetQCHigh() QC

func (Hotstuff) GetVoteCount

func (s Hotstuff) GetVoteCount() int

func (Hotstuff) GetVotes

func (s Hotstuff) GetVotes() []Vote

func (Hotstuff) IsProposing

func (s Hotstuff) IsProposing() bool

func (*Hotstuff) OnPropose

func (hs *Hotstuff) OnPropose() Block

OnPropose is called to propose a new block

func (*Hotstuff) OnReceiveProposal

func (hs *Hotstuff) OnReceiveProposal(bNew Block)

OnReceiveProposal is called when a new proposal is received

func (*Hotstuff) OnReceiveVote

func (hs *Hotstuff) OnReceiveVote(v Vote)

OnReceiveVote is called when received a vote

func (Hotstuff) SubscribeNewQCHigh

func (s Hotstuff) SubscribeNewQCHigh() *emitter.Subscription

func (*Hotstuff) Update

func (hs *Hotstuff) Update(bNew Block)

Update perform three chain consensus phases

func (*Hotstuff) UpdateQCHigh

func (hs *Hotstuff) UpdateQCHigh(qc QC)

UpdateQCHigh replaces qcHigh if the block of given qc is higher than the qcHigh block

type QC

type QC interface {
	Block() Block
}

QC type

type Vote

type Vote interface {
	Block() Block
	Voter() string
}

Vote type

Jump to

Keyboard shortcuts

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