Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
RateLimiter generic rate limiter
func NewRateLimiter ¶
func NewRateLimiter(limit rate.Limit, burst int, lockoutDuration time.Duration, opts ...p2p.RateLimiterOpt) *RateLimiter
NewRateLimiter returns a new RateLimiter.
func (*RateLimiter) Allow ¶
func (r *RateLimiter) Allow(peerID peer.ID, _ int) bool
Allow checks the cached limiter for the peer and returns limiterMap.Allow(). If a limiter is not cached for a peer one is created. This func can be overridden and the message size parameter can be used with AllowN.
func (*RateLimiter) GetLimiter ¶
func (r *RateLimiter) GetLimiter(peerID peer.ID) *rate.Limiter
GetLimiter returns limiter for the peerID, if a limiter does not exist one is created and stored.
func (*RateLimiter) IsRateLimited ¶
func (r *RateLimiter) IsRateLimited(peerID peer.ID) bool
IsRateLimited returns true is a peer is currently rate limited.
func (*RateLimiter) UpdateLastRateLimit ¶
func (r *RateLimiter) UpdateLastRateLimit(peerID peer.ID, lastRateLimit time.Time)
UpdateLastRateLimit updates the last time a peer was rate limited in the limiter map.
Click to show internal directories.
Click to hide internal directories.