consensus

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 12 Imported by: 0

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

This section is empty.

Types

type Acceptor added in v0.3.0

type Acceptor interface {
	// Accept returns true if the replica should accept the command, false otherwise.
	Accept(Command) bool
	// Proposed tells the acceptor that the propose phase for the given command succeeded, and it should no longer be
	// accepted in the future.
	Proposed(Command)
}

Acceptor decides if a replica should accept a command.

type AggregateQC added in v0.3.0

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

AggregateQC is a set of QCs extracted from timeout messages and an aggregate signature of the timeout signatures.

This is used by the Fast-HotStuff consensus protocol.

func NewAggregateQC added in v0.3.0

func NewAggregateQC(qcs map[hotstuff.ID]QuorumCert, sig ThresholdSignature, view View) AggregateQC

NewAggregateQC returns a new AggregateQC from the QC map and the threshold signature.

func (AggregateQC) QCs added in v0.3.0

func (aggQC AggregateQC) QCs() map[hotstuff.ID]QuorumCert

QCs returns the quorum certificates in the AggregateQC.

func (AggregateQC) Sig added in v0.3.0

func (aggQC AggregateQC) Sig() ThresholdSignature

Sig returns the threshold signature in the AggregateQC.

func (AggregateQC) View added in v0.3.0

func (aggQC AggregateQC) View() View

View returns the view in which the AggregateQC was created.

type Block added in v0.3.0

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

Block contains a propsed "command", metadata for the protocol, and a link to the "parent" block.

func GetGenesis added in v0.3.0

func GetGenesis() *Block

GetGenesis returns a pointer to the genesis block, the starting point for the hotstuff blockchain.

func NewBlock added in v0.3.0

func NewBlock(parent Hash, cert QuorumCert, cmd Command, view View, proposer hotstuff.ID) *Block

NewBlock creates a new Block

func (*Block) Command added in v0.3.0

func (b *Block) Command() Command

Command returns the command

func (*Block) Hash added in v0.3.0

func (b *Block) Hash() Hash

Hash returns the hash of the Block

func (*Block) Parent added in v0.3.0

func (b *Block) Parent() Hash

Parent returns the hash of the parent Block

func (*Block) Proposer added in v0.3.0

func (b *Block) Proposer() hotstuff.ID

Proposer returns the id of the replica who proposed the block.

func (*Block) QuorumCert added in v0.3.0

func (b *Block) QuorumCert() QuorumCert

QuorumCert returns the quorum certificate in the block

func (*Block) String added in v0.3.0

func (b *Block) String() string

func (*Block) ToBytes added in v0.3.0

func (b *Block) ToBytes() []byte

ToBytes returns the raw byte form of the Block, to be used for hashing, etc.

func (*Block) View added in v0.3.0

func (b *Block) View() View

View returns the view in which the Block was proposed

type BlockChain added in v0.3.0

type BlockChain interface {
	// Store stores a block in the blockchain.
	Store(*Block)

	// Get retrieves a block given its hash, attempting to fetching it from other replicas if necessary.
	Get(Hash) (*Block, bool)

	// LocalGet retrieves a block given its hash, without fetching it from other replicas.
	LocalGet(Hash) (*Block, bool)

	// Extends checks if the given block extends the branch of the target hash.
	Extends(block, target *Block) bool

	// Prunes blocks from the in-memory tree up to the specified height.
	// Returns a set of forked blocks (blocks that were on a different branch, and thus not committed).
	PruneToHeight(height View) (forkedBlocks []*Block)
}

BlockChain is a datastructure that stores a chain of blocks. It is not required that a block is stored forever, but a block must be stored until at least one of its children have been committed.

type Builder added in v0.3.0

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

Builder is a helper for constructing a HotStuff instance.

func NewBuilder added in v0.3.0

func NewBuilder(id hotstuff.ID, privateKey PrivateKey) Builder

NewBuilder creates a new Builder.

func (*Builder) Build added in v0.3.0

func (b *Builder) Build() *Modules

Build initializes all modules and returns the HotStuff object.

func (*Builder) Register added in v0.3.0

