mvbinconsrnd2

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	cons.StandardMvConfig
}

func (Config) GetAllowNoSignatures

func (Config) GetAllowNoSignatures(gt cons.GetOptionType) []bool

GetAllowNoSignatures returns true if the consensus can run without signatures

func (Config) GetCoinTypes

func (Config) GetCoinTypes(optionType cons.GetOptionType) []types.CoinType

GetCoinTypes returns the types of coins allowed.

func (Config) GetIncludeProofsTypes

func (Config) GetIncludeProofsTypes(_ cons.GetOptionType) []bool

GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.

func (Config) GetSigTypes

func (Config) GetSigTypes(gt cons.GetOptionType) []types.SigType

GetSigTypes return the types of signatures supported by the consensus

func (Config) GetStopOnCommitTypes

func (Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (Config) GetUsePubIndexTypes

func (Config) GetUsePubIndexTypes(_ cons.GetOptionType) []bool

GetUsePubIndex returns the values for if the consensus supports using pub index or not or both.

type MessageState

type MessageState struct {
	*messagestate.SimpleMessageStateWrapper // the simple message state is used to track the actual messages

	bincons1.BinConsMessageStateInterface // the binary consensus messages
	// contains filtered or unexported fields
}

RbBcast1Message state stores the message of RbBcast.

func NewMvBinConsRnd2MessageState

func NewMvBinConsRnd2MessageState(gc *generalconfig.GeneralConfig) *MessageState

NewMvBinConsRnd2MessageState generates a new MvBinConsRnd2MessageStateObject.

func (*MessageState) GenerateProofs

func (sms *MessageState) GenerateProofs(hdrID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal,
	pub sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error)

Generate proofs returns a signed message with signatures supporting the input values, it can be a MvEchoMessage.

func (*MessageState) GotMsg

GotMessage takes a deserialized message and the member checker for the current consensus index. If the message contains no new valid signatures then an error is returned. The value newTotalSigCount is the new number of signatures for the specific message, the value newMsgIDSigCount is the number of signatures for the MsgID of the message (see messages.MsgID). The valid message types are (1) HdrMvInit - the leaders proposal, here is ensures the message comes from the correct leader (2) HdrMvEcho - echo messages (3) HdrMvCommit - commit messages (4) HdrMvRequestRecover - unsigned message asking for the init message received for a given hash

func (*MessageState) New

New inits and returns a new MvBinConsRnd2MessageState object for the given consensus index.

type MvBinConsRnd2

type MvBinConsRnd2 struct {
	cons.AbsConsItem
	cons.AbsMVRecover
	// contains filtered or unexported fields
}

func (*MvBinConsRnd2) CanStartNext

func (sc *MvBinConsRnd2) CanStartNext() bool

CanStartNext should return true if it is safe to start the next consensus instance (if parallel instances are enabled)

func (*MvBinConsRnd2) Collect

func (sc *MvBinConsRnd2) Collect()

Collect is called when the item is being garbage collected.

func (*MvBinConsRnd2) GenerateMessageState

GenerateMessageState generates a new message state object given the inputs.

func (*MvBinConsRnd2) GenerateNewItem

GenerateNewItem creates a new cons item.

func (*MvBinConsRnd2) GetBinState

func (sc *MvBinConsRnd2) GetBinState(localOnly bool) ([]byte, error)

GetBinState returns the entire state of the consensus as a string of bytes using MessageState.GetMsgState() as the list of all messages, with a messagetypes.ConsBinStateMessage header appended to the beginning).

func (*MvBinConsRnd2) GetBufferCount

GetBufferCount checks a MessageID and returns the thresholds for which it should be forwarded using the BufferForwarder (see forwardchecker.ForwardChecker interface). The messages are: (1) HdrMvInit returns 0, 0 if generalconfig.MvBroadcastInitForBufferForwarder is true (meaning don't forward the message)

otherwise returns 1, 1 (meaning forward the message right away)

(2) HdrMvEcho returns n-t, n for the thresholds. (3) HdrMvCommit returns n-t, n for the thresholds.

func (*MvBinConsRnd2) GetCommitProof

func (sc *MvBinConsRnd2) GetCommitProof() []messages.MsgHeader

GetCommitProof returns a signed message header that counts at the commit message for this consensus.

func (*MvBinConsRnd2) GetConsType

func (sc *MvBinConsRnd2) GetConsType() types.ConsType

GetConsType returns the type of consensus this instance implements.

func (*MvBinConsRnd2) GetDecision

func (sc *MvBinConsRnd2) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)

GetDecision returns the decided value as a byte slice.

func (*MvBinConsRnd2) GetHeader

