Documentation ¶
Index ¶
Constants ¶
const (
// DefaultDisallowListNotificationQueueCacheSize is the default size of the disallow list notification queue.
DefaultDisallowListNotificationQueueCacheSize = 100
)
const (
// DefaultGossipSubInspectorNotificationQueueCacheSize is the default cache size for the gossipsub rpc inspector notification queue.
DefaultGossipSubInspectorNotificationQueueCacheSize = 10_000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DisallowListNotificationDistributor ¶
type DisallowListNotificationDistributor struct { component.Component // contains filtered or unexported fields }
DisallowListNotificationDistributor is a component that distributes disallow list updates to registered consumers in an asynchronous, fan-out manner. It is thread-safe and can be used concurrently from multiple goroutines.
func DefaultDisallowListNotificationDistributor ¶
func DefaultDisallowListNotificationDistributor(logger zerolog.Logger, opts ...queue.HeroStoreConfigOption) *DisallowListNotificationDistributor
DefaultDisallowListNotificationDistributor creates a new disallow list notification distributor with default configuration.
func NewDisallowListConsumer ¶
func NewDisallowListConsumer(logger zerolog.Logger, store engine.MessageStore) *DisallowListNotificationDistributor
NewDisallowListConsumer creates a new disallow list notification distributor. It takes a message store as a parameter, which is used to store the events that are distributed to the consumers. The message store is used to ensure that DistributeBlockListNotification is non-blocking.
func (*DisallowListNotificationDistributor) AddConsumer ¶
func (d *DisallowListNotificationDistributor) AddConsumer(consumer p2p.DisallowListNotificationConsumer)
AddConsumer adds a consumer to the distributor. The consumer will be called the distributor distributes a new event. AddConsumer must be concurrency safe. Once a consumer is added, it must be called for all future events. There is no guarantee that the consumer will be called for events that were already received by the distributor.
func (*DisallowListNotificationDistributor) DistributeBlockListNotification ¶
func (d *DisallowListNotificationDistributor) DistributeBlockListNotification(disallowList flow.IdentifierList) error
DistributeBlockListNotification distributes the event to all the consumers. Implementation is non-blocking, it submits the event to the worker pool and returns immediately. The event will be distributed to the consumers in the order it was submitted but asynchronously. If the worker pool is full, the event will be dropped and a warning will be logged. This implementation returns no error.
type GossipSubInspectorNotificationDistributor ¶
type GossipSubInspectorNotificationDistributor struct { component.Component // contains filtered or unexported fields }
GossipSubInspectorNotificationDistributor is a component that distributes gossipsub rpc inspector notifications to registered consumers in a non-blocking manner and asynchronously. It is thread-safe and can be used concurrently from multiple goroutines. The distribution is done by a worker pool. The worker pool is configured with a queue that has a fixed size. If the queue is full, the notification is discarded. The queue size and the number of workers can be configured.
func DefaultGossipSubInspectorNotificationDistributor ¶
func DefaultGossipSubInspectorNotificationDistributor(logger zerolog.Logger, opts ...queue.HeroStoreConfigOption) *GossipSubInspectorNotificationDistributor
DefaultGossipSubInspectorNotificationDistributor returns a new GossipSubInspectorNotificationDistributor component with the default configuration.
func NewGossipSubInspectorNotificationDistributor ¶
func NewGossipSubInspectorNotificationDistributor(log zerolog.Logger, store engine.MessageStore) *GossipSubInspectorNotificationDistributor
NewGossipSubInspectorNotificationDistributor returns a new GossipSubInspectorNotificationDistributor component. It takes a message store to store the notifications in memory and process them asynchronously.
func (*GossipSubInspectorNotificationDistributor) AddConsumer ¶
func (g *GossipSubInspectorNotificationDistributor) AddConsumer(consumer p2p.GossipSubInvalidControlMessageNotificationConsumer)
AddConsumer adds a consumer to the distributor. The consumer will be called when distributor distributes a new event. AddConsumer must be concurrency safe. Once a consumer is added, it must be called for all future events. There is no guarantee that the consumer will be called for events that were already received by the distributor.
func (*GossipSubInspectorNotificationDistributor) DistributeInvalidControlMessageNotification ¶
func (g *GossipSubInspectorNotificationDistributor) DistributeInvalidControlMessageNotification(notification *p2p.InvalidControlMessageNotification) error
DistributeInvalidControlMessageNotification distributes the gossipsub rpc inspector notification to all registered consumers. The distribution is done asynchronously and non-blocking. The notification is added to a queue and processed by a worker pool. DistributeEvent in this implementation does not return an error, but it logs a warning if the queue is full.