mvcons4

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: 19 Imported by: 0

Documentation

Overview

Implementation of multi-valued consensus in the likeness of PBFT.

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) GetAllowConcurrentTypes

func (Config) GetAllowConcurrentTypes(cons.GetOptionType) []bool

GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances when using total ordering or not or both. MvCons4 must run instances concurrently.

func (Config) GetCollectBroadcast

func (Config) GetCollectBroadcast(cons.GetOptionType) []types.CollectBroadcastType

GetCollectBroadcast returns the values for if the consensus supports broadcasting the commit message directly to the leader.

func (Config) GetIncludeProofsTypes

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

GetIncludeProofTypes returns false.

func (Config) GetMemberCheckerTypes

func (Config) GetMemberCheckerTypes(cons.GetOptionType) []types.MemberCheckerType

GetMemberCheckerTypes returns the types of member checkers valid for the consensus.

func (Config) GetOrderingTypes

func (Config) GetOrderingTypes(cons.GetOptionType) []types.OrderingType

GetOrderingTypes returns the types of ordering supported by the consensus.

func (Config) GetRandMemberCheckerTypes

func (Config) GetRandMemberCheckerTypes(cons.GetOptionType) []types.RndMemberType

GetRandMemberCheckerTypes returns the non-random type.

func (Config) GetRotateCoordTypes

func (Config) GetRotateCoordTypes(cons.GetOptionType) []bool

GetRotateCoordTypes returns false.

func (Config) GetSigTypes

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

GetSigTypes return the types of signatures supported by the consensus

func (Config) GetUsePubIndexTypes

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

GetUsePubIndex returns true.

func (Config) RequiresStaticMembership

func (Config) RequiresStaticMembership() bool

RequiresStaticMembership returns true if this consensus doesn't allow changing membership.

type MessageState

type MessageState struct {
	// contains filtered or unexported fields
}

MvCons4Message state stores the message of MvCons

func NewMvCons4MessageState

func NewMvCons4MessageState(gc *generalconfig.GeneralConfig) *MessageState

NewMvCons4MessageState generates a new MvCons4MessageStateObject.

func (*MessageState) GetCoinVal

func (sms *MessageState) GetCoinVal(hdr messages.InternalSignedMsgHeader, threshold int,
	mc *consinterface.MemCheckers) (coinVal types.BinVal, ready bool, err error)

GetCoinVal is unsupported.

func (*MessageState) GetIndex

func (sms *MessageState) GetIndex() types.ConsensusIndex

GetIndex returns the consensus index.

func (*MessageState) GetMsgState

func (sms *MessageState) GetMsgState(priv sig.Priv, localOnly bool,
	bufferCountFunc consinterface.BufferCountFunc,
	mc *consinterface.MemCheckers) ([]byte, error)

GetMsgState returns the serialized state of all the valid messages received since the previous index decided until either this index decided or all messages following the previous index if this index has not yet decided.

func (*MessageState) GetSigCountMsg

func (sms *MessageState) GetSigCountMsg(hsh types.HashStr) int

GetSigCountMsg returns the number of signatures received for this message.

func (*MessageState) GetSigCountMsgHeader

func (sms *MessageState) GetSigCountMsgHeader(header messages.InternalSignedMsgHeader,
	mc *consinterface.MemCheckers) (int, error)

GetSigCountMsgHeader returns the number of signatures received for this header.

func (*MessageState) GetSigCountMsgID

func (sms *MessageState) GetSigCountMsgID(msgID messages.MsgID) int

GetSigCountMsgID returns the number of sigs for this message's MsgID (see messages.MsgID).

func (*MessageState) GetSigCountMsgIDList

func (sms *MessageState) GetSigCountMsgIDList(msgID messages.MsgID) []consinterface.MsgIDCount

GetSigCountMsgIDList returns list of received messages that have msgID for their MsgID and how many signatures have been received for each.

func (*MessageState) GetThreshSig

func (sms *MessageState) GetThreshSig(hdr messages.InternalSignedMsgHeader, threshold int,
	mc *consinterface.MemCheckers) (*sig.SigItem, error)

GetThreshSig is no supported.

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) HdrEvent - a message containing an event

func (*MessageState) New

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

func (*MessageState) SetupSignedMessage

func (sms *MessageState) SetupSignedMessage(hdr messages.InternalSignedMsgHeader, generateMySig bool,
	addOthersSigsCount int, mc *consinterface.MemCheckers) (*sig.MultipleSignedMessage, error)

SetupSigned message takes a messages.InternalSignedMsgHeader, serializes the message appending signatures creating and returning a new *sig.MultipleSignedMessage. If generateMySig is true, the serialized message will include the local nodes signature. Up to addOtherSigs number of signatures received so far for this message will additionally be appended.

func (*MessageState) SetupSignedMessagesDuplicates

func (sms *MessageState) SetupSignedMessagesDuplicates(combined *messagetypes.CombinedMessage, hdrs []messages.InternalSignedMsgHeader,
	mc *consinterface.MemCheckers) (combinedSigned *sig.MultipleSignedMessage, partialsSigned []*sig.MultipleSignedMessage, err error)

