internal

package
v0.32.11-verification-... Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: AGPL-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 RateLimiterMap

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

RateLimiterMap stores a rateLimiterMetadata for each peer in an underlying map.

func NewLimiterMap

func NewLimiterMap(ttl, cleanupInterval time.Duration) *RateLimiterMap

func (*RateLimiterMap) CleanupLoop

func (r *RateLimiterMap) CleanupLoop(ctx irrecoverable.SignalerContext)

CleanupLoop starts a loop that periodically removes stale peers. This func blocks until the signaler context is canceled, when context is canceled the limiter map is cleaned up before the cleanup loop exits.

func (*RateLimiterMap) Get

func (r *RateLimiterMap) Get(peerID peer.ID) (*rateLimiterMetadata, bool)

Get returns limiter in RateLimiterMap map

func (*RateLimiterMap) Remove

func (r *RateLimiterMap) Remove(peerID peer.ID)

Remove deletes peerID key from underlying map.

func (*RateLimiterMap) Store

func (r *RateLimiterMap) Store(peerID peer.ID, lmtr *rate.Limiter)

Store stores limiter in RateLimiterMap map

func (*RateLimiterMap) UpdateLastRateLimit

func (r *RateLimiterMap) UpdateLastRateLimit(peerID peer.ID, lastRateLimit time.Time)

UpdateLastRateLimit sets the lastRateLimit field of the rateLimiterMetadata for a peer.

Jump to

Keyboard shortcuts

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