From d7eb5b7abc8e89cb1d5613e90c1a8ee5f82a9396 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 25 Nov 2016 20:07:45 +0000 Subject: [PATCH 1/6] docs: overall to the README, lots of more updated information --- README.md | 117 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index c7d1578bc8..69ad38ba2a 100644 --- a/README.md +++ b/README.md @@ -7,73 +7,110 @@ [![Dependency Status](https://david-dm.org/libp2p/js-libp2p.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +> libp2p is the networking stack of IPFS, a modular networking library to solve P2P application needs. + ## Table of Contents - [Background](#background) - - [Packages](#packages) - - [Notes](#notes) -- [Install](#install) +- [Bundles](#bundles) - [Usage](#usage) + - [Install](#install) + - [API](#api) +- [Development](#development) + - [Tests](#tests) + - [Packages](#packages) - [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:** +## Background -- [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) +libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, dev have long had to made custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API. -You can find the modules available for libp2p at the [Packages](#packages) section. +We are in the process of writting better documentation, blog posts, tutorials and a formal specification. Today you can find: -[![](https://github.com/libp2p/js-libp2p/blob/1e3e9db84d1e5fdd5682cc5e0fdaabfcd07ad55a/img/js-libp2p-ipfs.png?raw=true)](https://github.com/ipfs/js-libp2p-ipfs) -[![](https://github.com/libp2p/js-libp2p/blob/1e3e9db84d1e5fdd5682cc5e0fdaabfcd07ad55a/img/js-libp2p-ipfs-browser.png?raw=true)](https://github.com/ipfs/js-libp2p-ipfs-browser) +- libp2p.io - The libp2p Website (WIP) +- Specification (WIP) +- Talks + - [`libp2p <3 ethereum` at DEVCON2]() [video]()[slides]()[demo]() +- Articles + - The overview of libp2p -## Background +To sum up, libp2p 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. -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. +## Bundles -We will be writing a set of docs, posts, tutorials, and talks to explain what p2p is, why it is tremendously useful, and how it can help your existing and new projects. +With its modular nature, libp2p can be found being used in different projects with different sets of features, while perserving the same top level API. `js-libp2p` is only a skelleton and should not be installed directly, if you are looking for a prebundled libp2p stack, please check: -### Packages +- [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) -| Package | Version | Dependencies | DevDependencies | -|--------|-------|------------|----------| -| [`peer-book`](//github.com/libp2p/js-peer-book) | [![npm](https://img.shields.io/npm/v/peer-book.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-peer-book/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-peer-book.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-book) | [![devDependency Status](https://david-dm.org/libp2p/js-peer-book/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-book?type=dev) | -| [`libp2p-ipfs`](//github.com/ipfs/js-libp2p-ipfs) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs?type=dev) | -| [`libp2p-ipfs-browser`](//github.com/ipfs/js-libp2p-ipfs-browser) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs-browser.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs-browser/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser?type=dev) | -| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-secio/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio?type=dev) | -| [`libp2p-swarm`](//github.com/diasdavid/js-libp2p-swarm) | [![npm](https://img.shields.io/npm/v/libp2p-swarm.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-swarm/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-swarm.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-swarm) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-swarm/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-swarm?type=dev) | -| [`libp2p-ping`](//github.com/diasdavid/js-libp2p-ping) | [![npm](https://img.shields.io/npm/v/libp2p-ping.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-ping/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-ping.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-ping) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-ping/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-ping?type=dev) | -| [`interface-connection`](//github.com/diasdavid/interface-connection) | [![npm](https://img.shields.io/npm/v/interface-connection.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/interface-connection/releases) | [![Dependency Status](https://david-dm.org/diasdavid/interface-connection.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-connection) | [![devDependency Status](https://david-dm.org/diasdavid/interface-connection/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-connection?type=dev) | -| [`libp2p-utp`](//github.com/diasdavid/js-libp2p-utp) | [![npm](https://img.shields.io/npm/v/libp2p-utp.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-utp/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-utp.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-utp) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-utp/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-utp?type=dev) | -| [`interface-stream-muxer`](//github.com/diasdavid/interface-stream-muxer) | [![npm](https://img.shields.io/npm/v/interface-stream-muxer.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/interface-stream-muxer/releases) | [![Dependency Status](https://david-dm.org/diasdavid/interface-stream-muxer.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-stream-muxer) | [![devDependency Status](https://david-dm.org/diasdavid/interface-stream-muxer/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-stream-muxer?type=dev) | -| [`libp2p-spdy`](//github.com/diasdavid/js-libp2p-spdy) | [![npm](https://img.shields.io/npm/v/libp2p-spdy.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-spdy/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-spdy.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-spdy) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-spdy/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-spdy?type=dev) | -| [`libp2p-kad-routing`](//github.com/diasdavid/js-libp2p-kad-routing) | [![npm](https://img.shields.io/npm/v/libp2p-kad-routing.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-kad-routing/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-kad-routing.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-kad-routing) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-kad-routing/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-kad-routing?type=dev) | -| [`libp2p-mdns-discovery`](//github.com/diasdavid/js-libp2p-mdns-discovery) | [![npm](https://img.shields.io/npm/v/libp2p-mdns-discovery.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-mdns-discovery/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-mdns-discovery.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-mdns-discovery) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-mdns-discovery/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-mdns-discovery?type=dev) | -| [`libp2p-railing`](//github.com/diasdavid/js-libp2p-railing) | [![npm](https://img.shields.io/npm/v/libp2p-railing.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-railing/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-railing.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-railing) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-railing/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-railing?type=dev) | -| [`libp2p-record`](//github.com/diasdavid/js-libp2p-record) | [![npm](https://img.shields.io/npm/v/libp2p-record.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-record/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-record.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-record) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-record/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-record?type=dev) | -| [`interface-record-store`](//github.com/diasdavid/interface-record-store) | [![npm](https://img.shields.io/npm/v/interface-record-store.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/interface-record-store/releases) | [![Dependency Status](https://david-dm.org/diasdavid/interface-record-store.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-record-store) | [![devDependency Status](https://david-dm.org/diasdavid/interface-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/interface-record-store?type=dev) | -| [`libp2p-distributed-record-store`](//github.com/diasdavid/js-libp2p-distributed-record-store) | [![npm](https://img.shields.io/npm/v/undefined.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-distributed-record-store/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-distributed-record-store.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-distributed-record-store) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-distributed-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-distributed-record-store?type=dev) | -| [`libp2p-kad-record-store`](//github.com/diasdavid/js-libp2p-kad-record-store) | [![npm](https://img.shields.io/npm/v/libp2p-kad-record-store.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-kad-record-store/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-kad-record-store.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-kad-record-store) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-kad-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-kad-record-store?type=dev) | -| [`libp2p-websockets`](//github.com/diasdavid/js-libp2p-websockets) | [![npm](https://img.shields.io/npm/v/libp2p-websockets.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-libp2p-websockets/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-websockets) | [![devDependency Status](https://david-dm.org/diasdavid/js-libp2p-websockets/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-libp2p-websockets?type=dev) | -| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [![npm](https://img.shields.io/npm/v/libp2p-webrtc-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-webrtc-star/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star?type=dev) | -| [`multistream-select`](//github.com/diasdavid/js-multistream) | [![npm](https://img.shields.io/npm/v/multistream-select.svg?maxAge=86400&style=flat-square)](//github.com/diasdavid/js-multistream/releases) | [![Dependency Status](https://david-dm.org/diasdavid/js-multistream.svg?style=flat-square)](https://david-dm.org/diasdavid/js-multistream) | [![devDependency Status](https://david-dm.org/diasdavid/js-multistream/dev-status.svg?style=flat-square)](https://david-dm.org/diasdavid/js-multistream?type=dev) | +If you have developed a libp2p bundle, please consider submitting it to this list so that it can be found easily by the users of libp2p. ## Install +> Again, as noted above, this module is only a skeleton and should not be used directly other than libp2p bundle implementors that want to extend its code. + ```sh npm install --save libp2p ``` ## Usage -> **This is a work in progress. The interface might change at anytime.** +> **Disclamer - We haven't solidified [libp2p interface](https://github.com/libp2p/interface-libp2p) yet, it might change at anytime.** + +### Extending libp2p skeleton 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) +### libp2p API + +Defined by [interface-libp2p](https://github.com/libp2p/interface-libp2p) + +## Development + +## Linting + +```sh +> npm run lint +``` + +### Packages + +> List of packages currently in existance for libp2p + +| Package | Version | Dependencies | DevDependencies | +|---------|---------|--------------|-----------------| +| Bundles | +| [`libp2p-ipfs`](//github.com/ipfs/js-libp2p-ipfs) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs?type=dev) | +| [`libp2p-ipfs-browser`](//github.com/ipfs/js-libp2p-ipfs-browser) | [![npm](https://img.shields.io/npm/v/libp2p-ipfs-browser.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-libp2p-ipfs-browser/releases) | [![Dependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser) | [![devDependency Status](https://david-dm.org/ipfs/js-libp2p-ipfs-browser/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/js-libp2p-ipfs-browser?type=dev) | +| Transports | +| [`libp2p-utp`](//github.com/libp2p/js-libp2p-utp) | [![npm](https://img.shields.io/npm/v/libp2p-utp.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-utp/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-utp.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-utp) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-utp/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-utp?type=dev) | +| [`libp2p-websockets`](//github.com/libp2p/js-libp2p-websockets) | [![npm](https://img.shields.io/npm/v/libp2p-websockets.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-websockets/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-websockets.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-websockets/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websockets?type=dev) | +| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [![npm](https://img.shields.io/npm/v/libp2p-webrtc-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-webrtc-star/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star?type=dev) | +| Connection Upgrades | +| [`interface-connection`](//github.com/libp2p/interface-connection) | [![npm](https://img.shields.io/npm/v/interface-connection.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/interface-connection/releases) | [![Dependency Status](https://david-dm.org/libp2p/interface-connection.svg?style=flat-square)](https://david-dm.org/libp2p/interface-connection) | [![devDependency Status](https://david-dm.org/libp2p/interface-connection/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/interface-connection?type=dev) | +| Stream Muxers | +| [`interface-stream-muxer`](//github.com/libp2p/interface-stream-muxer) | [![npm](https://img.shields.io/npm/v/interface-stream-muxer.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/interface-stream-muxer/releases) | [![Dependency Status](https://david-dm.org/libp2p/interface-stream-muxer.svg?style=flat-square)](https://david-dm.org/libp2p/interface-stream-muxer) | [![devDependency Status](https://david-dm.org/libp2p/interface-stream-muxer/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/interface-stream-muxer?type=dev) | +| [`libp2p-spdy`](//github.com/libp2p/js-libp2p-spdy) | [![npm](https://img.shields.io/npm/v/libp2p-spdy.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-spdy/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-spdy.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-spdy) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-spdy/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-spdy?type=dev) | +| Discovery | +| [`libp2p-mdns-discovery`](//github.com/libp2p/js-libp2p-mdns-discovery) | [![npm](https://img.shields.io/npm/v/libp2p-mdns-discovery.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-mdns-discovery/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-mdns-discovery.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mdns-discovery) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-mdns-discovery/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mdns-discovery?type=dev) | +| [`libp2p-railing`](//github.com/libp2p/js-libp2p-railing) | [![npm](https://img.shields.io/npm/v/libp2p-railing.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-railing/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-railing.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-railing) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-railing/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-railing?type=dev) | +| Crypto Channels | +| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-secio/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio?type=dev) | +| Peer Routing | +| [`libp2p-kad-routing`](//github.com/libp2p/js-libp2p-kad-routing) | [![npm](https://img.shields.io/npm/v/libp2p-kad-routing.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-kad-routing/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-kad-routing.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-kad-routing) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-kad-routing/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-kad-routing?type=dev) | +| Content Routing | +| [`interface-record-store`](//github.com/libp2p/interface-record-store) | [![npm](https://img.shields.io/npm/v/interface-record-store.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/interface-record-store/releases) | [![Dependency Status](https://david-dm.org/libp2p/interface-record-store.svg?style=flat-square)](https://david-dm.org/libp2p/interface-record-store) | [![devDependency Status](https://david-dm.org/libp2p/interface-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/interface-record-store?type=dev) | +| [`libp2p-record`](//github.com/libp2p/js-libp2p-record) | [![npm](https://img.shields.io/npm/v/libp2p-record.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-record/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-record.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-record) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-record/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-record?type=dev) | +| [`libp2p-distributed-record-store`](//github.com/libp2p/js-libp2p-distributed-record-store) | [![npm](https://img.shields.io/npm/v/undefined.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-distributed-record-store/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-distributed-record-store.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-distributed-record-store) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-distributed-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-distributed-record-store?type=dev) | +| [`libp2p-kad-record-store`](//github.com/libp2p/js-libp2p-kad-record-store) | [![npm](https://img.shields.io/npm/v/libp2p-kad-record-store.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-kad-record-store/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-kad-record-store.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-kad-record-store) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-kad-record-store/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-kad-record-store?type=dev) | +| Generics | +| [`libp2p-swarm`](//github.com/libp2p/js-libp2p-swarm) | [![npm](https://img.shields.io/npm/v/libp2p-swarm.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-swarm/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-swarm.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-swarm) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-swarm/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-swarm?type=dev) | +| [`libp2p-ping`](//github.com/libp2p/js-libp2p-ping) | [![npm](https://img.shields.io/npm/v/libp2p-ping.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-ping/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-libp2p-ping.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-ping) | [![devDependency Status](https://david-dm.org/libp2p/js-libp2p-ping/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-ping?type=dev) | +| [`multistream-select`](//github.com/libp2p/js-multistream) | [![npm](https://img.shields.io/npm/v/multistream-select.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-multistream/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-multistream.svg?style=flat-square)](https://david-dm.org/libp2p/js-multistream) | [![devDependency Status](https://david-dm.org/libp2p/js-multistream/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-multistream?type=dev) | +| Data Types | +| [`peer-book`](//github.com/libp2p/js-peer-book) | [![npm](https://img.shields.io/npm/v/peer-book.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-peer-book/releases) | [![Dependency Status](https://david-dm.org/libp2p/js-peer-book.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-book) | [![devDependency Status](https://david-dm.org/libp2p/js-peer-book/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-peer-book?type=dev) | + ## 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: From 57c85fe346ace7525584d4526293da335c5b287b Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 25 Nov 2016 20:08:05 +0000 Subject: [PATCH 2/6] chore: update oldie package.json --- examples/browser-echo/README.md | 0 examples/node-browser-chat/README.md | 0 examples/node-browser-echo/README.md | 0 examples/node-echo/README.md | 0 .../README.md | 0 .../node-1.js | 0 .../node-2.js | 0 package.json | 33 ++++++++----------- test/index.spec.js | 13 ++------ 9 files changed, 17 insertions(+), 29 deletions(-) create mode 100644 examples/browser-echo/README.md create mode 100644 examples/node-browser-chat/README.md create mode 100644 examples/node-browser-echo/README.md create mode 100644 examples/node-echo/README.md rename examples/{level1-swarm => old-to-refactor}/README.md (100%) rename examples/{level1-swarm => old-to-refactor}/node-1.js (100%) rename examples/{level1-swarm => old-to-refactor}/node-2.js (100%) diff --git a/examples/browser-echo/README.md b/examples/browser-echo/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/node-browser-chat/README.md b/examples/node-browser-chat/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/node-browser-echo/README.md b/examples/node-browser-echo/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/node-echo/README.md b/examples/node-echo/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/level1-swarm/README.md b/examples/old-to-refactor/README.md similarity index 100% rename from examples/level1-swarm/README.md rename to examples/old-to-refactor/README.md diff --git a/examples/level1-swarm/node-1.js b/examples/old-to-refactor/node-1.js similarity index 100% rename from examples/level1-swarm/node-1.js rename to examples/old-to-refactor/node-1.js diff --git a/examples/level1-swarm/node-2.js b/examples/old-to-refactor/node-2.js similarity index 100% rename from examples/level1-swarm/node-2.js rename to examples/old-to-refactor/node-2.js diff --git a/package.json b/package.json index 95765ae001..de29273e73 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,27 @@ { "name": "libp2p", "version": "0.1.1", - "description": "Node.js implementation of libp2p", - "main": "lib/index.js", - "jsnext:main": "src/index.js", + "description": "JavaScript Skeleton for libp2p bundles", + "main": "src/index.js", "scripts": { - "lint": "dignified-lint", - "build": "dignified-build", - "test": "dignified-test", - "test:node": "dignified-test node", - "test:browser": "dignified-test browser", - "release": "dignified-release" + "test": "aegir-test node", + "lint": "aegir-lint", + "release": "aegir-release node", + "release-minor": "aegir-release --type minor", + "release-major": "aegir-release --type major", + "coverage": "aegir-coverage", + "coverage-publish": "aegir-coverage publish" }, "repository": { "type": "git", - "url": "https://github.com/diasdavid/js-libp2p.git" + "url": "https://github.com/libp2p/js-libp2p.git" }, "keywords": [ "IPFS" ], "engines": { - "node": "^4.0.0" + "node": ">=4.0.0", + "npm": ">=3.0.0" }, "pre-commit": [ "lint", @@ -29,18 +30,12 @@ "author": "David Dias ", "license": "MIT", "bugs": { - "url": "https://github.com/diasdavid/js-libp2p/issues" + "url": "https://github.com/libp2p/js-libp2p/issues" }, "homepage": "https://github.com/diasdavid/js-libp2p", "devDependencies": { "chai": "^3.5.0", - "dignified.js": "^1.0.0", - "libp2p-spdy": "^0.1.0", - "libp2p-swarm": "^0.26.0", - "libp2p-tcp": "^0.8.0", - "multiaddr": "^2.0.3", - "peer-id": "^0.4.0", - "peer-info": "^0.7.1", + "aegir": "^9.1.2", "pre-commit": "^1.1.1" } } diff --git a/test/index.spec.js b/test/index.spec.js index b18a94ee04..33318b431c 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -2,18 +2,11 @@ 'use strict' const expect = require('chai').expect -const Swarm = require('libp2p-swarm') -const Id = require('peer-id') -const Peer = require('peer-info') -const Node = require('../src') +const libp2p = require('../src') describe('libp2p', () => { - it('can be instantiated', () => { - const peer = new Peer(Id.create(), []) - const swarm = new Swarm(peer) - const node = new Node(swarm) - - expect(node.swarm).to.be.eql(swarm) + it('the skeleton is fine, now go build your own libp2p bundle', () => { + expect(libp2p).to.exist }) }) From 5d0b25cb00f640de3ddaa8b7558c9ffbf1cfdd9c Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 26 Nov 2016 03:07:52 +0100 Subject: [PATCH 3/6] feat: create base libp2p.Node class --- package.json | 8 ++ src/index.js | 241 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 239 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index de29273e73..45c8fc34b0 100644 --- a/package.json +++ b/package.json @@ -37,5 +37,13 @@ "chai": "^3.5.0", "aegir": "^9.1.2", "pre-commit": "^1.1.1" + }, + "dependencies": { + "libp2p-swarm": "^0.26.3", + "mafmt": "^2.1.2", + "multiaddr": "^2.1.1", + "peer-book": "^0.3.0", + "peer-id": "^0.8.0", + "peer-info": "^0.8.1" } } diff --git a/src/index.js b/src/index.js index d46f08e6ae..b70e12333c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,19 +1,240 @@ 'use strict' -exports = module.exports = Libp2p +const Swarm = require('libp2p-swarm') +const PeerId = require('peer-id') +const PeerInfo = require('peer-info') +const PeerBook = require('peer-book') +const multiaddr = require('multiaddr') +const mafmt = require('mafmt') +const EE = require('events').EventEmitter +const assert = require('assert') -function Libp2p (swarm, peerRouting, recordStore) { - var self = this +exports = module.exports - if (!(self instanceof Libp2p)) { - throw new Error('Must be called with new') +const OFFLINE_ERROR_MESSAGE = 'The libp2p node is not started yet' +const IPFS_CODE = 421 + +class Node { + constructor (_modules, _peerInfo, _peerBook) { + assert(_modules, 'requires modules to equip libp2p with features') + assert(_peerInfo, 'requires a PeerInfo instance') + + this.modules = _modules + this.peerInfo = _peerInfo + this.peerBook = _peerBook || new PeerBook() + this.isOnline = false + + this.discovery = new EE() + + this.swarm = new Swarm(this.peerInfo) + + // Attach stream multiplexers + if (this.modules.connection.muxer) { + let muxers = this.modules.connection.muxer + muxers = Array.isArray(muxers) ? muxers : [muxers] + muxers.forEach((muxer) => { + this.swarm.connection.addStreamMuxer(muxer) + }) + + // If muxer exists, we can use Identify + this.swarm.connection.reuse() + + // Received incommind dial and muxer upgrade happened, reuse this + // muxed connection + this.swarm.on('peer-mux-established', (peerInfo) => { + this.peerBook.put(peerInfo) + }) + + this.swarm.on('peer-mux-closed', (peerInfo) => { + this.peerBook.removeByB58String(peerInfo.id.toB58String()) + }) + } + + // Attach crypto channels + if (this.modules.connection.crypto) { + let cryptos = this.modules.connection.crypto + cryptos = Array.isArray(cryptos) ? cryptos : [cryptos] + cryptos.forEach((crypto) => { + this.swarm.connection.crypto(crypto.tag, crypto.encrypt) + }) + } + + // Attach discovery mechanisms + if (this.discovery) { + let discoveries = this.modules.discovery + discoveries = Array.isArray(discoveries) ? discoveries : [discoveries] + discoveries.forEach((discovery) => { + discovery.on('peer', (peerInfo) => { + this.discovery.emit('peer', peerInfo) + }) + }) + } + + // Not fully implemented in js-libp2p yet + this.routing = undefined + this.records = undefined + } + + /* + * Start the libp2p node + * - create listeners on the multiaddrs the Peer wants to listen + */ + start (callback) { + if (!this.modules.transport) { + return callback(new Error('no transports were present')) + } + let transports = this.modules.transport + transports = Array.isArray(transports) ? transports : [transports] + const multiaddrs = this.peerInfo.multiaddrs + transports.forEach((transport) => { + if (transport.filter(multiaddrs).length > 0) { + this.swarm.transport.add( + transport.tag || transport.constructor.name, transport) + } + }) + + this.swarm.listen((err) => { + if (err) { + return callback(err) + } + + this.isOnline = true + callback() + }) } - if (!swarm) { - throw new Error('a swarm must be passed') + /* + * Stop the libp2p node by closing its listeners and open connections + */ + stop (callback) { + this.isOnline = false + this.swarm.close(callback) } - self.swarm = swarm - self.routing = peerRouting - self.record = recordStore + // + // Dialing methods + // + + // TODO + dialById (id, protocol, callback) { + // NOTE: dialById only works if a previous dial was made. This will + // change once we have PeerRouting + + assert(this.isOnline, OFFLINE_ERROR_MESSAGE) + + if (typeof protocol === 'function') { + callback = protocol + protocol = undefined + } + + callback(new Error('not implemented yet')) + } + + dialByMultiaddr (maddr, protocol, callback) { + assert(this.isOnline, OFFLINE_ERROR_MESSAGE) + + if (typeof protocol === 'function') { + callback = protocol + protocol = undefined + } + + if (typeof maddr === 'string') { + maddr = multiaddr(maddr) + } + + if (!mafmt.IPFS.matches(maddr.toString())) { + return callback(new Error('multiaddr not valid')) + } + + const ipfsIdB58String = maddr.stringTuples().filter((tuple) => { + if (tuple[0] === IPFS_CODE) { + return true + } + })[0][1] + + let peer + try { + peer = this.peerBook.getByB58String(ipfsIdB58String) + } catch (err) { + peer = new PeerInfo(PeerId.createFromB58String(ipfsIdB58String)) + } + + peer.multiaddr.add(maddr) + this.dialByPeerInfo(peer, protocol, callback) + } + + dialByPeerInfo (peer, protocol, callback) { + assert(this.isOnline, OFFLINE_ERROR_MESSAGE) + + if (typeof protocol === 'function') { + callback = protocol + protocol = undefined + } + + this.swarm.dial(peer, protocol, (err, conn) => { + if (err) { + return callback(err) + } + this.peerBook.put(peer) + callback(null, conn) + }) + } + + // + // Disconnecting (hangUp) methods + // + + hangUpById (id, callback) { + // TODO + callback(new Error('not implemented yet')) + } + + hangUpByMultiaddr (maddr, callback) { + assert(this.isOnline, OFFLINE_ERROR_MESSAGE) + + if (typeof maddr === 'string') { + maddr = multiaddr(maddr) + } + + if (!mafmt.IPFS.matches(maddr.toString())) { + return callback(new Error('multiaddr not valid')) + } + + const ipfsIdB58String = maddr.stringTuples().filter((tuple) => { + if (tuple[0] === IPFS_CODE) { + return true + } + })[0][1] + + try { + const pi = this.peerBook.getByB58String(ipfsIdB58String) + this.hangUpByPeerInfo(pi, callback) + } catch (err) { + // already disconnected + callback() + } + } + + hangUpByPeerInfo (peer, callback) { + assert(this.isOnline, OFFLINE_ERROR_MESSAGE) + + this.peerBook.removeByB58String(peer.id.toB58String()) + this.swarm.hangUp(peer, callback) + } + + // + // Protocol multiplexing handling + // + + handle (protocol, handlerFunc, matchFunc) { + this.swarm.handle(protocol, handlerFunc, matchFunc) + } + + unhandle (protocol) { + this.swarm.unhandle(protocol) + } +} + +module.exports = { + Node: Node } From e10ec13c334e133432df4f2416d94630f8499e3f Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 26 Nov 2016 03:12:30 +0100 Subject: [PATCH 4/6] feat: add the CI stuffs --- .gitignore | 9 +++++++-- .npmignore | 28 ++++++++++++++++++++++++++++ .travis.yml | 40 ++++++++++++++++++++++++++++++---------- circle.yml | 12 ++++++++++++ 4 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 .npmignore create mode 100644 circle.yml diff --git a/.gitignore b/.gitignore index 5b1fd197ff..c2ba63700d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Logs logs *.log +npm-debug.log* # Runtime data pids @@ -23,8 +24,12 @@ coverage build/Release # Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + dist -lib \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..c57cab761a --- /dev/null +++ b/.npmignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3828e30dcd..4fe6550d7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,36 @@ -use_sudo: false +sudo: false language: node_js -node_js: - - 4 - - 5 - -branches: - only: - - master +matrix: + include: + - node_js: 4 + env: CXX=g++-4.8 + - node_js: 6 + env: + - SAUCE=true + - CXX=g++-4.8 + - node_js: stable + env: CXX=g++-4.8 +# Make sure we have new NPM. before_install: - - npm i -g npm - # Workaround for a permissions issue with Travis virtual machine images + - npm install -g npm + script: - npm run lint - npm test + - npm run coverage + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +after_success: + - npm run coverage-publish + +addons: + firefox: 'latest' + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 \ No newline at end of file diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000000..434211a760 --- /dev/null +++ b/circle.yml @@ -0,0 +1,12 @@ +machine: + node: + version: stable + +dependencies: + pre: + - google-chrome --version + - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + - sudo apt-get update + - sudo apt-get --only-upgrade install google-chrome-stable + - google-chrome --version From 40fdc4147cb173f8f8a1b12497633c230a21cc04 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 27 Nov 2016 18:20:25 +0000 Subject: [PATCH 5/6] feat: support websockets, even if no listener is added --- src/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.js b/src/index.js index b70e12333c..fc2e8ccc8f 100644 --- a/src/index.js +++ b/src/index.js @@ -83,13 +83,22 @@ class Node { if (!this.modules.transport) { return callback(new Error('no transports were present')) } + + let ws let transports = this.modules.transport + transports = Array.isArray(transports) ? transports : [transports] const multiaddrs = this.peerInfo.multiaddrs + transports.forEach((transport) => { if (transport.filter(multiaddrs).length > 0) { this.swarm.transport.add( transport.tag || transport.constructor.name, transport) + } else if (transport.constructor && + transport.constructor.name === 'WebSockets') { + // TODO find a cleaner way to signal that a transport is always + // used for dialing, even if no listener + ws = transport } }) @@ -97,6 +106,9 @@ class Node { if (err) { return callback(err) } + if (ws) { + this.swarm.transport.add(ws.tag || ws.constructor.name, ws) + } this.isOnline = true callback() From 3db3dca98b085e0097e391938fa07f5ac8a65c85 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 27 Nov 2016 18:23:50 +0000 Subject: [PATCH 6/6] docs: update examples folder --- examples/README.md | 6 ++++++ examples/{old-to-refactor => archived}/README.md | 0 examples/{old-to-refactor => archived}/node-1.js | 0 examples/{old-to-refactor => archived}/node-2.js | 0 examples/browser-chat/.gitkeep | 0 examples/node-chat/.gitkeep | 0 6 files changed, 6 insertions(+) create mode 100644 examples/README.md rename examples/{old-to-refactor => archived}/README.md (100%) rename examples/{old-to-refactor => archived}/node-1.js (100%) rename examples/{old-to-refactor => archived}/node-2.js (100%) create mode 100644 examples/browser-chat/.gitkeep create mode 100644 examples/node-chat/.gitkeep diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000000..fc8ae2e299 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,6 @@ +### Examples list + +Here are some examples built with libp2p bundles. + +- https://github.com/ipfs/js-libp2p-ipfs/tree/master/examples/echo +- https://github.com/ipfs/js-libp2p-ipfs/tree/master/examples/chat diff --git a/examples/old-to-refactor/README.md b/examples/archived/README.md similarity index 100% rename from examples/old-to-refactor/README.md rename to examples/archived/README.md diff --git a/examples/old-to-refactor/node-1.js b/examples/archived/node-1.js similarity index 100% rename from examples/old-to-refactor/node-1.js rename to examples/archived/node-1.js diff --git a/examples/old-to-refactor/node-2.js b/examples/archived/node-2.js similarity index 100% rename from examples/old-to-refactor/node-2.js rename to examples/archived/node-2.js diff --git a/examples/browser-chat/.gitkeep b/examples/browser-chat/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/node-chat/.gitkeep b/examples/node-chat/.gitkeep new file mode 100644 index 0000000000..e69de29bb2