Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit b6f79b7

Browse files
committed
Address PR feedback
Change position of const keyword, make some variables const, remove unnecessary "p2p.connect", change log level to trace
1 parent 9949dd4 commit b6f79b7

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

libp2p/Common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ using namespace std;
1515
const NodeIPEndpoint UnspecifiedNodeIPEndpoint = NodeIPEndpoint{{}, 0, 0};
1616
const Node UnspecifiedNode = Node{{}, UnspecifiedNodeIPEndpoint};
1717

18-
const char* packetTypeToString(PacketType _packetType)
18+
char const* packetTypeToString(PacketType _packetType)
1919
{
2020
switch (_packetType)
2121
{

libp2p/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ enum PacketType
8989
UserPacket = 0x10
9090
};
9191

92-
const char* packetTypeToString(PacketType _packetType);
92+
char const* packetTypeToString(PacketType _packetType);
9393

9494
enum DisconnectReason
9595
{

libp2p/RLPxHandshake.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
367367
<< m_socket->remoteEndpoint() << ". Validating contents...";
368368

369369
/// check frame size
370-
bytes& header = m_handshakeInBuffer;
371-
uint32_t frameSize = (uint32_t)(header[2]) | (uint32_t)(header[1]) << 8 |
372-
(uint32_t)(header[0]) << 16;
370+
bytes const& header = m_handshakeInBuffer;
371+
uint32_t const frameSize = (uint32_t)(header[2]) | (uint32_t)(header[1]) << 8 |
372+
(uint32_t)(header[0]) << 16;
373373
constexpr size_t expectedFrameSizeBytes = 1024;
374374
if (frameSize > expectedFrameSizeBytes)
375375
{
@@ -472,14 +472,6 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
472472
}
473473
}
474474

475-
const char* RLPXHandshake::connectionDirectionString() const
476-
{
477-
if (m_originated)
478-
return "p2p.connect.egress: ";
479-
else
480-
return "p2p.connect.ingress: ";
481-
}
482-
483475
bool RLPXHandshake::remoteSocketConnected() const
484476
{
485477
return m_socket && m_socket->isConnected() &&

libp2p/RLPxHandshake.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ class RLPXHandshake: public std::enable_shared_from_this<RLPXHandshake>
9494
virtual void transition(boost::system::error_code _ech = boost::system::error_code());
9595

9696
/// Get a string indicating if the connection is incoming or outgoing
97-
const char* connectionDirectionString() const;
97+
inline char const* connectionDirectionString() const
98+
{
99+
return m_originated ? "egress" : "ingress";
100+
}
98101

99102
/// Determine if the remote socket is still connected
100103
bool remoteSocketConnected() const;
@@ -132,7 +135,7 @@ class RLPXHandshake: public std::enable_shared_from_this<RLPXHandshake>
132135
/// Timer which enforces c_timeout. Reset for each stage of the handshake.
133136
ba::steady_timer m_idleTimer;
134137

135-
Logger m_logger{createLogger(VerbosityDebug, "rlpx")};
138+
Logger m_logger{createLogger(VerbosityTrace, "rlpx")};
136139
Logger m_errorLogger{createLogger(VerbosityError, "rlpx")};
137140
};
138141

0 commit comments

Comments
 (0)