bitcoin-inventory
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -34,3 +34,3 @@ 'use strict'; | ||
_this.ttl = opts.ttl != null ? opts.ttl : 2 * 60 * 1000; | ||
var ttl = opts.ttl != null ? opts.ttl : 2 * 60 * 1000; | ||
_this.peers = peers; | ||
@@ -45,2 +45,4 @@ _this.data = new MapDeque(); | ||
_this.lastCount = 0; | ||
_this.interval = setInterval(_this._removeOld.bind(_this), ttl); | ||
if (_this.interval.unref) _this.interval.unref(); | ||
return _this; | ||
@@ -141,7 +143,2 @@ } | ||
this.lastCount = this.data.length; | ||
if (this.data.length === 0) { | ||
this.timeout = null; | ||
} else { | ||
this.timeout = setTimeout(this._removeOld.bind(this), this.ttl); | ||
} | ||
} | ||
@@ -151,5 +148,2 @@ }, { | ||
value: function _add(tx, broadcast) { | ||
if (!this.timeout) { | ||
this.timeout = setTimeout(this._removeOld.bind(this), this.ttl); | ||
} | ||
var hashBuf = tx.getHash(); | ||
@@ -183,3 +177,3 @@ var hash = getHash(hashBuf); | ||
value: function close() { | ||
clearTimeout(this.timeout); | ||
clearInterval(this.interval); | ||
// TODO: stop listening to peers | ||
@@ -186,0 +180,0 @@ } |
{ | ||
"name": "bitcoin-inventory", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Exchange transactions with peers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,3 +18,3 @@ 'use strict' | ||
super() | ||
this.ttl = opts.ttl != null ? opts.ttl : 2 * 60 * 1000 | ||
var ttl = opts.ttl != null ? opts.ttl : 2 * 60 * 1000 | ||
this.peers = peers | ||
@@ -29,2 +29,4 @@ this.data = new MapDeque() | ||
this.lastCount = 0 | ||
this.interval = setInterval(this._removeOld.bind(this), ttl) | ||
if (this.interval.unref) this.interval.unref() | ||
} | ||
@@ -71,13 +73,5 @@ | ||
this.lastCount = this.data.length | ||
if (this.data.length === 0) { | ||
this.timeout = null | ||
} else { | ||
this.timeout = setTimeout(this._removeOld.bind(this), this.ttl) | ||
} | ||
} | ||
_add (tx, broadcast) { | ||
if (!this.timeout) { | ||
this.timeout = setTimeout(this._removeOld.bind(this), this.ttl) | ||
} | ||
var hashBuf = tx.getHash() | ||
@@ -109,3 +103,3 @@ var hash = getHash(hashBuf) | ||
close () { | ||
clearTimeout(this.timeout) | ||
clearInterval(this.interval) | ||
// TODO: stop listening to peers | ||
@@ -112,0 +106,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24559
536