update example, added log statements to status check in peer manager for showing how many good peers there are
This commit is contained in:
parent
def036b79f
commit
9934b29eff
|
@ -1,4 +1,4 @@
|
|||
var PeerManager = require('../lib/PeerManager');
|
||||
var peerman = new PeerManager();
|
||||
|
||||
peerman.discover({ limit: 6 }).start();
|
||||
peerman.discover({ limit: 12 }).start();
|
||||
|
|
|
@ -90,6 +90,13 @@ PeerManager.prototype.checkStatus = function checkStatus() {
|
|||
}
|
||||
});
|
||||
|
||||
// for debug purposes, print how many of our peers are actually connected
|
||||
var connected = 0
|
||||
this.peers.forEach(function(p) {
|
||||
if (p.connection && !p.connection._connecting) connected++
|
||||
});
|
||||
log.info(connected + ' of ' + this.peers.length + ' peers connected');
|
||||
|
||||
Object.keys(peerIndex).forEach(function(i) {
|
||||
this.connectTo(peerIndex[i]);
|
||||
}.bind(this));
|
||||
|
@ -192,8 +199,8 @@ PeerManager.prototype.handleDisconnect = function(e) {
|
|||
if(i != -1) this.connections.splice(i, 1);
|
||||
|
||||
this.removePeer(e.peer);
|
||||
log.info('replacing peer with one from the pool of: ' + this.pool.length);
|
||||
if (this.pool.length) {
|
||||
log.info('replacing peer using the pool of ' + this.pool.length + ' seeds');
|
||||
this.addPeer(this.pool.pop());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue