pool: some request refactoring.

This commit is contained in:
Christopher Jeffrey 2017-01-10 16:10:55 -08:00
parent d338f62078
commit c605638daf
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 10 additions and 6 deletions

View File

@ -77,8 +77,6 @@ function Mempool(options) {
this.network = this.chain.network;
this.logger = options.logger || this.chain.logger;
this.loaded = false;
this.locker = new Locker(true);
this.size = 0;

View File

@ -79,8 +79,8 @@ function Peer(pool) {
EventEmitter.call(this);
this.pool = pool;
this.options = pool.options;
this.logger = pool.logger;
this.options = this.pool.options;
this.logger = this.pool.logger;
this.chain = this.pool.chain;
this.mempool = this.pool.mempool;
this.network = this.chain.network;
@ -1303,7 +1303,7 @@ Peer.prototype.blockType = function blockType() {
if (this.options.spv)
return invTypes.FILTERED_BLOCK;
if (this.outbound) {
if (this.outbound && this.chain.synced) {
if (this.options.compact && this.compactMode !== -1) {
if (!this.options.witness || this.compactWitness)
return invTypes.CMPCT_BLOCK;

View File

@ -1696,7 +1696,7 @@ Pool.prototype.hasBlock = co(function* hasBlock(hash) {
* Queue a `getdata` request to be sent. Checks existence
* in the mempool before requesting.
* @param {Peer} peer
* @param {Hash} hash - TX hash.
* @param {Hash[]} hashes
* @returns {Boolean}
*/
@ -1727,6 +1727,12 @@ Pool.prototype.getTX = function getTX(peer, hashes) {
items.push(hash);
}
this.logger.debug(
'Requesting %d/%d txs from peer with getdata (%s).',
items.length,
this.requestMap.size,
peer.hostname);
peer.getTX(items);
};