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

feat: add createLibp2p to generate a PeerInfo instance #367

Merged
merged 1 commit into from
Jun 6, 2019

Conversation

jacobheun
Copy link
Contributor

createLibp2p is a new exported helper function that allows users to create a libp2p instance without worrying about creating a PeerInfo instance first.

Now instead of needing to do this:

const PeerInfo = require('peer-info')
const Libp2p = require('libp2p')
PeerInfo.create((err, peerInfo) => {
  const libp2p = new Libp2p({
    ...options,
    peerInfo
  }) 
  // Use libp2p
})

you can just do:

const { createLibp2p } = require('libp2p')
createLibp2p(options, (err, libp2p) => {
    // Use libp2p
}) 

While the code change is not significant, it removes the need to know about PeerInfo creation prior to creating a libp2p instance. This should hopefully help reduce the barrier to entry by a small degree.

I also changed Node to Libp2p because the naming is unnecessarily confusing and nondescript.

createLibp2p is a new exported helper function that allows users to create a libp2p instance without worrying about creating a PeerInfo instance first.
@jacobheun jacobheun added the kind/enhancement A net-new feature or improvement to an existing feature label Jun 6, 2019
Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

👍

@jacobheun jacobheun merged commit 04faf18 into master Jun 6, 2019
@jacobheun jacobheun deleted the feat/create-libp2p branch June 6, 2019 10:21
@dirkmc
Copy link
Contributor

dirkmc commented Jun 6, 2019

Nice 👍

Was there a docs change too?

@jacobheun
Copy link
Contributor Author

Was there a docs change too?

No but good call, I am updated deps so I will include a docs update with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants