consensus

package
v0.0.0-...-8aa4d74 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogging

func SetLogging(level logging.Lvl, handler logging.Handler)

Types

type BallotSendRecord

type BallotSendRecord struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Record the ballot sent by ISAACstate This is to avoid sending another voting result in the same ISAACState.

func NewBallotSendRecord

func NewBallotSendRecord(nodeAlias string) *BallotSendRecord

func (*BallotSendRecord) InitSent

func (r *BallotSendRecord) InitSent(state ISAACState)

InitSent initializes the ballot transfer record of this ISAACState.InitSent. This function is used when an existing ballot has expired.

func (*BallotSendRecord) RemoveLowerThanOrEqualHeight

func (r *BallotSendRecord) RemoveLowerThanOrEqualHeight(height uint64)

func (*BallotSendRecord) Sent

func (r *BallotSendRecord) Sent(state ISAACState) bool

func (*BallotSendRecord) SetSent

func (r *BallotSendRecord) SetSent(state ISAACState)

SetSent sets that the ballot of this ISAACState has already been sent. This is to prevent one node from retransmitting another result.

type ISAAC

type ISAAC struct {
	sync.RWMutex

	LatestBallot  ballot.Ballot
	Node          *node.LocalNode
	RunningRounds map[string]*RunningRound
	Conf          common.Config
	// contains filtered or unexported fields
}

func NewISAAC

ISAAC should know network.ConnectionManager because the ISAAC uses connected validators when calculating proposer

func (*ISAAC) CanGetVotingResult

func (is *ISAAC) CanGetVotingResult(blt ballot.Ballot) (rv RoundVoteResult, vh voting.Hole, finished bool)

func (*ISAAC) ConnectionManager

func (is *ISAAC) ConnectionManager() network.ConnectionManager

func (*ISAAC) GenerateExpiredBallot

func (is *ISAAC) GenerateExpiredBallot(basis voting.Basis, state ballot.State) (ballot.Ballot, error)

GenerateExpiredBallot create an expired ballot using voting.Basis and ballot.State. This function is used to create a ballot indicating that a node has expired to other nodes when a timeout occurs in the state.

func (*ISAAC) HasRunningRound

func (is *ISAAC) HasRunningRound(basisIndex string) bool

func (*ISAAC) HasSameProposer

func (is *ISAAC) HasSameProposer(b ballot.Ballot) bool

func (*ISAAC) IsValidVotingBasis

func (is *ISAAC) IsValidVotingBasis(basis voting.Basis, latestBlock block.Block) bool

Check if `basis` is a valid one for the current round of consensus

Params:

basis = `voting.Basis` received for the current round of consensus
latestBlock = the latest block known to the node

Returns:

bool = `true` if it's a valid voting basis, `false` otherwise

func (*ISAAC) IsVoted

func (is *ISAAC) IsVoted(b ballot.Ballot) bool

func (*ISAAC) IsVotedByNode

func (is *ISAAC) IsVotedByNode(b ballot.Ballot, node string) (bool, error)

func (*ISAAC) LatestBlock

func (is *ISAAC) LatestBlock() block.Block

func (*ISAAC) LatestVotingBasis

func (is *ISAAC) LatestVotingBasis() voting.Basis

func (*ISAAC) RemoveOldBallots

func (is *ISAAC) RemoveOldBallots(blt ballot.Ballot) (needRenewal bool)

RemoveOldBallots checks that `blt` has valid confirmed and proposed time. If it is invalid, it is removed. And if the invalid ballot is make by itself, return `needRenewal` = true for rebroadcasting EXP ballot

func (*ISAAC) RemoveRunningRoundsLowerOrEqualBasis

func (is *ISAAC) RemoveRunningRoundsLowerOrEqualBasis(basis voting.Basis)

func (*ISAAC) RemoveRunningRoundsLowerOrEqualHeight

func (is *ISAAC) RemoveRunningRoundsLowerOrEqualHeight(height uint64)

func (*ISAAC) SelectProposer

