msgqueue

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllIndicesCleaner

func AllIndicesCleaner(k Index) bool

AllIndicesCleaner is a cleaner that removes all existing indices

Types

type By

type By func(a, b *spectypes.SSVMessage) bool

By is function to compare messages

func ByConsensusMsgType

func ByConsensusMsgType(messageTypes ...specqbft.MessageType) By

ByConsensusMsgType implements By for msg type based priority ()

func ByRound

func ByRound() By

ByRound implements By for round based priority

func (By) Add

func (by By) Add(msgs []*MsgContainer, msg *MsgContainer) []*MsgContainer

Add adds a new container

func (By) Combine

func (by By) Combine(other By) By

Combine runs current By and if result is negative, tries to run the other By.

func (By) Sort

func (by By) Sort(msgs []*MsgContainer)

Sort sorts the given containers

type Cleaner

type Cleaner func(Index) bool

Cleaner is a function for iterating over keys and clean irrelevant ones

func DefaultMsgCleaner

func DefaultMsgCleaner(mid spectypes.MessageID, mts ...spectypes.MsgType) Cleaner

DefaultMsgCleaner cleans ssv msgs from the queue

func SignedMsgCleaner

func SignedMsgCleaner(mid spectypes.MessageID, h specqbft.Height) Cleaner

SignedMsgCleaner cleans consensus messages from the queue it will clean messages of the given identifier and under the given height

func SignedPostConsensusMsgCleaner

func SignedPostConsensusMsgCleaner(mid spectypes.MessageID, s spec.Slot) Cleaner

SignedPostConsensusMsgCleaner cleans post consensus messages from the queue it will clean messages of the given identifier and under the given slot

type Index

type Index struct {
	Name string
	// Mt is the message type
	Mt spectypes.MsgType
	// ID is the identifier
	ID string
	// H (optional) is the height, -1 is treated as nil
	H specqbft.Height
	// S (optional) is the slot
	S spec.Slot
	// Cmt (optional) is the consensus msg type, -1 is treated as nil
	Cmt specqbft.MessageType
}

Index is a struct representing an index in msg queue

func DecidedMsgIndex

func DecidedMsgIndex(mid string) Index

DecidedMsgIndex indexes a decided specqbft.SignedMessage by identifier, msg type

func DefaultMsgIndex

func DefaultMsgIndex(mt spectypes.MsgType, mid spectypes.MessageID) Index

DefaultMsgIndex is the default msg index

func SignedMsgIndex

func SignedMsgIndex(msgType spectypes.MsgType, mid string, h specqbft.Height, cmt ...specqbft.MessageType) []Index

SignedMsgIndex indexes a specqbft.SignedMessage by identifier, msg type and height

func SignedPostConsensusMsgIndex

func SignedPostConsensusMsgIndex(mid string, s spec.Slot) Index

SignedPostConsensusMsgIndex indexes a message.SignedPostConsensusMessage by identifier and height

func (*Index) String added in v0.3.2

func (i *Index) String() string

type IndexGenerator

type IndexGenerator func() Index

IndexGenerator generates an index

type IndexIterator

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

IndexIterator enables to iterate over future created indices

func NewIndexIterator

func NewIndexIterator() *IndexIterator

NewIndexIterator creates a new iterator

func (*IndexIterator) Add

func (ii *IndexIterator) Add(generators ...IndexGenerator) *IndexIterator

Add adds a new generator

func (*IndexIterator) AddIndex added in v0.3.2

func (ii *IndexIterator) AddIndex(idx Index) *IndexIterator

AddIndex adds an index

func (*IndexIterator) Next

func (ii *IndexIterator) Next() IndexGenerator

Next returns the next generator

func (*IndexIterator) Reset

func (ii *IndexIterator) Reset()

Reset set iterator to 0. NOTE: use only in case we want to reuse the iterator

type Indexer

type Indexer func(msg *spectypes.SSVMessage) Index

Indexer indexes the given message, returns an empty string if not applicable use WithIndexers to inject indexers upon start

func DecidedMsgIndexer

func DecidedMsgIndexer() Indexer

DecidedMsgIndexer is the Indexer used for decided specqbft.SignedMessage

func DefaultMsgIndexer

func DefaultMsgIndexer() Indexer

DefaultMsgIndexer returns the default msg indexer to use for message.SSVMessage

func SignedMsgIndexer

func SignedMsgIndexer() Indexer

SignedMsgIndexer is the Indexer used for specqbft.SignedMessage

func SignedPostConsensusMsgIndexer

func SignedPostConsensusMsgIndexer() Indexer

SignedPostConsensusMsgIndexer is the Indexer used for message.SignedPostConsensusMessage

type MsgContainer

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

MsgContainer is a container for a message

type MsgQueue

type MsgQueue interface {
	// Add adds a new message to the queue for the matching indices
	Add(msg *spectypes.SSVMessage)
	// Peek returns the first n messages for an index
	Peek(n int, idx Index) []*spectypes.SSVMessage
	// WithIterator looping through all indexes and return true when relevant and pop
	WithIterator(n int, peek bool, iterator func(index Index) bool) []*spectypes.SSVMessage
	// Pop clears and returns the first n messages for an index
	Pop(n int, idx Index) []*spectypes.SSVMessage
	// PopIndices clears and returns the first n messages for indices that are created on demand using the iterator
	PopIndices(n int, generator *IndexIterator) []*spectypes.SSVMessage
	// Purge clears indexed messages for the given index
	Purge(idx Index) int64
	// Clean enables to aid in a custom Cleaner to clear any set of indices
	// TODO: check performance
	Clean(cleaners ...Cleaner) int64
	// Count counts messages for the given index
	Count(idx Index) int
	// Len counts all messages
	Len() int
}

MsgQueue is a message broker for message.SSVMessage

func New

func New(logger *zap.Logger, opt ...Option) (MsgQueue, error)

New creates a new MsgQueue

type Option

type Option func(opts *Options) error

Option helps to configure the Options

func WithIndexers

func WithIndexers(indexers ...Indexer) Option

WithIndexers is an option that configures indexers. it can be called multiple times

type Options

type Options struct {
	Indexers []Indexer
}

Options is a set of message queue options.

func (*Options) Apply

func (opts *Options) Apply(options ...Option) error

Apply applies the given options to this DiscoveryOpts

Jump to

Keyboard shortcuts

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