SetupSignedMessageDuplicates is unsupported

func (*MessageState) SetupUnsignedMessage

SetupUnsignedMessage is unsupported

type MvCons4

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

func (*MvCons4) CanStartNext

func (sc *MvCons4) CanStartNext() bool

CanStartNext returns true

func (*MvCons4) Collect

func (sc *MvCons4) Collect()

Collect is called when the item is being garbage collected.

func (*MvCons4) ForwardOldIndices

func (sc *MvCons4) ForwardOldIndices() bool

ForwardOldIndices returns true since events from old indices may be needed for future decisions.

func (*MvCons4) GenerateMessageState

func (*MvCons4) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState

GenerateMessageState generates a new message state object given the inputs.

func (*MvCons4) GenerateNewItem

ResetState resets the stored state for the current consensus index, and prepares for the new consensus index given by the input.

func (*MvCons4) GetBinState

func (sc *MvCons4) 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 (*MvCons4) 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) HdrEventInfo returns 0, 0 if generalconfig.MvBroadcastInitForBufferForwarder is true (meaning don't forward the message)

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

func (*MvCons4) GetCommitProof

func (sc *MvCons4) GetCommitProof() (proof []messages.MsgHeader)

GetCommitProof returns nil for MvCons4. It generates the proofs itself since it piggybacks rounds with consensus instances.

func (*MvCons4) GetConsType

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

GetConsType returns the type of consensus this instance implements.

func (*MvCons4) GetCustomRecoverMsg

func (sc *MvCons4) GetCustomRecoverMsg(createEmpty bool) messages.MsgHeader

GetCustomRecoverMsg is called when there is no progress after a timeout. It returns an IndexRecoverMsg

func (*MvCons4) GetDecision

func (sc *MvCons4) GetDecision() (proposer sig.Pub, decision []byte, prvIdx, futureFixed types.ConsensusIndex)

GetDecision returns the decided value of the consensus. It should only be called after HasDecided returns true. Proposer is nil, prvIdx is the current index - 1, futureFixed is the first larger index that this decision does not depend, i.e. the current index + 1.

func (*MvCons4) GetHeader

func (*MvCons4) 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 HdrEventInfo.

func (*MvCons4) GetNextInfo

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

GetNextInfo will be called after CanStartNext returns true. prevIdx is the index that this consensus index will follow (i.e. idx - 1). proposer and preDecision are nil. hasInfo is false since this consensus does not support concurrent instances (it is built in).

func (*MvCons4) GetPrevCommitProof

func (sc *MvCons4) GetPrevCommitProof() (coordPub sig.Pub, proof []messages.MsgHeader)

GetPrevCommitProof is unsupported

func (*MvCons4) GetProposalIndex

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

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

func (*MvCons4) GetProposeHeaderID

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

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

func (*MvCons4) GetRecoverMsgType

func (sc *MvCons4) GetRecoverMsgType() messages.HeaderID

GetRecoverMsgType returns messages.HdrIdxRecover.

func (*MvCons4) GotProposal

func (sc *MvCons4) GotProposal(hdr messages.MsgHeader, _ channelinterface.MainChannel) error

GotProposal takes the proposal, and broadcasts it.

func (*MvCons4) HasDecided

func (sc *MvCons4) HasDecided() bool

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

func (*MvCons4) HasValidStarted

func (sc *MvCons4) HasValidStarted() bool

HasValidStarted is unsupported

func (*MvCons4) NeedsCompletionConcurrentProposals

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

NeedsConcurrent returns 1.

func (*MvCons4) PrevHasBeenReset

func (sc *MvCons4) PrevHasBeenReset()

PrevHasBeenReset is called when the previous consensus index has been reset to a new index, it is unused.

func (*MvCons4) ProcessCustomRecoveryMessage

func (sc *MvCons4) ProcessCustomRecoveryMessage(item *deserialized.DeserializedItem,
	sendChan *channelinterface.SendRecvChannel)

ProcessCustomRecoveryMessage handles recovery messages of type IndexRecoverMessage.

func (*MvCons4) ProcessMessage

func (sc *MvCons4) ProcessMessage(
	deser *deserialized.DeserializedItem,
	isLocal bool,
	senderChan *channelinterface.SendRecvChannel) (progress bool, forward 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.HdrEventInfo is an event info message.

func (*MvCons4) SetInitialState

func (sc *MvCons4) SetInitialState(value []byte, store storage.StoreInterface)

SetInitialState sets the value that is supported by the inital index (1).

func (*MvCons4) SetNextConsItem

func (sc *MvCons4) SetNextConsItem(next consinterface.ConsItem)

SetNextConsItem is unused.

func (*MvCons4) ShouldCreatePartial

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

ShouldCreatePartial returns false.

func (*MvCons4) Start

func (sc *MvCons4) Start(finishedLastRound 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