mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
net: expose transport types/session IDs of connections in RPC and logs
Co-authored-by: Dhruv Mehta <856960+dhruv@users.noreply.github.com>
This commit is contained in:
@@ -24,3 +24,17 @@ std::string ConnectionTypeAsString(ConnectionType conn_type)
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string TransportTypeAsString(TransportProtocolType transport_type)
|
||||
{
|
||||
switch (transport_type) {
|
||||
case TransportProtocolType::DETECTING:
|
||||
return "detecting";
|
||||
case TransportProtocolType::V1:
|
||||
return "v1";
|
||||
case TransportProtocolType::V2:
|
||||
return "v2";
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define BITCOIN_NODE_CONNECTION_TYPES_H
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
/** Different types of connections to a peer. This enum encapsulates the
|
||||
* information we have available at the time of opening or accepting the
|
||||
@@ -79,4 +80,14 @@ enum class ConnectionType {
|
||||
/** Convert ConnectionType enum to a string value */
|
||||
std::string ConnectionTypeAsString(ConnectionType conn_type);
|
||||
|
||||
/** Transport layer version */
|
||||
enum class TransportProtocolType : uint8_t {
|
||||
DETECTING, //!< Peer could be v1 or v2
|
||||
V1, //!< Unencrypted, plaintext protocol
|
||||
V2, //!< BIP324 protocol
|
||||
};
|
||||
|
||||
/** Convert TransportProtocolType enum to a string value */
|
||||
std::string TransportTypeAsString(TransportProtocolType transport_type);
|
||||
|
||||
#endif // BITCOIN_NODE_CONNECTION_TYPES_H
|
||||
|
||||
Reference in New Issue
Block a user