func (b *Builder) Register(mods ...interface{})

Register adds modules to the HotStuff object and initializes them. Modules are assigned to fields based on the interface they implement. If only the Module interface is implemented, the InitModule function will be called, but the HotStuff object will not save a reference to the module. Register will overwrite existing modules if the same type is registered twice.

type Command added in v0.3.0

type Command string

Command is a client request to be executed by the consensus protocol.

The string type is used because it is immutable and can hold arbitrary bytes of any length.

type CommandQueue added in v0.3.0

type CommandQueue interface {
	// Get returns the next command to be proposed.
	// It may run until the context is cancelled.
	// If no command is available, the 'ok' return value should be false.
	Get(ctx context.Context) (cmd Command, ok bool)
}

CommandQueue is a queue of commands to be proposed.

type CommitEvent added in v0.3.0

type CommitEvent struct {
	Commands int
}

CommitEvent is raised whenever a block is committed, and includes the number of client commands that were executed.

type Configuration added in v0.3.0

type Configuration interface {
	// Replicas returns all of the replicas in the configuration.
	Replicas() map[hotstuff.ID]Replica
	// Replica returns a replica if present in the configuration.
	Replica(hotstuff.ID) (replica Replica, ok bool)
	// Len returns the number of replicas in the configuration.
	Len() int
	// QuorumSize returns the size of a quorum.
	QuorumSize() int
	// Propose sends the block to all replicas in the configuration.
	Propose(proposal ProposeMsg)
	// Timeout sends the timeout message to all replicas.
	Timeout(msg TimeoutMsg)
	// Fetch requests a block from all the replicas in the configuration.
	Fetch(ctx context.Context, hash Hash) (block *Block, ok bool)
}

Configuration holds information about the current configuration of replicas that participate in the protocol, It provides methods to send messages to the other replicas.

type Consensus added in v0.3.0

type Consensus interface {
	// StopVoting ensures that no voting happens in a view earlier than `view`.
	StopVoting(view View)
	// Propose starts a new proposal. The command is fetched from the command queue.
	Propose(cert SyncInfo)
	// CommittedBlock returns the most recently committed block.
	CommittedBlock() *Block
}

Consensus implements a byzantine consensus protocol, such as HotStuff. It contains the protocol data for a single replica. The methods OnPropose, OnVote, OnNewView, and OnDeliver should be called upon receiving a corresponding message.

func New

func New(impl Rules) Consensus

New returns a new Consensus instance based on the given Rules implementation.

type Crypto added in v0.3.0

type Crypto interface {
	CryptoImpl
	// CreatePartialCert signs a single block and returns the partial certificate.
	CreatePartialCert(block *Block) (cert PartialCert, err error)
	// CreateQuorumCert creates a quorum certificate from a list of partial certificates.
	CreateQuorumCert(block *Block, signatures []PartialCert) (cert QuorumCert, err error)
	// CreateTimeoutCert creates a timeout certificate from a list of timeout messages.
	CreateTimeoutCert(view View, timeouts []TimeoutMsg) (cert TimeoutCert, err error)
	// CreateAggregateQC creates an AggregateQC from the given timeout messages.
	CreateAggregateQC(view View, timeouts []TimeoutMsg) (aggQC AggregateQC, err error)
	// VerifyPartialCert verifies a single partial certificate.
	VerifyPartialCert(cert PartialCert) bool
	// VerifyQuorumCert verifies a quorum certificate.
	VerifyQuorumCert(qc QuorumCert) bool
	// VerifyTimeoutCert verifies a timeout certificate.
	VerifyTimeoutCert(tc TimeoutCert) bool
	// VerifyAggregateQC verifies an AggregateQC.
	VerifyAggregateQC(aggQC AggregateQC) (ok bool, highQC QuorumCert)
}

Crypto implements the methods required to create and verify signatures and certificates. This is a higher level interface that is implemented by the crypto package itself.

type CryptoImpl added in v0.3.0

