|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| .github/ | H | 12-Jan-2021 | - | 272 | 259 |
| compat/ | H | 12-Jan-2021 | - | 612 | 577 |
| pb/ | H | 12-Jan-2021 | - | 10,473 | 9,991 |
| .codecov.yml | H A D | 12-Jan-2021 | 36 | 3 | 2 |
| .gitignore | H A D | 12-Jan-2021 | 36 | 4 | 3 |
| .travis.yml | H A D | 12-Jan-2021 | 411 | 27 | 20 |
| LICENSE | H A D | 12-Jan-2021 | 507 | 8 | 7 |
| LICENSE-APACHE | H A D | 12-Jan-2021 | 519 | 5 | 3 |
| LICENSE-MIT | H A D | 12-Jan-2021 | 1 KiB | 19 | 16 |
| README.md | H A D | 12-Jan-2021 | 6.2 KiB | 148 | 111 |
| blacklist.go | H A D | 12-Jan-2021 | 1.3 KiB | 65 | 46 |
| blacklist_test.go | H A D | 12-Jan-2021 | 2.3 KiB | 126 | 93 |
| codecov.yml | H A D | 12-Jan-2021 | 43 | 4 | 3 |
| comm.go | H A D | 12-Jan-2021 | 3.9 KiB | 206 | 171 |
| compat_test.go | H A D | 12-Jan-2021 | 1.8 KiB | 84 | 74 |
| discovery.go | H A D | 12-Jan-2021 | 8.4 KiB | 348 | 263 |
| discovery_test.go | H A D | 12-Jan-2021 | 7 KiB | 309 | 247 |
| doc.go | H A D | 12-Jan-2021 | 1.3 KiB | 28 | 1 |
| floodsub.go | H A D | 12-Jan-2021 | 2.3 KiB | 109 | 82 |
| floodsub_test.go | H A D | 12-Jan-2021 | 26.1 KiB | 1,257 | 955 |
| go.mod | H A D | 12-Jan-2021 | 582 | 19 | 16 |
| go.sum | H A D | 12-Jan-2021 | 41.8 KiB | 445 | 444 |
| gossip_tracer.go | H A D | 12-Jan-2021 | 4.3 KiB | 179 | 125 |
| gossip_tracer_test.go | H A D | 12-Jan-2021 | 2.5 KiB | 107 | 77 |
| gossipsub.go | H A D | 12-Jan-2021 | 51.8 KiB | 1,830 | 1,270 |
| gossipsub_connmgr_test.go | H A D | 12-Jan-2021 | 4.8 KiB | 173 | 126 |
| gossipsub_spam_test.go | H A D | 12-Jan-2021 | 21.4 KiB | 758 | 532 |
| gossipsub_test.go | H A D | 12-Jan-2021 | 52.2 KiB | 2,211 | 1,685 |
| maintainer.json | H A D | 12-Jan-2021 | 242 | 11 | 11 |
| mcache.go | H A D | 12-Jan-2021 | 2.4 KiB | 105 | 78 |
| mcache_test.go | H A D | 12-Jan-2021 | 3 KiB | 168 | 138 |
| notify.go | H A D | 12-Jan-2021 | 875 | 44 | 33 |
| peer_gater.go | H A D | 12-Jan-2021 | 11.2 KiB | 439 | 315 |
| peer_gater_test.go | H A D | 12-Jan-2021 | 2.3 KiB | 129 | 105 |
| pubsub.go | H A D | 12-Jan-2021 | 33.9 KiB | 1,280 | 874 |
| randomsub.go | H A D | 12-Jan-2021 | 3.2 KiB | 169 | 133 |
| randomsub_test.go | H A D | 12-Jan-2021 | 3.8 KiB | 195 | 156 |
| score.go | H A D | 12-Jan-2021 | 26.2 KiB | 1,038 | 710 |
| score_params.go | H A D | 12-Jan-2021 | 11.7 KiB | 287 | 162 |
| score_params_test.go | H A D | 12-Jan-2021 | 11.2 KiB | 265 | 242 |
| score_test.go | H A D | 12-Jan-2021 | 29.6 KiB | 1,021 | 771 |
| sign.go | H A D | 12-Jan-2021 | 3.4 KiB | 139 | 96 |
| sign_test.go | H A D | 12-Jan-2021 | 813 | 44 | 37 |
| subscription.go | H A D | 12-Jan-2021 | 1,006 | 48 | 34 |
| subscription_filter.go | H A D | 12-Jan-2021 | 4.6 KiB | 150 | 91 |
| subscription_filter_test.go | H A D | 12-Jan-2021 | 4.8 KiB | 211 | 184 |
| tag_tracer.go | H A D | 12-Jan-2021 | 6.6 KiB | 256 | 183 |
| tag_tracer_test.go | H A D | 12-Jan-2021 | 6.4 KiB | 247 | 177 |
| topic.go | H A D | 12-Jan-2021 | 8 KiB | 393 | 292 |
| topic_test.go | H A D | 12-Jan-2021 | 15.9 KiB | 749 | 581 |
| trace.go | H A D | 12-Jan-2021 | 8.6 KiB | 479 | 395 |
| trace_test.go | H A D | 12-Jan-2021 | 6.3 KiB | 322 | 259 |
| tracer.go | H A D | 12-Jan-2021 | 6.2 KiB | 304 | 237 |
| validation.go | H A D | 12-Jan-2021 | 13.7 KiB | 507 | 362 |
| validation_test.go | H A D | 12-Jan-2021 | 6.6 KiB | 296 | 243 |
README.md
1# go-libp2p-pubsub
2
3<p align="left">
4 <a href="http://protocol.ai"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
5 <a href="http://libp2p.io/"><img src="https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square" /></a>
6 <a href="http://webchat.freenode.net/?channels=%23libp2p"><img src="https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square" /></a>
7 <a href="https://discuss.libp2p.io"><img src="https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square"/></a>
8</p>
9
10<p align="left">
11 <a href="https://travis-ci.com/libp2p/go-libp2p-pubsub"><img src="https://travis-ci.com/libp2p/go-libp2p-pubsub.svg?branch=master"></a>
12 <a href="https://codecov.io/gh/libp2p/go-libp2p-pubsub"><img src="https://codecov.io/gh/libp2p/go-libp2p-pubsub/branch/master/graph/badge.svg"></a>
13 <a href="https://goreportcard.com/report/github.com/libp2p/go-libp2p-pubsub"><img src="https://goreportcard.com/badge/github.com/libp2p/go-libp2p-pubsub" /></a>
14 <a href="https://github.com/RichardLitt/standard-readme"><img src="https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square" /></a>
15 <a href="https://godoc.org/github.com/libp2p/go-libp2p-pubsub"><img src="http://img.shields.io/badge/godoc-reference-5272B4.svg?style=flat-square" /></a>
16 <a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.14.0-orange.svg?style=flat-square" /></a>
17 <br>
18</p>
19
20This repo contains the canonical pubsub implementation for libp2p. We currently provide three message router options:
21- Floodsub, which is the baseline flooding protocol.
22- Randomsub, which is a simple probabilistic router that propagates to random subsets of peers.
23- Gossipsub, which is a more advanced router with mesh formation and gossip propagation. See [spec](https://github.com/libp2p/specs/tree/master/pubsub/gossipsub) and [implementation](https://github.com/libp2p/go-libp2p-pubsub/blob/master/gossipsub.go) for more details.
24
25**PSA: The Hardening Extensions for Gossipsub (Gossipsub V1.1) can be found under development at https://github.com/libp2p/go-libp2p-pubsub/pull/263**
26
27## Repo Lead Maintainer
28
29[@vyzo](https://github.com/vyzo/)
30
31> This repo follows the [Repo Lead Maintainer Protocol](https://github.com/ipfs/team-mgmt/blob/master/LEAD_MAINTAINER_PROTOCOL.md)
32
33## Table of Contents
34
35<!-- START doctoc generated TOC please keep comment here to allow auto update -->
36<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
37
38- [Install](#install)
39- [Usage](#usage)
40- [Implementations](#implementations)
41- [Documentation](#documentation)
42- [Tracing](#tracing)
43- [Contribute](#contribute)
44- [License](#license)
45
46<!-- END doctoc generated TOC please keep comment here to allow auto update -->
47
48## Install
49
50```
51go get github.com/libp2p/go-libp2p-pubsub
52```
53
54## Usage
55
56To be used for messaging in p2p instrastructure (as part of libp2p) such as IPFS, Ethereum, other blockchains, etc.
57
58### Example
59
60https://github.com/libp2p/go-libp2p-examples/tree/master/pubsub
61
62## Documentation
63
64See the [libp2p specs](https://github.com/libp2p/specs/tree/master/pubsub) for high level documentation and [godoc](https://godoc.org/github.com/libp2p/go-libp2p-pubsub) for API documentation.
65
66### In this repo, you will find
67
68```
69.
70├── LICENSE
71├── README.md
72# Regular Golang repo set up
73├── codecov.yml
74├── pb
75├── go.mod
76├── go.sum
77├── doc.go
78# PubSub base
79├── pubsub.go
80├── blacklist.go
81├── notify.go
82├── comm.go
83├── discovery.go
84├── sign.go
85├── subscription.go
86├── topic.go
87├── trace.go
88├── tracer.go
89├── validation.go
90# Floodsub router
91├── floodsub.go
92# Randomsub router
93├── randomsub.go
94# Gossipsub router
95├── gossipsub.go
96├── score.go
97├── score_params.go
98└── mcache.go
99```
100
101### Tracing
102
103The pubsub system supports _tracing_, which collects all events pertaining to the internals of the system. This allows you to recreate the complete message flow and state of the system for analysis purposes.
104
105To enable tracing, instantiate the pubsub system using the `WithEventTracer` option; the option accepts a tracer with three available implementations in-package (trace to json, pb, or a remote peer).
106If you want to trace using a remote peer, you can do so using the `traced` daemon from [go-libp2p-pubsub-tracer](https://github.com/libp2p/go-libp2p-pubsub-tracer). The package also includes a utility program, `tracestat`, for analyzing the traces collected by the daemon.
107
108For instance, to capture the trace as a json file, you can use the following option:
109```go
110pubsub.NewGossipSub(..., pubsub.NewEventTracer(pubsub.NewJSONTracer("/path/to/trace.json")))
111```
112
113To capture the trace as a protobuf, you can use the following option:
114```go
115pubsub.NewGossipSub(..., pubsub.NewEventTracer(pubsub.NewPBTracer("/path/to/trace.pb")))
116```
117
118Finally, to use the remote tracer, you can use the following incantations:
119```go
120// assuming that your tracer runs in x.x.x.x and has a peer ID of QmTracer
121pi, err := peer.AddrInfoFromP2pAddr(ma.StringCast("/ip4/x.x.x.x/tcp/4001/p2p/QmTracer"))
122if err != nil {
123 panic(err)
124}
125
126tracer, err := pubsub.NewRemoteTracer(ctx, host, pi)
127if err != nil {
128 panic(err)
129}
130
131ps, err := pubsub.NewGossipSub(..., pubsub.WithEventTracer(tracer))
132```
133
134## Contribute
135
136Contributions welcome. Please check out [the issues](https://github.com/libp2p/go-libp2p-pubsub/issues).
137
138Check out our [contributing document](https://github.com/libp2p/community/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
139
140Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
141
142## License
143
144The go-libp2p-pubsub project is dual-licensed under Apache 2.0 and MIT terms:
145
146- Apache License, Version 2.0, ([LICENSE-APACHE](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
147- MIT license ([LICENSE-MIT](./LICENSE-MIT) or http://opensource.org/licenses/MIT)
148