smarter interval calculation

This commit is contained in:
Michał Adamski 2020-12-08 12:04:49 +01:00
parent ae9f83a3ce
commit 6c907e2840

View file

@ -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),