type CryptoImpl interface {
	// Sign signs a hash.
	Sign(hash Hash) (sig Signature, err error)
	// Verify verifies a signature given a hash.
	Verify(sig Signature, hash Hash) bool
	// CreateThresholdSignature creates a threshold signature from the given partial signatures.
	CreateThresholdSignature(partialSignatures []Signature, hash Hash) (ThresholdSignature, error)
	// CreateThresholdSignatureForMessageSet creates a threshold signature where each partial signature has signed a
	// different message hash.
	CreateThresholdSignatureForMessageSet(partialSignatures []Signature, hashes map[hotstuff.ID]Hash) (ThresholdSignature, error)
	// VerifyThresholdSignature verifies a threshold signature.
	VerifyThresholdSignature(signature ThresholdSignature, hash Hash) bool
	// VerifyThresholdSignatureForMessageSet verifies a threshold signature against a set of message hashes.
	VerifyThresholdSignatureForMessageSet(signature ThresholdSignature, hashes map[hotstuff.ID]Hash) bool
}

CryptoImpl implements only the cryptographic primitives that are needed for HotStuff. This interface is implemented by the ecdsa and bls12 packages.

type Executor added in v0.3.0

type Executor interface {
	// Exec executes the command.
	Exec(cmd Command)
}

Executor is responsible for executing the commands that are committed by the consensus protocol.

type ExecutorExt added in v0.4.0

type ExecutorExt interface {
	// Exec executes the command in the block.
	Exec(block *Block)
}

ExecutorExt is responsible for executing the commands that are committed by the consensus protocol.

This interface is similar to the Executor interface, except it takes a block as an argument, instead of a command, making it more flexible than the alternative interface.

type ForkHandler added in v0.3.0

type ForkHandler interface {
	// Fork handles the command from a forked block.
	Fork(cmd Command)
}

ForkHandler handles commands that do not get committed due to a forked blockchain.

TODO: think of a better name/interface

type ForkHandlerExt added in v0.4.0

type ForkHandlerExt interface {
	// Fork handles the forked block.
	Fork(block *Block)
}

ForkHandlerExt handles blocks that do not get committed due to a fork of the blockchain.

This interface is similar to the ForkHandler interface, except it takes a block as an argument, instead of a command.

type Hash added in v0.3.0

type Hash [32]byte

Hash is a SHA256 hash

func (Hash) String added in v0.3.0

func (h Hash) String() string

type IDSet added in v0.3.0

type IDSet interface {
	// Add adds an ID to the set.
	Add(id hotstuff.ID)
	// Contains returns true if the set contains the ID.
	Contains(id hotstuff.ID) bool
	// ForEach calls f for each ID in the set.
	ForEach(f func(hotstuff.ID))
}

IDSet implements a set of replica IDs. It is used to show which replicas participated in some event.

func NewIDSet added in v0.3.0

func NewIDSet() IDSet

NewIDSet returns a new IDSet using the default implementation.

type LeaderRotation added in v0.3.0

type LeaderRotation interface {
	// GetLeader returns the id of the leader in the given view.
	GetLeader(View) hotstuff.ID
}

LeaderRotation implements a leader rotation scheme.

type Module added in v0.3.0

type Module interface {
	// InitConsensusModule gives the module a reference to the Modules object.
	// It also allows the module to set module options using the OptionsBuilder.
	InitConsensusModule(mods *Modules, _ *OptionsBuilder)
}

Module is an interface that can be implemented by types that need access to other consensus modules.

type Modules added in v0.3.0

type Modules struct {
	// we embed a modules.Modules object so that we can use those modules too.
	*modules.Modules
	// contains filtered or unexported fields
}

Modules contains the modules that together implement the HotStuff protocol.

func (*Modules) Acceptor added in v0.3.0

func (mods *Modules) Acceptor() Acceptor

Acceptor returns the acceptor.

func (*Modules) BlockChain added in v0.3.0

func (mods *Modules) BlockChain() BlockChain

BlockChain returns the block chain.

func (*Modules) CommandQueue added in v0.3.0

func (mods *Modules) CommandQueue() CommandQueue

CommandQueue returns the command queue.

func (*Modules) Configuration added in v0.3.0

