pool: maxPeers option.
This commit is contained in:
parent
a0e0ecdd73
commit
a987513ce9
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user