Documentation
¶
Overview ¶
Package consensus defines the types and interfaces that are used to implement consensus.
In particular, this package defines the module system that allows the different components in a consensus protocol to interact with each other. This is an extension of the module system in the modules package, and thus any module that is written for the modules package can be used as a module with this package's module system, but not vice-versa.
The module system in this package nearly identical to the modules package, except it includes many more modules, and it adds a small configuration component, allowing modules to set configuration options at runtime. Thus, to write a module for the consensus.Modules system, you must instead implement the consensus.Module interface. Refer to the documentation of the modules package for a more detailed description of the module system.
This package also provides a default implementation of the Consensus interface that can be used by implementors of the Rules interface. This results in a clean and simple way to implement a new consensus protocol while sharing a lot of the code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProposeRuler ¶ added in v0.3.0
type ProposeRuler interface {
// ProposeRule creates a new proposal.
ProposeRule(cert hotstuff.SyncInfo, cmd hotstuff.Command) (proposal hotstuff.ProposeMsg, ok bool)
}
ProposeRuler is an optional interface that adds a ProposeRule method. This allows implementors to specify how new blocks are created.
type Rules ¶ added in v0.3.0
type Rules interface {
// VoteRule decides whether to vote for the block.
VoteRule(proposal hotstuff.ProposeMsg) bool
// CommitRule decides whether any ancestor of the block can be committed.
// Returns the youngest ancestor of the block that can be committed.
CommitRule(*hotstuff.Block) *hotstuff.Block
// ChainLength returns the number of blocks that need to be chained together in order to commit.
ChainLength() int
}
Rules is the minimum interface that a consensus implementations must implement. Implementations of this interface can be wrapped in the ConsensusBase struct. Together, these provide an implementation of the main Consensus interface. Implementors do not need to verify certificates or interact with other modules, as this is handled by the ConsensusBase struct.
type VotingMachine ¶ added in v0.3.0
type VotingMachine struct {
// contains filtered or unexported fields
}
VotingMachine collects votes.
func NewVotingMachine ¶ added in v0.3.0
func NewVotingMachine() *VotingMachine
NewVotingMachine returns a new VotingMachine.
func (*VotingMachine) InitModule ¶ added in v0.5.0
func (vm *VotingMachine) InitModule(mods *modules.Core)
InitModule initializes the VotingMachine.
func (*VotingMachine) OnVote ¶ added in v0.3.0
func (vm *VotingMachine) OnVote(vote hotstuff.VoteMsg)
OnVote handles an incoming vote.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package byzantine contiains byzantine behaviors that can be applied to the consensus protocols.
|
Package byzantine contiains byzantine behaviors that can be applied to the consensus protocols. |
|
Package chainedhotstuff implements the pipelined three-chain version of the HotStuff protocol.
|
Package chainedhotstuff implements the pipelined three-chain version of the HotStuff protocol. |
|
Package fasthotstuff implements the two-chain Fast-HotStuff protocol.
|
Package fasthotstuff implements the two-chain Fast-HotStuff protocol. |
|
Package simplehotstuff implements a simplified version of the three-chain HotStuff protocol.
|
Package simplehotstuff implements a simplified version of the three-chain HotStuff protocol. |