election

package
v6.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 9 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BubbleSortLeaderLevelMsg

func BubbleSortLeaderLevelMsg(arr []*messages.LeaderLevelMessage)

***************

***************

Types

type DepthLeaderLevel

type DepthLeaderLevel struct {
	Msg     *messages.LeaderLevelMessage
	VoteMsg *messages.VoteMessage
	Depth   int
}

func NewDepthLeaderLevel

func NewDepthLeaderLevel(ll *messages.LeaderLevelMessage, depth int) *DepthLeaderLevel

func (*DepthLeaderLevel) Copy

type Display

type Display struct {
	Identifier string

	Votes [][]string

	FedList []primitives.Identity

	primitives.AuthSet

	Global *Display
	// contains filtered or unexported fields
}

Display is a 2D array containing all the votes seen by all leaders

func NewDisplay

func NewDisplay(ele *Election, global *Display) *Display

func (*Display) Copy

func (a *Display) Copy(be *Election) *Display

func (*Display) DetectIllegalVote

func (d *Display) DetectIllegalVote(leader primitives.Identity) bool

DetectIllegalVote will detect if the vote sequence is valid

true ==> Illegal vote

func (*Display) DetectIllegalVotes

func (d *Display) DetectIllegalVotes() (loops int)

func (*Display) DetectLoopForLeader

func (d *Display) DetectLoopForLeader(leader primitives.Identity) bool

func (*Display) DetectLoops

func (d *Display) DetectLoops() (loops int)

Detecting Looping

func (*Display) DetectVerticalLoop

func (d *Display) DetectVerticalLoop(leader primitives.Identity) bool

detectVerticalLoop detects if leader # is looping vertically

func (*Display) Execute

func (d *Display) Execute(msg imessage.IMessage)

func (*Display) FormatLeaderLevelMsg

func (d *Display) FormatLeaderLevelMsg(msg *messages.LeaderLevelMessage) string

func (*Display) FormatLeaderLevelMsgShort

func (d *Display) FormatLeaderLevelMsgShort(msg *messages.LeaderLevelMessage) string

func (*Display) FormatMessage

func (d *Display) FormatMessage(msg imessage.IMessage) string

func (*Display) FormatVolunteerMsg

func (d *Display) FormatVolunteerMsg(msg *messages.VolunteerMessage) string

func (*Display) FormatVoteMsg

func (d *Display) FormatVoteMsg(msg *messages.VoteMessage) string

func (*Display) Lock

func (d *Display) Lock()

func (*Display) RLock

func (d *Display) RLock()

func (*Display) RUnlock

func (d *Display) RUnlock()

func (*Display) ResetIdentifier

func (d *Display) ResetIdentifier(ele *Election)

func (*Display) String

func (d *Display) String() string

func (*Display) Unlock

func (d *Display) Unlock()

type Election

type Election struct {
	// Level 0 volunteer votes map[vol]map[leader]msg
	VolunteerVotes map[Identity]map[Identity]*messages.VoteMessage

	// Indexed by volunteer
	VolunteerControls map[Identity]*volunteercontrol.VolunteerControl

	CurrentLevel int
	CurrentVote  messages.LeaderLevelMessage
	Self         Identity
	AuthSet

	// Used for debugging and seeing history
	MsgListIn  []*DepthLeaderLevel
	MsgListOut []*DepthLeaderLevel

	Display *Display
	// If I have committed to an answer and found enough to finish Election
	Committed bool

	// Some statistical info
	TotalMessages int

	// Each time I vote for the same vol in the next level
	CommitmentTally int
	// An observer never participates in an election, but can watch (audit or follower)
	Observer bool
}

func NewElection

func NewElection(self Identity, authset AuthSet) *Election

func (*Election) AddDisplay

func (e *Election) AddDisplay(global *Display) *Display

AddDisplay takes a global tracker. Send nil if you don't care about a global state

func (*Election) Copy

func (a *Election) Copy() *Election

func (*Election) Execute

func (e *Election) Execute(msg imessage.IMessage, depth int) (imessage.IMessage, bool)

func (*Election) NormalizedString

func (e *Election) NormalizedString() []byte

func (*Election) PrintMessages

func (e *Election) PrintMessages() string

func (*Election) SetObserver

func (e *Election) SetObserver(o bool)

func (*Election) StateString

func (e *Election) StateString() []byte

func (*Election) StateVCDataset

func (e *Election) StateVCDataset() [][]messages.LeaderLevelMessage

func (*Election) StateVotes

func (e *Election) StateVotes() []int

func (*Election) VolunteerControlString

func (e *Election) VolunteerControlString() string

type RoutingElection

type RoutingElection struct {
	*Election
}

RoutingElection is just an election that returns msgs for broadcasting

func NewRoutingElection

func NewRoutingElection(e *Election) *RoutingElection

func (*RoutingElection) Execute

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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