cryptonote_protocol: avoid copying block span in add_blocks
What changed, and why it matters
This is a tiny performance tweak in Monero's network code. It changes one function call so that a batch of downloaded blocks is moved rather than copied into an internal queue. There is no security fix here and no indication it addresses a vulnerability.
No security action required. Treat as a normal performance optimization during routine review or merge.
Security signals we found
No security-relevant change identified
Performance optimization only
No input validation, bounds checking, or cryptographic logic modified
Evidence from the diff
The commit replaces a copy of arg.blocks with std::move(arg.blocks) when passing it to m_block_queue.add_blocks(). This avoids an unnecessary copy of the block span vector, reducing CPU and memory overhead during block synchronization. It is a code-quality/optimization change, not a security patch.
Changed components
src/cryptonote_protocol/cryptonote_protocol_handler.inlcryptonote_protocol_handler::add_blocksInspect captured patch +1 / −1
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 825bb17..174b8fc 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -1282,7 +1282,7 @@ namespace cryptonote
const boost::posix_time::time_duration dt = now - request_time;
const float rate = size * 1e6 / (dt.total_microseconds() + 1);
MDEBUG(context << " adding span: " << arg.blocks.size() << " at height " << start_height << ", " << dt.total_microseconds()/1e6 << " seconds, " << (rate/1024) << " kB/s, size now " << (m_block_queue.get_data_size() + blocks_size) / 1048576.f << " MB");
- m_block_queue.add_blocks(start_height, arg.blocks, context.m_connection_id, context.m_remote_address, rate, blocks_size);
+ m_block_queue.add_blocks(start_height, std::move(arg.blocks), context.m_connection_id, context.m_remote_address, rate, blocks_size);
const crypto::hash last_block_hash = cryptonote::get_block_hash(b);
context.m_last_known_hash = last_block_hash;
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.