mirror of
https://github.com/monero-project/monero.git
synced 2026-01-15 22:32:40 -08:00
db_lmdb: save pruned and prunable tx data separately
This bumps DB version to 2, migration code will run for v1 DBs
This commit is contained in:
@@ -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<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||
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<crypto::hash>& qbloc
|
||||
// find split point between ours and foreign blockchain (or start at
|
||||
// blockchain height <req_start_block>), and return up to max_count FULL
|
||||
// blocks by reference.
|
||||
bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& 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<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& 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<crypto::hash> 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<bool(const crypto::hash&, const cryptonote::transaction&)> f) const
|
||||
bool Blockchain::for_all_transactions(std::function<bool(const crypto::hash&, const cryptonote::transaction&)> 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<bool(uint64_t amount, const crypto::hash &tx_hash, uint64_t height, size_t tx_idx)> f) const
|
||||
@@ -4531,4 +4533,5 @@ bool Blockchain::for_all_outputs(uint64_t amount, std::function<bool(uint64_t he
|
||||
|
||||
namespace cryptonote {
|
||||
template bool Blockchain::get_transactions(const std::vector<crypto::hash>&, std::list<transaction>&, std::list<crypto::hash>&) const;
|
||||
template bool Blockchain::get_transactions_blobs(const std::vector<crypto::hash>&, std::list<cryptonote::blobdata>&, std::list<crypto::hash>&, bool) const;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user