• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H12-Jan-2021-272259

compat/H12-Jan-2021-612577

pb/H12-Jan-2021-10,4739,991

.codecov.ymlH A D12-Jan-202136 32

.gitignoreH A D12-Jan-202136 43

.travis.ymlH A D12-Jan-2021411 2720

LICENSEH A D12-Jan-2021507 87

LICENSE-APACHEH A D12-Jan-2021519 53

LICENSE-MITH A D12-Jan-20211 KiB1916

README.mdH A D12-Jan-20216.2 KiB148111

blacklist.goH A D12-Jan-20211.3 KiB6546

blacklist_test.goH A D12-Jan-20212.3 KiB12693

codecov.ymlH A D12-Jan-202143 43

comm.goH A D12-Jan-20213.9 KiB206171

compat_test.goH A D12-Jan-20211.8 KiB8474

discovery.goH A D12-Jan-20218.4 KiB348263

discovery_test.goH A D12-Jan-20217 KiB309247

doc.goH A D12-Jan-20211.3 KiB281

floodsub.goH A D12-Jan-20212.3 KiB10982

floodsub_test.goH A D12-Jan-202126.1 KiB1,257955

go.modH A D12-Jan-2021582 1916

go.sumH A D12-Jan-202141.8 KiB445444

gossip_tracer.goH A D12-Jan-20214.3 KiB179125

gossip_tracer_test.goH A D12-Jan-20212.5 KiB10777

gossipsub.goH A D12-Jan-202151.8 KiB1,8301,270

gossipsub_connmgr_test.goH A D12-Jan-20214.8 KiB173126

gossipsub_spam_test.goH A D12-Jan-202121.4 KiB758532

gossipsub_test.goH A D12-Jan-202152.2 KiB2,2111,685

maintainer.jsonH A D12-Jan-2021242 1111

mcache.goH A D12-Jan-20212.4 KiB10578

mcache_test.goH A D12-Jan-20213 KiB168138

notify.goH A D12-Jan-2021875 4433

peer_gater.goH A D12-Jan-202111.2 KiB439315

peer_gater_test.goH A D12-Jan-20212.3 KiB129105

pubsub.goH A D12-Jan-202133.9 KiB1,280874

randomsub.goH A D12-Jan-20213.2 KiB169133

randomsub_test.goH A D12-Jan-20213.8 KiB195156

score.goH A D12-Jan-202126.2 KiB1,038710

score_params.goH A D12-Jan-202111.7 KiB287162

score_params_test.goH A D12-Jan-202111.2 KiB265242

score_test.goH A D12-Jan-202129.6 KiB1,021771

sign.goH A D12-Jan-20213.4 KiB13996

sign_test.goH A D12-Jan-2021813 4437

subscription.goH A D12-Jan-20211,006 4834

subscription_filter.goH A D12-Jan-20214.6 KiB15091

subscription_filter_test.goH A D12-Jan-20214.8 KiB211184

tag_tracer.goH A D12-Jan-20216.6 KiB256183

tag_tracer_test.goH A D12-Jan-20216.4 KiB247177

topic.goH A D12-Jan-20218 KiB393292

topic_test.goH A D12-Jan-202115.9 KiB749581

trace.goH A D12-Jan-20218.6 KiB479395

trace_test.goH A D12-Jan-20216.3 KiB322259

tracer.goH A D12-Jan-20216.2 KiB304237

validation.goH A D12-Jan-202113.7 KiB507362

validation_test.goH A D12-Jan-20216.6 KiB296243

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