mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 21:59:10 +02:00
Merge #20056: net: Use Span in ReceiveMsgBytes
fa5ed3b4canet: Use Span in ReceiveMsgBytes (MarcoFalke) Pull request description: Pass a data pointer and a size as span in `ReceiveMsgBytes` to get the benefits of a span ACKs for top commit: jonatack: ACKfa5ed3b4cacode review, rebased to current master12a1c3ad1a, debug build, unit tests, ran bitcoind/-netinfo/getpeerinfo theStack: ACKfa5ed3b4caTree-SHA512: 89bf111323148d6e6e50185ad20ab39f73ab3a58a27e46319e3a08bcf5dcf9d6aa84faff0fd6afb90cb892ac2f557a237c144560986063bc736a69ace353ab9d
This commit is contained in:
@@ -128,7 +128,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
case 11: {
|
||||
const std::vector<uint8_t> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
||||
bool complete;
|
||||
node.ReceiveMsgBytes((const char*)b.data(), b.size(), complete);
|
||||
node.ReceiveMsgBytes({(const char*)b.data(), b.size()}, complete);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,12 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
{
|
||||
// Construct deserializer, with a dummy NodeId
|
||||
V1TransportDeserializer deserializer{Params(), (NodeId)0, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
const char* pch = (const char*)buffer.data();
|
||||
size_t n_bytes = buffer.size();
|
||||
while (n_bytes > 0) {
|
||||
const int handled = deserializer.Read(pch, n_bytes);
|
||||
Span<const char> msg_bytes{(const char*)buffer.data(), buffer.size()};
|
||||
while (msg_bytes.size() > 0) {
|
||||
const int handled = deserializer.Read(msg_bytes);
|
||||
if (handled < 0) {
|
||||
break;
|
||||
}
|
||||
pch += handled;
|
||||
n_bytes -= handled;
|
||||
if (deserializer.Complete()) {
|
||||
const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()};
|
||||
uint32_t out_err_raw_size{0};
|
||||
|
||||
Reference in New Issue
Block a user