messages

package
v0.0.0-...-379b430 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package messages defines a sub-module to handle IBFT messages

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrWrongCommitMessageType is an error indicating wrong type in commit messages
	ErrWrongCommitMessageType = errors.New("wrong type message is included in COMMIT messages")
)

Functions

func AreValidPCMessages

func AreValidPCMessages(messages []*proto.Message, height uint64, roundLimit uint64) bool

AreValidPCMessages validates PreparedCertificate messages

func ExtractCommitHash

func ExtractCommitHash(commitMessage *proto.Message) []byte

ExtractCommitHash extracts the commit proposal hash from the passed in message

func ExtractLastPreparedProposal

func ExtractLastPreparedProposal(roundChangeMessage *proto.Message) *proto.Proposal

ExtractLastPreparedProposal extracts the latest prepared proposal from the passed in message

func ExtractLatestPC

func ExtractLatestPC(roundChangeMessage *proto.Message) *proto.PreparedCertificate

ExtractLatestPC extracts the latest PC from the passed in message

func ExtractPrepareHash

func ExtractPrepareHash(prepareMessage *proto.Message) []byte

ExtractPrepareHash extracts the prepare proposal hash from the passed in message

func ExtractProposal

func ExtractProposal(proposalMessage *proto.Message) *proto.Proposal

ExtractProposal extracts the (rawData,r) proposal from the passed in message

func ExtractProposalHash

func ExtractProposalHash(proposalMessage *proto.Message) []byte

ExtractProposalHash extracts the proposal hash from the passed in message

func ExtractRoundChangeCertificate

func ExtractRoundChangeCertificate(proposalMessage *proto.Message) *proto.RoundChangeCertificate

ExtractRoundChangeCertificate extracts the RCC from the passed in message

func HasUniqueSenders

func HasUniqueSenders(messages []*proto.Message) bool

HasUniqueSenders checks if the messages have unique senders

Types

type CommittedSeal

type CommittedSeal struct {
	Signer    []byte
	Signature []byte
}

CommittedSeal Validator proof of signing a committed proposal

func ExtractCommittedSeal

func ExtractCommittedSeal(commitMessage *proto.Message) *CommittedSeal

ExtractCommittedSeal extracts the committed seal from the passed in message

func ExtractCommittedSeals

func ExtractCommittedSeals(commitMessages []*proto.Message) ([]*CommittedSeal, error)

ExtractCommittedSeals extracts the committed seals from the passed in messages

type Messages

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

Messages contains the relevant messages for each view (height, round)

func NewMessages

func NewMessages() *Messages

NewMessages returns a new Messages wrapper

func (*Messages) AddMessage

func (ms *Messages) AddMessage(message *proto.Message)

AddMessage adds a new message to the message queue

func (*Messages) Close

func (ms *Messages) Close()

Close closes event manager

func (*Messages) GetExtendedRCC

func (ms *Messages) GetExtendedRCC(
	height uint64,
	isValidMessage func(message *proto.Message) bool,
	isValidRCC func(round uint64, messages []*proto.Message) bool,
) []*proto.Message

GetExtendedRCC returns Round-Change-Certificate for the highest round

func (*Messages) GetMostRoundChangeMessages

func (ms *Messages) GetMostRoundChangeMessages(minRound, height uint64) []*proto.Message

GetMostRoundChangeMessages fetches most round change messages for the minimum round and above

func (*Messages) GetValidMessages

func (ms *Messages) GetValidMessages(
	view *proto.View,
	messageType proto.MessageType,
	isValid func(message *proto.Message) bool,
) []*proto.Message

GetValidMessages fetches all messages of a specific type for the specified view, that pass the validity check; invalid messages are pruned out

func (*Messages) PruneByHeight

func (ms *Messages) PruneByHeight(height uint64)

PruneByHeight prunes out all old messages from the message queues by the specified height in the view

func (*Messages) SignalEvent

func (ms *Messages) SignalEvent(messageType proto.MessageType, view *proto.View)

SignalEvent signals event

func (*Messages) Subscribe

func (ms *Messages) Subscribe(details SubscriptionDetails) *Subscription

Subscribe creates a new message type subscription

func (*Messages) Unsubscribe

func (ms *Messages) Unsubscribe(id SubscriptionID)

Unsubscribe cancels a message type subscription

type Subscription

type Subscription struct {
	// ID is the unique identifier of the subscription
	ID SubscriptionID

	// SubCh is the notification channel
	// on which the listener will receive notifications
	SubCh chan uint64
}

Subscription is the subscription returned to the user

type SubscriptionDetails

type SubscriptionDetails struct {
	// MessageType is the type of message
	// being subscribed to
	MessageType proto.MessageType

	// View is the combination of height + round
	// being subscribed to
	View *proto.View

	// MinNumMessages is the threshold of messages
	// being subscribed to
	MinNumMessages int

	// HasMinRound is the flag indicating if the
	// round number is a lower bound
	HasMinRound bool
}

SubscriptionDetails contain the requested details for the subscription

type SubscriptionID

type SubscriptionID int32

SubscriptionID is a unique number to identify Subscription

Directories

Path Synopsis
Package proto defines the code for protocol buffer
Package proto defines the code for protocol buffer

Jump to

Keyboard shortcuts

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