pool: misc refactor.
This commit is contained in:
parent
761b6d6636
commit
463ebd9bd3
144
lib/net/peer.js
144
lib/net/peer.js
@ -1151,77 +1151,77 @@ Peer.prototype.__onPacket = co(function* onPacket(packet) {
|
||||
|
||||
switch (packet.type) {
|
||||
case packetTypes.VERSION:
|
||||
return yield this._handleVersion(packet);
|
||||
return yield this.handleVersion(packet);
|
||||
case packetTypes.VERACK:
|
||||
return yield this._handleVerack(packet);
|
||||
return yield this.handleVerack(packet);
|
||||
case packetTypes.PING:
|
||||
return yield this._handlePing(packet);
|
||||
return yield this.handlePing(packet);
|
||||
case packetTypes.PONG:
|
||||
return yield this._handlePong(packet);
|
||||
return yield this.handlePong(packet);
|
||||
case packetTypes.ALERT:
|
||||
return this._handleAlert(packet);
|
||||
return this.handleAlert(packet);
|
||||
case packetTypes.GETADDR:
|
||||
return yield this._handleGetAddr(packet);
|
||||
return yield this.handleGetAddr(packet);
|
||||
case packetTypes.ADDR:
|
||||
return yield this._handleAddr(packet);
|
||||
return yield this.handleAddr(packet);
|
||||
case packetTypes.INV:
|
||||
return yield this._handleInv(packet);
|
||||
return yield this.handleInv(packet);
|
||||
case packetTypes.GETDATA:
|
||||
return yield this._handleGetData(packet);
|
||||
return yield this.handleGetData(packet);
|
||||
case packetTypes.NOTFOUND:
|
||||
return yield this._handleNotFound(packet);
|
||||
return yield this.handleNotFound(packet);
|
||||
case packetTypes.GETBLOCKS:
|
||||
return yield this._handleGetBlocks(packet);
|
||||
return yield this.handleGetBlocks(packet);
|
||||
case packetTypes.GETHEADERS:
|
||||
return yield this._handleGetHeaders(packet);
|
||||
return yield this.handleGetHeaders(packet);
|
||||
case packetTypes.HEADERS:
|
||||
return yield this._handleHeaders(packet);
|
||||
return yield this.handleHeaders(packet);
|
||||
case packetTypes.SENDHEADERS:
|
||||
return yield this._handleSendHeaders(packet);
|
||||
return yield this.handleSendHeaders(packet);
|
||||
case packetTypes.BLOCK:
|
||||
return yield this._handleBlock(packet);
|
||||
return yield this.handleBlock(packet);
|
||||
case packetTypes.TX:
|
||||
return yield this._handleTX(packet);
|
||||
return yield this.handleTX(packet);
|
||||
case packetTypes.REJECT:
|
||||
return yield this._handleReject(packet);
|
||||
return yield this.handleReject(packet);
|
||||
case packetTypes.MEMPOOL:
|
||||
return yield this._handleMempool(packet);
|
||||
return yield this.handleMempool(packet);
|
||||
case packetTypes.FILTERLOAD:
|
||||
return yield this._handleFilterLoad(packet);
|
||||
return yield this.handleFilterLoad(packet);
|
||||
case packetTypes.FILTERADD:
|
||||
return yield this._handleFilterAdd(packet);
|
||||
return yield this.handleFilterAdd(packet);
|
||||
case packetTypes.FILTERCLEAR:
|
||||
return yield this._handleFilterClear(packet);
|
||||
return yield this.handleFilterClear(packet);
|
||||
case packetTypes.MERKLEBLOCK:
|
||||
return yield this._handleMerkleBlock(packet);
|
||||
return yield this.handleMerkleBlock(packet);
|
||||
case packetTypes.GETUTXOS:
|
||||
return yield this._handleGetUTXOs(packet);
|
||||
return yield this.handleGetUTXOs(packet);
|
||||
case packetTypes.UTXOS:
|
||||
return yield this._handleUTXOs(packet);
|
||||
return yield this.handleUTXOs(packet);
|
||||
case packetTypes.HAVEWITNESS:
|
||||
return yield this._handleHaveWitness(packet);
|
||||
return yield this.handleHaveWitness(packet);
|
||||
case packetTypes.FEEFILTER:
|
||||
return yield this._handleFeeFilter(packet);
|
||||
return yield this.handleFeeFilter(packet);
|
||||
case packetTypes.SENDCMPCT:
|
||||
return yield this._handleSendCmpct(packet);
|
||||
return yield this.handleSendCmpct(packet);
|
||||
case packetTypes.CMPCTBLOCK:
|
||||
return yield this._handleCmpctBlock(packet);
|
||||
return yield this.handleCmpctBlock(packet);
|
||||
case packetTypes.GETBLOCKTXN:
|
||||
return yield this._handleGetBlockTxn(packet);
|
||||
return yield this.handleGetBlockTxn(packet);
|
||||
case packetTypes.BLOCKTXN:
|
||||
return yield this._handleBlockTxn(packet);
|
||||
return yield this.handleBlockTxn(packet);
|
||||
case packetTypes.ENCINIT:
|
||||
return yield this._handleEncinit(packet);
|
||||
return yield this.handleEncinit(packet);
|
||||
case packetTypes.ENCACK:
|
||||
return yield this._handleEncack(packet);
|
||||
return yield this.handleEncack(packet);
|
||||
case packetTypes.AUTHCHALLENGE:
|
||||
return yield this._handleAuthChallenge(packet);
|
||||
return yield this.handleAuthChallenge(packet);
|
||||
case packetTypes.AUTHREPLY:
|
||||
return yield this._handleAuthReply(packet);
|
||||
return yield this.handleAuthReply(packet);
|
||||
case packetTypes.AUTHPROPOSE:
|
||||
return yield this._handleAuthPropose(packet);
|
||||
return yield this.handleAuthPropose(packet);
|
||||
case packetTypes.UNKNOWN:
|
||||
return yield this._handleUnknown(packet);
|
||||
return yield this.handleUnknown(packet);
|
||||
default:
|
||||
assert(false, 'Bad packet type.');
|
||||
break;
|
||||
@ -1258,7 +1258,7 @@ Peer.prototype.fire = function fire(cmd, payload) {
|
||||
* @param {FilterLoadPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleFilterLoad = co(function* _handleFilterLoad(packet) {
|
||||
Peer.prototype.handleFilterLoad = co(function* handleFilterLoad(packet) {
|
||||
if (!packet.isWithinConstraints()) {
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
@ -1274,7 +1274,7 @@ Peer.prototype._handleFilterLoad = co(function* _handleFilterLoad(packet) {
|
||||
* @param {FilterAddPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleFilterAdd = co(function* _handleFilterAdd(packet) {
|
||||
Peer.prototype.handleFilterAdd = co(function* handleFilterAdd(packet) {
|
||||
var data = packet.data;
|
||||
|
||||
if (data.length > constants.script.MAX_PUSH) {
|
||||
@ -1294,7 +1294,7 @@ Peer.prototype._handleFilterAdd = co(function* _handleFilterAdd(packet) {
|
||||
* @param {FilterClearPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleFilterClear = co(function* _handleFilterClear(packet) {
|
||||
Peer.prototype.handleFilterClear = co(function* handleFilterClear(packet) {
|
||||
if (this.spvFilter)
|
||||
this.spvFilter.reset();
|
||||
|
||||
@ -1307,7 +1307,7 @@ Peer.prototype._handleFilterClear = co(function* _handleFilterClear(packet) {
|
||||
* @param {MerkleBlockPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleMerkleBlock = co(function* _handleMerkleBlock(packet) {
|
||||
Peer.prototype.handleMerkleBlock = co(function* handleMerkleBlock(packet) {
|
||||
var block = packet.block;
|
||||
|
||||
block.verifyPartial();
|
||||
@ -1325,7 +1325,7 @@ Peer.prototype._handleMerkleBlock = co(function* _handleMerkleBlock(packet) {
|
||||
* @param {FeeFilterPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleFeeFilter = co(function* _handleFeeFilter(packet) {
|
||||
Peer.prototype.handleFeeFilter = co(function* handleFeeFilter(packet) {
|
||||
var rate = packet.rate;
|
||||
|
||||
if (!(rate >= 0 && rate <= constants.MAX_MONEY)) {
|
||||
@ -1344,7 +1344,7 @@ Peer.prototype._handleFeeFilter = co(function* _handleFeeFilter(packet) {
|
||||
* @param {UTXOsPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleUTXOs = co(function* _handleUTXOs(utxos) {
|
||||
Peer.prototype.handleUTXOs = co(function* handleUTXOs(utxos) {
|
||||
this.logger.debug('Received %d utxos (%s).',
|
||||
utxos.coins.length, this.hostname);
|
||||
this.fire('utxos', utxos);
|
||||
@ -1355,7 +1355,7 @@ Peer.prototype._handleUTXOs = co(function* _handleUTXOs(utxos) {
|
||||
* @private
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetUTXOs = co(function* _handleGetUTXOs(packet) {
|
||||
Peer.prototype.handleGetUTXOs = co(function* handleGetUTXOs(packet) {
|
||||
var i, utxos, prevout, hash, index, coin;
|
||||
|
||||
if (!this.chain.synced)
|
||||
@ -1415,7 +1415,7 @@ Peer.prototype._handleGetUTXOs = co(function* _handleGetUTXOs(packet) {
|
||||
* @param {HaveWitnessPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleHaveWitness = co(function* _handleHaveWitness(packet) {
|
||||
Peer.prototype.handleHaveWitness = co(function* handleHaveWitness(packet) {
|
||||
this.haveWitness = true;
|
||||
this.fire('havewitness');
|
||||
});
|
||||
@ -1426,7 +1426,7 @@ Peer.prototype._handleHaveWitness = co(function* _handleHaveWitness(packet) {
|
||||
* @param {GetHeadersPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetHeaders = co(function* _handleGetHeaders(packet) {
|
||||
Peer.prototype.handleGetHeaders = co(function* handleGetHeaders(packet) {
|
||||
var headers = [];
|
||||
var hash, entry;
|
||||
|
||||
@ -1474,7 +1474,7 @@ Peer.prototype._handleGetHeaders = co(function* _handleGetHeaders(packet) {
|
||||
* @param {GetBlocksPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetBlocks = co(function* _handleGetBlocks(packet) {
|
||||
Peer.prototype.handleGetBlocks = co(function* handleGetBlocks(packet) {
|
||||
var blocks = [];
|
||||
var hash;
|
||||
|
||||
@ -1518,7 +1518,7 @@ Peer.prototype._handleGetBlocks = co(function* _handleGetBlocks(packet) {
|
||||
* @param {VersionPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleVersion = co(function* _handleVersion(version) {
|
||||
Peer.prototype.handleVersion = co(function* handleVersion(version) {
|
||||
if (this.version)
|
||||
throw new Error('Peer sent a duplicate version.');
|
||||
|
||||
@ -1589,7 +1589,7 @@ Peer.prototype._handleVersion = co(function* _handleVersion(version) {
|
||||
* @param {VerackPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleVerack = co(function* _handleVerack(packet) {
|
||||
Peer.prototype.handleVerack = co(function* handleVerack(packet) {
|
||||
this.fire('verack');
|
||||
});
|
||||
|
||||
@ -1599,7 +1599,7 @@ Peer.prototype._handleVerack = co(function* _handleVerack(packet) {
|
||||
* @param {MempoolPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleMempool = co(function* _handleMempool(packet) {
|
||||
Peer.prototype.handleMempool = co(function* handleMempool(packet) {
|
||||
var items = [];
|
||||
var i, hashes;
|
||||
|
||||
@ -1759,7 +1759,7 @@ Peer.prototype._sendCompactBlock = function _sendCompactBlock(block, witness) {
|
||||
* @param {GetDataPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetData = co(function* _handleGetData(packet) {
|
||||
Peer.prototype.handleGetData = co(function* handleGetData(packet) {
|
||||
var notFound = [];
|
||||
var txs = 0;
|
||||
var blocks = 0;
|
||||
@ -1900,7 +1900,7 @@ Peer.prototype._handleGetData = co(function* _handleGetData(packet) {
|
||||
* @param {NotFoundPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleNotFound = co(function* _handleNotFound(packet) {
|
||||
Peer.prototype.handleNotFound = co(function* handleNotFound(packet) {
|
||||
this.fire('notfound', packet.items);
|
||||
});
|
||||
|
||||
@ -1910,7 +1910,7 @@ Peer.prototype._handleNotFound = co(function* _handleNotFound(packet) {
|
||||
* @param {AddrPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleAddr = co(function* _handleAddr(packet) {
|
||||
Peer.prototype.handleAddr = co(function* handleAddr(packet) {
|
||||
var now = this.network.now();
|
||||
var addrs = packet.items;
|
||||
var i, addr;
|
||||
@ -1940,7 +1940,7 @@ Peer.prototype._handleAddr = co(function* _handleAddr(packet) {
|
||||
* @param {PingPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handlePing = co(function* _handlePing(packet) {
|
||||
Peer.prototype.handlePing = co(function* handlePing(packet) {
|
||||
this.fire('ping', this.minPing);
|
||||
if (packet.nonce)
|
||||
this.send(new packets.PongPacket(packet.nonce));
|
||||
@ -1952,7 +1952,7 @@ Peer.prototype._handlePing = co(function* _handlePing(packet) {
|
||||
* @param {PongPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handlePong = co(function* _handlePong(packet) {
|
||||
Peer.prototype.handlePong = co(function* handlePong(packet) {
|
||||
var nonce = packet.nonce;
|
||||
var now = util.ms();
|
||||
|
||||
@ -1991,7 +1991,7 @@ Peer.prototype._handlePong = co(function* _handlePong(packet) {
|
||||
* @param {GetAddrPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetAddr = co(function* _handleGetAddr(packet) {
|
||||
Peer.prototype.handleGetAddr = co(function* handleGetAddr(packet) {
|
||||
var items = [];
|
||||
var i, addr;
|
||||
|
||||
@ -2032,7 +2032,7 @@ Peer.prototype._handleGetAddr = co(function* _handleGetAddr(packet) {
|
||||
* @param {InvPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleInv = co(function* _handleInv(packet) {
|
||||
Peer.prototype.handleInv = co(function* handleInv(packet) {
|
||||
var items = packet.items;
|
||||
var blocks = [];
|
||||
var txs = [];
|
||||
@ -2085,7 +2085,7 @@ Peer.prototype._handleInv = co(function* _handleInv(packet) {
|
||||
* @param {HeadersPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleHeaders = co(function* _handleHeaders(packet) {
|
||||
Peer.prototype.handleHeaders = co(function* handleHeaders(packet) {
|
||||
var headers = packet.items;
|
||||
|
||||
this.logger.debug(
|
||||
@ -2106,7 +2106,7 @@ Peer.prototype._handleHeaders = co(function* _handleHeaders(packet) {
|
||||
* @param {SendHeadersPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleSendHeaders = co(function* _handleSendHeaders(packet) {
|
||||
Peer.prototype.handleSendHeaders = co(function* handleSendHeaders(packet) {
|
||||
this.preferHeaders = true;
|
||||
this.fire('sendheaders');
|
||||
});
|
||||
@ -2117,7 +2117,7 @@ Peer.prototype._handleSendHeaders = co(function* _handleSendHeaders(packet) {
|
||||
* @param {BlockPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleBlock = co(function* _handleBlock(packet) {
|
||||
Peer.prototype.handleBlock = co(function* handleBlock(packet) {
|
||||
this.fire('block', packet.block);
|
||||
});
|
||||
|
||||
@ -2127,7 +2127,7 @@ Peer.prototype._handleBlock = co(function* _handleBlock(packet) {
|
||||
* @param {TXPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleTX = co(function* _handleTX(packet) {
|
||||
Peer.prototype.handleTX = co(function* handleTX(packet) {
|
||||
var tx = packet.tx;
|
||||
|
||||
if (this.lastBlock) {
|
||||
@ -2148,7 +2148,7 @@ Peer.prototype._handleTX = co(function* _handleTX(packet) {
|
||||
* @param {RejectPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleReject = co(function* _handleReject(details) {
|
||||
Peer.prototype.handleReject = co(function* handleReject(details) {
|
||||
var hash, entry;
|
||||
|
||||
this.fire('reject', details);
|
||||
@ -2171,7 +2171,7 @@ Peer.prototype._handleReject = co(function* _handleReject(details) {
|
||||
* @param {AlertPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleAlert = co(function* _handleAlert(alert) {
|
||||
Peer.prototype.handleAlert = co(function* handleAlert(alert) {
|
||||
this.invFilter.add(alert.hash());
|
||||
this.fire('alert', alert);
|
||||
});
|
||||
@ -2182,7 +2182,7 @@ Peer.prototype._handleAlert = co(function* _handleAlert(alert) {
|
||||
* @param {EncinitPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleEncinit = co(function* _handleEncinit(packet) {
|
||||
Peer.prototype.handleEncinit = co(function* handleEncinit(packet) {
|
||||
if (!this.bip151)
|
||||
return;
|
||||
|
||||
@ -2199,7 +2199,7 @@ Peer.prototype._handleEncinit = co(function* _handleEncinit(packet) {
|
||||
* @param {EncackPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleEncack = co(function* _handleEncack(packet) {
|
||||
Peer.prototype.handleEncack = co(function* handleEncack(packet) {
|
||||
if (!this.bip151)
|
||||
return;
|
||||
|
||||
@ -2214,7 +2214,7 @@ Peer.prototype._handleEncack = co(function* _handleEncack(packet) {
|
||||
* @param {AuthChallengePacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleAuthChallenge = co(function* _handleAuthChallenge(packet) {
|
||||
Peer.prototype.handleAuthChallenge = co(function* handleAuthChallenge(packet) {
|
||||
var sig;
|
||||
|
||||
if (!this.bip150)
|
||||
@ -2233,7 +2233,7 @@ Peer.prototype._handleAuthChallenge = co(function* _handleAuthChallenge(packet)
|
||||
* @param {AuthReplyPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleAuthReply = co(function* _handleAuthReply(packet) {
|
||||
Peer.prototype.handleAuthReply = co(function* handleAuthReply(packet) {
|
||||
var hash;
|
||||
|
||||
if (!this.bip150)
|
||||
@ -2253,7 +2253,7 @@ Peer.prototype._handleAuthReply = co(function* _handleAuthReply(packet) {
|
||||
* @param {AuthProposePacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleAuthPropose = co(function* _handleAuthPropose(packet) {
|
||||
Peer.prototype.handleAuthPropose = co(function* handleAuthPropose(packet) {
|
||||
var hash;
|
||||
|
||||
if (!this.bip150)
|
||||
@ -2272,7 +2272,7 @@ Peer.prototype._handleAuthPropose = co(function* _handleAuthPropose(packet) {
|
||||
* @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.fire('unknown', packet);
|
||||
});
|
||||
@ -2283,7 +2283,7 @@ Peer.prototype._handleUnknown = co(function* _handleUnknown(packet) {
|
||||
* @param {SendCmpctPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleSendCmpct = co(function* _handleSendCmpct(packet) {
|
||||
Peer.prototype.handleSendCmpct = co(function* handleSendCmpct(packet) {
|
||||
var max = this.options.witness ? 2 : 1;
|
||||
|
||||
if (packet.version > max) {
|
||||
@ -2319,7 +2319,7 @@ Peer.prototype._handleSendCmpct = co(function* _handleSendCmpct(packet) {
|
||||
* @param {CmpctBlockPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleCmpctBlock = co(function* _handleCmpctBlock(packet) {
|
||||
Peer.prototype.handleCmpctBlock = co(function* handleCmpctBlock(packet) {
|
||||
var block = packet.block;
|
||||
var hash = block.hash('hex');
|
||||
var ret = new VerifyResult();
|
||||
@ -2385,7 +2385,7 @@ Peer.prototype._handleCmpctBlock = co(function* _handleCmpctBlock(packet) {
|
||||
* @param {GetBlockTxnPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleGetBlockTxn = co(function* _handleGetBlockTxn(packet) {
|
||||
Peer.prototype.handleGetBlockTxn = co(function* handleGetBlockTxn(packet) {
|
||||
var req = packet.request;
|
||||
var res, item, block, height;
|
||||
|
||||
@ -2432,7 +2432,7 @@ Peer.prototype._handleGetBlockTxn = co(function* _handleGetBlockTxn(packet) {
|
||||
* @param {BlockTxnPacket}
|
||||
*/
|
||||
|
||||
Peer.prototype._handleBlockTxn = co(function* _handleBlockTxn(packet) {
|
||||
Peer.prototype.handleBlockTxn = co(function* handleBlockTxn(packet) {
|
||||
var res = packet.response;
|
||||
var block = this.compactBlocks[res.hash];
|
||||
|
||||
|
||||
@ -440,7 +440,7 @@ Pool.prototype.listen = function listen() {
|
||||
}
|
||||
|
||||
this.server.on('connection', function(socket) {
|
||||
self._handleLeech(socket);
|
||||
self.handleLeech(socket);
|
||||
});
|
||||
|
||||
this.server.on('listening', function() {
|
||||
@ -481,7 +481,7 @@ Pool.prototype.unlisten = function unlisten() {
|
||||
* @param {net.Socket} socket
|
||||
*/
|
||||
|
||||
Pool.prototype._handleLeech = function _handleLeech(socket) {
|
||||
Pool.prototype.handleLeech = function handleLeech(socket) {
|
||||
var addr;
|
||||
|
||||
if (!socket.remoteAddress) {
|
||||
@ -762,10 +762,10 @@ Pool.prototype.stopSync = co(function* stopSync() {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype._handleHeaders = co(function* _handleHeaders(headers, peer) {
|
||||
Pool.prototype.handleHeaders = co(function* handleHeaders(headers, peer) {
|
||||
var unlock = yield this.locker.lock();
|
||||
try {
|
||||
return yield this.__handleHeaders(headers, peer);
|
||||
return yield this._handleHeaders(headers, peer);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
@ -780,7 +780,7 @@ Pool.prototype._handleHeaders = co(function* _handleHeaders(headers, peer) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) {
|
||||
Pool.prototype._handleHeaders = co(function* handleHeaders(headers, peer) {
|
||||
var i, ret, header, hash, last;
|
||||
|
||||
if (!this.options.headers)
|
||||
@ -844,7 +844,7 @@ Pool.prototype.__handleHeaders = co(function* _handleHeaders(headers, peer) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype._handleBlocks = co(function* _handleBlocks(hashes, peer) {
|
||||
Pool.prototype.handleBlocks = co(function* handleBlocks(hashes, peer) {
|
||||
var i, hash;
|
||||
|
||||
assert(!this.options.headers);
|
||||
@ -910,10 +910,10 @@ Pool.prototype._handleBlocks = co(function* _handleBlocks(hashes, peer) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype._handleInv = co(function* _handleInv(hashes, peer) {
|
||||
Pool.prototype.handleInv = co(function* handleInv(hashes, peer) {
|
||||
var unlock = yield this.locker.lock();
|
||||
try {
|
||||
return yield this.__handleInv(hashes, peer);
|
||||
return yield this._handleInv(hashes, peer);
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
@ -927,7 +927,7 @@ Pool.prototype._handleInv = co(function* _handleInv(hashes, peer) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
|
||||
Pool.prototype._handleInv = co(function* handleInv(hashes, peer) {
|
||||
var i, hash;
|
||||
|
||||
// Ignore for now if we're still syncing
|
||||
@ -938,7 +938,7 @@ Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
|
||||
return;
|
||||
|
||||
if (!this.options.headers) {
|
||||
yield this._handleBlocks(hashes, peer);
|
||||
yield this.handleBlocks(hashes, peer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -958,7 +958,7 @@ Pool.prototype.__handleInv = co(function* _handleInv(hashes, peer) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype._handleBlock = co(function* _handleBlock(block, peer) {
|
||||
Pool.prototype.handleBlock = co(function* handleBlock(block, peer) {
|
||||
var requested = this.fulfill(block);
|
||||
|
||||
// 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
|
||||
// to the chain (not orphans), reset the timeout.
|
||||
try {
|
||||
yield self._handleBlock(block, peer);
|
||||
yield self.handleBlock(block, peer);
|
||||
} catch (e) {
|
||||
self.emit('error', e);
|
||||
return;
|
||||
@ -1178,7 +1178,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
|
||||
// If the peer sent us a block that was added
|
||||
// to the chain (not orphans), reset the timeout.
|
||||
try {
|
||||
yield self._handleBlock(block, peer);
|
||||
yield self.handleBlock(block, peer);
|
||||
} catch (e) {
|
||||
self.emit('error', e);
|
||||
return;
|
||||
@ -1229,7 +1229,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
|
||||
|
||||
peer.on('tx', co(function* (tx) {
|
||||
try {
|
||||
yield self._handleTX(tx, peer);
|
||||
yield self.handleTX(tx, peer);
|
||||
} catch (e) {
|
||||
self.emit('error', e);
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
|
||||
return;
|
||||
|
||||
try {
|
||||
yield self._handleHeaders(headers, peer);
|
||||
yield self.handleHeaders(headers, peer);
|
||||
} catch (e) {
|
||||
self.emit('error', e);
|
||||
}
|
||||
@ -1313,7 +1313,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
|
||||
return;
|
||||
|
||||
try {
|
||||
yield self._handleInv(hashes, peer);
|
||||
yield self.handleInv(hashes, peer);
|
||||
} catch (e) {
|
||||
self.emit('error', e);
|
||||
}
|
||||
@ -1327,7 +1327,7 @@ Pool.prototype.bindPeer = function bindPeer(peer) {
|
||||
* @param {Peer} peer
|
||||
*/
|
||||
|
||||
Pool.prototype._handleAlert = function _handleAlert(alert, peer) {
|
||||
Pool.prototype.handleAlert = function handleAlert(alert, peer) {
|
||||
var now = this.network.now();
|
||||
|
||||
if (!alert.verify(this.network.alertKey)) {
|
||||
@ -1401,7 +1401,7 @@ Pool.prototype.hasReject = function hasReject(hash) {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Pool.prototype._handleTX = co(function* _handleTX(tx, peer) {
|
||||
Pool.prototype.handleTX = co(function* handleTX(tx, peer) {
|
||||
var requested = this.fulfill(tx);
|
||||
var i, missing;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user