Help us shape the future of Go! Take the 2026 Go Developer Survey

ratelimit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ratelimit bounds how often an individual peer may make a node or router do pre-authentication work.

Index

Constants

View Source
const (
	// Rate limiting defaults for peers
	PeerRateLimit = 5
	PeerBurst     = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerRateLimiter

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

PeerRateLimiter tracks rate limits per peer using an LRU cache.

func NewPeerRateLimiter

func NewPeerRateLimiter(size int) (*PeerRateLimiter, error)

NewPeerRateLimiter creates a new PeerRateLimiter with specified cache size and the default pre-authentication peer rate limit and burst.

func NewPeerRateLimiterWithRate

func NewPeerRateLimiterWithRate(size int, limit float64, burst int) (*PeerRateLimiter, error)

NewPeerRateLimiterWithRate creates a new PeerRateLimiter with specified cache size, rate limit (requests/sec), and burst size.

func (*PeerRateLimiter) Allow

func (prl *PeerRateLimiter) Allow(peerID string) bool

Allow checks if the peer is allowed to perform an action.

Jump to

Keyboard shortcuts

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