Skip to content

docs: getting started #514

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

Merged
merged 12 commits into from
Jan 23, 2020
Merged

docs: getting started #514

merged 12 commits into from
Jan 23, 2020

Conversation

vasco-santos
Copy link
Member

This getting started doc aims to be the entry point for new users of js-libp2p since it goes deeper in detail within each concept.

For more advanced users, we expect that they consult the API and CONFIG docs mostly, as they are more straightforward documents

@vasco-santos vasco-santos force-pushed the docs/getting-started branch 3 times, most recently from 8dc4726 to 570da2a Compare December 13, 2019 13:53
@vasco-santos vasco-santos marked this pull request as ready for review December 13, 2019 14:00
@vasco-santos
Copy link
Member Author

cc @terichadbourne

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.

@vasco-santos I created a PR to discuss some edits, #520. I think it might be easier to do it that way than individual comments across this PR for the larger changes. I only did the first bit of configuration so we can discuss the approach.

A few thoughts:

  • I think reducing the amount of text for each section would be helpful. If we can succinctly describe each step and then link off to further reading, I think that might be easier for folks to consume.
  • I think it would be good to have the final code of this in ./examples. If anyone gets stuck, they can go reference the example code and we can more easily ensure this is running properly in future releases, as we test all examples.
  • While multiplexing is not required, we should have it in the basic setup. If it's not configured the node won't be able to speak to the main network. The majority of users will likely need multiplexing. For me, basic setup means I should be able to start talking with the main network, even if it's in a limited fashion.

@vasco-santos
Copy link
Member Author

vasco-santos commented Dec 18, 2019

I think it would be good to have the final code of this in ./examples. If anyone gets stuck, they can go reference the example code and we can more easily ensure this is running properly in future releases, as we test all examples.

👍

  • While multiplexing is not required, we should have it in the basic setup. If it's not configured the node won't be able to speak to the main network. The majority of users will likely need multiplexing. For me, basic setup means I should be able to start talking with the main network, even if it's in a limited fashion.

sounds good, I will change that once we get #520 here

@vasco-santos
Copy link
Member Author

I think I addressed all the feedback except for:

I think it would be good to have the final code of this in ./examples. If anyone gets stuck, they can go reference the example code and we can more easily ensure this is running properly in future releases, as we test all examples.

For that one in specific, I will create an issue to track all the remaining endeavours. I want to get all the examples being tested in CI, in order to ease the release process


You can install `libp2p-mplex` and add it to your libp2p node as follows in the next example. You should revisit the [API](./API.md) document, more specifically [API#dial](./API.md#dial) and [API#handle](./API.md#handle).

We will also install the next dependencies for easily work with [async iterable duplex streams](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9).
Copy link
Contributor

Choose a reason for hiding this comment

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

We should point to the local README we have for this, as we'll also be including more examples of using iterable streams in libp2p https://github.com/libp2p/js-libp2p/blob/refactor/async-await/doc/STREAMING_ITERABLES.md

await node.stop()
```

If you are not familiar with multiaddrs, you should read the [multiformats/js-multiaddr](https://github.com/multiformats/js-multiaddr) README.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems out of place, not sure where this should go.

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 think we can just remove it

npm install libp2p-kad-dht
```

`js-libp2p` configuration is not well defined yet regarding content routing routing. Therefore, the `dht` should be plugged through a `modules.dht` property, while the `libp2p-delegated-content-routing` should be plugged into `modules.contentRouting` array.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, it is defined, but the DHT does not yet conform to the separate configuration.

await node.start()

// provide cid
await libp2p.contentRouting.provide(cid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're aiming to have people join the live network we should probably not have them provide content, as their node is going to go offline pretty quickly. What do you think?

For findProviders we should just use a well known cid, and we should include the cid module here. A website or the ipfs readme might be good options.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call!


const node = await Libp2p.create({
modules: {
transport: [TCP],
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here, why the switch to TCP?

@jacobheun jacobheun force-pushed the docs/getting-started branch from e437c0a to 462d303 Compare January 22, 2020 12:55
@jacobheun
Copy link
Contributor

I went ahead and cleaned up some of the language. I also removed mdns, DHT and Pubsub setup from the guide for now. The problem with having these included is that the setup as it was, wasn't sufficient for these things to work properly. For example, you could start and run pubsub, but you wouldn't be publishing to anything. I think it's more valuable to get people running a node and connecting it to the public network, and then referencing the Configuration readme and examples folder for additional sources of configuration. The examples do a better job of ensuring each piece will yield results by doing things like running multiple nodes when necessary.

I think we can add additional components to this in the future, but they should work without needing any additional configuration/resources.

@jacobheun jacobheun requested review from alanshaw and dirkmc January 22, 2020 13:03
doc/API.md Outdated

- `peer`: instance of [PeerInfo][https://github.com/libp2p/js-peer-info]

#### We have a new connection to a peer
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#### We have a new connection to a peer
#### An incoming connection from a peer has been established

Is it only incoming or outgoing also?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is both.

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, might be an idea just to be explicit that it is!


#### Transports

Libp2p uses Transports to establish connections between peers over the network. You can configure any number of Transports, but you only need 1 to start with. Supporting more Transports will improve the ability of your node to speak to a larger number of nodes on the network.
Copy link
Member

Choose a reason for hiding this comment

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

Could we explain a little what a transport is?

@jacobheun jacobheun merged commit 461faca into refactor/async-await Jan 23, 2020
@jacobheun jacobheun deleted the docs/getting-started branch January 23, 2020 16:12
jacobheun added a commit that referenced this pull request Jan 24, 2020
* docs: getting started

* docs: review getting started (#520)

* doc: initial review of getting started

Co-Authored-By: Vasco Santos <[email protected]>

* chore: move multiplexing to basic setup

* chore: add read more cta

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <[email protected]>

* chore: just configure multiplexer

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <[email protected]>

* chore: just use websockets and changed dht module introduction

* chore: add reference for events in the API doc

* docs: simplify getting started guide and clean up language

* chore: apply suggestions from code review

Co-Authored-By: Alan Shaw <[email protected]>

* docs(fix): address review comments

Co-authored-by: Jacob Heun <[email protected]>
Co-authored-by: Alan Shaw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants