pool: some request refactoring.
This commit is contained in:
parent
d338f62078
commit
c605638daf
@ -77,8 +77,6 @@ function Mempool(options) {
|
|||||||
|
|
||||||
this.network = this.chain.network;
|
this.network = this.chain.network;
|
||||||
this.logger = options.logger || this.chain.logger;
|
this.logger = options.logger || this.chain.logger;
|
||||||
this.loaded = false;
|
|
||||||
|
|
||||||
this.locker = new Locker(true);
|
this.locker = new Locker(true);
|
||||||
|
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
|
|||||||
@ -79,8 +79,8 @@ function Peer(pool) {
|
|||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
this.options = pool.options;
|
this.options = this.pool.options;
|
||||||
this.logger = pool.logger;
|
this.logger = this.pool.logger;
|
||||||
this.chain = this.pool.chain;
|
this.chain = this.pool.chain;
|
||||||
this.mempool = this.pool.mempool;
|
this.mempool = this.pool.mempool;
|
||||||
this.network = this.chain.network;
|
this.network = this.chain.network;
|
||||||
@ -1303,7 +1303,7 @@ Peer.prototype.blockType = function blockType() {
|
|||||||
if (this.options.spv)
|
if (this.options.spv)
|
||||||
return invTypes.FILTERED_BLOCK;
|
return invTypes.FILTERED_BLOCK;
|
||||||
|
|
||||||
if (this.outbound) {
|
if (this.outbound && this.chain.synced) {
|
||||||
if (this.options.compact && this.compactMode !== -1) {
|
if (this.options.compact && this.compactMode !== -1) {
|
||||||
if (!this.options.witness || this.compactWitness)
|
if (!this.options.witness || this.compactWitness)
|
||||||
return invTypes.CMPCT_BLOCK;
|
return invTypes.CMPCT_BLOCK;
|
||||||
|
|||||||
@ -1696,7 +1696,7 @@ Pool.prototype.hasBlock = co(function* hasBlock(hash) {
|
|||||||
* Queue a `getdata` request to be sent. Checks existence
|
* Queue a `getdata` request to be sent. Checks existence
|
||||||
* in the mempool before requesting.
|
* in the mempool before requesting.
|
||||||
* @param {Peer} peer
|
* @param {Peer} peer
|
||||||
* @param {Hash} hash - TX hash.
|
* @param {Hash[]} hashes
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1727,6 +1727,12 @@ Pool.prototype.getTX = function getTX(peer, hashes) {
|
|||||||
items.push(hash);
|
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);
|
peer.getTX(items);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user