mempool locker hasPending.

This commit is contained in:
Christopher Jeffrey 2016-05-09 00:56:44 -07:00
parent 5c61760fef
commit 4700990bcd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 7 additions and 3 deletions

View File

@ -71,7 +71,7 @@ function Mempool(options) {
this.loaded = false;
this.locker = new bcoin.locker(this, this.addTX, 20 << 20);
this.locker = new bcoin.locker(this, this.addTX, 100 << 20);
this.writeLock = new bcoin.locker(this);
this.db = null;
@ -510,8 +510,12 @@ Mempool.prototype.hasTX = function hasTX(hash, callback) {
* @param {Function} callback - Returns [Error, Boolean].
*/
Mempool.prototype.hasAny = function hasAny(hash, callback) {
Mempool.prototype.has = function has(hash, callback) {
var self = this;
if (this.locker.hasPending(hash))
return utils.asyncify(callback)(null, true);
return this.hasTX(hash, function(err, exists) {
if (err)
return callback(err);

View File

@ -1642,7 +1642,7 @@ Pool.prototype.getData = function getData(peer, type, hash, options, callback) {
if (type === this.tx.type) {
if (!this.mempool)
return utils.asyncify(done)(null, false);
return this.mempool.hasAny(hash, done);
return this.mempool.has(hash, done);
}
return this.chain.has(hash, done);