MCPcopy Create free account
hub / github.com/bcndev/bytecoin / on_msg_notify_request_objects

Method on_msg_notify_request_objects

src/Core/Node_P2PProtocolBytecoin.cpp:381–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381void Node::P2PProtocolBytecoin::on_msg_notify_request_objects(p2p::GetObjects::Request &&req) {
382 if (req.txs.size() + req.blocks.size() != 1)
383 return disconnect("Must be 1 block or 1 transaction in GetObjectsRequest");
384 p2p::GetObjects::Response msg;
385 for (const auto &bid : req.blocks) {
386 RawBlock raw_block;
387 if (m_node->m_block_chain.get_block(bid, &raw_block)) {
388 msg.blocks.push_back(std::move(raw_block));
389 continue;
390 }
391 msg.missed_ids.push_back(bid);
392 }
393 for (const auto &tid : req.txs) {
394 const auto &pool = m_node->m_block_chain.get_memory_state_transactions();
395 auto tit = pool.find(tid);
396 if (tit != pool.end()) {
397 msg.txs.push_back(tit->second.binary_tx);
398 continue;
399 }
400 BinaryArray binary_tx;
401 size_t index_in_block = 0;
402 Height block_height = 0;
403 Hash block_hash;
404 if (m_node->m_block_chain.get_transaction(tid, &binary_tx, &block_height, &block_hash, &index_in_block)) {
405 msg.txs.push_back(std::move(binary_tx));
406 continue;
407 }
408 msg.missed_ids.push_back(tid);
409 }
410 send(LevinProtocol::send(msg));
411}
412
413void Node::P2PProtocolBytecoin::on_msg_notify_request_objects(p2p::GetObjects::Response &&req) {
414 if (req.blocks.size() + req.txs.size() + req.missed_ids.size() != 1)

Callers

nothing calls this directly

Calls 15

from_binaryFunction · 0.85
get_blockMethod · 0.80
in_chainMethod · 0.80
onceMethod · 0.80
broadcastMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
get_transactionMethod · 0.45
add_blockMethod · 0.45

Tested by

no test coverage detected