{"id":20388372,"url":"https://github.com/chainsafe/js-libp2p-gossipsub","last_synced_at":"2025-05-15T04:08:08.323Z","repository":{"id":37852623,"uuid":"144341841","full_name":"ChainSafe/js-libp2p-gossipsub","owner":"ChainSafe","description":"TypeScript implementation of Gossipsub","archived":false,"fork":false,"pushed_at":"2025-03-28T13:54:50.000Z","size":12266,"stargazers_count":157,"open_issues_count":27,"forks_count":48,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-11T13:03:53.199Z","etag":null,"topics":["gossip-protocol","javascript","libp2p","networking","p2p","peer-to-peer","pubsub"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChainSafe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-08-10T23:53:29.000Z","updated_at":"2025-04-16T11:29:32.000Z","dependencies_parsed_at":"2023-02-11T07:40:18.961Z","dependency_job_id":"e3b0f17d-8637-4230-a34c-c3c381639f8e","html_url":"https://github.com/ChainSafe/js-libp2p-gossipsub","commit_stats":{"total_commits":662,"total_committers":35,"mean_commits":"18.914285714285715","dds":0.6344410876132931,"last_synced_commit":"f62859b346474ff3e29d59e31449b15d60e054d6"},"previous_names":[],"tags_count":103,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fjs-libp2p-gossipsub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fjs-libp2p-gossipsub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fjs-libp2p-gossipsub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fjs-libp2p-gossipsub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChainSafe","download_url":"https://codeload.github.com/ChainSafe/js-libp2p-gossipsub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270656,"owners_count":22042860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gossip-protocol","javascript","libp2p","networking","p2p","peer-to-peer","pubsub"],"created_at":"2024-11-15T03:09:33.008Z","updated_at":"2025-05-15T04:08:03.298Z","avatar_url":"https://github.com/ChainSafe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-libp2p-gossipsub\n\n[![](https://img.shields.io/badge/made%20by-ChainSafe-blue.svg?style=flat-square)](https://chainsafe.io/)\n[![Travis CI](https://flat.badgen.net/travis/ChainSafe/gossipsub-js)](https://travis-ci.com/ChainSafe/gossipsub-js)\n![ES Version](https://img.shields.io/badge/ES-2017-yellow)\n![Node Version](https://img.shields.io/badge/node-10.x-green)\n\n## Table of Contents\n\n- [js-libp2p-gossipsub](#js-libp2p-gossipsub)\n  - [Lead Maintainer](#lead-maintainer)\n  - [Table of Contents](#table-of-contents)\n  - [Specs](#specs)\n  - [Install](#install)\n  - [Usage](#usage)\n  - [API](#api)\n    - [Create a gossipsub implementation](#create-a-gossipsub-implementation)\n  - [Contribute](#contribute)\n  - [License](#license)\n\n## Specs\n\nGossipsub is an implementation of pubsub based on meshsub and floodsub. You can read the specification [here](https://github.com/libp2p/specs/tree/master/pubsub/gossipsub).\n\n`libp2p-gossipsub` currently implements the [`v1.1`](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) of the spec.\n\n## Install\n\n`npm install @chainsafe/libp2p-gossipsub`\n\n## Usage\n\n```javascript\nimport { gossipsub } from '@chainsafe/libp2p-gossipsub'\n\n\nconst libp2p = await createLibp2p({\n  // ...\n  services: {\n    pubsub: gossipsub(options)\n  }\n});\n\nlibp2p.services.pubsub.addEventListener('message', (message) =\u003e {\n  console.log(`${message.detail.topic}:`, new TextDecoder().decode(message.detail.data))\n})\n\nlibp2p.services.pubsub.subscribe('fruit')\n\nlibp2p.services.pubsub.publish('fruit', new TextEncoder().encode('banana'))\n```\n\n## API\n\n### Create a gossipsub implementation\n\n```js\nconst options = {…}\nconst gossipsub = gossipsub(options)(libp2p)\n```\n\nOptions is an optional object with the following key-value pairs:\n\n- **`emitSelf`**: boolean identifying whether the node should emit to self on publish, in the event of the topic being subscribed (defaults to **false**).\n- **`gossipIncoming`**: boolean identifying if incoming messages on a subscribed topic should be automatically gossiped (defaults to **true**).\n- **`fallbackToFloodsub`**: boolean identifying whether the node should fallback to the floodsub protocol, if another connecting peer does not support gossipsub (defaults to **true**).\n- **`floodPublish`**: boolean identifying if self-published messages should be sent to all peers, (defaults to **true**).\n- **`doPX`**: boolean identifying whether PX is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes (defaults to **false**).\n- **`msgIdFn`**: a function with signature `(message) =\u003e string` defining the message id given a message, used internally to deduplicate gossip (defaults to `(message) =\u003e message.from + message.seqno.toString('hex')`)\n- **`signMessages`**: boolean identifying if we want to sign outgoing messages or not (default: `true`)\n- **`strictSigning`**: boolean identifying if message signing is required for incoming messages or not (default: `true`)\n- **`messageCache`**: optional, a customized `MessageCache` instance, see the implementation for the interface.\n- **`scoreParams`**: optional, a customized peer score parameters Object.\n- **`scoreThresholds`**: optional, a customized peer score thresholds Object.\n- **`directPeers`**: optional, an array of `AddrInfo` of peers with which we will maintain direct connections.\n\nFor the remaining API, see [@libp2p/interface-pubsub](https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-pubsub).\n\n## Contribute\n\nThis module is actively under development. Please check out the issues and submit PRs!\n\n## License\n\nMIT © ChainSafe Systems\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fjs-libp2p-gossipsub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainsafe%2Fjs-libp2p-gossipsub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fjs-libp2p-gossipsub/lists"}