Retrieve the registered handler for a given protocol.
The protocol to query.
A StreamHandlerRecord
containing the handler and options.
Register a handler for a specific protocol.
The protocol string (e.g., /my-protocol/1.0.0
).
The function that handles incoming streams.
Optional
options: StreamHandlerOptionsOptional configuration options for the handler.
A promise that resolves once the handler is registered.
Register a topology handler for a protocol - the topology will be invoked when peers are discovered on the network that support the passed protocol.
An id will be returned that can later be used to unregister the topology.
The protocol to register.
The topology handler to register.
A promise resolving to a unique ID for the registered topology.
The
Registrar
provides an interface for registering protocol handlers - these are invoked when remote peers open streams on the local node with the corresponding protocol name.It also allows configuring network topologies for a given protocol(s). The topology callbacks are invoked when a peer that supports those protocols connects or disconnects.
The Identify protocol must be configured on the current node for topologies to function.