Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libp2p-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p-pubsub

Pubsub base protocol for libp2p pubsub routers

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

js-libp2p-pubsub

Coverage Status Travis CI Circle CI Dependency Status js-standard-style standard-readme compliant

libp2p-pubsub consits on the base protocol for libp2p pubsub implementation. This module is responsible for all the logic regarding peer connections.

Lead Maintainer

Vasco Santos.

Table of Contents

Install

> npm install libp2p-pubsub

Usage

A pubsub implementation MUST override the _processConnection, publish, subscribe and unsubscribe functions. add_peer and remove_peer may be overwritten if the pubsub implementation needs to add custom logic when peers are added and remove. All the remaining functions MUST NOT be overwritten.

The following example aims to show how to create your pubsub implementation extending this base protocol. The pubsub implementation will handle the subscriptions logic.

const Pubsub = require('libp2p-pubsub')

class PubsubImplementation extends Pubsub {
  constructor(libp2p) {
    super('libp2p:pubsub', '/pubsub-implementation/1.0.0', libp2p)
  }

  _processConnection(idB58Str, conn, peer) {
    // Required to be implemented by the subclass
    // Process each message accordingly
  }

  publish() {
    // Required to be implemented by the subclass
  }

  subscribe() {
    // Required to be implemented by the subclass
  }

  unsubscribe() {
    // Required to be implemented by the subclass
  }
}

Implementations using this base protocol

You can use the following implementations as examples for building your own pubsub implementation.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

Copyright (c) Protocol Labs, Inc. under the MIT License. See LICENSE file for details.

Keywords

FAQs

Package last updated on 08 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc