@@ -7,7 +7,6 @@ var compact2string = require('compact2string')
77var debug = require ( 'debug' ) ( 'bittorrent-tracker' )
88var dgram = require ( 'dgram' )
99var EventEmitter = require ( 'events' ) . EventEmitter
10- var extend = require ( 'extend.js' )
1110var get = require ( 'simple-get' )
1211var hat = require ( 'hat' )
1312var inherits = require ( 'inherits' )
@@ -218,10 +217,10 @@ Tracker.prototype.destroy = function () {
218217 */
219218Tracker . prototype . _announce = function ( opts ) {
220219 var self = this
221- opts = extend ( {
222- uploaded : 0 , // default , user should provide real value
223- downloaded : 0 // default, user should provide real value
224- } , opts )
220+
221+ // defaults , user should provide real values
222+ if ( ! opts . uploaded ) opts . uploaded = 0
223+ if ( ! opts . downloaded ) opts . downloaded = 0
225224
226225 if ( self . client . torrentLength != null && opts . left == null ) {
227226 opts . left = self . client . torrentLength - ( opts . downloaded || 0 )
@@ -262,17 +261,13 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) {
262261 var self = this
263262
264263 if ( opts . _scrape ) {
265- opts = extend ( {
266- info_hash : self . client . _infoHash . toString ( 'binary' )
267- } , opts )
264+ if ( ! opts . info_hash ) opts . info_hash = self . client . _infoHash . toString ( 'binary' )
268265 } else {
269- opts = extend ( {
270- info_hash : self . client . _infoHash . toString ( 'binary' ) ,
271- peer_id : self . client . _peerId . toString ( 'binary' ) ,
272- port : self . client . _port ,
273- compact : 1 ,
274- numwant : self . client . _numWant
275- } , opts )
266+ if ( ! opts . info_hash ) opts . info_hash = self . client . _infoHash . toString ( 'binary' )
267+ if ( ! opts . peer_id ) opts . peer_id = self . client . _peerId . toString ( 'binary' )
268+ if ( ! opts . port ) opts . port = self . client . _port
269+ if ( ! opts . compact ) opts . compact = 1
270+ if ( ! opts . numwant ) opts . numwant = self . client . _numWant
276271
277272 if ( self . _trackerId ) {
278273 opts . trackerid = self . _trackerId
0 commit comments