processutil

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomGoodValue added in v0.4.1

func RandomGoodValue(r *rand.Rand) process.Value

RandomGoodValue consumes a source of randomness and returns a truly random value which is proposed by the proposer, on which consensus can be reached

func RandomHeight

func RandomHeight(r *rand.Rand) process.Height

RandomHeight consumes a source of randomness and returns a random height for the consensus mechanism. It returns a truly random height 70% of the times, whereas for the other 30% of the times it returns heights for edge scenarios

func RandomPrecommit

func RandomPrecommit(r *rand.Rand) process.Precommit

RandomPrecommit consumes a source of randomness and returns a random precommit message. The message is a valid message 70% of the times, and other times this function returns some edge scenarios, including empty message

func RandomPrevote

func RandomPrevote(r *rand.Rand) process.Prevote

RandomPrevote consumes a source of randomness and returns a random prevote message. The message is a valid message 70% of the times, and other times this function returns some edge scenarios, including empty message

func RandomPropose

func RandomPropose(r *rand.Rand) process.Propose

RandomPropose consumes a source of randomness and returns a random propose message. The message is a valid message 70% of the times, and other times this function returns some edge scenarios, including empty message

func RandomRound

func RandomRound(r *rand.Rand) process.Round

RandomRound consumes a source of randomness and returns a random round for the consensus mechanism. It returns a truly random round 70% of the times, whereas for the other 30% of the times it returns rounds for edge scenarios

func RandomState

func RandomState(r *rand.Rand) process.State

RandomState consumes a source of randomness and returns a random state of a process in the consensus mechanism.

func RandomStep

func RandomStep(r *rand.Rand) process.Step

RandomStep consumes a source of randomness and returns a random step for the consensus mechanism. A random step could be a valid or invalid step

func RandomValue

func RandomValue(r *rand.Rand) process.Value

RandomValue consumes a source of randomness and returns a random value for the consensus mechanism. It returns a truly random round 80% of the times, whereas for the other 20% of the times it returns rounds for edge scenarios

Types

type BroadcasterCallbacks

type BroadcasterCallbacks struct {
	BroadcastProposeCallback   func(process.Propose)
	BroadcastPrevoteCallback   func(process.Prevote)
	BroadcastPrecommitCallback func(process.Precommit)
}

BroadcasterCallbacks provide callback functions to test the broadcaster behaviour required by a Process

func (BroadcasterCallbacks) BroadcastPrecommit

func (broadcaster BroadcasterCallbacks) BroadcastPrecommit(precommit process.Precommit)

BroadcastPrecommit passes the precommit message to the precommit callback, if present

func (BroadcasterCallbacks) BroadcastPrevote

func (broadcaster BroadcasterCallbacks) BroadcastPrevote(prevote process.Prevote)

BroadcastPrevote passes the prevote message to the prevote callback, if present

func (BroadcasterCallbacks) BroadcastPropose

func (broadcaster BroadcasterCallbacks) BroadcastPropose(propose process.Propose)

BroadcastPropose passes the propose message to the propose callback, if present

type CatcherCallbacks added in v0.4.1

type CatcherCallbacks struct {
	CatchDoubleProposeCallback    func(process.Propose, process.Propose)
	CatchDoublePrevoteCallback    func(process.Prevote, process.Prevote)
	CatchDoublePrecommitCallback  func(process.Precommit, process.Precommit)
	CatchOutOfTurnProposeCallback func(process.Propose)
}

CatcherCallbacks provide callback functions to test the Catcher interface required by a Process

func (CatcherCallbacks) CatchDoublePrecommit added in v0.4.1

func (catcher CatcherCallbacks) CatchDoublePrecommit(precommit1 process.Precommit, precommit2 process.Precommit)

CatchDoublePrecommit implements the interface method of handling the event when two different precommit messages were received from the same process. In this case, it simply passes those to the appropriate callback function

func (CatcherCallbacks) CatchDoublePrevote added in v0.4.1

func (catcher CatcherCallbacks) CatchDoublePrevote(prevote1 process.Prevote, prevote2 process.Prevote)

CatchDoublePrevote implements the interface method of handling the event when two different prevote messages were received from the same process. In this case, it simply passes those to the appropriate callback function

func (CatcherCallbacks) CatchDoublePropose added in v0.4.1

func (catcher CatcherCallbacks) CatchDoublePropose(propose1 process.Propose, propose2 process.Propose)

CatchDoublePropose implements the interface method of handling the event when two different propose messages were received from the same process. In this case, it simply passes those to the appropriate callback function

func (CatcherCallbacks) CatchOutOfTurnPropose added in v0.4.1

func (catcher CatcherCallbacks) CatchOutOfTurnPropose(propose process.Propose)

CatchOutOfTurnPropose implements the interface method of handling the event when a process not scheduled to propose for the current height/round broadcasts a propose. In this case, it simply passes those to the appropriate callback function

type CommitterCallback added in v0.4.1

type CommitterCallback struct {
	Callback func(process.Height, process.Value)
}

CommitterCallback provides a callback function to test the Committer behaviour required by a Process

func (CommitterCallback) Commit added in v0.4.1

func (committer CommitterCallback) Commit(height process.Height, value process.Value)

Commit passes the commitment parameters height and round to the commit callback, if present

type MockProposer added in v0.4.1

type MockProposer struct {
	MockValue func() process.Value
}

MockProposer is a mock implementation of the Proposer interface It always proposes the value MockValue

func (MockProposer) Propose added in v0.4.1

func (p MockProposer) Propose(height process.Height, round process.Round) process.Value

Propose implements the propose behaviour as required by the Proposer interface The MockProposer's propose method does not take into consideration the consensus parameters height and round, but simply returns the value MockValue

type MockValidator added in v0.4.1

type MockValidator struct {
	MockValid func(value process.Value) bool
}

MockValidator is a mock implementation of the Validator interface It always returns the MockValid value as its validation check

func (MockValidator) Valid added in v0.4.1

func (v MockValidator) Valid(value process.Value) bool

Valid implements the validation behaviour as required by the Validator interface The MockValidator's valid method does not take into consideration the received propose message, but simply returns the MockValid value as its validation check

Jump to

Keyboard shortcuts

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