github.com/aergoio/aergo@v1.3.1/p2p/list/blacklist.go (about)

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  package list
     7  
     8  import (
     9  	"time"
    10  )
    11  
    12  // BanStatus keep kickout logs and decide how long the ban duration is
    13  type BanStatus interface {
    14  	// ID is ip address or peer id
    15  	ID() string
    16  
    17  	// BanUntil show when this ban items is expired.
    18  	BanUntil() time.Time
    19  	Banned(refTime time.Time) bool
    20  	Events() []BanEvent
    21  	PruneOldEvents(pruneTime time.Time) int
    22  }
    23  
    24  type BanEvent interface {
    25  	When() time.Time
    26  	Why() string
    27  }
    28  
    29  // BanThreshold is number of events to ban address or peerid
    30  const BanThreshold = 5
    31  
    32  var BanDurations = []time.Duration{
    33  	0,
    34  	0,
    35  	time.Minute,
    36  	time.Minute*3,
    37  	time.Minute*10,
    38  	time.Hour,
    39  	time.Hour*24,
    40  	time.Hour*24*30,
    41  	time.Hour*24*3650,
    42  }
    43  const BanValidDuration = time.Minute * 30
    44  const BanReleaseDuration = time.Hour * 24 * 730