pool: remove old functions.
This commit is contained in:
parent
8447790a84
commit
a99725f8ff
@ -454,8 +454,11 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
|
|||||||
blockPeer = peer;
|
blockPeer = peer;
|
||||||
|
|
||||||
// if (this.options.multiplePeers) {
|
// if (this.options.multiplePeers) {
|
||||||
// if (this.peers.block.length)
|
// if (this.peers.block.length) {
|
||||||
// blockPeer = this.peers.block[i % this.peers.block.length];
|
// blockPeer = this.peers.block[i % (this.peers.block.length + 1)];
|
||||||
|
// if (!blockPeer)
|
||||||
|
// blockPeer = this.peers.load;
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (last && block.prevBlock !== last.hash('hex'))
|
if (last && block.prevBlock !== last.hash('hex'))
|
||||||
@ -465,7 +468,7 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!this.chain.has(block))
|
if (!this.chain.has(block))
|
||||||
this._request(this.block.type, block.hash('hex'), blockPeer);
|
this._request(blockPeer, this.block.type, block.hash('hex'));
|
||||||
|
|
||||||
last = block;
|
last = block;
|
||||||
}
|
}
|
||||||
@ -480,14 +483,8 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
|
|||||||
if (last && headers.length === 2000)
|
if (last && headers.length === 2000)
|
||||||
peer.loadHeaders(this.chain.locatorHashes(last), null);
|
peer.loadHeaders(this.chain.locatorHashes(last), null);
|
||||||
|
|
||||||
// Push our getdata packet
|
|
||||||
this._scheduleRequests();
|
|
||||||
|
|
||||||
// Reset interval to avoid calling getheaders unnecessarily
|
// Reset interval to avoid calling getheaders unnecessarily
|
||||||
this._startInterval();
|
this._startInterval();
|
||||||
|
|
||||||
// Reset timeout to avoid killing the loader
|
|
||||||
// this._startTimer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._handleBlocks = function _handleBlocks(hashes, peer) {
|
Pool.prototype._handleBlocks = function _handleBlocks(hashes, peer) {
|
||||||
@ -535,14 +532,11 @@ Pool.prototype._handleBlocks = function _handleBlocks(hashes, peer) {
|
|||||||
// a failsafe because we _need_ to request
|
// a failsafe because we _need_ to request
|
||||||
// the hashContinue no matter what.
|
// the hashContinue no matter what.
|
||||||
if (!this.chain.has(hash) || i === hashes.length - 1) {
|
if (!this.chain.has(hash) || i === hashes.length - 1) {
|
||||||
this._request(this.block.type, hash, peer);
|
this._request(peer, this.block.type, hash);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push our getdata packet
|
|
||||||
this._scheduleRequests();
|
|
||||||
|
|
||||||
// Reset interval to avoid calling getblocks unnecessarily
|
// Reset interval to avoid calling getblocks unnecessarily
|
||||||
this._startInterval();
|
this._startInterval();
|
||||||
|
|
||||||
@ -563,12 +557,9 @@ Pool.prototype._handleInv = function _handleInv(hashes, peer) {
|
|||||||
if (this.options.headers)
|
if (this.options.headers)
|
||||||
this.peers.load.loadHeaders(this.chain.locatorHashes(), hash);
|
this.peers.load.loadHeaders(this.chain.locatorHashes(), hash);
|
||||||
else
|
else
|
||||||
this._request(this.block.type, hash, peer);
|
this._request(peer, this.block.type, hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.options.headers)
|
|
||||||
this._scheduleRequests();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._handleBlock = function _handleBlock(block, peer) {
|
Pool.prototype._handleBlock = function _handleBlock(block, peer) {
|
||||||
@ -786,9 +777,8 @@ Pool.prototype._createPeer = function _createPeer(priority) {
|
|||||||
txs.forEach(function(hash) {
|
txs.forEach(function(hash) {
|
||||||
hash = utils.toHex(hash);
|
hash = utils.toHex(hash);
|
||||||
if (self._addTX(hash, 0))
|
if (self._addTX(hash, 0))
|
||||||
self._request('tx', hash, peer);
|
self._request(peer, 'tx', hash);
|
||||||
});
|
});
|
||||||
self._scheduleRequests();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
peer.on('version', function(version) {
|
peer.on('version', function(version) {
|
||||||
@ -857,8 +847,6 @@ Pool.prototype._addPeer = function _addPeer() {
|
|||||||
entry.e.emit('reject', payload, peer);
|
entry.e.emit('reject', payload, peer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
self._scheduleRequests();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
peer.on('merkleblock', function(block) {
|
peer.on('merkleblock', function(block) {
|
||||||
@ -1255,7 +1243,7 @@ Pool.prototype.search = function search(id, range, e) {
|
|||||||
return e;
|
return e;
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._request = function _request(type, hash, peer, options, cb) {
|
Pool.prototype._request = function _request(peer, type, hash, options, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var item;
|
var item;
|
||||||
|
|
||||||
@ -1369,21 +1357,13 @@ Pool.prototype._response = function _response(hash) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._scheduleRequests = function _scheduleRequests() {
|
|
||||||
};
|
|
||||||
|
|
||||||
Pool.prototype._doRequests = function _doRequests() {
|
|
||||||
};
|
|
||||||
|
|
||||||
Pool.prototype.getBlock = function getBlock(hash, cb) {
|
Pool.prototype.getBlock = function getBlock(hash, cb) {
|
||||||
if (!this.peers.load)
|
if (!this.peers.load)
|
||||||
return setTimeout(this.getBlock.bind(this, hash, cb), 1000);
|
return setTimeout(this.getBlock.bind(this, hash, cb), 1000);
|
||||||
|
|
||||||
this._request('block', hash, this.peers.load, { force: true }, function(block) {
|
this._request(this.peers.load, 'block', hash, { force: true }, function(block) {
|
||||||
cb(null, block);
|
cb(null, block);
|
||||||
});
|
});
|
||||||
|
|
||||||
this._scheduleRequests();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.sendBlock = function sendBlock(block) {
|
Pool.prototype.sendBlock = function sendBlock(block) {
|
||||||
@ -1417,7 +1397,7 @@ Pool.prototype.getTX = function getTX(hash, range, cb) {
|
|||||||
// Add request without queueing it to get notification at the time of load
|
// Add request without queueing it to get notification at the time of load
|
||||||
tx = null;
|
tx = null;
|
||||||
finished = false;
|
finished = false;
|
||||||
req = this._request('tx', hash, this.peers.load, { noQueue: true }, function(t) {
|
req = this._request(this.peers.load, 'tx', hash, { noQueue: true }, function(t) {
|
||||||
finished = true;
|
finished = true;
|
||||||
tx = t;
|
tx = t;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user