internal

package
v0.35.15-crescendo-pre... Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuplicateMessageTrackerCache added in v0.33.30

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

DuplicateMessageTrackerCache is a cache used to store the current count of duplicate messages detected from a peer. This count is utilized to calculate a penalty for duplicate messages, which is then applied to the peer's application-specific score. The duplicate message tracker decays over time to prevent perpetual penalization of a peer.

func NewDuplicateMessageTrackerCache added in v0.33.30

func NewDuplicateMessageTrackerCache(sizeLimit uint32, decay, skipDecayThreshold float64, logger zerolog.Logger, collector module.HeroCacheMetrics) *DuplicateMessageTrackerCache

NewDuplicateMessageTrackerCache returns a new HeroCache-based duplicate message counter cache. Args:

sizeLimit: the maximum number of entries that can be stored in the cache.
decay: the record decay.
logger: the logger to be used by the cache.
collector: the metrics collector to be used by the cache.

Returns:

  • *DuplicateMessageTrackerCache: the newly created cache with a HeroCache-based backend.

func (*DuplicateMessageTrackerCache) DuplicateMessageReceived added in v0.33.30

func (d *DuplicateMessageTrackerCache) DuplicateMessageReceived(peerID peer.ID) (float64, error)

DuplicateMessageReceived applies an adjustment that increments the number of duplicate messages received by a peer. Returns number of duplicate messages received after the adjustment. The record is initialized before the adjustment func is applied that will increment the counter value.

  • exception only in cases of internal data inconsistency or bugs. No errors are expected.

func (*DuplicateMessageTrackerCache) GetWithInit added in v0.33.30

func (d *DuplicateMessageTrackerCache) GetWithInit(peerID peer.ID) (float64, bool, error)

GetWithInit returns the current number of duplicate messages received from a peer. The record is initialized before the count is returned. Before the counter value is returned it is decayed using the configured decay function. Returns the record and true if the record exists, nil and false otherwise. Args: - peerID: peerID of the remote peer. Returns: - The duplicate messages counter value after the decay and true if the record exists, 0 and false otherwise. No errors are expected during normal operation, all errors returned are considered irrecoverable.

type RPCSentTracker

type RPCSentTracker struct {
	component.Component
	// contains filtered or unexported fields
}

RPCSentTracker tracks RPC messages and the size of the last largest iHave rpc control message sent.

func NewRPCSentTracker

func NewRPCSentTracker(config *RPCSentTrackerConfig) *RPCSentTracker

NewRPCSentTracker returns a new *NewRPCSentTracker.

func (*RPCSentTracker) LastHighestIHaveRPCSize

func (t *RPCSentTracker) LastHighestIHaveRPCSize() int64

LastHighestIHaveRPCSize returns the last highest size of iHaves sent in a rpc. Returns: - int64: the last highest size.

func (*RPCSentTracker) Track

func (t *RPCSentTracker) Track(rpc *pubsub.RPC) error

Track submits the control message to the worker queue for async tracking. Args: - *pubsub.RPC: the rpc sent. All errors returned from this function can be considered benign.

func (*RPCSentTracker) WasIHaveRPCSent

func (t *RPCSentTracker) WasIHaveRPCSent(messageID string) bool

WasIHaveRPCSent checks if an iHave control message with the provided message ID was sent. Args: - messageID: the message ID of the iHave RPC. Returns: - bool: true if the iHave rpc with the provided message ID was sent.

type RPCSentTrackerConfig

type RPCSentTrackerConfig struct {
	Logger zerolog.Logger
	//RPCSentCacheSize size of the *rpcSentCache cache.
	RPCSentCacheSize uint32
	// RPCSentCacheCollector metrics collector for the *rpcSentCache cache.
	RPCSentCacheCollector module.HeroCacheMetrics
	// WorkerQueueCacheCollector metrics factory for the worker pool.
	WorkerQueueCacheCollector module.HeroCacheMetrics
	// WorkerQueueCacheSize the worker pool herostore cache size.
	WorkerQueueCacheSize uint32
	// NumOfWorkers number of workers in the worker pool.
	NumOfWorkers int
	// LastHighestIhavesSentResetInterval the refresh interval to reset the lastHighestIHaveRPCSize.
	LastHighestIhavesSentResetInterval time.Duration
}

RPCSentTrackerConfig configuration for the RPCSentTracker.

Jump to

Keyboard shortcuts

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