func (mods *Modules) Configuration() Configuration

Configuration returns the configuration of replicas.

func (*Modules) Consensus added in v0.3.0

func (mods *Modules) Consensus() Consensus

Consensus returns the consensus implementation.

func (*Modules) Crypto added in v0.3.0

func (mods *Modules) Crypto() Crypto

Crypto returns the cryptography implementation.

func (*Modules) Executor added in v0.3.0

func (mods *Modules) Executor() ExecutorExt

Executor returns the executor.

func (*Modules) ForkHandler added in v0.3.0

func (mods *Modules) ForkHandler() ForkHandlerExt

ForkHandler returns the module responsible for handling forked blocks.

func (*Modules) LeaderRotation added in v0.3.0

func (mods *Modules) LeaderRotation() LeaderRotation

LeaderRotation returns the leader rotation implementation.

func (*Modules) Options added in v0.3.0

func (mods *Modules) Options() *Options

Options returns the current configuration settings.

func (*Modules) PrivateKey added in v0.3.0

func (mods *Modules) PrivateKey() PrivateKey

PrivateKey returns the private key.

func (*Modules) Run added in v0.3.0

func (mods *Modules) Run(ctx context.Context)

Run starts both event loops using the provided context and returns when both event loops have exited.

func (*Modules) Synchronizer added in v0.3.0

func (mods *Modules) Synchronizer() Synchronizer

Synchronizer returns the view synchronizer implementation.

type NewViewMsg added in v0.3.0

type NewViewMsg struct {
	ID       hotstuff.ID // The ID of the replica who sent the message.
	SyncInfo SyncInfo    // The highest QC / TC.
}

NewViewMsg is sent to the leader whenever a replica decides to advance to the next view. It contains the highest QC or TC known to the replica.

type Options added in v0.3.0

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

Options stores runtime configuration settings.

func (Options) ShouldUseAggQC added in v0.3.0

func (c Options) ShouldUseAggQC() bool

ShouldUseAggQC returns true if aggregated quorum certificates should be used. This is true for Fast-Hotstuff: https://arxiv.org/abs/2010.11454

func (Options) ShouldVerifyVotesSync added in v0.4.0

func (c Options) ShouldVerifyVotesSync() bool

ShouldVerifyVotesSync returns true if votes should be verified synchronously. Enabling this should make the voting machine process votes synchronously.

type OptionsBuilder added in v0.3.0

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

OptionsBuilder is used to set the values of immutable configuration settings.

func (*OptionsBuilder) SetShouldUseAggQC added in v0.3.0

func (builder *OptionsBuilder) SetShouldUseAggQC()

SetShouldUseAggQC sets the ShouldUseAggQC setting to true.

func (*OptionsBuilder) SetShouldVerifyVotesSync added in v0.4.0

func (builder *OptionsBuilder) SetShouldVerifyVotesSync()

SetShouldVerifyVotesSync sets the ShouldVerifyVotesSync setting to true.

type PartialCert added in v0.3.0

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

PartialCert is a signed block hash.

func NewPartialCert added in v0.3.0

func NewPartialCert(signature Signature, blockHash Hash) PartialCert

NewPartialCert returns a new partial certificate.

func (PartialCert) BlockHash added in v0.3.0

func (pc PartialCert) BlockHash() Hash

BlockHash returns the hash of the block that was signed.

func (PartialCert) Signature added in v0.3.0

func (pc PartialCert) Signature() Signature

Signature returns the signature.

func (PartialCert) ToBytes added in v0.3.0

func (pc PartialCert) ToBytes() []byte

ToBytes returns a byte representation of the partial certificate.

type PrivateKey added in v0.3.0

type PrivateKey interface {
	// Public returns the public key associated with this private key.
	Public() PublicKey
}

PrivateKey is the private part of a replica's key pair.

type ProposeMsg added in v0.3.0

type ProposeMsg struct {
	ID          hotstuff.ID  // The ID of the replica who sent the message.
	Block       *Block       // The block that is proposed.
	AggregateQC *AggregateQC // Optional AggregateQC
}

