minor refactor.
This commit is contained in:
parent
28274cdba4
commit
48d7b95d61
@ -80,8 +80,8 @@ function Pool(options) {
|
||||
this.synced = false;
|
||||
|
||||
this.load = {
|
||||
timeout: options.loadTimeout || 30000,
|
||||
interval: options.loadInterval || 5000
|
||||
timeout: options.loadTimeout || 40000,
|
||||
interval: options.loadInterval || 20000
|
||||
};
|
||||
|
||||
this.requestTimeout = options.requestTimeout || 600000;
|
||||
@ -628,7 +628,7 @@ Pool.prototype._handleInv = function _handleInv(hashes, peer) {
|
||||
var i, hash;
|
||||
|
||||
// Ignore for now if we're still syncing
|
||||
if (!this.chain.isFull())
|
||||
if (!this.synced)
|
||||
return;
|
||||
|
||||
for (i = 0; i < hashes.length; i++) {
|
||||
@ -706,10 +706,6 @@ Pool.prototype._handleBlock = function _handleBlock(block, peer, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
Pool.prototype.isFull = function isFull() {
|
||||
return this.chain.isFull();
|
||||
};
|
||||
|
||||
Pool.prototype._load = function _load() {
|
||||
var self = this;
|
||||
var next;
|
||||
@ -793,7 +789,7 @@ Pool.prototype._createPeer = function _createPeer(options) {
|
||||
self.emit('txs', txs, peer);
|
||||
|
||||
if (!self.options.spv) {
|
||||
if (!self.chain.isFull())
|
||||
if (!self.synced)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -818,18 +814,20 @@ Pool.prototype._createPeer = function _createPeer(options) {
|
||||
|
||||
Pool.prototype._handleTX = function _handleTX(tx, peer, callback) {
|
||||
var self = this;
|
||||
var requested, added;
|
||||
var requested, updated;
|
||||
|
||||
callback = utils.asyncify(callback);
|
||||
|
||||
requested = this.fulfill(tx);
|
||||
added = this.markTX(tx, 1);
|
||||
updated = this.markTX(tx, 1);
|
||||
|
||||
function addMempool(tx, peer, callback) {
|
||||
if (!self.mempool)
|
||||
return callback();
|
||||
|
||||
if (tx.ts !== 0)
|
||||
return callback();
|
||||
|
||||
self.mempool.addTX(tx, peer, callback);
|
||||
}
|
||||
|
||||
@ -841,7 +839,7 @@ Pool.prototype._handleTX = function _handleTX(tx, peer, callback) {
|
||||
if (err && self.synced)
|
||||
utils.debug('Mempool error: %s', err.message);
|
||||
|
||||
if (added || tx.block)
|
||||
if (updated || tx.block)
|
||||
self.emit('tx', tx, peer);
|
||||
|
||||
if (self.options.spv && tx.block)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user