

If you register your handler with a match function, you can choose whether The handler function will be invoked when an incoming stream is tagged with the registered protocol id. Switch (aka “swarm”), or a higher level interface such as go’s Host interface. To accept connections, a libp2p application will register handler functions for protocols using their protocol id with the Using the recommended path structure with a version component is bothĭeveloper-friendly and enables easier matching by version. While libp2p will technically accept any string as a valid protocol id, How version selection works during the dialing and listening process. See the protocol negotiation section for more information about Libp2p protocols have unique string identifiers, which are used in the protocol negotiation process when connections are first opened.īy convention, protocol ids have a path-like structure, with a version number as the final component: /my-app/amazing-protocol/1.0.1īreaking changes to your protocol’s wire format or semantics should result in a new version What is a libp2p protocol? #Ī libp2p protocol has these key features: Protocol IDs # This article will walk through some of the key defining features of a libp2p protocol, give an overview of the protocol negotiation process, and outline some of the core libp2p protocols that are included with libp2p and provide key functionality. These are the protocols that define your application and provide its core functionality. Throughout this article, we’ll call this kind of protocol that is built with libp2pĪ libp2p protocol, but you may also see them referred to as “wire protocols” or “application protocols”. Using the core libp2p abstractions like transport, peer identity, addressing, and so on. The kind of protocols this article is concerned with are the ones built with libp2p itself, There are protocols everywhere you look when you’re writing network applications, and libp2p is
