mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-10 21:23:27 +01:00
blockchain: simplify/speedup handle_get_objects
This commit is contained in:
parent
f025ae9760
commit
ef2cb63287
@ -1633,14 +1633,17 @@ bool Blockchain::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NO
|
|||||||
std::vector<std::pair<cryptonote::blobdata,block>> blocks;
|
std::vector<std::pair<cryptonote::blobdata,block>> blocks;
|
||||||
get_blocks(arg.blocks, blocks, rsp.missed_ids);
|
get_blocks(arg.blocks, blocks, rsp.missed_ids);
|
||||||
|
|
||||||
for (const auto& bl: blocks)
|
for (auto& bl: blocks)
|
||||||
{
|
{
|
||||||
std::vector<crypto::hash> missed_tx_ids;
|
std::vector<crypto::hash> missed_tx_ids;
|
||||||
std::vector<cryptonote::blobdata> txs;
|
std::vector<cryptonote::blobdata> txs;
|
||||||
|
|
||||||
|
rsp.blocks.push_back(block_complete_entry());
|
||||||
|
block_complete_entry& e = rsp.blocks.back();
|
||||||
|
|
||||||
// FIXME: s/rsp.missed_ids/missed_tx_id/ ? Seems like rsp.missed_ids
|
// FIXME: s/rsp.missed_ids/missed_tx_id/ ? Seems like rsp.missed_ids
|
||||||
// is for missed blocks, not missed transactions as well.
|
// is for missed blocks, not missed transactions as well.
|
||||||
get_transactions_blobs(bl.second.tx_hashes, txs, missed_tx_ids);
|
get_transactions_blobs(bl.second.tx_hashes, e.txs, missed_tx_ids);
|
||||||
|
|
||||||
if (missed_tx_ids.size() != 0)
|
if (missed_tx_ids.size() != 0)
|
||||||
{
|
{
|
||||||
@ -1657,20 +1660,12 @@ bool Blockchain::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NO
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.blocks.push_back(block_complete_entry());
|
|
||||||
block_complete_entry& e = rsp.blocks.back();
|
|
||||||
//pack block
|
//pack block
|
||||||
e.block = bl.first;
|
e.block = std::move(bl.first);
|
||||||
//pack transactions
|
|
||||||
for (const cryptonote::blobdata& tx: txs)
|
|
||||||
e.txs.push_back(tx);
|
|
||||||
}
|
}
|
||||||
//get another transactions, if need
|
//get and pack other transactions, if needed
|
||||||
std::vector<cryptonote::blobdata> txs;
|
std::vector<cryptonote::blobdata> txs;
|
||||||
get_transactions_blobs(arg.txs, txs, rsp.missed_ids);
|
get_transactions_blobs(arg.txs, rsp.txs, rsp.missed_ids);
|
||||||
//pack aside transactions
|
|
||||||
for (const auto& tx: txs)
|
|
||||||
rsp.txs.push_back(tx);
|
|
||||||
|
|
||||||
m_db->block_txn_stop();
|
m_db->block_txn_stop();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user