diff --git a/lib/http/rpc.js b/lib/http/rpc.js index 4a8dd17b..3974dfd3 100644 --- a/lib/http/rpc.js +++ b/lib/http/rpc.js @@ -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 diff --git a/lib/net/peer.js b/lib/net/peer.js index 63a3b430..bfe64fe3 100644 --- a/lib/net/peer.js +++ b/lib/net/peer.js @@ -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.