fix(announce): fixed announce issue of download score

This commit is contained in:
OldHawk
2018-02-01 14:41:18 +08:00
parent 494f0ad63f
commit 424cbec663
2 changed files with 9 additions and 7 deletions

View File

@@ -323,16 +323,16 @@ module.exports = {
additionSize: 1024 * 1024 * 1024 * 10, //10G
perlSize: 1024 * 1024 * 1024, //1G
uploadValue: 5,
uploadValue: 2,
uploadEnable: true,
downloadValue: 2,
downloadValue: 1,
downloadEnable: true,
vipRatio: 2,
vipRatio: 1.5,
seederBasicRatio: 1,
seederCoefficient: 0.1,
lifeBasicRatio: 1,
lifeCoefficientOfDay: 0.01,
lifeCoefficientOfDay: 0.005,
enable: true
},
@@ -341,12 +341,12 @@ module.exports = {
name: 'seedTimed',
additionTime: 60 * 1000 * 5,
timedValue: 1,
vipRatio: 2,
vipRatio: 1.5,
seederBasicRatio: 1,
seederCoefficient: 0.1,
lifeBasicRatio: 1,
lifeCoefficientOfDay: 0.01,
lifeCoefficientOfDay: 0.005,
enable: true
}

View File

@@ -552,6 +552,7 @@ exports.announce = function (req, res) {
if (action.enable) {
var uploadScore = 0;
var downloadScore = 0;
if (curru > 0 && action.uploadEnable) {
var upUnitScore = 1;
if (req.torrent.torrent_size > action.additionSize) {
@@ -560,12 +561,13 @@ exports.announce = function (req, res) {
var upScore = Math.round((curru / action.perlSize) * 100) / 100;
uploadScore = upUnitScore * action.uploadValue * upScore;
}
if (currd > 0 && action.downloadEnable) {
var downUnitScore = 1;
if (req.torrent.torrent_size > action.additionSize) {
downUnitScore = Math.round(Math.sqrt(req.torrent.torrent_size / action.additionSize) * 100) / 100;
}
var downScore = Math.round((curru / action.perlSize) * 100) / 100;
var downScore = Math.round((currd / action.perlSize) * 100) / 100;
downloadScore = downUnitScore * action.downloadValue * downScore;
}