consensus

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ChangeProposerTimeout time.Duration `toml:"change_proposer_timeout"`
	ChangeProposerDelta   time.Duration `toml:"change_proposer_delta"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) CalculateChangeProposerTimeout

func (conf *Config) CalculateChangeProposerTimeout(round int16) time.Duration

func (*Config) SanityCheck

func (conf *Config) SanityCheck() error

type Consensus

type Consensus interface {
	Reader

	MoveToNewHeight()
	Start() error
	Stop()
	AddVote(v *vote.Vote)
	SetProposal(proposal *proposal.Proposal)
}

func NewConsensus

func NewConsensus(
	conf *Config,
	state state.Facade,
	signer crypto.Signer,
	broadcastCh chan message.Message) Consensus

type MockConsensus

type MockConsensus struct {
	Lock     sync.RWMutex
	Votes    []*vote.Vote
	Proposal *proposal.Proposal
	State    *state.MockState
	Height   uint32
	Round    int16
}

func MockingConsensus

func MockingConsensus(state *state.MockState) *MockConsensus

func (*MockConsensus) AddVote

func (m *MockConsensus) AddVote(v *vote.Vote)

func (*MockConsensus) AllVotes

func (m *MockConsensus) AllVotes() []*vote.Vote

func (*MockConsensus) Fingerprint

func (m *MockConsensus) Fingerprint() string

func (*MockConsensus) HeightRound

func (m *MockConsensus) HeightRound() (uint32, int16)

func (*MockConsensus) MoveToNewHeight

func (m *MockConsensus) MoveToNewHeight()

func (*MockConsensus) PickRandomVote

func (m *MockConsensus) PickRandomVote() *vote.Vote

func (*MockConsensus) RoundProposal

func (m *MockConsensus) RoundProposal(round int16) *proposal.Proposal

func (*MockConsensus) RoundVotes

func (m *MockConsensus) RoundVotes(round int16) []*vote.Vote

func (*MockConsensus) SetProposal

func (m *MockConsensus) SetProposal(p *proposal.Proposal)

func (*MockConsensus) Start

func (m *MockConsensus) Start() error

func (*MockConsensus) Stop

func (m *MockConsensus) Stop()

type Reader

type Reader interface {
	PickRandomVote() *vote.Vote
	AllVotes() []*vote.Vote
	RoundVotes(round int16) []*vote.Vote
	RoundProposal(round int16) *proposal.Proposal
	HeightRound() (uint32, int16)
	Fingerprint() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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