mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 04:45:10 +02:00
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.
This commit is contained in:
@@ -32,16 +32,19 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
n_bytes -= handled;
|
||||
if (deserializer.Complete()) {
|
||||
const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
|
||||
const CNetMessage msg = deserializer.GetMessage(Params().MessageStart(), m_time);
|
||||
assert(msg.m_command.size() <= CMessageHeader::COMMAND_SIZE);
|
||||
assert(msg.m_raw_message_size <= buffer.size());
|
||||
assert(msg.m_raw_message_size == CMessageHeader::HEADER_SIZE + msg.m_message_size);
|
||||
assert(msg.m_time == m_time);
|
||||
if (msg.m_valid_header) {
|
||||
assert(msg.m_valid_netmagic);
|
||||
}
|
||||
if (!msg.m_valid_netmagic) {
|
||||
assert(!msg.m_valid_header);
|
||||
uint32_t out_err_raw_size{0};
|
||||
Optional<CNetMessage> result{deserializer.GetMessage(Params().MessageStart(), m_time, out_err_raw_size)};
|
||||
if (result) {
|
||||
assert(result->m_command.size() <= CMessageHeader::COMMAND_SIZE);
|
||||
assert(result->m_raw_message_size <= buffer.size());
|
||||
assert(result->m_raw_message_size == CMessageHeader::HEADER_SIZE + result->m_message_size);
|
||||
assert(result->m_time == m_time);
|
||||
if (result->m_valid_header) {
|
||||
assert(result->m_valid_netmagic);
|
||||
}
|
||||
if (!result->m_valid_netmagic) {
|
||||
assert(!result->m_valid_header);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user