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