ProposeMsg is broadcast when a leader makes a proposal.

type ProposeRuler added in v0.3.0

type ProposeRuler interface {
	// ProposeRule creates a new proposal.
	ProposeRule(cert SyncInfo, cmd Command) (proposal ProposeMsg, ok bool)
}

ProposeRuler is an optional interface that adds a ProposeRule method. This allows implementors to specify how new blocks are created.

type PublicKey added in v0.3.0

type PublicKey = crypto.PublicKey

PublicKey is the public part of a replica's key pair.

type QuorumCert added in v0.3.0

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

QuorumCert (QC) is a certificate for a Block created by a quorum of partial certificates.

func NewQuorumCert added in v0.3.0

func NewQuorumCert(signature ThresholdSignature, view View, hash Hash) QuorumCert

NewQuorumCert creates a new quorum cert from the given values.

func (QuorumCert) BlockHash added in v0.3.0

func (qc QuorumCert) BlockHash() Hash

BlockHash returns the hash of the block that was signed.

func (QuorumCert) Equals added in v0.3.0

func (qc QuorumCert) Equals(other QuorumCert) bool

Equals returns true if the other QC equals this QC.

func (QuorumCert) Signature added in v0.3.0

func (qc QuorumCert) Signature() ThresholdSignature

Signature returns the threshold signature.

func (QuorumCert) String added in v0.3.0

func (qc QuorumCert) String() string

func (QuorumCert) ToBytes added in v0.3.0

func (qc QuorumCert) ToBytes() []byte

ToBytes returns a byte representation of the quorum certificate.

func (QuorumCert) View added in v0.3.0

func (qc QuorumCert) View() View

View returns the view in which the QC was created.

type Replica added in v0.3.0

type Replica interface {
	// ID returns the replica's id.
	ID() hotstuff.ID
	// PublicKey returns the replica's public key.
	PublicKey() PublicKey
	// Vote sends the partial certificate to the other replica.
	Vote(cert PartialCert)
	// NewView sends the quorum certificate to the other replica.
	NewView(SyncInfo)
}

Replica represents a remote replica participating in the consensus protocol. The methods Vote, NewView, and Deliver must send the respective arguments to the remote replica.

type Rules added in v0.3.0

