net: implement peer ids.

This commit is contained in:
Christopher Jeffrey 2017-05-15 03:53:30 -07:00
parent 028fee9eee
commit 0b13452df1
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 9 additions and 2 deletions

View File

@ -391,7 +391,6 @@ RPC.prototype.getNetTotals = co(function* getNetTotals(args, help) {
RPC.prototype.getPeerInfo = co(function* getPeerInfo(args, help) {
var peers = [];
var id = 0;
var peer, offset;
if (help || args.length !== 0)
@ -404,7 +403,7 @@ RPC.prototype.getPeerInfo = co(function* getPeerInfo(args, help) {
offset = 0;
peers.push({
id: id++,
id: peer.id,
addr: peer.hostname(),
addrlocal: !peer.local.isNull()
? peer.local.hostname

View File

@ -79,6 +79,7 @@ function Peer(options) {
this.parser = new Parser(this.network);
this.framer = new Framer(this.network);
this.id = Peer.uid++;
this.socket = null;
this.opened = false;
this.outbound = false;
@ -148,6 +149,13 @@ function Peer(options) {
util.inherits(Peer, EventEmitter);
/**
* Peer ID counter.
* @type {Number}
*/
Peer.uid = 0;
/**
* Max output bytes buffered before
* invoking stall behavior for peer.