electionMsgTesting

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestVolunteerMessage

func NewTestVolunteerMessage(ele *elections.Elections, f, a int) *electionMsgs.FedVoteVolunteerMsg

Types

type Controller

type Controller struct {
	Elections        []*elections.Elections
	ElectionAdapters []*electionMsgs.ElectionAdapter
	Volunteers       []*electionMsgs.FedVoteVolunteerMsg

	Buffer        *MessageBuffer
	GlobalDisplay *election.Display

	//Router          *Router
	OutputsToRouter bool

	*priminterpreter.Primitives

	PrintingTrace bool

	History []string
	// contains filtered or unexported fields
}

Controller will be able to route messages to a set of nodes and control various communication patterns

func NewController

func NewController(feds, auds int) *Controller

NewController creates all the elections and initial volunteer messages

func (*Controller) ElectionStatus

func (c *Controller) ElectionStatus(node int) string

func (*Controller) RouteLeaderLevelMessage

func (c *Controller) RouteLeaderLevelMessage(from int, level int, to []int) bool

func (*Controller) RouteLeaderSetLevelMessage

func (c *Controller) RouteLeaderSetLevelMessage(from []int, level int, to []int) bool

func (*Controller) RouteLeaderSetVoteMessage

func (c *Controller) RouteLeaderSetVoteMessage(from []int, vol int, to []int) bool

func (*Controller) RouteLeaderVoteMessage

func (c *Controller) RouteLeaderVoteMessage(from int, vol int, to []int) bool

func (*Controller) RouteMessage

func (c *Controller) RouteMessage(msg interfaces.IMsg, nodes []int)

RouteMessage will execute message on all nodes given and add the messages returned to the buffer

func (*Controller) RouteVolunteerMessage

func (c *Controller) RouteVolunteerMessage(vol int, nodes []int)

type MessageBuffer

type MessageBuffer struct {
	// A list of all messages, it's an ever growing set, trimming the front
	// keeps the index the same by using the 'base' field.
	Messages []interfaces.IMsg
	Base     int

	// When looking for a message by someone, this helps searching
	MessagesMap map[[32]byte][]int
}

MessageBuffer will manage all messages in the message list

func NewMessageBuffer

func NewMessageBuffer() *MessageBuffer

func (*MessageBuffer) Add

func (b *MessageBuffer) Add(msg interfaces.IMsg)

func (*MessageBuffer) RetrieveIndex

func (b *MessageBuffer) RetrieveIndex(index int) (interfaces.IMsg, error)

func (*MessageBuffer) RetrieveLeaderLevelMessageByLevel

func (b *MessageBuffer) RetrieveLeaderLevelMessageByLevel(leader interfaces.IHash, level int) interfaces.IMsg

func (*MessageBuffer) RetrieveLeaderVoteMessage

func (b *MessageBuffer) RetrieveLeaderVoteMessage(leader interfaces.IHash, vol interfaces.IHash) interfaces.IMsg

RetrieveLeaderVoteMessage takes a vol too as multiple vote 0s can be sent out

Jump to

Keyboard shortcuts

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