peer address and port.

This commit is contained in:
Christopher Jeffrey 2015-12-22 03:17:49 -08:00
parent 68c16b214a
commit a6e3024e9b

View File

@ -11,6 +11,7 @@ var bcoin = require('../bcoin');
var utils = bcoin.utils;
var assert = utils.assert;
var constants = bcoin.protocol.constants;
var network = bcoin.protocol.network;
// Browserify, I'm looking at you
try {
@ -41,6 +42,8 @@ function Peer(pool, createSocket, options) {
this.destroyed = false;
this.ack = false;
this.ts = this.options.ts || 0;
this.address = '0.0.0.0';
this.port = network.port;
if (this.options.backoff) {
setTimeout(function() {
@ -79,15 +82,13 @@ function Peer(pool, createSocket, options) {
inherits(Peer, EventEmitter);
Peer.prototype.__defineGetter__('address', function() {
return this.socket && (this.socket.remoteAddress || '0.0.0.0');
});
Peer.prototype._init = function init() {
var self = this;
this.socket.once('connect', function() {
self.ts = Date.now() / 1000 | 0;
self.address = self.socket.remoteAddress;
self.port = self.socket.remotePort;
});
this.socket.once('error', function(err) {
@ -115,8 +116,6 @@ Peer.prototype._init = function init() {
self.pool.emit('debug',
'Sent version (%s): height=%s',
self.address, this.pool.chain.getStartHeight());
// self.pool.emit('debug', 'version (%s): sending locator hashes', ip);
// self.loadBlocks(self.chain.locatorHashes(), 0);
});
}