mq

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageQueue

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

A MessageQueue is used to sort incoming messages by their height and round, where messages with lower heights/rounds are found at the beginning of the queue. Every sender, identified by their pid, has their own dedicated queue with its own dedicated maximum capacity. This limits how far in the future the MessageQueue will buffer messages, to prevent running out of memory. However, this also means that explicit resynchronisation is needed, because not all messages that are received are guaranteed to be kept. MessageQueues do not handle de-duplication, and are not safe for concurrent use.

func New

func New(opts Options) MessageQueue

New returns an empty MessageQueue.

func (*MessageQueue) Consume

func (mq *MessageQueue) Consume(h process.Height, propose func(process.Propose), prevote func(process.Prevote), precommit func(process.Precommit)) (n int)

Consume Propose, Prevote, and Precommit messages from the MessageQueue that have heights up to (and including) the given height. The appropriate callback will be called for every message that is consumed. All consumed messages will be dropped from the MessageQueue.

func (*MessageQueue) DropMessagesBelowHeight added in v0.4.7

func (mq *MessageQueue) DropMessagesBelowHeight(h process.Height)

DropMessagesBelowHeight removes all messages from the internal message queues that have height less than the given height.

func (*MessageQueue) InsertPrecommit

func (mq *MessageQueue) InsertPrecommit(precommit process.Precommit)

InsertPrecommit message into the MessageQueue. This method assumes that the sender has already been authenticated and filtered.

func (*MessageQueue) InsertPrevote

func (mq *MessageQueue) InsertPrevote(prevote process.Prevote)

InsertPrevote message into the MessageQueue. This method assumes that the sender has already been authenticated and filtered.

func (*MessageQueue) InsertPropose

func (mq *MessageQueue) InsertPropose(propose process.Propose)

InsertPropose message into the MessageQueue. This method assumes that the sender has already been authenticated and filtered.

type Options

type Options struct {
	Logger      *zap.Logger
	MaxCapacity int
}

Options define the Message Queue options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options as used by the Message Queue

func (Options) WithLogger added in v0.4.1

func (opts Options) WithLogger(logger *zap.Logger) Options

WithLogger updates the logger used in the Message Queue

func (Options) WithMaxCapacity added in v0.4.1

func (opts Options) WithMaxCapacity(capacity int) Options

WithMaxCapacity updates the maximum capacity of the Message Queue

Jump to

Keyboard shortcuts

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