The PubSub implementation for go-libp2p https://github.com/libp2p/specs/tree/master/pubsub
Go to file
Richard Ramos 91851dda63
refactor: removing event emitter
2021-10-06 11:19:08 -04:00
.github Update label-syncer.yml 2020-03-25 08:08:35 +00:00
compat remove multi-topic message support 2020-10-08 20:18:21 +03:00
pb add receivedFrom field in delivery trace 2020-12-16 20:17:23 +02:00
.codecov.yml disable codecov annotations, makes things unreadable 2020-09-07 13:38:02 +03:00
.gitignore gx publish v0.5.0 2016-09-14 15:27:34 -07:00
.travis.yml revert travis timeout change 2020-05-19 19:26:53 +03:00
LICENSE docs: Tidy up (#271) 2020-03-25 08:42:05 +00:00
LICENSE-APACHE docs: Tidy up (#271) 2020-03-25 08:42:05 +00:00
LICENSE-MIT docs: Tidy up (#271) 2020-03-25 08:42:05 +00:00
README.md Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
blacklist.go [blacklist] Use .Has check before add in time cached version - adjust signature 2020-05-16 19:58:13 +03:00
blacklist_test.go replace lru cache blacklist implementation with a time cache 2020-02-04 20:05:16 +05:30
codecov.yml Update Travis CI to use standard test script and go 1.9.x. 2017-11-17 22:36:56 -05:00
comm.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
compat_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
discovery.go track discovery API change 2020-05-19 19:26:53 +03:00
discovery_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
doc.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
floodsub.go remove multi-topic message support 2020-10-08 20:18:21 +03:00
floodsub_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
go.mod Change mod name and remove unused parameter 2021-03-24 09:49:43 -04:00
go.sum Change mod name and remove unused parameter 2021-03-24 09:49:43 -04:00
gossip_tracer.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
gossip_tracer_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
gossipsub_connmgr_test.go even fewer peers in connmgr test 2020-05-19 19:26:53 +03:00
maintainer.json docs: Tidy up (#271) 2020-03-25 08:42:05 +00:00
mcache.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
mcache_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
notify.go fix: treat peers already connected to the host before pubsub is initialized as valid potential pubsub peers 2020-12-07 10:27:35 +02:00
peer_gater.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
peer_gater_test.go decouple global coutner decay from source counter decay 2020-09-07 13:38:02 +03:00
pubsub.go refactor: removing event emitter 2021-10-06 11:19:08 -04:00
randomsub.go remove multi-topic message support 2020-10-08 20:18:21 +03:00
randomsub_test.go relax message delivery requirements for randomsub tests 2020-04-23 21:36:48 +03:00
score.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
score_params.go remove obsolete explicit IP whitelisting in favor of subnets 2021-02-12 21:47:58 +02:00
score_params_test.go fix test for behaviour penalty validation 2020-05-06 19:41:53 +03:00
score_test.go remove obsolete explicit IP whitelisting in favor of subnets 2021-02-12 21:47:58 +02:00
sign.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
sign_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
subscription.go interface: New Topic + TopicEventHandlers objects. 2019-10-31 15:37:44 -04:00
subscription_filter.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
subscription_filter_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
tag_tracer.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
tag_tracer_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
topic.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
topic_test.go Prevent multiple invocations of relay cancel function 2020-05-01 12:22:22 +03:00
trace.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
trace_test.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
tracer.go Rename gossipsub to wakurelaysub 2021-03-24 09:42:37 -04:00
validation.go remove multi-topic message support 2020-10-08 20:18:21 +03:00
validation_test.go remove multi-topic message support 2020-10-08 20:18:21 +03:00
wakurelaysub.go fix: add protocol to matcher function 2021-07-29 12:28:17 -04:00
wakurelaysub_spam_test.go Adding WakuRelay default options 2021-03-24 10:41:34 -04:00
wakurelaysub_test.go Adding WakuRelay default options 2021-03-24 10:41:34 -04:00

README.md

go-libp2p-pubsub


This repo contains the canonical pubsub implementation for libp2p. We currently provide three message router options:

  • Floodsub, which is the baseline flooding protocol.
  • Randomsub, which is a simple probabilistic router that propagates to random subsets of peers.
  • Gossipsub, which is a more advanced router with mesh formation and gossip propagation. See spec and implementation for more details.

PSA: The Hardening Extensions for Gossipsub (Gossipsub V1.1) can be found under development at https://github.com/libp2p/go-libp2p-pubsub/pull/263

Repo Lead Maintainer

@vyzo

This repo follows the Repo Lead Maintainer Protocol

Table of Contents

Install

go get github.com/libp2p/go-libp2p-pubsub

Usage

To be used for messaging in p2p instrastructure (as part of libp2p) such as IPFS, Ethereum, other blockchains, etc.

Example

https://github.com/libp2p/go-libp2p-examples/tree/master/pubsub

Documentation

See the libp2p specs for high level documentation and godoc for API documentation.

In this repo, you will find

.
├── LICENSE
├── README.md
# Regular Golang repo set up
├── codecov.yml
├── pb
├── go.mod
├── go.sum
├── doc.go
# PubSub base
├── pubsub.go
├── blacklist.go
├── notify.go
├── comm.go
├── discovery.go
├── sign.go
├── subscription.go
├── topic.go
├── trace.go
├── tracer.go
├── validation.go
# Floodsub router
├── floodsub.go
# Randomsub router
├── randomsub.go
# Gossipsub router
├── gossipsub.go
├── score.go
├── score_params.go
└── mcache.go

Tracing

The 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.

To 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). If you want to trace using a remote peer, you can do so using the traced daemon from go-libp2p-pubsub-tracer. The package also includes a utility program, tracestat, for analyzing the traces collected by the daemon.

For instance, to capture the trace as a json file, you can use the following option:

pubsub.NewWakuRelaySub(..., pubsub.NewEventTracer(pubsub.NewJSONTracer("/path/to/trace.json")))

To capture the trace as a protobuf, you can use the following option:

pubsub.NewWakuRelaySub(..., pubsub.NewEventTracer(pubsub.NewPBTracer("/path/to/trace.pb")))

Finally, to use the remote tracer, you can use the following incantations:

// assuming that your tracer runs in x.x.x.x and has a peer ID of QmTracer
pi, err := peer.AddrInfoFromP2pAddr(ma.StringCast("/ip4/x.x.x.x/tcp/4001/p2p/QmTracer"))
if err != nil {
  panic(err)
}

tracer, err := pubsub.NewRemoteTracer(ctx, host, pi)
if err != nil {
  panic(err)
}

ps, err := pubsub.NewWakuRelaySub(..., pubsub.WithEventTracer(tracer))

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document 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.

Small note: If editing the README, please conform to the standard-readme specification.

License

The go-libp2p-pubsub project is dual-licensed under Apache 2.0 and MIT terms: