pool: minor fixes.
This commit is contained in:
parent
b1c735702c
commit
d94c143b5d
@ -1045,7 +1045,7 @@ Pool.prototype.createPeer = function createPeer(addr, socket) {
|
|||||||
self.stopInterval();
|
self.stopInterval();
|
||||||
self.stopTimeout();
|
self.stopTimeout();
|
||||||
|
|
||||||
if (self.peers.regular.length === 0) {
|
if (self.peers.size() === 0) {
|
||||||
self.logger.warning('%s %s %s',
|
self.logger.warning('%s %s %s',
|
||||||
'Could not connect to any peers.',
|
'Could not connect to any peers.',
|
||||||
'Do you have a network connection?',
|
'Do you have a network connection?',
|
||||||
@ -1969,15 +1969,25 @@ PeerList.prototype.remove = function remove(peer) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PeerList.prototype.repurpose = function repurpose(peer) {
|
PeerList.prototype.repurpose = function repurpose(peer) {
|
||||||
|
var r1, r2;
|
||||||
|
|
||||||
assert(peer.outbound);
|
assert(peer.outbound);
|
||||||
assert(!this.load);
|
assert(!this.load);
|
||||||
utils.binaryRemove(this.pending, peer, compare);
|
|
||||||
utils.binaryRemove(this.regular, peer, compare);
|
r1 = utils.binaryRemove(this.pending, peer, compare);
|
||||||
|
r2 = utils.binaryRemove(this.regular, peer, compare);
|
||||||
|
|
||||||
|
assert(r1 || r2);
|
||||||
|
|
||||||
this.load = peer;
|
this.load = peer;
|
||||||
};
|
};
|
||||||
|
|
||||||
PeerList.prototype.isFull = function isFull() {
|
PeerList.prototype.isFull = function isFull() {
|
||||||
return this.regular.length + this.pending.length >= this.pool.maxPeers - 1;
|
return this.size() >= this.pool.maxPeers - 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
PeerList.prototype.size = function size() {
|
||||||
|
return this.regular.length + this.pending.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
PeerList.prototype.addLeech = function addLeech(peer) {
|
PeerList.prototype.addLeech = function addLeech(peer) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user