The PubSub implementation for go-libp2p https://github.com/libp2p/specs/tree/master/pubsub
Go to file
vyzo f6f34cfc99 make PX optional and disabled by default, gate by acceptPXThreshold 2020-04-18 11:09:06 +03:00
.github Update label-syncer.yml 2020-03-25 08:08:35 +00:00
pb track changes to peer records in -core 2020-03-24 15:52:34 +02:00
.gitignore gx publish v0.5.0 2016-09-14 15:27:34 -07:00
.travis.yml chore: update travis config 2020-03-25 09:38:32 +02: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 docs: update readme welcome message 2020-04-05 13:22:28 +01:00
blacklist.go defer unlocking 2020-02-05 14:33:20 +05:30
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 make wire protocol message size configurable. (#261) 2020-02-25 18:07:16 -08:00
discovery.go fix: fix a busy loop while offline (#278) 2020-04-06 23:26:05 -07:00
discovery_test.go fixed closed Topic handles still being able to perform some actions on the topic 2019-11-02 19:28:44 -04:00
doc.go godoc is not html either 2019-01-11 12:17:48 +02:00
floodsub.go allow gossipsub to graylist peers based on score 2020-04-18 11:09:06 +03:00
floodsub_test.go make wire protocol message size configurable. (#261) 2020-02-25 18:07:16 -08:00
go.mod gomod: use go-libp2p-core@peer-records and go-libp2p-peerstore@certified-addrs 2020-04-18 11:09:06 +03:00
go.sum gomod tidy 2020-04-18 11:09:06 +03:00
gossipsub.go make PX optional and disabled by default, gate by acceptPXThreshold 2020-04-18 11:09:06 +03:00
gossipsub_test.go make PX optional and disabled by default, gate by acceptPXThreshold 2020-04-18 11:09:06 +03:00
maintainer.json docs: Tidy up (#271) 2020-03-25 08:42:05 +00:00
mcache.go track peer (re)transmissions in message cache 2020-04-18 11:09:06 +03:00
mcache_test.go fixes #247: implement msg id function as pubsub option 2019-12-16 03:54:40 +01:00
notify.go migrate to consolidated types. (#185) 2019-05-26 17:19:03 +01:00
pubsub.go fix bug in WithEventTracer 2020-04-18 11:09:06 +03:00
randomsub.go allow gossipsub to graylist peers based on score 2020-04-18 11:09:06 +03:00
score.go move score parameter types to their own file 2020-04-18 11:09:06 +03:00
score_params.go move score parameter types to their own file 2020-04-18 11:09:06 +03:00
sign.go migrate to consolidated types. (#185) 2019-05-26 17:19:03 +01:00
sign_test.go migrate to consolidated types. (#185) 2019-05-26 17:19:03 +01:00
subscription.go interface: New Topic + TopicEventHandlers objects. 2019-10-31 15:37:44 -04:00
topic.go add ValidatorData field to Message 2019-11-15 20:16:58 +02:00
topic_test.go fixed closed Topic handles still being able to perform some actions on the topic 2019-11-02 19:28:44 -04:00
trace.go track message delivery time within the validation pipeline 2020-04-18 11:09:06 +03:00
tracer.go nits and beauty 2019-11-19 02:28:23 +02:00
validation.go distinguish throttled validation because of a full worker queue. 2020-04-18 11:09:06 +03: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.

Examples

To be written

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
└── 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.NewGossipSub(..., pubsub.NewEventTracer(pubsub.NewJSONTracer("/path/to/trace.json")))

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

pubsub.NewGossipSub(..., 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.NewGossipSub(..., 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: