Documentation ¶
Index ¶
Constants ¶
const ( // Halflife defines the time (in seconds) by which the transient part // of the ban score decays to one half of it's original value. Halflife = 60 // Lifetime defines the maximum age of the transient part of the ban // score to be considered a non-zero score (in seconds). Lifetime = 1800 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DynamicBanScore ¶
type DynamicBanScore struct {
// contains filtered or unexported fields
}
DynamicBanScore provides dynamic ban scores consisting of a persistent and a decaying component. The persistent score could be utilized to create simple additive banning policies similar to those found in other bitcoin node implementations.
The decaying score enables the creation of evasive logic which handles misbehaving peers (especially application layer DoS attacks) gracefully by disconnecting and banning peers attempting various kinds of flooding. DynamicBanScore allows these two approaches to be used in tandem.
Zero value: Values of type DynamicBanScore are immediately ready for use upon declaration.
func (*DynamicBanScore) Increase ¶
func (s *DynamicBanScore) Increase(persistent, transient uint64) uint64
Increase increases both the persistent and decaying scores by the values passed as parameters. The resulting score is returned.
This function is safe for concurrent access.
func (*DynamicBanScore) Int ¶
func (s *DynamicBanScore) Int() uint64
Int returns the current ban score, the sum of the persistent and decaying scores.
This function is safe for concurrent access.
func (*DynamicBanScore) Reset ¶
func (s *DynamicBanScore) Reset()
Reset set both persistent and decaying scores to zero.
This function is safe for concurrent access.
func (*DynamicBanScore) ResetFrom ¶
func (s *DynamicBanScore) ResetFrom(o *DynamicBanScore)
func (*DynamicBanScore) String ¶
func (s *DynamicBanScore) String() string
String returns the ban score as a human-readable string.