aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorTroy Giorshev <troygiorshev@gmail.com>2020-06-29 14:15:06 -0400
committerTroy Giorshev <troygiorshev@gmail.com>2020-09-22 22:01:14 -0400
commit890b1d7c2b8312d41d048d2db124586c5dbc8a49 (patch)
tree8ef643a06cbda557a380e7fa261af30c47bcac35 /src/net.h
parent2716647ebf60cea05fc9edce6a18dcce4e7727ad (diff)
Move checksum check from net_processing to net
This removes the m_valid_checksum member from CNetMessage. Instead, GetMessage() returns an Optional. Additionally, GetMessage() has been given an out parameter to be used to hold error information. For now it is specifically a uint32_t used to hold the raw size of the corrupt message. The checksum check is now done in GetMessage.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/net.h b/src/net.h
index bda6007e73..f581ce8ff9 100644
--- a/src/net.h
+++ b/src/net.h
@@ -14,8 +14,9 @@
#include <crypto/siphash.h>
#include <hash.h>
#include <limitedmap.h>
-#include <netaddress.h>
#include <net_permissions.h>
+#include <netaddress.h>
+#include <optional.h>
#include <policy/feerate.h>
#include <protocol.h>
#include <random.h>
@@ -706,7 +707,6 @@ public:
std::chrono::microseconds m_time{0}; //!< time of message receipt
bool m_valid_netmagic = false;
bool m_valid_header = false;
- bool m_valid_checksum = false;
uint32_t m_message_size{0}; //!< size of the payload
uint32_t m_raw_message_size{0}; //!< used wire size of the message (including header/checksum)
std::string m_command;
@@ -732,7 +732,7 @@ public:
// read and deserialize data
virtual int Read(const char *data, unsigned int bytes) = 0;
// decomposes a message from the context
- virtual CNetMessage GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time) = 0;
+ virtual Optional<CNetMessage> GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time, uint32_t& out_err) = 0;
virtual ~TransportDeserializer() {}
};
@@ -790,7 +790,7 @@ public:
if (ret < 0) Reset();
return ret;
}
- CNetMessage GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time) override;
+ Optional<CNetMessage> GetMessage(const CMessageHeader::MessageStartChars& message_start, std::chrono::microseconds time, uint32_t& out_err_raw_size) override;
};
/** The TransportSerializer prepares messages for the network transport