pool: maxPeers option.

This commit is contained in:
Christopher Jeffrey 2016-07-28 22:33:11 -07:00
parent a0e0ecdd73
commit a987513ce9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 7 additions and 4 deletions

View File

@ -99,6 +99,8 @@ function Fullnode(options) {
headers: this.options.headers,
compact: this.options.compact,
bip151: this.options.bip151,
maxPeers: this.options.maxPeers,
maxLeeches: this.options.maxLeeches,
proxyServer: this.options.proxyServer,
preferredSeed: this.options.preferredSeed,
spv: false

View File

@ -25,7 +25,7 @@ var InvItem = bcoin.packets.InvItem;
* @param {Object} options
* @param {Chain} options.chain
* @param {Mempool?} options.mempool
* @param {Number?} [options.size=8] - Maximum number of peers.
* @param {Number?} [options.maxPeers=8] - Maximum number of peers.
* @param {Boolean?} options.spv - Do an SPV sync.
* @param {Boolean?} options.relay - Whether to ask
* for relayed transactions.
@ -135,7 +135,7 @@ function Pool(options) {
});
this.server = null;
this.size = options.size || 8;
this.maxPeers = options.maxPeers || 8;
this.maxLeeches = options.maxLeeches || 8;
this.connected = false;
this.uid = 0;
@ -395,7 +395,7 @@ Pool.prototype.connect = function connect() {
this._addLoader();
for (i = 0; i < this.size - 1; i++)
for (i = 0; i < this.maxPeers - 1; i++)
this._addPeer();
this.connected = true;
@ -1303,7 +1303,7 @@ Pool.prototype._addPeer = function _addPeer() {
if (!this.loaded)
return;
if (this.peers.regular.length + this.peers.pending.length >= this.size - 1)
if (this.peers.regular.length + this.peers.pending.length >= this.maxPeers - 1)
return;
host = this.getHost();

View File

@ -58,6 +58,7 @@ function SPVNode(options) {
witness: this.network.witness,
proxyServer: this.options.proxyServer,
preferredSeed: this.options.preferredSeed,
maxPeers: this.options.maxPeers,
selfish: true,
listen: false,
spv: true