обновление сидов
This commit is contained in:
parent
df12e2f109
commit
2f17037a27
11
index.js
11
index.js
@ -302,9 +302,6 @@ io.on('connection', function(socket)
|
|||||||
if(hash.length != 40)
|
if(hash.length != 40)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(typeof callback != 'function')
|
|
||||||
return;
|
|
||||||
|
|
||||||
updateTorrentTrackers(hash);
|
updateTorrentTrackers(hash);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -360,6 +357,13 @@ setInterval(() => {
|
|||||||
|
|
||||||
const updateTorrentTrackers = (hash) => {
|
const updateTorrentTrackers = (hash) => {
|
||||||
let maxSeeders = 0, maxLeechers = 0, maxCompleted = 0;
|
let maxSeeders = 0, maxLeechers = 0, maxCompleted = 0;
|
||||||
|
pushDatabaseBalance();
|
||||||
|
listenerMysql.query('UPDATE torrents SET trackersChecked = ? WHERE hash = ?', [new Date(), hash], function(err, result) {
|
||||||
|
popDatabaseBalance();
|
||||||
|
if(!result) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
udpTrackers.forEach((tracker) => {
|
udpTrackers.forEach((tracker) => {
|
||||||
getPeersStatisticUDP(tracker.host, tracker.port, hash, ({seeders, completed, leechers}) => {
|
getPeersStatisticUDP(tracker.host, tracker.port, hash, ({seeders, completed, leechers}) => {
|
||||||
if(seeders == 0 && completed == 0 && leechers == 0)
|
if(seeders == 0 && completed == 0 && leechers == 0)
|
||||||
@ -406,6 +410,7 @@ const updateTorrentTrackers = (hash) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
client.on('complete', function (metadata, infohash, rinfo) {
|
client.on('complete', function (metadata, infohash, rinfo) {
|
||||||
|
@ -144,8 +144,28 @@ export default class TorrentPage extends Page {
|
|||||||
this.torrent = data
|
this.torrent = data
|
||||||
this.setTitle('Download ' + this.torrent.name);
|
this.setTitle('Download ' + this.torrent.name);
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
|
||||||
|
// Получаем более новую статистику пира
|
||||||
|
if((new Date).getTime() - this.torrent.trackersChecked > 10 * 60 * 1000) {
|
||||||
|
window.torrentSocket.emit('checkTrackers', this.torrent.hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
this.trackerUpdate = (info) => {
|
||||||
|
if(this.props.hash != info.hash)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!this.torrent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Object.assign(this.torrent, info);
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
window.torrentSocket.on('trackerTorrentUpdate', this.trackerUpdate);
|
||||||
|
}
|
||||||
|
componentWillUnmount() {
|
||||||
|
if(this.trackerUpdate)
|
||||||
|
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user