| 379 | } |
| 380 | |
| 381 | void 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 | |
| 413 | void Node::P2PProtocolBytecoin::on_msg_notify_request_objects(p2p::GetObjects::Response &&req) { |
| 414 | if (req.blocks.size() + req.txs.size() + req.missed_ids.size() != 1) |
nothing calls this directly
no test coverage detected