pool/peer: fixes. cleanup.
This commit is contained in:
parent
58f8035add
commit
be4145e163
@ -1581,17 +1581,10 @@ Peer.prototype.handlePacket = co(function* handlePacket(packet) {
|
||||
if (this.onPacket)
|
||||
yield this.onPacket(packet);
|
||||
|
||||
if (entry)
|
||||
entry.resolve(packet);
|
||||
|
||||
this.emit('packet', packet);
|
||||
|
||||
if (packet.type === packetTypes.UNKNOWN) {
|
||||
this.emit('unknown', packet);
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit(packet.cmd, packet);
|
||||
if (entry)
|
||||
entry.resolve(packet);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -161,6 +161,10 @@ Pool.prototype._init = function _init() {
|
||||
self.emit('listening', data);
|
||||
});
|
||||
|
||||
this.chain.on('block', function(block, entry) {
|
||||
self.emit('block', block, entry);
|
||||
});
|
||||
|
||||
this.chain.on('reset', function() {
|
||||
self.resetChain();
|
||||
self.forceSync();
|
||||
@ -172,6 +176,12 @@ Pool.prototype._init = function _init() {
|
||||
self.logger.info('Chain is fully synced (height=%d).', self.chain.height);
|
||||
});
|
||||
|
||||
if (this.mempool) {
|
||||
this.mempool.on('tx', function(tx) {
|
||||
self.emit('tx', tx);
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.options.selfish && !this.options.spv) {
|
||||
if (this.mempool) {
|
||||
this.mempool.on('tx', function(tx) {
|
||||
@ -1058,13 +1068,6 @@ Pool.prototype.handlePacket = co(function* handlePacket(peer, packet) {
|
||||
}
|
||||
|
||||
this.emit('packet', packet, peer);
|
||||
|
||||
if (packet.type === packetTypes.UNKNOWN) {
|
||||
this.emit('unknown', packet, peer);
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit(packet.cmd, packet, peer);
|
||||
});
|
||||
|
||||
/**
|
||||
@ -2083,8 +2086,10 @@ Pool.prototype._handleTX = co(function* handleTX(peer, packet) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.mempool)
|
||||
if (!this.mempool) {
|
||||
this.emit('tx', tx);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
missing = yield this.mempool.addTX(tx);
|
||||
@ -2104,6 +2109,8 @@ Pool.prototype._handleTX = co(function* handleTX(peer, packet) {
|
||||
|
||||
this.getTX(peer, missing);
|
||||
}
|
||||
|
||||
this.emit('tx', tx);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -135,11 +135,11 @@ SPVNode.prototype._init = function _init() {
|
||||
if (this.http)
|
||||
this.http.on('error', onError);
|
||||
|
||||
this.pool.on('tx', function(packet) {
|
||||
this.pool.on('tx', function(tx) {
|
||||
if (self.rescanJob)
|
||||
return;
|
||||
|
||||
self.emit('tx', packet.tx);
|
||||
self.emit('tx', tx);
|
||||
});
|
||||
|
||||
this.chain.on('block', function(block) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user