README.md 21.1 KB
Newer Older
1

2
<h1 align="center">
David Dias's avatar
David Dias committed
3
  <a href="libp2p.io"><img width="250" src="https://github.com/libp2p/libp2p/blob/master/logo/black-bg-2.png?raw=true" alt="libp2p hex logo" /></a>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</h1>

<h3 align="center">The Go implementation of the libp2p Networking Stack.</h3>

<p align="center">
  <a href="http://ipn.io"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
  <a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-blue.svg?style=flat-square" /></a>
  <a href="http://webchat.freenode.net/?channels=%23ipfs"><img src="https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square" /></a>
  <a href="https://waffle.io/libp2p/libp2p"><img src="https://img.shields.io/badge/pm-waffle-blue.svg?style=flat-square" /></a>
</p>

<p align="center">
  <a href="https://travis-ci.org/libp2p/go-libp2p"><img src="https://travis-ci.org/libp2p/go-libp2p.svg?branch=master" /></a>
  <!--<a href="https://circleci.com/gh/libp2p/go-libp2p"><img src="https://circleci.com/gh/libp2p/go-libp2p.svg?style=svg" /></a>-->
18
  <!--<a href="https://coveralls.io/github/libp2p/go-libp2p?branch=master"><img src="https://coveralls.io/repos/github/libp2p/go-libp2p/badge.svg?branch=master"></a>-->
19
20
21
22
23
24
25
26
27
28
29
  <br>
  <a href="https://github.com/RichardLitt/standard-readme"><img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" /></a>
  <a href="https://godoc.org/github.com/libp2p/go-libp2p"><img src="https://godoc.org/github.com/ipfs/go-libp2p?status.svg" /></a>
  <a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.8.0-orange.svg?style=flat-square" /></a>
  <br>
</p>

# Project status

