FloodSub (aka dumbsub is an implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).

Hierarchy (view full)

Constructors

Properties

#private: any
canRelayMessage: boolean

If router can relay received messages, even if not subscribed

components: PubSubComponents
emitSelf: boolean

if publish should emit to self, if subscribed

enabled: boolean
globalSignaturePolicy: "StrictSign" | "StrictNoSign"

The signature policy to follow by default

log: Logger
multicodecs: string[]

A list of multicodecs that contain the pubsub protocol name.

Map of peer streams

seenCache: SimpleTimeCache<boolean>
started: boolean
subscriptions: Set<string>

List of our subscriptions

topicValidators: Map<string, TopicValidatorFn>

Topic validator map

Keyed by topic Topic validators are functions with the following input:

topics: Map<string, PeerSet>

Map of topics to which peers are subscribed to

Methods

  • Whether to accept a message from a peer Override to create a graylist

    Parameters

    Returns boolean

  • Normalizes the message and signs it, if signing is enabled. Should be used by the routers to create the message to send.

    Parameters

    • message: {
          data: Uint8Array;
          from: PeerId;
          sequenceNumber: bigint;
          topic: string;
      }

    Returns Promise<Message>

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    Returns boolean

  • Get a list of the peer-ids that are subscribed to one topic.

    Parameters

    • topic: string

    Returns PeerId[]

  • Get the list of topics which the peer is subscribed to.

    Returns string[]

  • Parameters

    • type: string

    Returns number

  • Send an rpc object to a peer

    Parameters

    • peer: PeerId
    • data: {
          messages?: Message[];
          subscribe?: boolean;
          subscriptions?: string[];
      }
      • Optional messages?: Message[]
      • Optional subscribe?: boolean
      • Optional subscriptions?: string[]

    Returns void

  • Unregister the pubsub protocol and the streams with other peers will be closed.

    Returns Promise<void>

  • Subscribes to a given topic.

    Parameters

    • topic: string

    Returns void

  • Unsubscribe from the given topic

    Parameters

    • topic: string

    Returns void

  • Validates the given message. The signature will be checked for authenticity. Throws an error on invalid messages

    Parameters

    Returns Promise<void>