aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-04-10 16:01:37 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-04-10 16:01:37 -0500
commit7954f8cb180eef88585c6b44a5c0226626352405 (patch)
treed3090f988ec1c728600e71a6923a411bd8cd0083 /src/cryptonote_core
parentMerge pull request #6341 (diff)
parentblockchain_db: faster fetching of consecutive txes (diff)
downloadmonero-7954f8cb180eef88585c6b44a5c0226626352405.tar.xz
Merge pull request #6358
8958b4e blockchain_db: faster fetching of consecutive txes (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 7a13705a3..2571e4203 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2493,38 +2493,10 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons
}
db_rtxn_guard rtxn_guard(m_db);
- total_height = get_current_blockchain_height();
- size_t count = 0, size = 0;
blocks.reserve(std::min(std::min(max_count, (size_t)10000), (size_t)(total_height - start_height)));
- for(uint64_t i = start_height; i < total_height && count < max_count && (size < FIND_BLOCKCHAIN_SUPPLEMENT_MAX_SIZE || count < 3); i++, count++)
- {
- blocks.resize(blocks.size()+1);
- blocks.back().first.first = m_db->get_block_blob_from_height(i);
- block b;
- CHECK_AND_ASSERT_MES(parse_and_validate_block_from_blob(blocks.back().first.first, b), false, "internal error, invalid block");
- blocks.back().first.second = get_miner_tx_hash ? cryptonote::get_transaction_hash(b.miner_tx) : crypto::null_hash;
- std::vector<cryptonote::blobdata> txs;
- if (pruned)
- {
- CHECK_AND_ASSERT_MES(m_db->get_pruned_tx_blobs_from(b.tx_hashes.front(), b.tx_hashes.size(), txs), false, "Failed to retrieve all transactions needed");
- }
- else
- {
- std::vector<crypto::hash> mis;
- get_transactions_blobs(b.tx_hashes, txs, mis, pruned);
- CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found");
- }
- size += blocks.back().first.first.size();
- for (const auto &t: txs)
- size += t.size();
+ CHECK_AND_ASSERT_MES(m_db->get_blocks_from(start_height, 3, max_count, FIND_BLOCKCHAIN_SUPPLEMENT_MAX_SIZE, blocks, pruned, true, get_miner_tx_hash),
+ false, "Error getting blocks");
- CHECK_AND_ASSERT_MES(txs.size() == b.tx_hashes.size(), false, "mismatched sizes of b.tx_hashes and txs");
- blocks.back().second.reserve(txs.size());
- for (size_t i = 0; i < txs.size(); ++i)
- {
- blocks.back().second.push_back(std::make_pair(b.tx_hashes[i], std::move(txs[i])));
- }
- }
return true;
}
//------------------------------------------------------------------