consensus

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 15 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(signers []crypto.Signer) (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, proposal *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:"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

SanityCheck performs basic checks on the configuration.

type Consensus

type Consensus interface {
	Reader

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

func NewConsensus

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

type Manager added in v0.10.0

type Manager interface {
	ManagerReader

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

func NewManager added in v0.10.0

func NewManager(
	conf *Config,
	state state.Facade,
	signers []crypto.Signer,
	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 signer and reward address.

type ManagerReader added in v0.10.0

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

type MockConsensus

type MockConsensus struct {
	Signer   crypto.Signer
	Votes    []*vote.Vote
	Proposal *proposal.Proposal
	Active   bool
	Height   uint32
	Round    int16
	// contains filtered or unexported fields
}

func MockingConsensus

func MockingConsensus(signer crypto.Signer) *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) HasVote added in v0.11.0

func (m *MockConsensus) HasVote(hash 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) 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) SetActive added in v0.10.0

func (m *MockConsensus) SetActive(active bool)

func (*MockConsensus) SetProposal

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

func (*MockConsensus) SignerKey added in v0.10.0

func (m *MockConsensus) SignerKey() crypto.PublicKey

func (*MockConsensus) Start

func (m *MockConsensus) Start() error

func (*MockConsensus) Stop

func (m *MockConsensus) Stop()

type Reader

type Reader interface {
	SignerKey() crypto.PublicKey
	AllVotes() []*vote.Vote
	PickRandomVote() *vote.Vote
	RoundProposal(round int16) *proposal.Proposal
	HasVote(hash hash.Hash) bool
	HeightRound() (uint32, int16)
	IsActive() bool
	Fingerprint() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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