handle mempool.
This commit is contained in:
parent
ee09a6d2d0
commit
c5fc69ee93
@ -1148,15 +1148,27 @@ Peer.prototype._handleMempool = function _handleMempool() {
|
|||||||
var items = [];
|
var items = [];
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
if (!this.mempool)
|
var unlock = this.locker.lock(_handleMempool, []);
|
||||||
|
if (!unlock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
function done(err) {
|
||||||
|
if (err) {
|
||||||
|
self.emit('error', err);
|
||||||
|
return unlock();
|
||||||
|
}
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.mempool)
|
||||||
|
return done();
|
||||||
|
|
||||||
if (this.pool.options.selfish)
|
if (this.pool.options.selfish)
|
||||||
return;
|
return done();
|
||||||
|
|
||||||
this.mempool.getSnapshot(function(err, hashes) {
|
this.mempool.getSnapshot(function(err, hashes) {
|
||||||
if (err)
|
if (err)
|
||||||
return self.emit('error', err);
|
return done(err);
|
||||||
|
|
||||||
for (i = 0; i < hashes.length; i++)
|
for (i = 0; i < hashes.length; i++)
|
||||||
items.push({ type: constants.inv.TX, hash: hashes[i] });
|
items.push({ type: constants.inv.TX, hash: hashes[i] });
|
||||||
@ -1164,6 +1176,7 @@ Peer.prototype._handleMempool = function _handleMempool() {
|
|||||||
bcoin.debug('Sending mempool snapshot (%s).', self.hostname);
|
bcoin.debug('Sending mempool snapshot (%s).', self.hostname);
|
||||||
|
|
||||||
self.sendInv(items);
|
self.sendInv(items);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user