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 ¶
- type SimpleMessageState
- func (sms *SimpleMessageState) CheckGenThresholdCoin(hdr messages.InternalSignedMsgHeader, threshold int, ...) (err error)
- func (sms *SimpleMessageState) CheckGenThresholdSig(hdr messages.InternalSignedMsgHeader, threshold int, ...) (err error)
- func (sms *SimpleMessageState) GetCoinVal(hdr messages.InternalSignedMsgHeader, threshold int, ...) (coinVal types.BinVal, ready bool, err error)
- func (sms *SimpleMessageState) GetIndex() types.ConsensusIndex
- func (sms *SimpleMessageState) GetMsgState(priv sig.Priv, localOnly bool, bufferCountFunc consinterface.BufferCountFunc, ...) ([]byte, error)
- func (sms *SimpleMessageState) GetSigCountMsg(sm types.HashStr) int
- func (sms *SimpleMessageState) GetSigCountMsgHeader(hdr messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (int, error)
- func (sms *SimpleMessageState) GetSigCountMsgID(sm messages.MsgID) int
- func (sms *SimpleMessageState) GetSigCountMsgIDList(msgID messages.MsgID) []consinterface.MsgIDCount
- func (sms *SimpleMessageState) GetThreshSig(hdr messages.InternalSignedMsgHeader, threshold int, ...) (*sig.SigItem, error)
- func (sms *SimpleMessageState) GetTotalSigCount(mc *consinterface.MemCheckers, hdrs ...messages.InternalSignedMsgHeader) (totalCount int, eachCount []int)
- func (sms *SimpleMessageState) GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, ...) ([]*deserialized.DeserializedItem, error)
- func (sms *SimpleMessageState) New(idx types.ConsensusIndex) consinterface.MessageState
- func (sms *SimpleMessageState) SetupSignedMessage(hdr messages.InternalSignedMsgHeader, generateMySig bool, ...) (*sig.MultipleSignedMessage, error)
- func (sms *SimpleMessageState) SetupSignedMessagesDuplicates(combined *messagetypes.CombinedMessage, ...) (combinedSigned *sig.MultipleSignedMessage, ...)
- func (sms *SimpleMessageState) SetupUnsignedMessage(hdr messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (*sig.UnsignedMessage, error)
- func (sms *SimpleMessageState) TrackTotalSigCount(mc *consinterface.MemCheckers, hdrs ...messages.InternalSignedMsgHeader)
- type SimpleMessageStateWrapper
- func (sms *SimpleMessageStateWrapper) GetCoinVal(hdr messages.InternalSignedMsgHeader, threshold int, ...) (coinVal types.BinVal, ready bool, err error)
- func (sms *SimpleMessageStateWrapper) GetIndex() types.ConsensusIndex
- func (sms *SimpleMessageStateWrapper) GetMsgState(priv sig.Priv, localOnly bool, bufferCountFunc consinterface.BufferCountFunc, ...) ([]byte, error)
- func (sms *SimpleMessageStateWrapper) GetSigCountMsg(hashStr types.HashStr) int
- func (sms *SimpleMessageStateWrapper) GetSigCountMsgHeader(header messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (int, error)
- func (sms *SimpleMessageStateWrapper) GetSigCountMsgID(msgID messages.MsgID) int
- func (sms *SimpleMessageStateWrapper) GetSigCountMsgIDList(msgID messages.MsgID) []consinterface.MsgIDCount
- func (sms *SimpleMessageStateWrapper) GetThreshSig(hdr messages.InternalSignedMsgHeader, threshold int, ...) (*sig.SigItem, error)
- func (sms *SimpleMessageStateWrapper) NewWrapper(firstIdx types.ConsensusIndex) *SimpleMessageStateWrapper
- func (sms *SimpleMessageStateWrapper) SetupSignedMessage(hdr messages.InternalSignedMsgHeader, generateMySig bool, ...) (*sig.MultipleSignedMessage, error)
- func (sms *SimpleMessageStateWrapper) SetupSignedMessagesDuplicates(combined *messagetypes.CombinedMessage, ...) (combinedSigned *sig.MultipleSignedMessage, ...)
- func (sms *SimpleMessageStateWrapper) SetupUnsignedMessage(hdr messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (*sig.UnsignedMessage, error)
- type SortBlsItem
- type SortSigItem
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 ¶
func (sms *SimpleMessageState) GetThreshSig(hdr messages.InternalSignedMsgHeader, threshold int, mc *consinterface.MemCheckers) (*sig.SigItem, error)
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 ¶
func (sms *SimpleMessageState) GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, gc *generalconfig.GeneralConfig, mc *consinterface.MemCheckers) ([]*deserialized.DeserializedItem, error)
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 ¶
func (sms *SimpleMessageState) New(idx types.ConsensusIndex) consinterface.MessageState
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 (sms *SimpleMessageState) SetupUnsignedMessage(hdr messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (*sig.UnsignedMessage, error)
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 (sms *SimpleMessageStateWrapper) GetIndex() types.ConsensusIndex
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 (sms *SimpleMessageStateWrapper) GetSigCountMsgHeader(header messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (int, error)
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 ¶
func (sms *SimpleMessageStateWrapper) GetThreshSig(hdr messages.InternalSignedMsgHeader, threshold int, mc *consinterface.MemCheckers) (*sig.SigItem, error)
GetThreshSig returns the threshold signature for the message ID (if supported).
func (*SimpleMessageStateWrapper) NewWrapper ¶
func (sms *SimpleMessageStateWrapper) NewWrapper(firstIdx types.ConsensusIndex) *SimpleMessageStateWrapper
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 ¶
func (sms *SimpleMessageStateWrapper) SetupUnsignedMessage(hdr messages.InternalSignedMsgHeader, mc *consinterface.MemCheckers) (*sig.UnsignedMessage, error)
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 ¶
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)