mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
commit
14d14ff0b6
76
README.md
76
README.md
@ -1,19 +1,12 @@
|
||||
js-libp2p
|
||||
=========
|
||||
|
||||

|
||||

|
||||
|
||||
[](http://ipn.io)
|
||||
[[](http://webchat.freenode.net/?channels=%23ipfs)
|
||||
[](https://travis-ci.org/diasdavid/js-libp2p)
|
||||
[](https://travis-ci.org/libp2p/js-libp2p)
|
||||

|
||||
[](https://david-dm.org/diasdavid/js-libp2p)
|
||||
[](https://david-dm.org/libp2p/js-libp2p)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
> JavaScript implementation of libp2p
|
||||
|
||||
libp2p is a networking stack and library modularized out of The IPFS Project, and bundled separately for other tools to use.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Background](#background)
|
||||
@ -21,14 +14,23 @@ libp2p is a networking stack and library modularized out of The IPFS Project, an
|
||||
- [Notes](#notes)
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Setting everything up](#setting-everything-up)
|
||||
- [Dialing and listening](#dialing-and-listening)
|
||||
- [Using Peer Routing](#using-peer-routing)
|
||||
- [Using Records](#using-records)
|
||||
- [Stats](#stats)
|
||||
- [Contribute](#contribute)
|
||||
- [License](#license)
|
||||
|
||||
## Description
|
||||
|
||||
libp2p is a networking stack and library modularized out of The IPFS Project, and bundled separately for other tools to use.
|
||||
|
||||
This repo is only the skeleton to create libp2p builds. If you want 'off the shelf' builds of libp2p, you can check:
|
||||
|
||||
- [libp2p-ipfs](https://github.com/ipfs/js-libp2p-ipfs) - The libp2p build used by js-ipfs when run in Node.js
|
||||
- [libp2p-ipfs-browser](https://github.com/ipfs/js-libp2p-ipfs-browser) - The libp2p build used by js-ipfs when run in a Browser (that supports WebRTC)
|
||||
|
||||
You can find the modules available for libp2p at the [Packages](#packages) section.
|
||||
|
||||
[](https://github.com/ipfs/js-libp2p-ipfs)
|
||||
[](https://github.com/ipfs/js-libp2p-ipfs-browser)
|
||||
|
||||
## Background
|
||||
|
||||
libp2p is the product of a long, and arduous quest of understanding -- a deep dive into the internet's network stack, and plentiful peer-to-peer protocols from the past. Building large scale peer-to-peer systems has been complex and difficult in the last 15 years, and libp2p is a way to fix that. It is a "network stack" -- a protocol suite -- that cleanly separates concerns, and enables sophisticated applications to only use the protocols they absolutely need, without giving up interoperability and upgradeability. libp2p grew out of IPFS, but it is built so that lots of people can use it, for lots of different projects.
|
||||
@ -60,60 +62,18 @@ We will be writing a set of docs, posts, tutorials, and talks to explain what p2
|
||||
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [](https://david-dm.org/libp2p/js-libp2p-webrtc-star?type=dev) |
|
||||
| [`multistream-select`](//github.com/diasdavid/js-multistream) | [](//github.com/diasdavid/js-multistream/releases) | [](https://david-dm.org/diasdavid/js-multistream) | [](https://david-dm.org/diasdavid/js-multistream?type=dev) |
|
||||
|
||||
### Notes
|
||||
|
||||
Img for ref (till we get a better graph)
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm i --save libp2p
|
||||
npm install --save libp2p
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
> **This is a work in progress. The interface might change at anytime.**
|
||||
|
||||
libp2p expects a [Record Store interface](https://github.com/diasdavid/abstract-record-store), a swarm and one or more Peer Routers that implement the [Peer Routing](https://github.com/diasdavid/abstract-peer-routing), the goal is to keep simplicity and plugability while the remaining modules execute the heavy lifting.
|
||||
|
||||
libp2p becomes very simple and basically acts as a glue for every module that compose this library. Since it can be highly customized, it requires some setup. What we recommend is to have a libp2p build for the system you are developing taking into account in your needs (e.g. for a browser working version of libp2p that acts as the network layer of IPFS, we have a built and minified version that browsers can require)
|
||||
|
||||
### Setting everything up
|
||||
|
||||
```js
|
||||
var Libp2p = require('libp2p')
|
||||
|
||||
// set up a Swarm, Peer Routing and Record Store instances, the last two are optional
|
||||
|
||||
var p2p = new Libp2p(swarm, [peerRouting, recordStore])
|
||||
```
|
||||
|
||||
### Dialing and listening
|
||||
|
||||
```js
|
||||
p2p.swarm.dial(peerInfo, options, protocol, function (err, stream) {})
|
||||
p2p.swarm.handleProtocol(protocol, options, handlerFunction)
|
||||
```
|
||||
|
||||
### Using Peer Routing
|
||||
|
||||
```js
|
||||
p2p.routing.findPeers(key, function (err, peerInfos) {})
|
||||
```
|
||||
|
||||
### Using Records
|
||||
|
||||
```js
|
||||
p2p.record.get(key, function (err, records) {})
|
||||
p2p.record.store(key, record)
|
||||
```
|
||||
|
||||
### Stats
|
||||
|
||||
TODO
|
||||
|
||||
## Contribute
|
||||
|
||||
THe libp2p implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:
|
||||
|
BIN
img/js-libp2p-ipfs-browser.png
Normal file
BIN
img/js-libp2p-ipfs-browser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
BIN
img/js-libp2p-ipfs.png
Normal file
BIN
img/js-libp2p-ipfs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
BIN
img/js-libp2p.png
Normal file
BIN
img/js-libp2p.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
img/libp2p-arch.png
Normal file
BIN
img/libp2p-arch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 MiB |
BIN
img/libp2p-logos.sketch
Normal file
BIN
img/libp2p-logos.sketch
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user