Transport

The Transport converts one connection's sent messages to wire bytes, and received bytes back.

Synopsis

Declared in <net.h>

class Transport;

Types

NameDescription
Info Summary information about a transport, exposed for stats.

Type Aliases

NameDescription
BytesToSend Return type for GetBytesToSend, consisting of: - std::span<const uint8_t> to_send: span of bytes to be sent over the wire (possibly empty). - bool more: whether there will be more bytes to be sent after the ones in to_send are all sent (as signaled by MarkBytesSent()). - const std::string& m_type: message type on behalf of which this is being sent ("" for bytes that are not on behalf of any message).

Member Functions

NameDescription
~Transport [destructor] [virtual]Destroy the transport.
GetBytesToSend [virtual]Get bytes to send on the wire, if any, along with other information about it.
GetInfo [virtual]Retrieve information about this transport.
GetReceivedMessage [virtual]Retrieve a completed message from transport.
GetSendMemoryUsage [virtual]Return the memory usage of this transport attributable to buffered data to send.
MarkBytesSent [virtual]Report how many bytes returned by the last GetBytesToSend() have been sent.
ReceivedBytes [virtual]Feed wire bytes to the transport.
ReceivedMessageComplete [virtual]Returns true if the current message is complete (so GetReceivedMessage can be called).
SetMessageToSend [virtual]Set the next message to send.
ShouldReconnectV1 [virtual]Whether upon disconnections, a reconnect with V1 is warranted.

Derived Classes

NameDescription
V1Transport Transport implementation for the legacy (v1) unencrypted P2P protocol.
V2Transport Transport implementation for the encrypted BIP324 (v2) P2P protocol, with automatic fallback to v1 when the peer does not speak v2.