Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

fix: validate list #97

Merged
merged 1 commit into from
Nov 28, 2019
Merged

fix: validate list #97

merged 1 commit into from
Nov 28, 2019

Conversation

vasco-santos
Copy link
Member

if the list was not provided before, we would have a runtime error

*
*/
constructor (options) {
constructor (options = {}) {
assert(options.list && options.list.length, 'Bootstrap requires a list of peer addresses')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to create problems for people. I've seen several configs from people getting started where they include a bunch of the modules but not all the options, such as the bootstrap list. If we had warn level logging I think my preference would be to do that, since we don't I think logging that nothing was provided and not throwing might be best for usability. There's definitely another argument here about making libp2p easier to configure for less advanced users, but we can discuss that elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change to a warning for now.

My main reason to this change instead of log, if someone adds Bootstrap without any peers, this module will blindly not do nothing (unless someone goes through the logs). Ideally, we would avoid this type of behavior

Copy link
Contributor

@jacobheun jacobheun Nov 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can just update the assert error to be more specific about how to fix the problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think on: 'Bootstrap requires a list of peer addresses on its configuration options'

I would like to go on more detail, but feels out of scope to explain libp2p specificity here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, nvm, I think this should be solved in libp2p itself and the assert here is fine. The reason for this is that how bootstrap is configured here is not how users configure it in libp2p as it as modules vs config options.

Aside from the package.json conflict this looks good.

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebased, but otherwise this LGTM

@vasco-santos vasco-santos merged commit 5041f28 into master Nov 28, 2019
@vasco-santos vasco-santos deleted the fix/validate-list branch November 28, 2019 12:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants