Merge pull request #2 from braydonf/frelay-optional
Added jsdocs for options and changed size to maxSize
This commit is contained in:
commit
fe08f5a4de
10
lib/pool.js
10
lib/pool.js
@ -30,7 +30,11 @@ function now() {
|
||||
* ```
|
||||
*
|
||||
* @param {Network|String} network - The network to connect
|
||||
* @param {Object} options - Options object
|
||||
* @param {Object} [options] - Options object
|
||||
* @param {Boolean} [options.listenAddr=true] - Prevent new peers being added from addr messages
|
||||
* @param {Boolean} [options.dnsSeed=true] - Prevent seeding with DNS discovered known peers
|
||||
* @param {Boolean} [options.relay=true] - Prevent inventory announcements until a filter is loaded
|
||||
* @param {Number} [options.maxSize=Pool.MaxConnectedPeers] - The max number of peers
|
||||
* @returns {Pool}
|
||||
* @constructor
|
||||
*/
|
||||
@ -48,7 +52,7 @@ function Pool(network, options) {
|
||||
this.listenAddr = options.listenAddr === false ? false : true;
|
||||
this.dnsSeed = options.dnsSeed === false ? false : true;
|
||||
this.relay = options.relay === false ? false : true;
|
||||
this.size = options.size || Pool.MaxConnectedPeers;
|
||||
this.maxSize = options.maxSize || Pool.MaxConnectedPeers;
|
||||
|
||||
if (options.addrs) {
|
||||
for(var i = 0; i < options.addrs.length; i++) {
|
||||
@ -147,7 +151,7 @@ Pool.prototype.numberConnected = function numberConnected() {
|
||||
Pool.prototype._fillConnections = function _fillConnections() {
|
||||
var length = this._addrs.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (this.numberConnected() >= this.size) {
|
||||
if (this.numberConnected() >= this.maxSize) {
|
||||
break;
|
||||
}
|
||||
var addr = this._addrs[i];
|
||||
|
||||
@ -194,7 +194,7 @@ describe('Pool', function() {
|
||||
this.emit('disconnect', this, {});
|
||||
});
|
||||
|
||||
var pool = new Pool(null, { size: 1 });
|
||||
var pool = new Pool(null, { dnsSeed: false });
|
||||
pool._addAddr({ ip: { v4: 'localhost' } });
|
||||
|
||||
// Not great, but needed so pool won't catch its on event and fail the test
|
||||
|
||||
Loading…
Reference in New Issue
Block a user