refactor: rename Transport class receive functions

Now that the Transport class deals with both the sending and receiving side
of things, make the receive side have function names that clearly indicate
they're about receiving.

* Transport::Read() -> Transport::ReceivedBytes()
* Transport::Complete() -> Transport::ReceivedMessageComplete()
* Transport::GetMessage() -> Transport::GetReceivedMessage()
* Transport::SetVersion() -> Transport::SetReceiveVersion()

Further, also update the comments on these functions to (among others) remove
the "deserialization" terminology. That term is better reserved for just the
serialization/deserialization between objects and bytes (see serialize.h), and
not the conversion from/to wire bytes as performed by the Transport.
This commit is contained in:
Pieter Wuille
2023-08-14 16:37:05 -04:00
parent 27f9ba23ef
commit 649a83c7f7
3 changed files with 20 additions and 19 deletions

View File

@@ -681,16 +681,16 @@ bool CNode::ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete)
nRecvBytes += msg_bytes.size();
while (msg_bytes.size() > 0) {
// absorb network data
int handled = m_transport->Read(msg_bytes);
int handled = m_transport->ReceivedBytes(msg_bytes);
if (handled < 0) {
// Serious header problem, disconnect from the peer.
return false;
}
if (m_transport->Complete()) {
if (m_transport->ReceivedMessageComplete()) {
// decompose a transport agnostic CNetMessage from the deserializer
bool reject_message{false};
CNetMessage msg = m_transport->GetMessage(time, reject_message);
CNetMessage msg = m_transport->GetReceivedMessage(time, reject_message);
if (reject_message) {
// Message deserialization failed. Drop the message but don't disconnect the peer.
// store the size of the corrupt message
@@ -785,7 +785,7 @@ const uint256& V1Transport::GetMessageHash() const
return data_hash;
}
CNetMessage V1Transport::GetMessage(const std::chrono::microseconds time, bool& reject_message)
CNetMessage V1Transport::GetReceivedMessage(const std::chrono::microseconds time, bool& reject_message)
{
AssertLockNotHeld(m_recv_mutex);
// Initialize out parameter