Documentation ¶
Overview ¶
Atomic
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodedSSVMessage ¶
type DecodedSSVMessage struct { *types.SSVMessage // Body is the decoded Data. Body interface{} // *SignedMessage | *SignedPartialSignatureMessage }
DecodedSSVMessage is a bundle of SSVMessage and it's decoding.
func DecodeSSVMessage ¶
func DecodeSSVMessage(m *types.SSVMessage) (*DecodedSSVMessage, error)
DecodeSSVMessage decodes an SSVMessage and returns a DecodedSSVMessage.
type Filter ¶
type Filter func(*DecodedSSVMessage) bool
Filter is a function that returns true if the given message should be included.
func FilterRole ¶
func FilterRole(role types.BeaconRole) Filter
FilterRole returns a Filter which returns true for messages whose BeaconRole matches the given role.
type MessagePrioritizer ¶
type MessagePrioritizer interface { // Prior returns true if message A should be prioritized over B. Prior(a, b *DecodedSSVMessage) bool }
MessagePrioritizer is an interface for prioritizing messages.
func NewMessagePrioritizer ¶
func NewMessagePrioritizer(state *State) MessagePrioritizer
NewMessagePrioritizer returns a standard implementation for MessagePrioritizer which prioritizes messages according to the given State.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue implements Queue, it manages a lock-free linked list of DecodedSSVMessage. Implemented using atomic CAS (CompareAndSwap) operations to handle multiple goroutines that add/pop messages.
func (*PriorityQueue) IsEmpty ¶
func (q *PriorityQueue) IsEmpty() bool
func (*PriorityQueue) Pop ¶
func (q *PriorityQueue) Pop(prioritizer MessagePrioritizer) *DecodedSSVMessage
func (*PriorityQueue) Push ¶
func (q *PriorityQueue) Push(msg *DecodedSSVMessage)
func (*PriorityQueue) WaitAndPop ¶
func (q *PriorityQueue) WaitAndPop(ctx context.Context, priority MessagePrioritizer) *DecodedSSVMessage
type Queue ¶
type Queue interface { // Push inserts a message to the queue Push(*DecodedSSVMessage) // Pop removes & returns the highest priority message which matches the given filter. // Returns nil if no message is found. Pop(MessagePrioritizer) *DecodedSSVMessage // IsEmpty checks if the q is empty IsEmpty() bool // WaitAndPop waits for a message to be pushed to the queue and then returns it. WaitAndPop(context.Context, MessagePrioritizer) *DecodedSSVMessage }
Queue objective is to receive messages and pop the right msg by to specify priority.