commit
2697d37753
@ -322,6 +322,7 @@ Peer.prototype._handleVersion = function handleVersion(payload) {
|
|||||||
// ACK
|
// ACK
|
||||||
this._write(this.framer.verack());
|
this._write(this.framer.verack());
|
||||||
this.version = payload;
|
this.version = payload;
|
||||||
|
this.emit('version', payload);
|
||||||
};
|
};
|
||||||
|
|
||||||
Peer.prototype._handleGetData = function handleGetData(items) {
|
Peer.prototype._handleGetData = function handleGetData(items) {
|
||||||
|
|||||||
@ -340,6 +340,14 @@ Pool.prototype._addPeer = function _addPeer(backoff) {
|
|||||||
peer.on('txs', function(txs) {
|
peer.on('txs', function(txs) {
|
||||||
self.emit('txs', txs, peer);
|
self.emit('txs', txs, peer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
peer.on('version', function(version) {
|
||||||
|
self.emit('version', version, peer);
|
||||||
|
});
|
||||||
|
|
||||||
|
utils.nextTick(function() {
|
||||||
|
self.emit('peer', peer);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype._removePeer = function _removePeer(peer) {
|
Pool.prototype._removePeer = function _removePeer(peer) {
|
||||||
|
|||||||
@ -372,9 +372,18 @@ utils.isEqual = function isEqual(a, b) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(indutny): use process.nextTick in node.js
|
|
||||||
utils.nextTick = function nextTick(fn) {
|
utils.nextTick = function nextTick(fn) {
|
||||||
setTimeout(fn, 0);
|
if (typeof setImmediate === 'function') {
|
||||||
|
setImmediate(fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof process === 'object' && process.nextTick) {
|
||||||
|
process.nextTick(fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(fn, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
function RequestCache() {
|
function RequestCache() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user