pool: remove old functions.

This commit is contained in:
Christopher Jeffrey 2016-01-30 02:31:15 -08:00
parent 8447790a84
commit a99725f8ff

View File

@ -454,8 +454,11 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
blockPeer = peer;
// if (this.options.multiplePeers) {
// if (this.peers.block.length)
// blockPeer = this.peers.block[i % this.peers.block.length];
// if (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'))
@ -465,7 +468,7 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
break;
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;
}
@ -480,14 +483,8 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer) {
if (last && headers.length === 2000)
peer.loadHeaders(this.chain.locatorHashes(last), null);
// Push our getdata packet
this._scheduleRequests();
// Reset interval to avoid calling getheaders unnecessarily
this._startInterval();
// Reset timeout to avoid killing the loader
// this._startTimer();
};
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
// the hashContinue no matter what.
if (!this.chain.has(hash) || i === hashes.length - 1) {
this._request(this.block.type, hash, peer);
this._request(peer, this.block.type, hash);
continue;
}
}
// Push our getdata packet
this._scheduleRequests();
// Reset interval to avoid calling getblocks unnecessarily
this._startInterval();
@ -563,12 +557,9 @@ Pool.prototype._handleInv = function _handleInv(hashes, peer) {
if (this.options.headers)
this.peers.load.loadHeaders(this.chain.locatorHashes(), hash);
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) {
@ -786,9 +777,8 @@ Pool.prototype._createPeer = function _createPeer(priority) {
txs.forEach(function(hash) {
hash = utils.toHex(hash);
if (self._addTX(hash, 0))
self._request('tx', hash, peer);
self._request(peer, 'tx', hash);
});
self._scheduleRequests();
});
peer.on('version', function(version) {
@ -857,8 +847,6 @@ Pool.prototype._addPeer = function _addPeer() {
entry.e.emit('reject', payload, peer);
});
});
self._scheduleRequests();
});
peer.on('merkleblock', function(block) {
@ -1255,7 +1243,7 @@ Pool.prototype.search = function search(id, range, 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 item;
@ -1369,21 +1357,13 @@ Pool.prototype._response = function _response(hash) {
return true;
};
Pool.prototype._scheduleRequests = function _scheduleRequests() {
};
Pool.prototype._doRequests = function _doRequests() {
};
Pool.prototype.getBlock = function getBlock(hash, cb) {
if (!this.peers.load)
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);
});
this._scheduleRequests();
};
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
tx = null;
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;
tx = t;
});