func (*MvBinConsRnd2) GetHeader(emptyPub sig.Pub, gc *generalconfig.GeneralConfig,
	headerType messages.HeaderID) (messages.MsgHeader, error)

GetHeader return blank message header for the HeaderID, this object will be used to deserialize a message into itself (see consinterface.DeserializeMessage). The valid headers are HdrMvInit, HdrMvEcho, HdrMvCommit, HdrMvRequestRecover.

func (*MvBinConsRnd2) GetNextInfo

func (sc *MvBinConsRnd2) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, hasInfo bool)

GetNextInfo will be called after CanStartNext returns true. It returns sc.Index - 1, nil. If false is returned then the next is started, but the current instance has no state machine created. // TODO

func (*MvBinConsRnd2) GetPrevCommitProof

func (sc *MvBinConsRnd2) GetPrevCommitProof() (cordPub sig.Pub, proof []messages.MsgHeader)

GetPrevCommitProof returns a signed message header that counts at the commit message for the previous consensus. This should only be called after DoneKeep has been called on this instance. cordPub is the expected public key of the coordinator of the current round (used for collect broadcast)

func (*MvBinConsRnd2) GetProposalIndex

func (sc *MvBinConsRnd2) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)

GetProposalIndex returns sc.Index - 1. It returns false until start is called.

func (*MvBinConsRnd2) GetProposeHeaderID

func (sc *MvBinConsRnd2) GetProposeHeaderID() messages.HeaderID

GetProposeHeaderID returns the HeaderID messages.HdrMvPropose that will be input to GotProposal.

func (*MvBinConsRnd2) GotProposal

func (sc *MvBinConsRnd2) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error

GotProposal takes the proposal, and broadcasts it if it is the leader.

func (*MvBinConsRnd2) HasDecided

func (sc *MvBinConsRnd2) HasDecided() bool

HasDecided should return true if this consensus item has reached a decision.

func (*MvBinConsRnd2) HasValidStarted

func (sc *MvBinConsRnd2) HasValidStarted() bool

HasValidStarted returns true if the cons has received a valid proposal, or the binary reduction has terminated.

func (*MvBinConsRnd2) NeedsCompletionConcurrentProposals

func (sc *MvBinConsRnd2) NeedsCompletionConcurrentProposals() types.ConsensusInt

NeedsConcurrent returns 1.

func (*MvBinConsRnd2) PrevHasBeenReset

func (sc *MvBinConsRnd2) PrevHasBeenReset()

PrevHasBeenReset is called when the previous consensus index has been reset to a new index

func (*MvBinConsRnd2) ProcessMessage

func (sc *MvBinConsRnd2) ProcessMessage(
	deser *deserialized.DeserializedItem,
	isLocal bool,
	senderChan *channelinterface.SendRecvChannel) (bool, bool)

ProcessMessage is called on every message once it has been checked that it is a valid message (using the static method ConsItem.DerserializeMessage), that it comes from a member of the consensus and that it is not a duplicate message (using the MemberChecker and MessageState objects). This function processes the message and update the state of the consensus. For this consensus implementation messageState must be an instance of BinConsMessageStateInterface. It returns true in first position if made progress towards decision, or false if already decided, and return true in second position if the message should be forwarded. The following are the valid message types: messages.HdrMvInit is the leader proposal, once this is received an echo is sent containing the hash, and starts the echo timeoutout. messages.HdrMvEcho is the echo message, when these are received we run CheckEchoState. messages.HdrMvRequestRecover a node terminated bin cons with 1, but didn't get the init message, so if we have it we send it. messages.HdrMvRecoverTimeout if a node terminated bin cons with 1, but didn't get the init mesage this timeout is started, once it runs out, we ask other nodes to send the init message.

func (*MvBinConsRnd2) SetInitialState

func (sc *MvBinConsRnd2) SetInitialState([]byte, storage.StoreInterface)

SetInitialState does noting for this algorithm.

func (*MvBinConsRnd2) SetNextConsItem

func (sc *MvBinConsRnd2) SetNextConsItem(consinterface.ConsItem)

SetNextConsItem gives a pointer to the next consensus item at the next consensus instance, it is called when the next instance is created

func (*MvBinConsRnd2) ShouldCreatePartial

func (sc *MvBinConsRnd2) ShouldCreatePartial(headerType messages.HeaderID) bool

ShouldCreatePartial returns true if the message type should be sent as a partial message

func (*MvBinConsRnd2) Start

func (sc *MvBinConsRnd2) Start(finishedLastIndex bool)

Start allows GetProposalIndex to return true.

Jump to

Keyboard shortcuts

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