mirror of
https://github.com/SinTan1729/privtracker.git
synced 2024-12-26 23:38:37 -06:00
smarter interval calculation
This commit is contained in:
parent
ae9f83a3ce
commit
6c907e2840
1 changed files with 7 additions and 1 deletions
8
main.go
8
main.go
|
@ -58,8 +58,14 @@ func announce(c *gin.Context) {
|
|||
PutPeer(c.Param("room"), req.InfoHash, req.IP, req.Port, req.IsSeeding())
|
||||
}
|
||||
peersv4, peersv6, numSeeders, numLeechers := GetPeers(c.Param("room"), req.InfoHash, req.Numwant, req.IsSeeding())
|
||||
interval := 120
|
||||
if numSeeders == 0 {
|
||||
interval /= 2
|
||||
} else if numLeechers == 0 {
|
||||
interval *= 2
|
||||
}
|
||||
resp := AnnounceResponse{
|
||||
Interval: 120,
|
||||
Interval: interval,
|
||||
Complete: numSeeders,
|
||||
Incomplete: numLeechers,
|
||||
Peers: string(peersv4),
|
||||
|
|
Loading…
Reference in a new issue