sebak: Index | Files

package consensus

import ""


Package Files

ballot_send_record.go init.go isaac.go isaac_state.go proposer_selector.go round_vote.go running_round.go voting_policy.go

func SetLogging Uses

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

type BallotSendRecord Uses

type BallotSendRecord struct {
    // 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 Uses

func NewBallotSendRecord(nodeAlias string) *BallotSendRecord

func (*BallotSendRecord) InitSent Uses

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 Uses

func (r *BallotSendRecord) RemoveLowerThanOrEqualHeight(height uint64)

func (*BallotSendRecord) Sent Uses

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

func (*BallotSendRecord) SetSent Uses

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 Uses

type ISAAC struct {

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

func NewISAAC Uses

func NewISAAC(node *node.LocalNode, p voting.ThresholdPolicy,
    cm network.ConnectionManager, st *storage.LevelDBBackend, conf common.Config, syncer SyncController) (is *ISAAC, err error)

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

func (*ISAAC) CanGetVotingResult Uses

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

func (*ISAAC) ConnectionManager Uses

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

func (*ISAAC) GenerateExpiredBallot Uses

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 Uses

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

func (*ISAAC) HasSameProposer Uses

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

func (*ISAAC) IsValidVotingBasis Uses

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

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


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


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

func (*ISAAC) IsVoted Uses

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

func (*ISAAC) IsVotedByNode Uses

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

func (*ISAAC) LatestBlock Uses

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

func (*ISAAC) LatestVotingBasis Uses

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

func (*ISAAC) RemoveOldBallots Uses

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 Uses

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

func (*ISAAC) RemoveRunningRoundsLowerOrEqualHeight Uses

func (is *ISAAC) RemoveRunningRoundsLowerOrEqualHeight(height uint64)

func (*ISAAC) SelectProposer Uses

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

func (*ISAAC) SetLatestVotingBasis Uses

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

func (*ISAAC) SetProposerSelector Uses

func (is *ISAAC) SetProposerSelector(p ProposerSelector)

func (*ISAAC) StartSync Uses

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

func (*ISAAC) Vote Uses

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

type ISAACState Uses

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

func (ISAACState) IsLater Uses

func (s ISAACState) IsLater(target ISAACState) bool

type ISAACVotingThresholdPolicy Uses

type ISAACVotingThresholdPolicy struct {
    // contains filtered or unexported fields

func NewDefaultVotingThresholdPolicy Uses

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

func (*ISAACVotingThresholdPolicy) Connected Uses

func (vt *ISAACVotingThresholdPolicy) Connected() int

func (*ISAACVotingThresholdPolicy) MarshalJSON Uses

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

func (*ISAACVotingThresholdPolicy) SetConnected Uses

func (vt *ISAACVotingThresholdPolicy) SetConnected(n int)

func (*ISAACVotingThresholdPolicy) SetValidators Uses

func (vt *ISAACVotingThresholdPolicy) SetValidators(n int)

func (*ISAACVotingThresholdPolicy) Threshold Uses

func (vt *ISAACVotingThresholdPolicy) Threshold() int

func (*ISAACVotingThresholdPolicy) Validators Uses

func (vt *ISAACVotingThresholdPolicy) Validators() int

type ProposerSelector Uses

type ProposerSelector interface {
    Select(uint64, uint64) string

type RoundVote Uses

type RoundVote struct {
    SIGN   RoundVoteResult
    ACCEPT RoundVoteResult

func NewRoundVote Uses

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

func (*RoundVote) CanGetVotingResult Uses

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

func (*RoundVote) GetResult Uses

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

func (*RoundVote) IsVoted Uses

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

func (*RoundVote) IsVotedByNode Uses

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

func (*RoundVote) Vote Uses

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

type RoundVoteResult Uses

type RoundVoteResult map[string]ballot.Ballot

type RunningRound Uses

type RunningRound struct {

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

func NewRunningRound Uses

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

func (*RunningRound) IsVoted Uses

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

func (*RunningRound) RoundVote Uses

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

func (*RunningRound) Vote Uses

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

type SequentialSelector Uses

type SequentialSelector struct {
    // contains filtered or unexported fields

func (SequentialSelector) Select Uses

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

type SyncController Uses

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

Package consensus imports 14 packages (graph) and is imported by 4 packages. Updated 2019-03-27. Refresh now. Tools for package owners.