diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-12-03 10:44:26 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-12-03 10:44:37 +0100 |
commit | 8b1de78577a02300340cec37e26cd6418ef6e645 (patch) | |
tree | ed76866aede610e6759fe76f841aa1613084aa56 /src/net.cpp | |
parent | fd1c9e26d30c0e7a891f63955fd42f61b4216cc0 (diff) | |
parent | 11daf6ceb1d9ea1f8d638b123eecfe39d162a7c3 (diff) |
Merge bitcoin/bitcoin#23413: Replace MakeSpan helper with Span deduction guide
11daf6ceb1d9ea1f8d638b123eecfe39d162a7c3 More Span simplifications (Pieter Wuille)
568dd2f83900a11a4dbba1250722791a135bf0a9 Replace MakeSpan helper with Span deduction guide (Pieter Wuille)
Pull request description:
C++17 supports [user-defined deduction guides](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction), allowing class constructors to be invoked without specifying class template arguments. Instead, the code can contain rules to infer the template arguments from the constructor argument types.
This alleviates the need for the `MakeSpan` helper. Convert the existing MakeSpan rules into deduction rules for `Span` itself, and replace all invocations of `MakeSpan` with just `Span` ones.
ACKs for top commit:
MarcoFalke:
re-ACK 11daf6ceb1d9ea1f8d638b123eecfe39d162a7c3 Only change is removing a hunk in the tests 🌕
Tree-SHA512: 10f3e82e4338f39d9b7b407cd11aac7ebe1e9191b58e3d7f4e5e338a4636c0e126b4a1d912127c7446f57ba356c8d6544482e47f97901efea6a54fffbfd7895f
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp index f6d40a7854..2d9e69b6fb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -761,7 +761,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) { LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n", SanitizeString(msg.m_command), msg.m_message_size, - HexStr(Span<uint8_t>(hash.begin(), hash.begin() + CMessageHeader::CHECKSUM_SIZE)), + HexStr(Span{hash}.first(CMessageHeader::CHECKSUM_SIZE)), HexStr(hdr.pchChecksum), m_node_id); reject_message = true; @@ -1583,8 +1583,9 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes, if (nBytes > 0) { bool notify = false; - if (!pnode->ReceiveMsgBytes(Span<const uint8_t>(pchBuf, nBytes), notify)) + if (!pnode->ReceiveMsgBytes({pchBuf, (size_t)nBytes}, notify)) { pnode->CloseSocketDisconnect(); + } RecordBytesRecv(nBytes); if (notify) { size_t nSizeAdded = 0; |