pool: misc refactor.

This commit is contained in:
Christopher Jeffrey 2016-12-16 13:52:33 -08:00
parent 761b6d6636
commit 463ebd9bd3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 90 additions and 90 deletions

View File

@ -1151,77 +1151,77 @@ Peer.prototype.__onPacket = co(function* onPacket(packet) {
switch (packet.type) { switch (packet.type) {
case packetTypes.VERSION: case packetTypes.VERSION:
return yield this._handleVersion(packet); return yield this.handleVersion(packet);
case packetTypes.VERACK: case packetTypes.VERACK:
return yield this._handleVerack(packet); return yield this.handleVerack(packet);
case packetTypes.PING: case packetTypes.PING:
return yield this._handlePing(packet); return yield this.handlePing(packet);
case packetTypes.PONG: case packetTypes.PONG:
return yield this._handlePong(packet); return yield this.handlePong(packet);
case packetTypes.ALERT: case packetTypes.ALERT:
return this._handleAlert(packet); return this.handleAlert(packet);
case packetTypes.GETADDR: case packetTypes.GETADDR:
return yield this._handleGetAddr(packet); return yield this.handleGetAddr(packet);
case packetTypes.ADDR: case packetTypes.ADDR:
return yield this._handleAddr(packet); return yield this.handleAddr(packet);
case packetTypes.INV: case packetTypes.INV:
return yield this._handleInv(packet); return yield this.handleInv(packet);
case packetTypes.GETDATA: case packetTypes.GETDATA:
return yield this._handleGetData(packet); return yield this.handleGetData(packet);
case packetTypes.NOTFOUND: case packetTypes.NOTFOUND:
return yield this._handleNotFound(packet); return yield this.handleNotFound(packet);
case packetTypes.GETBLOCKS: case packetTypes.GETBLOCKS:
return yield this._handleGetBlocks(packet); return yield this.handleGetBlocks(packet);
case packetTypes.GETHEADERS: case packetTypes.GETHEADERS:
return yield this._handleGetHeaders(packet); return yield this.handleGetHeaders(packet);
case packetTypes.HEADERS: case packetTypes.HEADERS:
return yield this._handleHeaders(packet); return yield this.handleHeaders(packet);
case packetTypes.SENDHEADERS: case packetTypes.SENDHEADERS:
return yield this._handleSendHeaders(packet); return yield this.handleSendHeaders(packet);
case packetTypes.BLOCK: case packetTypes.BLOCK:
return yield this._handleBlock(packet); return yield this.handleBlock(packet);
case packetTypes.TX: case packetTypes.TX:
return yield this._handleTX(packet); return yield this.handleTX(packet);
case packetTypes.REJECT: case packetTypes.REJECT:
return yield this._handleReject(packet); return yield this.handleReject(packet);
case packetTypes.MEMPOOL: case packetTypes.MEMPOOL:
return yield this._handleMempool(packet); return yield this.handleMempool(packet);
case packetTypes.FILTERLOAD: case packetTypes.FILTERLOAD:
return yield this._handleFilterLoad(packet); return yield this.handleFilterLoad(packet);
case packetTypes.FILTERADD: case packetTypes.FILTERADD:
return yield this._handleFilterAdd(packet); return yield this.handleFilterAdd(packet);
case packetTypes.FILTERCLEAR: case packetTypes.FILTERCLEAR:
return yield this._handleFilterClear(packet); return yield this.handleFilterClear(packet);
case packetTypes.MERKLEBLOCK: case packetTypes.MERKLEBLOCK:
return yield this._handleMerkleBlock(packet); return yield this.handleMerkleBlock(packet);
case packetTypes.GETUTXOS: case packetTypes.GETUTXOS:
return yield this._handleGetUTXOs(packet); return yield this.handleGetUTXOs(packet);
case packetTypes.UTXOS: case packetTypes.UTXOS:
return yield this._handleUTXOs(packet); return yield this.handleUTXOs(packet);
case packetTypes.HAVEWITNESS: case packetTypes.HAVEWITNESS:
return yield this._handleHaveWitness(packet); return yield this.handleHaveWitness(packet);
case packetTypes.FEEFILTER: case packetTypes.FEEFILTER:
return yield this._handleFeeFilter(packet); return yield this.handleFeeFilter(packet);
case packetTypes.SENDCMPCT: case packetTypes.SENDCMPCT:
return yield this._handleSendCmpct(packet); return yield this.handleSendCmpct(packet);
case packetTypes.CMPCTBLOCK: case packetTypes.CMPCTBLOCK:
return yield this._handleCmpctBlock(packet); return yield this.handleCmpctBlock(packet);
case packetTypes.GETBLOCKTXN: case packetTypes.GETBLOCKTXN:
return yield this._handleGetBlockTxn(packet); return yield this.handleGetBlockTxn(packet);
case packetTypes.BLOCKTXN: case packetTypes.BLOCKTXN:
return yield this._handleBlockTxn(packet); return yield this.handleBlockTxn(packet);
case packetTypes.ENCINIT: case packetTypes.ENCINIT:
return yield this._handleEncinit(packet); return yield this.handleEncinit(packet);
case packetTypes.ENCACK: case packetTypes.ENCACK:
return yield this._handleEncack(packet); return yield this.handleEncack(packet);
case packetTypes.AUTHCHALLENGE: case packetTypes.AUTHCHALLENGE:
return yield this._handleAuthChallenge(packet); return yield this.handleAuthChallenge(packet);
case packetTypes.AUTHREPLY: case packetTypes.AUTHREPLY:
return yield this._handleAuthReply(packet); return yield this.handleAuthReply(packet);
case packetTypes.AUTHPROPOSE: case packetTypes.AUTHPROPOSE:
return yield this._handleAuthPropose(packet); return yield this.handleAuthPropose(packet);
case packetTypes.UNKNOWN: case packetTypes.UNKNOWN:
return yield this._handleUnknown(packet); return yield this.handleUnknown(packet);
default: default:
assert(false, 'Bad packet type.'); assert(false, 'Bad packet type.');
break; break;
@ -1258,7 +1258,7 @@ Peer.prototype.fire = function fire(cmd, payload) {
* @param {FilterLoadPacket} * @param {FilterLoadPacket}
*/ */
Peer.prototype._handleFilterLoad = co(function* _handleFilterLoad(packet) { Peer.prototype.handleFilterLoad = co(function* handleFilterLoad(packet) {
if (!packet.isWithinConstraints()) { if (!packet.isWithinConstraints()) {
this.setMisbehavior(100); this.setMisbehavior(100);
return; return;
@ -1274,7 +1274,7 @@ Peer.prototype._handleFilterLoad = co(function* _handleFilterLoad(packet) {
* @param {FilterAddPacket} * @param {FilterAddPacket}
*/ */
Peer.prototype._handleFilterAdd = co(function* _handleFilterAdd(packet) { Peer.prototype.handleFilterAdd = co(function* handleFilterAdd(packet) {
var data = packet.data; var data = packet.data;
if (data.length > constants.script.MAX_PUSH) { if (data.length > constants.script.MAX_PUSH) {
@ -1294,7 +1294,7 @@ Peer.prototype._handleFilterAdd = co(function* _handleFilterAdd(packet) {
* @param {FilterClearPacket} * @param {FilterClearPacket}
*/ */
Peer.prototype._handleFilterClear = co(function* _handleFilterClear(packet) { Peer.prototype.handleFilterClear = co(function* handleFilterClear(packet) {
if (this.spvFilter) if (this.spvFilter)
this.spvFilter.reset(); this.spvFilter.reset();
@ -1307,7 +1307,7 @@ Peer.prototype._handleFilterClear = co(function* _handleFilterClear(packet) {
* @param {MerkleBlockPacket} * @param {MerkleBlockPacket}
*/ */
Peer.prototype._handleMerkleBlock = co(function* _handleMerkleBlock(packet) { Peer.prototype.handleMerkleBlock = co(function* handleMerkleBlock(packet) {
var block = packet.block; var block = packet.block;
block.verifyPartial(); block.verifyPartial();
@ -1325,7 +1325,7 @@ Peer.prototype._handleMerkleBlock = co(function* _handleMerkleBlock(packet) {
* @param {FeeFilterPacket} * @param {FeeFilterPacket}
*/ */
Peer.prototype._handleFeeFilter = co(function* _handleFeeFilter(packet) { Peer.prototype.handleFeeFilter = co(function* handleFeeFilter(packet) {
var rate = packet.rate; var rate = packet.rate;
if (!(rate >= 0 && rate <= constants.MAX_MONEY)) { if (!(rate >= 0 && rate <= constants.MAX_MONEY)) {
@ -1344,7 +1344,7 @@ Peer.prototype._handleFeeFilter = co(function* _handleFeeFilter(packet) {
* @param {UTXOsPacket} * @param {UTXOsPacket}
*/ */
Peer.prototype._handleUTXOs = co(function* _handleUTXOs(utxos) { Peer.prototype.handleUTXOs = co(function* handleUTXOs(utxos) {
this.logger.debug('Received %d utxos (%s).', this.logger.debug('Received %d utxos (%s).',
utxos.coins.length, this.hostname); utxos.coins.length, this.hostname);
this.fire('utxos', utxos); this.fire('utxos', utxos);
@ -1355,7 +1355,7 @@ Peer.prototype._handleUTXOs = co(function* _handleUTXOs(utxos) {
* @private * @private
*/ */
Peer.prototype._handleGetUTXOs = co(function* _handleGetUTXOs(packet) { Peer.prototype.handleGetUTXOs = co(function* handleGetUTXOs(packet) {
var i, utxos, prevout, hash, index, coin; var i, utxos, prevout, hash, index, coin;
if (!this.chain.synced) if (!this.chain.synced)
@ -1415,7 +1415,7 @@ Peer.prototype._handleGetUTXOs = co(function* _handleGetUTXOs(packet) {
* @param {HaveWitnessPacket} * @param {HaveWitnessPacket}
*/ */
Peer.prototype._handleHaveWitness = co(function* _handleHaveWitness(packet) { Peer.prototype.handleHaveWitness = co(function* handleHaveWitness(packet) {
this.haveWitness = true; this.haveWitness = true;
this.fire('havewitness'); this.fire('havewitness');
}); });
@ -1426,7 +1426,7 @@ Peer.prototype._handleHaveWitness = co(function* _handleHaveWitness(packet) {
* @param {GetHeadersPacket} * @param {GetHeadersPacket}
*/ */
Peer.prototype._handleGetHeaders = co(function* _handleGetHeaders(packet) { Peer.prototype.handleGetHeaders = co(function* handleGetHeaders(packet) {
var headers = []; var headers = [];
var hash, entry; var hash, entry;
@ -1474,7 +1474,7 @@ Peer.prototype._handleGetHeaders = co(function* _handleGetHeaders(packet) {
* @param {GetBlocksPacket} * @param {GetBlocksPacket}
*/ */
Peer.prototype._handleGetBlocks = co(function* _handleGetBlocks(packet) { Peer.prototype.handleGetBlocks = co(function* handleGetBlocks(packet) {
var blocks = []; var blocks = [];
var hash; var hash;
@ -1518,7 +1518,7 @@ Peer.prototype._handleGetBlocks = co(function* _handleGetBlocks(packet) {
* @param {VersionPacket} * @param {VersionPacket}
*/ */
Peer.prototype._handleVersion = co(function* _handleVersion(version) { Peer.prototype.handleVersion = co(function* handleVersion(version) {
if (this.version) if (this.version)
throw new Error('Peer sent a duplicate version.'); throw new Error('Peer sent a duplicate version.');
@ -1589,7 +1589,7 @@ Peer.prototype._handleVersion = co(function* _handleVersion(version) {
* @param {VerackPacket} * @param {VerackPacket}
*/ */
Peer.prototype._handleVerack = co(function* _handleVerack(packet) { Peer.prototype.handleVerack = co(function* handleVerack(packet) {
this.fire('verack'); this.fire('verack');
}); });
@ -1599,7 +1599,7 @@ Peer.prototype._handleVerack = co(function* _handleVerack(packet) {
* @param {MempoolPacket} * @param {MempoolPacket}
*/ */
Peer.prototype._handleMempool = co(function* _handleMempool(packet) { Peer.prototype.handleMempool = co(function* handleMempool(packet) {
var items = []; var items = [];
var i, hashes; var i, hashes;
@ -1759,7 +1759,7 @@ Peer.prototype._sendCompactBlock = function _sendCompactBlock(block, witness) {
* @param {GetDataPacket} * @param {GetDataPacket}
*/ */
Peer.prototype._handleGetData = co(function* _handleGetData(packet) { Peer.prototype.handleGetData = co(function* handleGetData(packet) {
var notFound = []; var notFound = [];
var txs = 0; var txs = 0;
var blocks = 0; var blocks = 0;
@ -1900,7 +1900,7 @@ Peer.prototype._handleGetData = co(function* _handleGetData(packet) {
* @param {NotFoundPacket} * @param {NotFoundPacket}
*/ */
Peer.prototype._handleNotFound = co(function* _handleNotFound(packet) { Peer.prototype.handleNotFound = co(function* handleNotFound(packet) {
this.fire('notfound', packet.items); this.fire('notfound', packet.items);
}); });
@ -1910,7 +1910,7 @@ Peer.prototype._handleNotFound = co(function* _handleNotFound(packet) {
* @param {AddrPacket} * @param {AddrPacket}
*/ */
Peer.prototype._handleAddr = co(function* _handleAddr(packet) { Peer.prototype.handleAddr = co(function* handleAddr(packet) {
var now = this.network.now(); var now = this.network.now();
var addrs = packet.items; var addrs = packet.items;
var i, addr; var i, addr;
@ -1940,7 +1940,7 @@ Peer.prototype._handleAddr = co(function* _handleAddr(packet) {
* @param {PingPacket} * @param {PingPacket}
*/ */
Peer.prototype._handlePing = co(function* _handlePing(packet) { Peer.prototype.handlePing = co(function* handlePing(packet) {
this.fire('ping', this.minPing); this.fire('ping', this.minPing);
if (packet.nonce) if (packet.nonce)
this.send(new packets.PongPacket(packet.nonce)); this.send(new packets.PongPacket(packet.nonce));
@ -1952,7 +1952,7 @@ Peer.prototype._handlePing = co(function* _handlePing(packet) {
* @param {PongPacket} * @param {PongPacket}
*/ */
Peer.prototype._handlePong = co(function* _handlePong(packet) { Peer.prototype.handlePong = co(function* handlePong(packet) {
var nonce = packet.nonce; var nonce = packet.nonce;
var now = util.ms(); var now = util.ms();
@ -1991,7 +1991,7 @@ Peer.prototype._handlePong = co(function* _handlePong(packet) {
* @param {GetAddrPacket} * @param {GetAddrPacket}
*/ */
Peer.prototype._handleGetAddr = co(function* _handleGetAddr(packet) { Peer.prototype.handleGetAddr = co(function* handleGetAddr(packet) {
var items = []; var items = [];
var i, addr; var i, addr;
@ -2032,7 +2032,7 @@ Peer.prototype._handleGetAddr = co(function* _handleGetAddr(packet) {
* @param {InvPacket} * @param {InvPacket}
*/ */
Peer.prototype._handleInv = co(function* _handleInv(packet) { Peer.prototype.handleInv = co(function* handleInv(packet) {
var items = packet.items; var items = packet.items;
var blocks = []; var blocks = [];
var txs = []; var txs = [];
@ -2085,7 +2085,7 @@ Peer.prototype._handleInv = co(function* _handleInv(packet) {
* @param {HeadersPacket} * @param {HeadersPacket}
*/ */
Peer.prototype._handleHeaders = co(function* _handleHeaders(packet) { Peer.prototype.handleHeaders = co(function* handleHeaders(packet) {
var headers = packet.items; var headers = packet.items;
this.logger.debug( this.logger.debug(
@ -2106,7 +2106,7 @@ Peer.prototype._handleHeaders = co(function* _handleHeaders(packet) {
* @param {SendHeadersPacket} * @param {SendHeadersPacket}
*/ */
Peer.prototype._handleSendHeaders = co(function* _handleSendHeaders(packet) { Peer.prototype.handleSendHeaders = co(function* handleSendHeaders(packet) {
this.preferHeaders = true; this.preferHeaders = true;
this.fire('sendheaders'); this.fire('sendheaders');
}); });
@ -2117,7 +2117,7 @@ Peer.prototype._handleSendHeaders = co(function* _handleSendHeaders(packet) {
* @param {BlockPacket} * @param {BlockPacket}
*/ */
Peer.prototype._handleBlock = co(function* _handleBlock(packet) { Peer.prototype.handleBlock = co(function* handleBlock(packet) {
this.fire('block', packet.block); this.fire('block', packet.block);
}); });
@ -2127,7 +2127,7 @@ Peer.prototype._handleBlock = co(function* _handleBlock(packet) {
* @param {TXPacket} * @param {TXPacket}
*/ */
Peer.prototype._handleTX = co(function* _handleTX(packet) { Peer.prototype.handleTX = co(function* handleTX(packet) {
var tx = packet.tx; var tx = packet.tx;
if (this.lastBlock) { if (this.lastBlock) {
@ -2148,7 +2148,7 @@ Peer.prototype._handleTX = co(function* _handleTX(packet) {
* @param {RejectPacket} * @param {RejectPacket}
*/ */
Peer.prototype._handleReject = co(function* _handleReject(details) { Peer.prototype.handleReject = co(function* handleReject(details) {
var hash, entry; var hash, entry;
this.fire('reject', details); this.fire('reject', details);
@ -2171,7 +2171,7 @@ Peer.prototype._handleReject = co(function* _handleReject(details) {
* @param {AlertPacket} * @param {AlertPacket}
*/ */
Peer.prototype._handleAlert = co(function* _handleAlert(alert) { Peer.prototype.handleAlert = co(function* handleAlert(alert) {
this.invFilter.add(alert.hash()); this.invFilter.add(alert.hash());
this.fire('alert', alert); this.fire('alert', alert);
}); });
@ -2182,7 +2182,7 @@ Peer.prototype._handleAlert = co(function* _handleAlert(alert) {
* @param {EncinitPacket} * @param {EncinitPacket}
*/ */
Peer.prototype._handleEncinit = co(function* _handleEncinit(packet) { Peer.prototype.handleEncinit = co(function* handleEncinit(packet) {
if (!this.bip151) if (!this.bip151)
return; return;
@ -2199,7 +2199,7 @@ Peer.prototype._handleEncinit = co(function* _handleEncinit(packet) {
* @param {EncackPacket} * @param {EncackPacket}
*/ */
Peer.prototype._handleEncack = co(function* _handleEncack(packet) { Peer.prototype.handleEncack = co(function* handleEncack(packet) {
if (!this.bip151) if (!this.bip151)
return; return;
@ -2214,7 +2214,7 @@ Peer.prototype._handleEncack = co(function* _handleEncack(packet) {
* @param {AuthChallengePacket} * @param {AuthChallengePacket}
*/ */
Peer.prototype._handleAuthChallenge = co(function* _handleAuthChallenge(packet) { Peer.prototype.handleAuthChallenge = co(function* handleAuthChallenge(packet) {
var sig; var sig;
if (!this.bip150) if (!this.bip150)
@ -2233,7 +2233,7 @@ Peer.prototype._handleAuthChallenge = co(function* _handleAuthChallenge(packet)
* @param {AuthReplyPacket} * @param {AuthReplyPacket}
*/ */
Peer.prototype._handleAuthReply = co(function* _handleAuthReply(packet) { Peer.prototype.handleAuthReply = co(function* handleAuthReply(packet) {
var hash; var hash;
if (!this.bip150) if (!this.bip150)
@ -2253,7 +2253,7 @@ Peer.prototype._handleAuthReply = co(function* _handleAuthReply(packet) {
* @param {AuthProposePacket} * @param {AuthProposePacket}
*/ */
Peer.prototype._handleAuthPropose = co(function* _handleAuthPropose(packet) { Peer.prototype.handleAuthPropose = co(function* handleAuthPropose(packet) {
var hash; var hash;
if (!this.bip150) if (!this.bip150)
@ -2272,7 +2272,7 @@ Peer.prototype._handleAuthPropose = co(function* _handleAuthPropose(packet) {
* @param {UnknownPacket} * @param {UnknownPacket}
*/ */
Peer.prototype._handleUnknown = co(function* _handleUnknown(packet) { Peer.prototype.handleUnknown = co(function* handleUnknown(packet) {
this.logger.warning('Unknown packet: %s.', packet.cmd); this.logger.warning('Unknown packet: %s.', packet.cmd);
this.fire('unknown', packet); this.fire('unknown', packet);
}); });
@ -2283,7 +2283,7 @@ Peer.prototype._handleUnknown = co(function* _handleUnknown(packet) {
* @param {SendCmpctPacket} * @param {SendCmpctPacket}
*/ */
Peer.prototype._handleSendCmpct = co(function* _handleSendCmpct(packet) { Peer.prototype.handleSendCmpct = co(function* handleSendCmpct(packet) {
var max = this.options.witness ? 2 : 1; var max = this.options.witness ? 2 : 1;
if (packet.version > max) { if (packet.version > max) {
@ -2319,7 +2319,7 @@ Peer.prototype._handleSendCmpct = co(function* _handleSendCmpct(packet) {
* @param {CmpctBlockPacket} * @param {CmpctBlockPacket}
*/ */
Peer.prototype._handleCmpctBlock = co(function* _handleCmpctBlock(packet) { Peer.prototype.handleCmpctBlock = co(function* handleCmpctBlock(packet) {
var block = packet.block; var block = packet.block;
var hash = block.hash('hex'); var hash = block.hash('hex');
var ret = new VerifyResult(); var ret = new VerifyResult();
@ -2385,7 +2385,7 @@ Peer.prototype._handleCmpctBlock = co(function* _handleCmpctBlock(packet) {
* @param {GetBlockTxnPacket} * @param {GetBlockTxnPacket}
*/ */
Peer.prototype._handleGetBlockTxn = co(function* _handleGetBlockTxn(packet) { Peer.prototype.handleGetBlockTxn = co(function* handleGetBlockTxn(packet) {
var req = packet.request; var req = packet.request;
var res, item, block, height; var res, item, block, height;
@ -2432,7 +2432,7 @@ Peer.prototype._handleGetBlockTxn = co(function* _handleGetBlockTxn(packet) {
* @param {BlockTxnPacket} * @param {BlockTxnPacket}
*/ */
Peer.prototype._handleBlockTxn = co(function* _handleBlockTxn(packet) { Peer.prototype.handleBlockTxn = co(function* handleBlockTxn(packet) {
var res = packet.response; var res = packet.response;
var block = this.compactBlocks[res.hash]; var block = this.compactBlocks[res.hash];

View File

@ -440,7 +440,7 @@ Pool.prototype.listen = function listen() {
} }
this.server.on('connection', function(socket) { this.server.on('connection', function(socket) {
self._handleLeech(socket); self.handleLeech(socket);
}); });
this.server.on('listening', function() { this.server.on('listening', function() {
@ -481,7 +481,7 @@ Pool.prototype.unlisten = function unlisten() {
* @param {net.Socket} socket * @param {net.Socket} socket
*/ */
Pool.prototype._handleLeech = function _handleLeech(socket) { Pool.prototype.handleLeech = function handleLeech(socket) {
var addr; var addr;
if (!socket.remoteAddress) { if (!socket.remoteAddress) {
@ -762,10 +762,10 @@ Pool.prototype.stopSync = co(function* stopSync() {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype._handleHeaders = co(function* _handleHeaders(headers, peer) { Pool.prototype.handleHeaders = co(function* handleHeaders(headers, peer) {
var unlock = yield this.locker.lock(); var unlock = yield this.locker.lock();
try { try {
return yield this.__handleHeaders(headers, peer); return yield this._handleHeaders(headers, peer);
} finally { } finally {
unlock(); unlock();
} }
@ -780,7 +780,7 @@ Pool.prototype._handleHeaders = co(function* _handleHeaders(headers, peer) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) { Pool.prototype._handleHeaders = co(function* handleHeaders(headers, peer) {
var i, ret, header, hash, last; var i, ret, header, hash, last;
if (!this.options.headers) if (!this.options.headers)
@ -844,7 +844,7 @@ Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype._handleBlocks = co(function* _handleBlocks(hashes, peer) { Pool.prototype.handleBlocks = co(function* handleBlocks(hashes, peer) {
var i, hash; var i, hash;
assert(!this.options.headers); assert(!this.options.headers);
@ -910,10 +910,10 @@ Pool.prototype._handleBlocks = co(function* _handleBlocks(hashes, peer) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype._handleInv = co(function* _handleInv(hashes, peer) { Pool.prototype.handleInv = co(function* handleInv(hashes, peer) {
var unlock = yield this.locker.lock(); var unlock = yield this.locker.lock();
try { try {
return yield this.__handleInv(hashes, peer); return yield this._handleInv(hashes, peer);
} finally { } finally {
unlock(); unlock();
} }
@ -927,7 +927,7 @@ Pool.prototype._handleInv = co(function* _handleInv(hashes, peer) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) { Pool.prototype._handleInv = co(function* handleInv(hashes, peer) {
var i, hash; var i, hash;
// Ignore for now if we're still syncing // Ignore for now if we're still syncing
@ -938,7 +938,7 @@ Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
return; return;
if (!this.options.headers) { if (!this.options.headers) {
yield this._handleBlocks(hashes, peer); yield this.handleBlocks(hashes, peer);
return; return;
} }
@ -958,7 +958,7 @@ Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype._handleBlock = co(function* _handleBlock(block, peer) { Pool.prototype.handleBlock = co(function* handleBlock(block, peer) {
var requested = this.fulfill(block); var requested = this.fulfill(block);
// Someone is sending us blocks without // Someone is sending us blocks without
@ -1156,7 +1156,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
// If the peer sent us a block that was added // If the peer sent us a block that was added
// to the chain (not orphans), reset the timeout. // to the chain (not orphans), reset the timeout.
try { try {
yield self._handleBlock(block, peer); yield self.handleBlock(block, peer);
} catch (e) { } catch (e) {
self.emit('error', e); self.emit('error', e);
return; return;
@ -1178,7 +1178,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
// If the peer sent us a block that was added // If the peer sent us a block that was added
// to the chain (not orphans), reset the timeout. // to the chain (not orphans), reset the timeout.
try { try {
yield self._handleBlock(block, peer); yield self.handleBlock(block, peer);
} catch (e) { } catch (e) {
self.emit('error', e); self.emit('error', e);
return; return;
@ -1229,7 +1229,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
peer.on('tx', co(function* (tx) { peer.on('tx', co(function* (tx) {
try { try {
yield self._handleTX(tx, peer); yield self.handleTX(tx, peer);
} catch (e) { } catch (e) {
self.emit('error', e); self.emit('error', e);
} }
@ -1302,7 +1302,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
return; return;
try { try {
yield self._handleHeaders(headers, peer); yield self.handleHeaders(headers, peer);
} catch (e) { } catch (e) {
self.emit('error', e); self.emit('error', e);
} }
@ -1313,7 +1313,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
return; return;
try { try {
yield self._handleInv(hashes, peer); yield self.handleInv(hashes, peer);
} catch (e) { } catch (e) {
self.emit('error', e); self.emit('error', e);
} }
@ -1327,7 +1327,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
* @param {Peer} peer * @param {Peer} peer
*/ */
Pool.prototype._handleAlert = function _handleAlert(alert, peer) { Pool.prototype.handleAlert = function handleAlert(alert, peer) {
var now = this.network.now(); var now = this.network.now();
if (!alert.verify(this.network.alertKey)) { if (!alert.verify(this.network.alertKey)) {
@ -1401,7 +1401,7 @@ Pool.prototype.hasReject = function hasReject(hash) {
* @returns {Promise} * @returns {Promise}
*/ */
Pool.prototype._handleTX = co(function* _handleTX(tx, peer) { Pool.prototype.handleTX = co(function* handleTX(tx, peer) {
var requested = this.fulfill(tx); var requested = this.fulfill(tx);
var i, missing; var i, missing;