mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-10 18:48:11 -07:00
config: make reaping configurable
This allows for configurable reaping rates and changes the default to what many public trackers use in the wild.
This commit is contained in:
+2
-9
@@ -49,8 +49,8 @@ func New(cfg *config.Config) (*Tracker, error) {
|
||||
|
||||
go tkr.purgeInactivePeers(
|
||||
cfg.PurgeInactiveTorrents,
|
||||
cfg.Announce.Duration*2,
|
||||
cfg.Announce.Duration,
|
||||
time.Duration(float64(cfg.MinAnnounce.Duration)*cfg.ReapRatio),
|
||||
cfg.ReapInterval.Duration,
|
||||
)
|
||||
|
||||
if cfg.ClientWhitelistEnabled {
|
||||
@@ -86,13 +86,6 @@ type Writer interface {
|
||||
|
||||
// purgeInactivePeers periodically walks the torrent database and removes
|
||||
// peers that haven't announced recently.
|
||||
//
|
||||
// The default threshold is 2x the announce interval, which gives delayed
|
||||
// peers a chance to stay alive, while ensuring the majority of responses
|
||||
// contain active peers.
|
||||
//
|
||||
// The default interval is equal to the announce interval, since this is a
|
||||
// relatively expensive operation.
|
||||
func (tkr *Tracker) purgeInactivePeers(purgeEmptyTorrents bool, threshold, interval time.Duration) {
|
||||
for _ = range time.NewTicker(interval).C {
|
||||
before := time.Now().Add(-threshold)
|
||||
|
||||
Reference in New Issue
Block a user