Abstract
If router can relay received messages, even if not subscribed
if publish should emit to self, if subscribed
Protected
enabledThe signature policy to follow by default
Protected
logA list of multicodecs that contain the pubsub protocol name.
Map of peer streams
List of our subscriptions
Map of topics to which peers are subscribed to
Topic validator map
Keyed by topic Topic validators are functions with the following input:
Protected
_Protected
_Registrar notifies an established connection with pubsub protocol
Protected
_Registrar notifies a closing connection with pubsub protocol
Optional
conn: ConnectionProtected
_Notifies the router that a peer has been disconnected
Whether to accept a message from a peer Override to create a gray list
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Optional
options: boolean | AddEventListenerOptionsNotifies the router that a peer has been connected
Normalizes the message and signs it, if signing is enabled. Should be used by the routers to create the message to send.
Abstract
decodeDecode Uint8Array into an RPC object. This can be override to use a custom router protobuf.
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.
Abstract
encodeEncode RPC object into a Uint8Array. This can be override to use a custom router protobuf.
Abstract
encodeEncode RPC object into a Uint8Array. This can be override to use a custom router protobuf.
The default msgID implementation Child class can override this.
Get a list of the peer-ids that are subscribed to one topic.
Get the list of topics which the peer is subscribed to.
Responsible for processing each RPC message received by other peers.
Handles an rpc request from a peer
Handles a subscription change from a peer
Publishes messages to all subscribed peers
Optional
data: Uint8Array<ArrayBufferLike>Abstract
publishOverriding the implementation of publish should handle the appropriate algorithms for the publish/subscriber implementation. For example, a Floodsub implementation might simply publish each message to each topic for every peer.
sender
might be this peer, or we might be forwarding a message on behalf of another peer, in which case sender
is the peer we received the message from, which may not be the peer the message was created by.
Removes the event listener in target's event listener list with the same type, callback, and options.
Optional
listener: null | EventHandler<Events[K]>Optional
options: boolean | EventListenerOptionsRegister the pubsub protocol onto the libp2p node.
Unregister the pubsub protocol and the streams with other peers will be closed.
Subscribes to a given topic.
Unsubscribe from the given topic
PubSubBaseProtocol handles the peers and connections logic for pubsub routers and specifies the API that pubsub routers should have.