Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerRateLimiter ¶
type PeerRateLimiter struct { Events *Events // contains filtered or unexported fields }
PeerRateLimiter is an object to count activity of peers and notify the subscribers in case the limit of activity is exceeded.
func NewPeerRateLimiter ¶
func NewPeerRateLimiter(interval time.Duration, baseLimit int, log *logger.Logger) (*PeerRateLimiter, error)
NewPeerRateLimiter returns a new instance of the PeerRateLimiter object.
func (*PeerRateLimiter) Close ¶
func (prl *PeerRateLimiter) Close()
Close closes PeerRateLimiter instance, it can't be used after that.
func (*PeerRateLimiter) Count ¶
func (prl *PeerRateLimiter) Count(p *peer.Peer)
Count counts a new activity of the peer towards its rate limit.
func (*PeerRateLimiter) ExtendLimit ¶
func (prl *PeerRateLimiter) ExtendLimit(p *peer.Peer, val int)
ExtendLimit extends the activity limit of the peer.
func (*PeerRateLimiter) SetBaseLimit ¶
func (prl *PeerRateLimiter) SetBaseLimit(limit int)
SetBaseLimit updates the value of the base limit.
Click to show internal directories.
Click to hide internal directories.