func (is *ISAAC) SelectProposer(blockHeight uint64, round uint64) string

func (*ISAAC) SetLatestVotingBasis

func (is *ISAAC) SetLatestVotingBasis(basis voting.Basis)

func (*ISAAC) SetProposerSelector

func (is *ISAAC) SetProposerSelector(p ProposerSelector)

func (*ISAAC) StartSync

func (is *ISAAC) StartSync(height uint64, nodeAddrs []string)

func (*ISAAC) Vote

func (is *ISAAC) Vote(b ballot.Ballot) (isNew bool, err error)

type ISAACState

type ISAACState struct {
	Height      uint64
	Round       uint64
	BallotState ballot.State
}

func (ISAACState) IsLater

func (s ISAACState) IsLater(target ISAACState) bool

type ISAACVotingThresholdPolicy

type ISAACVotingThresholdPolicy struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDefaultVotingThresholdPolicy

func NewDefaultVotingThresholdPolicy(threshold int) (vt *ISAACVotingThresholdPolicy, err error)

func (*ISAACVotingThresholdPolicy) Connected

func (vt *ISAACVotingThresholdPolicy) Connected() int

func (*ISAACVotingThresholdPolicy) MarshalJSON

func (vt *ISAACVotingThresholdPolicy) MarshalJSON() ([]byte, error)

func (*ISAACVotingThresholdPolicy) SetConnected

func (vt *ISAACVotingThresholdPolicy) SetConnected(n int)

func (*ISAACVotingThresholdPolicy) SetValidators

func (vt *ISAACVotingThresholdPolicy) SetValidators(n int)

func (*ISAACVotingThresholdPolicy) Threshold

func (vt *ISAACVotingThresholdPolicy) Threshold() int

func (*ISAACVotingThresholdPolicy) Validators

func (vt *ISAACVotingThresholdPolicy) Validators() int

type ProposerSelector

type ProposerSelector interface {
	Select(uint64, uint64) string
}

type RoundVote

type RoundVote struct {
	SIGN   RoundVoteResult
	ACCEPT RoundVoteResult
}

func NewRoundVote

func NewRoundVote(ballot ballot.Ballot) (rv *RoundVote)

func (*RoundVote) CanGetVotingResult

func (rv *RoundVote) CanGetVotingResult(policy voting.ThresholdPolicy, state ballot.State, log logging.Logger) (RoundVoteResult, voting.Hole, bool)

func (*RoundVote) GetResult

func (rv *RoundVote) GetResult(state ballot.State) (result RoundVoteResult)

func (*RoundVote) IsVoted

func (rv *RoundVote) IsVoted(ballot ballot.Ballot) bool

func (*RoundVote) IsVotedByNode

func (rv *RoundVote) IsVotedByNode(state ballot.State, node string) bool

func (*RoundVote) Vote

func (rv *RoundVote) Vote(b ballot.Ballot) (isNew bool, err error)

type RoundVoteResult

type RoundVoteResult map[string]ballot.Ballot

type RunningRound

type RunningRound struct {
	sync.RWMutex

	VotingBasis  voting.Basis
	Proposer     string              // LocalNode's `Proposer`
	Transactions map[string][]string /* Transaction.Hash */
	Voted        map[string]*RoundVote
	Ballots      []ballot.Ballot
}

func NewRunningRound

func NewRunningRound(proposer string, blt ballot.Ballot) (*RunningRound, error)

func (*RunningRound) IsVoted

func (rr *RunningRound) IsVoted(ballot ballot.Ballot) bool

func (*RunningRound) RoundVote

func (rr *RunningRound) RoundVote(proposer string) (rv *RoundVote, err error)

func (*RunningRound) Vote

func (rr *RunningRound) Vote(ballot ballot.Ballot)

type SequentialSelector

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

func (SequentialSelector) Select

func (s SequentialSelector) Select(blockHeight uint64, round uint64) string

type SyncController

type SyncController interface {
	SetSyncTargetBlock(ctx context.Context, height uint64, nodeAddrs []string) error
}

Jump to

Keyboard shortcuts

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