status-go/vendor/github.com/libp2p/go-libp2p-pubsub
richΛrd 56cc5c96c5
feat_: bump go-waku to introduce new keep alive interval (#5484)
- Also renames the existing keepAliveInterval to randomPeerKeepAliveInterval, and uses time.Duration instead of int
2024-07-11 14:36:34 -04:00
..
pb chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
timecache chore: bump go-waku to fix mem leak 2023-03-27 10:56:23 -04:00
.codecov.yml chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
.gitignore feat: wakuv2 store (#2780) 2022-08-19 12:34:07 -04:00
LICENSE chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
LICENSE-APACHE chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
LICENSE-MIT chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
README.md feat: wakuv2 store (#2780) 2022-08-19 12:34:07 -04:00
backoff.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
blacklist.go chore: upgrade go-waku to v0.5 (#3213) 2023-02-22 17:58:17 -04:00
codecov.yml chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
comm.go chore_: bump go-waku (#5150) 2024-05-15 19:15:00 -04:00
discovery.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
doc.go chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
floodsub.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
gossip_tracer.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
gossipsub.go feat_: bump go-waku to introduce new keep alive interval (#5484) 2024-07-11 14:36:34 -04:00
gossipsub_feat.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
maintainer.json chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
mcache.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
midgen.go feat: wakuv2 store (#2780) 2022-08-19 12:34:07 -04:00
notify.go chore_: bump go-waku (#5289) 2024-06-05 16:10:03 -04:00
peer_gater.go chore_: bump go-waku (#5289) 2024-06-05 16:10:03 -04:00
pubsub.go feat_: bump go-waku to introduce new keep alive interval (#5484) 2024-07-11 14:36:34 -04:00
randomsub.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
score.go chore_: bump go-waku (#5289) 2024-06-05 16:10:03 -04:00
score_params.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
sign.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
subscription.go chore: bump go-waku (#2404) 2021-10-19 09:43:41 -04:00
subscription_filter.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
tag_tracer.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
topic.go chore: upgrade go-waku to v0.5 (#3213) 2023-02-22 17:58:17 -04:00
trace.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
tracer.go chore: upgrade deps 2022-11-09 17:39:17 +03:00
validation.go chore: bump go-waku to fix mem leak 2023-03-27 10:56:23 -04:00
validation_builtin.go chore: bump go-waku to fix mem leak 2023-03-27 10:56:23 -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.

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/tree/master/examples/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:

tracer, err := pubsub.NewJSONTracer("/path/to/trace.json")
if err != nil {
  panic(err)
}

pubsub.NewGossipSub(..., pubsub.WithEventTracer(tracer))

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

tracer, err := pubsub.NewPBTracer("/path/to/trace.pb")
if err != nil {
  panic(err)
}

pubsub.NewGossipSub(..., pubsub.WithEventTracer(tracer))

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: