Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement addAnounceEvent.

  • Loading branch information...
commit 7e9fb17f260b7453f050185171e2effd48cd9fd6 1 parent 790a07b
@Kami authored
Showing with 10 additions and 1 deletion.
  1. +8 −0 lib/database/memory.js
  2. +2 −1  lib/http/endpoints/announce.js
View
8 lib/database/memory.js
@@ -51,6 +51,14 @@ MemoryDatabaseBackend.prototype.getPeersByInfoHash = function(infoHash, compact,
callback(null, result);
};
+MemoryDatabaseBackend.prototype.addAnnonceEvent = function(infoHash, peerInfo, uploaded,
+ downloaded, left, callback) {
+ this._updatePeerData(infoHash, peerInfo, { 'uploaded': uploaded,
+ 'downloaded': downloaded,
+ 'left': left });
+ callback(null);
+};
+
MemoryDatabaseBackend.prototype.addStartedEvent = function(infoHash, peerInfo, callback) {
this._updatePeerData(infoHash, peerInfo, { 'left': 0, 'started_date': misc.getUnixTimestamp() });
callback(null);
View
3  lib/http/endpoints/announce.js
@@ -47,7 +47,8 @@ function announceHandler(req, res) {
async.series([
function savaDataIntoDatabase(callback) {
if (params['event'] === 'announce') {
- // Regular announce request
+ db.addAnnonceEvent(params['info_hash'], peerInfo, params['uploaded'],
+ params['downloaded'], params['left'], callback);
}
else if (params['event'] === 'started') {
db.addStartedEvent(params['info_hash'], peerInfo, callback);
Please sign in to comment.
Something went wrong with that request. Please try again.