consensus

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockingManager added in v0.10.0

func MockingManager(ts *testsuite.TestSuite, state *state.MockState,
	valKeys []*bls.ValidatorKey,
) (Manager, []*MockConsensus)

Types

type ConcreteMediator added in v0.10.0

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

ConcreteMediator struct.

func (*ConcreteMediator) OnBlockAnnounce added in v0.10.0

func (m *ConcreteMediator) OnBlockAnnounce(from Consensus)

func (*ConcreteMediator) OnPublishProposal added in v0.10.0

func (m *ConcreteMediator) OnPublishProposal(from Consensus, prop *proposal.Proposal)

func (*ConcreteMediator) OnPublishVote added in v0.10.0

func (m *ConcreteMediator) OnPublishVote(from Consensus, vote *vote.Vote)

func (*ConcreteMediator) Register added in v0.10.0

func (m *ConcreteMediator) Register(cons Consensus)

Register a new Consensus instance to the mediator.

type Config

type Config struct {
	ChangeProposerTimeout    time.Duration `toml:"-"`
	ChangeProposerDelta      time.Duration `toml:"-"`
	QueryVoteTimeout         time.Duration `toml:"-"`
	MinimumAvailabilityScore float64       `toml:"-"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) BasicCheck added in v0.15.0

func (conf *Config) BasicCheck() error

BasicCheck performs basic checks on the configuration.

func (*Config) CalculateChangeProposerTimeout

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

type ConfigError added in v1.0.0

type ConfigError struct {
	Reason string
}

ConfigError is returned when the config is not valid with a descriptive Reason message.

func (ConfigError) Error added in v1.0.0

func (e ConfigError) Error() string

type Consensus

type Consensus interface {
	Reader

	Start()
	MoveToNewHeight()
	AddVote(vote *vote.Vote)
	SetProposal(prop *proposal.Proposal)
}

func NewConsensus

func NewConsensus(
	conf *Config,
	bcState state.Facade,
	valKey *bls.ValidatorKey,
	rewardAddr crypto.Address,
	broadcastCh chan message.Message,
	mediator mediator,
) Consensus

type InvalidJustificationError added in v1.5.0

type InvalidJustificationError struct {
	JustType vote.JustType
	Reason   string
}

InvalidJustificationError is returned when the justification for a change-proposer vote is invalid.

func (InvalidJustificationError) Error added in v1.5.0

type Manager added in v0.10.0

type Manager interface {
	ManagerReader

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

func NewManager added in v0.10.0

func NewManager(
	conf *Config,
	state state.Facade,
	valKeys []*bls.ValidatorKey,
	rewardAddrs []crypto.Address,
	broadcastCh chan message.Message,
) Manager

NewManager creates a new manager instance that manages a set of consensus instances, each associated with a validator key and a reward address. It is not thread-safe.

type ManagerReader added in v0.10.0

type ManagerReader interface {
	Instances() []Reader
	HandleQueryVote(height uint32, round int16) *vote.Vote
	HandleQueryProposal(height uint32, round int16) *proposal.Proposal
	Proposal() *proposal.Proposal
	HeightRound() (uint32, int16)
	HasActiveInstance() bool
}

type MockConsensus

type MockConsensus struct {
	State       *state.MockState
	ValKey      *bls.ValidatorKey
	Votes       []*vote.Vote
	CurProposal *proposal.Proposal
	Active      bool
	Proposer    bool
	Height      uint32
	Round       int16
	// contains filtered or unexported fields
}

func MockingConsensus

func MockingConsensus(ts *testsuite.TestSuite, state *state.MockState, valKey *bls.ValidatorKey) *MockConsensus

func (*MockConsensus) AddVote

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

func (*MockConsensus) AllVotes

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

func (*MockConsensus) ConsensusKey added in v0.15.0

func (m *MockConsensus) ConsensusKey() *bls.PublicKey

func (*MockConsensus) HandleQueryProposal added in v1.4.0

func (m *MockConsensus) HandleQueryProposal(_ uint32, _ int16) *proposal.Proposal

func (*MockConsensus) HandleQueryVote added in v1.4.0

func (m *MockConsensus) HandleQueryVote(_ uint32, _ int16) *vote.Vote

func (*MockConsensus) HasVote added in v0.11.0

func (m *MockConsensus) HasVote(h hash.Hash) bool

func (*MockConsensus) HeightRound

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

func (*MockConsensus) IsActive added in v0.10.0

func (m *MockConsensus) IsActive() bool

func (*MockConsensus) IsProposer added in v1.1.7

func (m *MockConsensus) IsProposer() bool

func (*MockConsensus) MoveToNewHeight

func (m *MockConsensus) MoveToNewHeight()

func (*MockConsensus) Proposal

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

func (*MockConsensus) SetActive added in v0.10.0

func (m *MockConsensus) SetActive(active bool)

func (*MockConsensus) SetProposal

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

func (*MockConsensus) Start

func (*MockConsensus) Start()

func (*MockConsensus) String added in v0.15.0

func (*MockConsensus) String() string

type Reader

type Reader interface {
	ConsensusKey() *bls.PublicKey
	AllVotes() []*vote.Vote
	HandleQueryVote(height uint32, round int16) *vote.Vote
	HandleQueryProposal(height uint32, round int16) *proposal.Proposal
	Proposal() *proposal.Proposal
	HasVote(h hash.Hash) bool
	HeightRound() (uint32, int16)
	IsActive() bool
	IsProposer() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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