add orphan events to mempool.

This commit is contained in:
Christopher Jeffrey 2016-05-23 03:24:25 -07:00
parent ed08f36e07
commit 7cf1f8802f
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 15 additions and 0 deletions

View File

@ -804,6 +804,7 @@ Mempool.prototype.addUnchecked = function addUnchecked(entry, callback, force) {
bcoin.debug('Could not resolve orphan %s: %s.',
tx.rhash,
err.message);
self.emit('bad orphan', tx, entry);
return next();
}
self.emit('error', err);
@ -1102,6 +1103,7 @@ Mempool.prototype.storeOrphan = function storeOrphan(tx) {
if (tx.getSize() > 5000) {
bcoin.debug('Ignoring large orphan: %s', tx.rhash);
this.emit('bad orphan', tx);
return;
}
@ -1129,6 +1131,8 @@ Mempool.prototype.storeOrphan = function storeOrphan(tx) {
bcoin.debug('Added orphan %s to mempool.', tx.rhash);
this.emit('add orphan', tx);
this.limitOrphans();
};
@ -1294,6 +1298,8 @@ Mempool.prototype.removeOrphan = function removeOrphan(tx) {
delete this.orphans[hash];
this.emit('remove orphan', tx);
this.totalOrphans--;
};

View File

@ -270,6 +270,15 @@ Pool.prototype._init = function _init() {
var self = this;
var i;
if (this.mempool) {
this.mempool.on('add orphan', function(tx) {
self.rejects.add(tx.hash());
});
this.mempool.on('bad orphan', function(tx) {
self.rejects.add(tx.hash());
});
}
this.chain.on('block', function(block, entry, peer) {
// Emit merkle txs after the fact
if (self.options.spv) {