[![Throughput Graph](https://graphs.waffle.io/libp2p/go-libp2p/throughput.svg)](https://waffle.io/libp2p/go-libp2p/metrics/throughput)

David Dias's avatar
David Dias committed
30
31
[**`Weekly Core Dev Calls`**](https://github.com/ipfs/pm/issues/674)

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Table of Contents

- [Background](#background)
- [Bundles](#bundles)
- [Usage](#usage)
  - [Install](#install)
  - [API](#api)
  - [Examples](#examples)
- [Development](#development)
  - [Tests](#tests)
  - [Packages](#packages)
- [Contribute](#contribute)
- [License](#license)

## Background
47

48
[libp2p](https://github.com/libp2p/specs) is a networking stack and library modularized out of [The IPFS Project](https://github.com/ipfs/ipfs), and bundled separately for other tools to use.
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
49
>
50
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.
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
51
52
53
>
> 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. But in the meantime, check out
>
David Dias's avatar
David Dias committed
54
> - [**The libp2p Specification**](https://github.com/libp2p/specs)
55
56
> - [**go-libp2p implementation**](https://github.com/libp2p/go-libp2p)
> - [**js-libp2p implementation**](https://github.com/libp2p/js-libp2p)
57

58

59
## Bundles
60

61
62
63
There is currently only one bundle of `go-libp2p`, this package. This bundle is used by [`go-ipfs`](https://github.com/ipfs/go-ipfs).

## Usage
64

David Dias's avatar
David Dias committed
65
`go-libp2p` repo is a place holder for the list of Go modules that compose Go libp2p, as well as its entry point.
66

67
### Install
68
69

```bash
qidu's avatar
qidu committed
70
> go get -u -d github.com/libp2p/go-libp2p/...
71
72
73
> cd $GOPATH/src/github.com/libp2p/go-libp2p
> make
> make deps
74
```
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
75

76
77
78
79
80
### API

[![GoDoc](https://godoc.org/github.com/ipfs/go-libp2p?status.svg)](https://godoc.org/github.com/libp2p/go-libp2p)

### Examples
David Dias's avatar
David Dias committed
81

82
Examples can be found in the [examples repo](https://github.com/libp2p/go-libp2p-examples).
David Dias's avatar
David Dias committed
83

84
## Development
85

86
87
### Dependencies

David Dias's avatar
David Dias committed
88
While developing, you need to use [gx to install and link your dependencies](https://github.com/whyrusleeping/gx#dependencies), to do that, run:
89
90
91
92
93
94
95
96
97
98
99

```sh
> make deps
```

Before commiting and pushing to Github, make sure to rewind the gx'ify of dependencies. You can do that with:

```sh
> make publish
```

100
101
### Tests

David Dias's avatar
David Dias committed
102
Running of individual tests is done through `gx test <path to test>`
103

104
105
106
107
108
109
```bash
$ cd $GOPATH/src/github.com/libp2p/go-libp2p
$ make deps
$ gx test ./p2p/<path of module you want to run tests for>
```

110
111
### Packages

Henrique Dias's avatar
Henrique Dias committed
112
113
> This table is generated using the module [`package-table`](https://github.com/ipfs-shipyard/package-table) with `package-table --data=package-list.json`.

David Dias's avatar
David Dias committed
114
List of packages currently in existence for libp2p:
115

Henrique Dias's avatar
Henrique Dias committed
116
117
| Name | CI/Travis | CI/Jenkins | Coverage |
| ---------|---------|---------|--------- |
Henrique Dias's avatar
Henrique Dias committed
118
| **Libp2p** |
Henrique Dias's avatar
Henrique Dias committed
119
| [`interface-libp2p`](//github.com/libp2p/interface-libp2p) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
120
| [`libp2p`](//github.com/libp2p/go-libp2p) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p) |
Henrique Dias's avatar
Henrique Dias committed
121
| **Connection** |
Henrique Dias's avatar
Henrique Dias committed
122
| [`interface-connection`](//github.com/libp2p/interface-connection) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
123
| [`go-libp2p-net`](//github.com/libp2p/go-libp2p-net) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-net.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-net) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-net/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-net/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-net/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-net) |
Henrique Dias's avatar
Henrique Dias committed
124
| **Transport** |
Henrique Dias's avatar
Henrique Dias committed
125
| [`interface-transport`](//github.com/libp2p/interface-transport) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
126
127
128
129
| [`go-ws-transport`](//github.com/libp2p/go-ws-transport) | [![Travis CI](https://travis-ci.org/libp2p/go-ws-transport.svg?branch=master)](https://travis-ci.org/libp2p/go-ws-transport) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-ws-transport/master)](https://ci.ipfs.team/job/libp2p/job/go-ws-transport/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-ws-transport/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-ws-transport) |
| [`go-libp2p-transport`](//github.com/libp2p/go-libp2p-transport) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-transport.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-transport) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-transport/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-transport/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-transport/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-transport) |
| [`go-tcp-transport`](//github.com/libp2p/go-tcp-transport) | [![Travis CI](https://travis-ci.org/libp2p/go-tcp-transport.svg?branch=master)](https://travis-ci.org/libp2p/go-tcp-transport) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-tcp-transport/master)](https://ci.ipfs.team/job/libp2p/job/go-tcp-transport/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-tcp-transport/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-tcp-transport) |
| [`go-libp2p-transport-upgrader`](//github.com/libp2p/go-libp2p-transport-upgrader) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-transport-upgrader.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-transport-upgrader) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-transport-upgrader/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-transport-upgrader/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-transport-upgrader/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-transport-upgrader) |
Henrique Dias's avatar
Henrique Dias committed
130
| **Crypto Channels** |
Henrique Dias's avatar
Henrique Dias committed
131
| [`go-libp2p-secio`](//github.com/libp2p/go-libp2p-secio) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-secio.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-secio) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-secio/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-secio/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-secio/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-secio) |
Henrique Dias's avatar
Henrique Dias committed
132
| **Stream Muxers** |
Henrique Dias's avatar
Henrique Dias committed
133
| [`go-stream-muxer`](//github.com/libp2p/go-stream-muxer) | [![Travis CI](https://travis-ci.org/libp2p/go-stream-muxer.svg?branch=master)](https://travis-ci.org/libp2p/go-stream-muxer) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-stream-muxer/master)](https://ci.ipfs.team/job/libp2p/job/go-stream-muxer/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-stream-muxer/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-stream-muxer) |
Henrique Dias's avatar
Henrique Dias committed
134
| **Discovery** |
Henrique Dias's avatar
Henrique Dias committed
135
| [`interface-peer-discovery`](//github.com/libp2p/interface-peer-discovery) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
136
| **NAT Traversal** |
Henrique Dias's avatar
Henrique Dias committed
137
138
| [`go-libp2p-circuit`](//github.com/libp2p/go-libp2p-circuit) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-circuit.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-circuit) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-circuit/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-circuit/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-circuit/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-circuit) |
| [`go-libp2p-nat`](//github.com/libp2p/go-libp2p-nat) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-nat.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-nat) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-nat/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-nat/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-nat/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-nat) |
Henrique Dias's avatar
Henrique Dias committed
139
| **Data Types** |
Henrique Dias's avatar
Henrique Dias committed
140
141
142
| [`go-libp2p-peer`](//github.com/libp2p/go-libp2p-peer) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-peer.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-peer) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-peer/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-peer/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-peer/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-peer) |
| [`go-libp2p-peerstore`](//github.com/libp2p/go-libp2p-peerstore) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-peerstore.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-peerstore) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-peerstore/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-peerstore/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-peerstore/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-peerstore) |
| [`go-libp2p-protocol`](//github.com/libp2p/go-libp2p-protocol) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-protocol.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-protocol) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-protocol/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-protocol/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-protocol/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-protocol) |
Henrique Dias's avatar
Henrique Dias committed
143
| **Content Routing** |
Henrique Dias's avatar
Henrique Dias committed
144
| [`interface-content-routing`](//github.com/libp2p/interface-content-routing) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
145
| **Peer Routing** |
Henrique Dias's avatar
Henrique Dias committed
146
| [`interface-peer-routing`](//github.com/libp2p/interface-peer-routing) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
147
| **Record Store** |
Henrique Dias's avatar
Henrique Dias committed
148
| [`interface-record-store`](//github.com/libp2p/interface-record-store) |  |  |  |
Henrique Dias's avatar
Henrique Dias committed
149
| **Miscellaneous** |
Henrique Dias's avatar
Henrique Dias committed
150
151
152
153
154
155
156
157
158
| [`go-libp2p-crypto`](//github.com/libp2p/go-libp2p-crypto) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-crypto.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-crypto) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-crypto/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-crypto/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-crypto/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-crypto) |
| [`go-libp2p-interface-connmgr`](//github.com/libp2p/go-libp2p-interface-connmgr) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-interface-connmgr.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-interface-connmgr) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-interface-connmgr/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-interface-connmgr/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-interface-connmgr/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-interface-connmgr) |
| [`go-libp2p-swarm`](//github.com/libp2p/go-libp2p-swarm) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-swarm.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-swarm) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-swarm/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-swarm/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-swarm/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-swarm) |
| [`go-libp2p-host`](//github.com/libp2p/go-libp2p-host) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-host.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-host) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-host/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-host/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-host/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-host) |
| [`go-libp2p-blankhost`](//github.com/libp2p/go-libp2p-blankhost) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-blankhost.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-blankhost) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-blankhost/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-blankhost/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-blankhost/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-blankhost) |
| [`go-conn-security-multistream`](//github.com/libp2p/go-conn-security-multistream) | [![Travis CI](https://travis-ci.org/libp2p/go-conn-security-multistream.svg?branch=master)](https://travis-ci.org/libp2p/go-conn-security-multistream) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-conn-security-multistream/master)](https://ci.ipfs.team/job/libp2p/job/go-conn-security-multistream/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-conn-security-multistream/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-conn-security-multistream) |
| [`go-conn-security`](//github.com/libp2p/go-conn-security) | [![Travis CI](https://travis-ci.org/libp2p/go-conn-security.svg?branch=master)](https://travis-ci.org/libp2p/go-conn-security) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-conn-security/master)](https://ci.ipfs.team/job/libp2p/job/go-conn-security/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-conn-security/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-conn-security) |
| [`go-libp2p-interface-pnet`](//github.com/libp2p/go-libp2p-interface-pnet) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-interface-pnet.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-interface-pnet) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-interface-pnet/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-interface-pnet/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-interface-pnet/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-interface-pnet) |
| [`go-libp2p-metrics`](//github.com/libp2p/go-libp2p-metrics) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-metrics.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-metrics) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-metrics/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-metrics/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-metrics/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-metrics) |
Henrique Dias's avatar
Henrique Dias committed
159
| **Utilities** |
Henrique Dias's avatar
Henrique Dias committed
160
161
162
163
| [`go-libp2p-loggables`](//github.com/libp2p/go-libp2p-loggables) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-loggables.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-loggables) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-loggables/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-loggables/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-loggables/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-loggables) |
| [`go-maddr-filter`](//github.com/libp2p/go-maddr-filter) | [![Travis CI](https://travis-ci.org/libp2p/go-maddr-filter.svg?branch=master)](https://travis-ci.org/libp2p/go-maddr-filter) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-maddr-filter/master)](https://ci.ipfs.team/job/libp2p/job/go-maddr-filter/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-maddr-filter/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-maddr-filter) |
| [`go-libp2p-netutil`](//github.com/libp2p/go-libp2p-netutil) | [![Travis CI](https://travis-ci.org/libp2p/go-libp2p-netutil.svg?branch=master)](https://travis-ci.org/libp2p/go-libp2p-netutil) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-libp2p-netutil/master)](https://ci.ipfs.team/job/libp2p/job/go-libp2p-netutil/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-libp2p-netutil/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-libp2p-netutil) |
| [`go-testutil`](//github.com/libp2p/go-testutil) | [![Travis CI](https://travis-ci.org/libp2p/go-testutil.svg?branch=master)](https://travis-ci.org/libp2p/go-testutil) | [![jenkins](https://ci.ipfs.team/buildStatus/icon?job=libp2p/go-testutil/master)](https://ci.ipfs.team/job/libp2p/job/go-testutil/job/master/) | [![codecov](https://codecov.io/gh/libp2p/go-testutil/branch/master/graph/badge.svg)](https://codecov.io/gh/libp2p/go-testutil) |
Henrique Dias's avatar
Henrique Dias committed
164

165
166
167
168
169
170
171
172
# Contribute

go-libp2p is part of [The IPFS Project](https://github.com/ipfs/ipfs), and is MIT licensed open source software. We welcome contributions big and small! Take a look at the [community contributing notes](https://github.com/ipfs/community/blob/master/contributing.md). Please make sure to check the [issues](https://github.com/ipfs/go-libp2p/issues). Search the closed ones before reporting things, and help us with the open ones.

Guidelines:

- read the [libp2p spec](https://github.com/libp2p/specs)
- please make branches + pull-request, even if working on the main repository
David Dias's avatar
David Dias committed
173
- ask questions or talk about things in [Issues](https://github.com/libp2p/go-libp2p/issues) or #ipfs on freenode.
174
175
176
177
178
179
180
181
182
183
- ensure you are able to contribute (no legal issues please-- we use the DCO)
- run `go fmt` before pushing any code
- run `golint` and `go vet` too -- some things (like protobuf files) are expected to fail.
- get in touch with @jbenet and @diasdavid about how best to contribute
- have fun!

There's a few things you can do right now to help out:
 - Go through the modules below and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrasture behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
 - **Perform code reviews**.
 - **Add tests**. There can never be enough tests.
Lars Gierth's avatar
Lars Gierth committed
184

185
## Modularizing go-libp2p
Lars Gierth's avatar
Lars Gierth committed
186

187
We have currently a work in progress of modularizing go-libp2p from a repo monolith to several packages in different repos that can be reused for other projects of swapped for custom libp2p builds.
Lars Gierth's avatar
Lars Gierth committed
188

189
We want to maintain history, so we'll use git-subtree for extracting packages. Find instructions below:
Lars Gierth's avatar
Lars Gierth committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

```sh
# 1) create the extracted tree (has the directory specified as -P as its root)
> cd go-libp2p/
> git subtree split -P p2p/crypto/secio/ -b libp2p-secio
62b0a5c21574bcbe06c422785cd5feff378ae5bd
# important to delete the tree now, so that outdated imports fail in step 5
> git rm -r p2p/crypto/secio/
> git commit
> cd ../

# 2) make the new repo
> mkdir go-libp2p-secio
> cd go-libp2p-secio/
> git init && git commit --allow-empty

# 3) fetch the extracted tree from the previous repo
> git remote add libp2p ../go-libp2p
> git fetch libp2p
> git reset --hard libp2p/libp2p-secio

# 4) update self import paths
> sed -someflagsidontknow 'go-libp2p/p2p/crypto/secio' 'golibp2p-secio'
> git commit

# 5) create package.json and check all imports are correct
> vim package.json
> gx --verbose install --global
> gx-go rewrite
> go test ./...
> gx-go rewrite --undo
> git commit

# 4) make the package ready
> vim README.md LICENSE
> git commit

# 5) bump the version separately
> vim package.json
> gx publish
> git add package.json .gx/
> git commit -m 'Publish 1.2.3'

# 6) clean up and push
> git remote rm libp2p
> git push origin master
```