If router can relay received messages, even if not subscribed
if publish should emit to self, if subscribed
The signature policy to follow by default
Map of peer streams
List of our subscriptions
Topic validator map
Keyed by topic Topic validators are functions with the following input:
Map of topics to which peers are subscribed to
Whether to accept a message from a peer Override to create a graylist
Notifies 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.
Decode Uint8Array into an RPC object. This can be override to use a custom router protobuf.
Emit a message from a peer
Encode RPC object into a Uint8Array. This can be override to use a custom router protobuf.
On an inbound stream opened.
Registrar notifies an established connection with pubsub protocol.
remote peer-id
connection to the peer
Responsible for processing each RPC message received by other peers.
peer id string in base58
inbound stream
PubSub peer
Handles an rpc request from a peer
Handles an message from a peer
Handles a subscription change from a peer
Overriding 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
Notifies the router that a peer has been disconnected.
Send an rpc object to a peer
peer id
Send subscroptions to a peer
peer id
set to false for unsubscriptions
The default msgID implementation Child class can override this.
the message object
message id as bytes
Get a list of the peer-ids that are subscribed to one topic.
Get the list of topics which the peer is subscribed to.
Publishes messages to all subscribed peers
Register 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.
Validates the given message. The signature will be checked for authenticity. Throws an error on invalid messages
PubsubBaseProtocol handles the peers and connections logic for pubsub routers and specifies the API that pubsub routers should have.