type Rules interface {
	// VoteRule decides whether to vote for the block.
	VoteRule(proposal 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(*Block) *Block
}

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 Signature added in v0.3.0

type Signature interface {
	ToBytes
	// Signer returns the ID of the replica that created the signature.
	Signer() hotstuff.ID
}

Signature is a cryptographic signature of a block.

type SyncInfo added in v0.3.0

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

SyncInfo holds the highest known QC or TC. Generally, if highQC.View > highTC.View, there is no need to include highTC in the SyncInfo. However, if highQC.View < highTC.View, we should still include highQC. This can also hold an AggregateQC for Fast-Hotstuff.

func NewSyncInfo added in v0.3.0

func NewSyncInfo() SyncInfo

NewSyncInfo returns a new SyncInfo struct.

func (SyncInfo) AggQC added in v0.3.0

func (si SyncInfo) AggQC() (_ AggregateQC, _ bool)

AggQC returns the AggregateQC, if present.

func (SyncInfo) QC added in v0.3.0

func (si SyncInfo) QC() (_ QuorumCert, _ bool)

QC returns the quorum certificate, if present.

func (SyncInfo) String added in v0.3.0

func (si SyncInfo) String() string

func (SyncInfo) TC added in v0.3.0

func (si SyncInfo) TC() (_ TimeoutCert, _ bool)

TC returns the timeout certificate, if present.

func (SyncInfo) WithAggQC added in v0.3.0

func (si SyncInfo) WithAggQC(aggQC AggregateQC) SyncInfo

WithAggQC returns a copy of the SyncInfo struct with the given AggregateQC.

func (SyncInfo) WithQC added in v0.3.0

func (si SyncInfo) WithQC(qc QuorumCert) SyncInfo

WithQC returns a copy of the SyncInfo struct with the given QC.

func (SyncInfo) WithTC added in v0.3.0

func (si SyncInfo) WithTC(tc TimeoutCert) SyncInfo

WithTC returns a copy of the SyncInfo struct with the given TC.

type Synchronizer added in v0.3.0

type Synchronizer interface {
	// AdvanceView attempts to advance to the next view using the given QC.
	// qc must be either a regular quorum certificate, or a timeout certificate.
	AdvanceView(SyncInfo)
	// UpdateHighQC attempts to update HighQC using the given QC.
	UpdateHighQC(QuorumCert)
	// View returns the current view.
	View() View
	// ViewContext returns a context that is cancelled at the end of the view.
	ViewContext() context.Context
	// HighQC returns the highest known QC.
	HighQC() QuorumCert
	// LeafBlock returns the current leaf block.
	LeafBlock() *Block
	// Start starts the synchronizer with the given context.
	Start(context.Context)
}

Synchronizer synchronizes replicas to the same view.

type ThresholdSignature added in v0.3.0

type ThresholdSignature interface {
	ToBytes
	// Participants returns the IDs of replicas who participated in the threshold signature.
	Participants() IDSet
}

ThresholdSignature is a signature that is only valid when it contains the signatures of a quorum of replicas.

type TimeoutCert added in v0.3.0

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

TimeoutCert (TC) is a certificate created by a quorum of timeout messages.

func NewTimeoutCert added in v0.3.0

func NewTimeoutCert(signature ThresholdSignature, view View) TimeoutCert

NewTimeoutCert returns a new timeout certificate.

func (TimeoutCert) Signature added in v0.3.0

func (tc TimeoutCert) Signature() ThresholdSignature

Signature returns the threshold signature.

func (TimeoutCert) String added in v0.3.0

func (tc TimeoutCert) String() string

func (TimeoutCert) ToBytes added in v0.3.0

func (tc TimeoutCert) ToBytes() []byte

ToBytes returns a byte representation of the timeout certificate.

func (TimeoutCert) View added in v0.3.0

func (tc TimeoutCert) View() View

View returns the view in which the timeouts occurred.

type TimeoutMsg added in v0.3.0

type TimeoutMsg struct {
	ID            hotstuff.ID // The ID of the replica who sent the message.
	View          View        // The view that the replica wants to enter.
	ViewSignature Signature   // A signature of the view
	MsgSignature  Signature   // A signature of the view, QC.BlockHash, and the replica ID
	SyncInfo      SyncInfo    // The highest QC/TC known to the sender.
}

TimeoutMsg is broadcast whenever a replica has a local timeout.

func (TimeoutMsg) Hash added in v0.3.0

func (timeout TimeoutMsg) Hash() Hash

Hash returns a hash of the timeout message.

func (TimeoutMsg) String added in v0.3.0

func (timeout TimeoutMsg) String() string

type ToBytes added in v0.3.0

type ToBytes interface {
	// ToBytes returns the object as bytes.
	ToBytes() []byte
}

ToBytes is an object that can be converted into bytes for the purposes of hashing, etc.

type View added in v0.3.0

type View uint64

View is a number that uniquely identifies a view.

func (View) ToBytes added in v0.3.0

func (v View) ToBytes() []byte

ToBytes returns the view as bytes.

func (View) ToHash added in v0.3.0

func (v View) ToHash() Hash

ToHash converts the view to a Hash type. It does not actually hash the view.

type VoteMsg added in v0.3.0

type VoteMsg struct {
	ID          hotstuff.ID // the ID of the replica who sent the message.
	PartialCert PartialCert // The partial certificate.
	Deferred    bool
}

VoteMsg is sent to the leader by replicas voting on a proposal.

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) InitConsensusModule added in v0.3.0

func (vm *VotingMachine) InitConsensusModule(mods *Modules, _ *OptionsBuilder)

InitConsensusModule gives the module a reference to the Modules object. It also allows the module to set module options using the OptionsBuilder.

func (*VotingMachine) OnVote added in v0.3.0

func (vm *VotingMachine) OnVote(vote 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.

Jump to

Keyboard shortcuts

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