messagestate

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

Overview

MessageState tracks the signed messages received for each consensus instance,

and does things like reject duplicates and check message thresholds. SignedItem messages are those that implement sig.MultiSigMsgHeader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleMessageState

type SimpleMessageState struct {
	sync.RWMutex

	GC *generalconfig.GeneralConfig
	// contains filtered or unexported fields
}

func NewSimpleMessageState

func NewSimpleMessageState(gc *generalconfig.GeneralConfig) *SimpleMessageState

NewSimpleMessageState creates a new simple message state object for a single consensus index.

func (*SimpleMessageState) CheckGenThresholdCoin

func (sms *SimpleMessageState) CheckGenThresholdCoin(hdr messages.InternalSignedMsgHeader,
	threshold int, mc *consinterface.MemCheckers) (err error)

CheckGenThresholdCoin will see if a random coin value can be generated. If it is then it will be generated and stored in the message state. Note that SetupSignedMessage will generate a coin automatically if possible.

func (*SimpleMessageState) CheckGenThresholdSig

func (sms *SimpleMessageState) CheckGenThresholdSig(hdr messages.InternalSignedMsgHeader,
	threshold int, mc *consinterface.MemCheckers) (err error)

CheckGenThresholdSig will see if a threshold signature can be generated. If it is then it will be generated and stored in the message state. Note that SetupSignedMessage will generate a threshold signature automatically if possible.

func (*SimpleMessageState) GetCoinVal

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

GetCoinVal returns the threshold coin value for the message ID (if supported).

func (*SimpleMessageState) GetIndex

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

GetIndex returns the consensus index.

func (*SimpleMessageState) GetMsgState

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

GetMsgState should return the serialized state of all the valid messages received for this consensus instance. This should be able to be processed by UnwrapMessage. If generalconfig.UseFullBinaryState is true it returns the received signed messages together in a list. Otherwise it returns each unique message with the list of signatures for each message behind it. If localOnly is true then only proposal messages and signatures from the local node will be included.

func (*SimpleMessageState) GetSigCountMsg

func (sms *SimpleMessageState) GetSigCountMsg(sm types.HashStr) int

GetSigCountMsg returns the number of signatures received for this message.

func (*SimpleMessageState) GetSigCountMsgHeader

func (sms *SimpleMessageState) GetSigCountMsgHeader(hdr messages.InternalSignedMsgHeader,
	mc *consinterface.MemCheckers) (int, error)

GetSigCountMsgHeader returns the number of signatures received for this message header.

func (*SimpleMessageState) GetSigCountMsgID

func (sms *SimpleMessageState) GetSigCountMsgID(sm messages.MsgID) int

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

func (*SimpleMessageState) GetSigCountMsgIDList

func (sms *SimpleMessageState) 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 (*SimpleMessageState) GetThreshSig

GetThreshSig returns the threshold signature for the message header (if supported).

func (*SimpleMessageState) GetTotalSigCount

func (sms *SimpleMessageState) GetTotalSigCount(mc *consinterface.MemCheckers,
	hdrs ...messages.InternalSignedMsgHeader) (totalCount int, eachCount []int)

getTotalSigCount returns the number of unique signers for the set of msgHashes. Unique means if a signer signs multiple of msgHashes he will still only be counted once. Note that trackTotalSigCount must be called first (but only once) with the same set of msgsHashes.

func (*SimpleMessageState) 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). If the message is not a signed type message (not type *sig.MultipleSignedMessage then (0, 0, nil) is returned).

func (*SimpleMessageState) New

New creates a new empty SimpleMessageState object for the consensus index idx.

func (*SimpleMessageState) SetupSignedMessage

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

SetupSignedMessage takes a MultiSigMsgHeader, serializes the message appending signatures. If generateMySig is true, the serialized message will include the local nodes signature. It will generate a threshold signature if supported and enough signatures. Up to addOtherSigs number of signatures received so far for this message will additionally be appended. If alwaysSign is true signatures will be generated even if the configuration is set to not use signatures. If alwaysIncludeVRF is true then a VRF is added even if the configuration is set to not use signatures.

func (*SimpleMessageState) SetupSignedMessagesDuplicates

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

SetupSignedMessageDuplicates takes a list of headers that are assumed to have the same set of bytes to sign (i.e. the signed part are all the same though they may have different contents following the signed part, for example this is true with partial messages)

func (*SimpleMessageState) SetupUnsignedMessage

func (*SimpleMessageState) TrackTotalSigCount

func (sms *SimpleMessageState) TrackTotalSigCount(mc *consinterface.MemCheckers,
	hdrs ...messages.InternalSignedMsgHeader)

TrackTotalSigCount must be called before getTotalSigCount with the same set of hashes. This can be called for multiple sets of messages, but they all must be unique.

type SimpleMessageStateWrapper

type SimpleMessageStateWrapper struct {
	Sms SimpleMessageState
}

SimpleMessageStateWrapper is just a wrapper that allows the bin cons and mv cons message state objects to reuse these methods directly without reimplementing them.

func InitSimpleMessageStateWrapper

func InitSimpleMessageStateWrapper(gc *generalconfig.GeneralConfig) *SimpleMessageStateWrapper

InitSimpleMessageStateWrapper initializes the wrapper.

func (*SimpleMessageStateWrapper) GetCoinVal

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

GetCoinVal returns the threshold coin value for the message ID (if supported).

func (*SimpleMessageStateWrapper) GetIndex

func (*SimpleMessageStateWrapper) GetMsgState

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

func (*SimpleMessageStateWrapper) GetSigCountMsg

func (sms *SimpleMessageStateWrapper) GetSigCountMsg(hashStr types.HashStr) int

func (*SimpleMessageStateWrapper) GetSigCountMsgHeader

func (*SimpleMessageStateWrapper) GetSigCountMsgID

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

func (*SimpleMessageStateWrapper) GetSigCountMsgIDList

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

func (*SimpleMessageStateWrapper) GetThreshSig

GetThreshSig returns the threshold signature for the message ID (if supported).

func (*SimpleMessageStateWrapper) NewWrapper

NewWrapper creates a new SimpleMessageStateWrapper by calling the New(idx) method on the SimpleMessageState object.

func (*SimpleMessageStateWrapper) SetupSignedMessage

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

func (*SimpleMessageStateWrapper) SetupSignedMessagesDuplicates

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

func (*SimpleMessageStateWrapper) SetupUnsignedMessage

type SortBlsItem

type SortBlsItem []*blsSigItem

func (SortBlsItem) Len

func (a SortBlsItem) Len() int

func (SortBlsItem) Less

func (a SortBlsItem) Less(i, j int) bool

func (SortBlsItem) Swap

func (a SortBlsItem) Swap(i, j int)

type SortSigItem

type SortSigItem []*sig.SigItem

func (SortSigItem) Len

func (a SortSigItem) Len() int

func (SortSigItem) Less

func (a SortSigItem) Less(i, j int) bool

func (SortSigItem) Swap

func (a SortSigItem) Swap(i, j int)

Jump to

Keyboard shortcuts

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