mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
Updates all deps needed to support passing lists of byte arrays where they have been created from multiple input buffers. When reading multiplexed data, all messages arrive in length-prefixed buffers, which means the first few bytes tell the consumer how many bytes long next chunk will be. One length prefixed chunk can be delivered in several payloads from the underlying network transport. The first payload can also include the length prefix and some or all of the data, so we stitch these together in a `Uint8ArrayList` to avoid having to concatenate `Uint8Array`s together. Previously once we'd received enough bytes to satisfy the length prefix we'd concatenate the bytes together, but this is a potentially expensive operation where transports have small message sizes so instead just pass the `Uint8ArrayList` to the consumer and let them decide wether to concatenate or not as some consumers will be smart enough to operate on lists of `Uint8Array`s instead of always requiring a contiguous block of memory. BREAKING CHANGE: Streams are now `Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>`
js-libp2p
Examples and Tutorials
In this folder, you can find a variety of examples to help you get started in using js-libp2p, in Node.js and in the Browser. Every example has a specific purpose and some incorporate a full tutorial that you can follow through, helping you expand your knowledge about libp2p and p2p networks in general.
Let us know if you find any issues, or if you want to contribute and add a new tutorial, feel free to submit a PR, thank you!
Understanding how libp2p works
- Transports
- Protocol and Stream Muxing
- Connection Encryption
- Discovery Mechanisms
- Peer and Content Routing
- PubSub
- NAT Traversal
- Circuit Relay (future)
- Naming (future)
Other examples
- Running libp2p in the Browser
- Running libp2p in the Electron (future)
- The standard echo net example with libp2p
- A simple chat app with libp2p
For go-libp2p examples, check out https://github.com/libp2p/go-libp2p-examples#examples-and-tutorials