MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ReceiveGarbage

Method ReceiveGarbage

src/test/net_tests.cpp:1287–1300  ·  view source on GitHub ↗

Expect garbage and garbage terminator to have been received, and process them (only after * ReceiveKey). */

Source from the content-addressed store, hash-verified

1285 /** Expect garbage and garbage terminator to have been received, and process them (only after
1286 * ReceiveKey). */
1287 void ReceiveGarbage()
1288 {
1289 // Figure out the garbage length.
1290 size_t garblen;
1291 for (garblen = 0; garblen <= V2Transport::MAX_GARBAGE_LEN; ++garblen) {
1292 BOOST_REQUIRE(m_received.size() >= garblen + BIP324Cipher::GARBAGE_TERMINATOR_LEN);
1293 auto term_span = MakeByteSpan(std::span{m_received}.subspan(garblen, BIP324Cipher::GARBAGE_TERMINATOR_LEN));
1294 if (std::ranges::equal(term_span, m_cipher.GetReceiveGarbageTerminator())) break;
1295 }
1296 // Copy the garbage to a buffer.
1297 m_recv_garbage.assign(m_received.begin(), m_received.begin() + garblen);
1298 // Strip garbage + garbage terminator off the front of the receive buffer.
1299 m_received.erase(m_received.begin(), m_received.begin() + garblen + BIP324Cipher::GARBAGE_TERMINATOR_LEN);
1300 }
1301
1302 /** Expect version packet to have been received, and process it (only after ReceiveKey). */
1303 void ReceiveVersion()

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 6

MakeByteSpanFunction · 0.85
sizeMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected