github.com/koko1123/flow-go-1@v0.29.6/network/p2p/unicast/ratelimit/noop_rate_limiter.go (about) 1 package ratelimit 2 3 import ( 4 "github.com/libp2p/go-libp2p/core/peer" 5 6 "github.com/koko1123/flow-go-1/network/p2p" 7 ) 8 9 type NoopRateLimiter struct{} 10 11 func (n *NoopRateLimiter) Allow(_ peer.ID, _ int) bool { 12 return true 13 } 14 15 func (n *NoopRateLimiter) IsRateLimited(_ peer.ID) bool { 16 return false 17 } 18 19 func (n *NoopRateLimiter) SetTimeNowFunc(_ p2p.GetTimeNow) {} 20 21 func (n *NoopRateLimiter) Stop() {} 22 23 func (n *NoopRateLimiter) Start() {} 24 25 func NewNoopRateLimiter() *NoopRateLimiter { 26 return &NoopRateLimiter{} 27 } 28 29 // NoopRateLimiters returns noop rate limiters. 30 func NoopRateLimiters() *RateLimiters { 31 return &RateLimiters{ 32 MessageRateLimiter: &NoopRateLimiter{}, 33 BandWidthRateLimiter: &NoopRateLimiter{}, 34 OnRateLimitedPeer: nil, 35 disabled: true, 36 } 37 }