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

Clarify readme "bundles" section #231

Closed
ghost opened this issue Aug 6, 2018 · 4 comments
Closed

Clarify readme "bundles" section #231

ghost opened this issue Aug 6, 2018 · 4 comments
Labels
status/ready Ready to be worked

Comments

@ghost
Copy link

ghost commented Aug 6, 2018

We just had someone in IRC confused about the relationship between the bundles and js-libp2p. I feel like the section should avoid the word skeleton, which sounds like death and lack of substance, and feels more like a quantification of project status vs. a qualification of the js-libp2p repo's function within the js-libp2p project.

Instead it should probably say something like:

  • This is an umbrella repo and the actual functionality is in separate packages, which you pull in and wire up based on your needs
  • For most purposes, use the wiring from js-ipfs (ipfs-browser and ipfs-node bundles)
  • If that doesn't fit you, modify that wiring code as you please

(I think the concept of bundles generally needs clarification and rethinking. Maybe "snippets" get closer to what we're trying to achieve there.)

cc @Mr0grog

@Isan-Rivkin
Copy link
Contributor

It's me on the IRC and agreed :D

@Mr0grog
Copy link

Mr0grog commented Aug 6, 2018

Hmmm, what’s the story with the libp2p-ipfs-nodejs and libp2p-ipfs-browser links? They read like they should link to actual packages (which seemed surprising, since I know how js-ipfs uses libp2p), but then I clicked them and realized they just linked to js-ipfs’s internal configuration. Were these once intended to become wrapper packages of some sort? I definitely agree it’s confusing.

Are there any published “bundles” that wrap up groups of libp2p modules so you can just create an instance [of the bundle] instead of manually composing a bunch of libp2p parts? If not, I don’t think we should even call this section “bundles.” Maybe it could be “composing functionality” or something similar.

My take:

Composing Functionality

js-libp2p itself is just a tool for plugging together different pieces of a peer-to-peer networking stack. To create a working libp2p instance, you’ll need to select a set of transports (like TCP, WebSockets, etc.), multiplexers, encryption mechanisms, peer discovery mechanisms, and DHT implementations to use. The libp2p project contains packages that implement all of these, but it’s up to you to import those packages and send them to the js-libp2p constructor.

For example, you might use the TCP and WebSocket transports, MPLEX multiplexing, SecIO encryption, Multicast discovery, and Kademlia DHT:

const libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const WS = require('libp2p-websockets')
const MPLEX = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const MulticastDNS = require('libp2p-mdns')
const KademliaDHT = require('libp2p-kad-dht')

const p2pInstance = new libp2p({
  modules: {
    transport: [ TCP, new WS() ],
    streamMuxer: [ MPLEX ],
    connEncryption: [ SECIO ],
    peerDiscovery: [ MulticastDNS ],
    dht: KademliaDHT
  }
})

See the packages section below for a list of officially maintained packages you can use to configure an instance.

You can also check out how js-ipfs creates a Libp2p constructor with different standard defaults for different environments here:

^ Not sure if this is a great set of choices for an example. I am 100% sure other people have more expert opinions here. That code is also untested, so I’m not even sure if works :P


I also think the usage example could use a lot of work here — it only demonstrates how to construct a libp2p instance and doesn’t show how to use it. The constructor is also unnecessarily elaborate (looks like it’s just a copy of the one from js-ipfs) and doesn’t make it especially clear what’s happening. In fact, it’s not even quite complete because it requires a PeerInfo and PeerBook instance without showing what they are or how to create them :\

A better example might:

  1. Directly create a libp2p instance (instead of a constructor that creates instances with default options).
  2. Starts the instance.
  3. Does something simple, like pinging or dialing a peer.
  4. Stops the instance. (Side note: does that gracefully hang up on connected peers, or would a good example do that before stopping?)

@Mr0grog
Copy link

Mr0grog commented Aug 6, 2018

Or maybe “Composable Functionality” as a title instead?

@vasco-santos
Copy link
Member

We don't use the bundles name anymore, so I am going to close this

maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
Ensure we get the right version of the module. Also updates project config to the latest version.
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## [6.0.3](libp2p/js-libp2p-tcp@v6.0.2...v6.0.3) (2022-11-22)

### Bug Fixes

* make metrics interface a dep instead of a dev dep ([libp2p#231](libp2p/js-libp2p-tcp#231)) ([876ca13](libp2p/js-libp2p-tcp@876ca13))
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
* fix: apply message size limit before decoding message

If we apply the message size limit after decoding the message it's
too late as we've already processed the bad message.

Instead, if the buffer full of unprocessed messages grows to be
large than the max message size (e.g. we have not recieved a complete
message under the size limit), throw an error which will cause the
stream to be reset.

* fix: add implementation
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## [7.0.5](libp2p/js-libp2p-mplex@v7.0.4...v7.0.5) (2022-11-24)

### Bug Fixes

* apply message size limit before decoding message ([libp2p#231](libp2p/js-libp2p-mplex#231)) ([279ad47](libp2p/js-libp2p-mplex@279ad47))
* limit unprocessed message queue size separately to message size ([libp2p#234](libp2p/js-libp2p-mplex#234)) ([2297856](libp2p/js-libp2p-mplex@2297856))
* yield single buffers ([libp2p#233](libp2p/js-libp2p-mplex#233)) ([31d3938](libp2p/js-libp2p-mplex@31d3938))
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## [5.0.10](libp2p/js-libp2p-websockets@v5.0.9...v5.0.10) (2023-04-12)

### Dependencies

* bump @libp2p/interface-connection from 3.1.1 to 4.0.0 ([libp2p#231](libp2p/js-libp2p-websockets#231)) ([e2f7204](libp2p/js-libp2p-websockets@e2f7204))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

4 participants