Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not dial all known peers in parallel on startup #698

Merged
merged 9 commits into from
Jul 14, 2020
Prev Previous commit
Next Next commit
chore: use retimer reschedule
  • Loading branch information
vasco-santos committed Jul 14, 2020
commit 2985a5f7db34e727b1cf5621a093b9bed7c5694a
13 changes: 10 additions & 3 deletions src/connection-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,17 @@ class ConnectionManager extends EventEmitter {
async _autoDial () {
const minConnections = this._options.minConnections

const recursiveTimeoutTrigger = () => {
if (this._autoDialTimeout) {
this._autoDialTimeout.reschedule(this._options.autoDialInterval)
} else {
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
}
}

// Already has enough connections
if (this.size >= minConnections) {
this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)

recursiveTimeoutTrigger()
return
jacobheun marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -325,7 +332,7 @@ class ConnectionManager extends EventEmitter {
}
}

this._autoDialTimeout = retimer(this._autoDial, this._options.autoDialInterval)
recursiveTimeoutTrigger()
}

/**
Expand Down