Skip to content
Cosmopediaby Unity Nodes
DocumentationCometBFT specificationcometbft/cometbft › spec › p2p › legacy-docs › messagesView on CometBFT specification ↗

Peer Exchange


order: 6

Peer Exchange

Channels

Pex has one channel. The channel identifier is listed below.

NameNumber
PexChannel0

Message Types

The current PEX service has two versions. The first uses IP/port pair but since the p2p stack is moving towards a transport agnostic approach, node endpoints require a Protocol and Path hence the V2 version uses a url instead.

PexRequest

PexRequest is an empty message requesting a list of peers.

EmptyRequest

PexResponse

PexResponse is an list of net addresses provided to a peer to dial.

NameTypeDescriptionField Number
addressesrepeated PexAddressList of peer addresses available to dial1

PexAddress

PexAddress provides needed information for a node to dial a peer.

NameTypeDescriptionField Number
idstringNodeID of a peer1
ipstringThe IP of a node2
portportPort of a peer3

PexRequestV2

PexRequest is an empty message requesting a list of peers.

EmptyRequest

PexResponseV2

PexResponse is an list of net addresses provided to a peer to dial.

NameTypeDescriptionField Number
addressesrepeated PexAddressV2List of peer addresses available to dial1

PexAddressV2

PexAddress provides needed information for a node to dial a peer.

NameTypeDescriptionField Number
urlstringSee golang url1

Message

Message is a oneof protobuf type. The one of consists of two messages.

NameTypeDescriptionField Number
pex_requestPexRequestEmpty request asking for a list of addresses to dial1
pex_responsePexResponseList of addresses to dial2
pex_request_v2PexRequestV2Empty request asking for a list of addresses to dial3
pex_response_v2PexRespinseV2List of addresses to dial4