From b9389e582eb4e1806ce25a14fa492259c3d40dfc Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 1 Oct 2017 11:24:33 +0100 Subject: db_lmdb: save pruned and prunable tx data separately This bumps DB version to 2, migration code will run for v1 DBs --- src/cryptonote_core/blockchain.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/cryptonote_core/blockchain.cpp') diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index d1ef7d6fe..339876a93 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2092,7 +2092,7 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container //TODO: return type should be void, throw on exception // alternatively, return true only if no transactions missed template -bool Blockchain::get_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const +bool Blockchain::get_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs, bool pruned) const { LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); @@ -2102,7 +2102,9 @@ bool Blockchain::get_transactions_blobs(const t_ids_container& txs_ids, t_tx_con try { cryptonote::blobdata tx; - if (m_db->get_tx_blob(tx_hash, tx)) + if (pruned && m_db->get_pruned_tx_blob(tx_hash, tx)) + txs.push_back(std::move(tx)); + else if (!pruned && m_db->get_tx_blob(tx_hash, tx)) txs.push_back(std::move(tx)); else missed_txs.push_back(tx_hash); @@ -2187,7 +2189,7 @@ bool Blockchain::find_blockchain_supplement(const std::list& qbloc // find split point between ours and foreign blockchain (or start at // blockchain height ), and return up to max_count FULL // blocks by reference. -bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list& qblock_ids, std::list > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const +bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list& qblock_ids, std::list > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, size_t max_count) const { LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); @@ -2220,7 +2222,7 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons block b; CHECK_AND_ASSERT_MES(parse_and_validate_block_from_blob(blocks.back().first, b), false, "internal error, invalid block"); std::list mis; - get_transactions_blobs(b.tx_hashes, blocks.back().second, mis); + get_transactions_blobs(b.tx_hashes, blocks.back().second, mis, pruned); CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found"); size += blocks.back().first.size(); for (const auto &t: blocks.back().second) @@ -4514,9 +4516,9 @@ bool Blockchain::for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::f return m_db->for_blocks_range(h1, h2, f); } -bool Blockchain::for_all_transactions(std::function f) const +bool Blockchain::for_all_transactions(std::function f, bool pruned) const { - return m_db->for_all_transactions(f); + return m_db->for_all_transactions(f, pruned); } bool Blockchain::for_all_outputs(std::function f) const @@ -4531,4 +4533,5 @@ bool Blockchain::for_all_outputs(uint64_t amount, std::function&, std::list&, std::list&) const; +template bool Blockchain::get_transactions_blobs(const std::vector&, std::list&, std::list&, bool) const; } -- cgit v1.2.3