mirror of
https://github.com/monero-project/monero.git
synced 2024-12-29 12:16:14 -05:00
core: speed up print_coinbase_tx_sum
It only needs to parse the tx headers, not the full tx data
This commit is contained in:
parent
0b6bfb1fd8
commit
254a1338ad
@ -2608,7 +2608,7 @@ bool Blockchain::get_split_transactions_blobs(const t_ids_container& txs_ids, t_
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const
|
bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs, bool pruned) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
@ -2619,10 +2619,12 @@ bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
cryptonote::blobdata tx;
|
cryptonote::blobdata tx;
|
||||||
if (m_db->get_tx_blob(tx_hash, tx))
|
bool res = pruned ? m_db->get_pruned_tx_blob(tx_hash, tx) : m_db->get_tx_blob(tx_hash, tx);
|
||||||
|
if (res)
|
||||||
{
|
{
|
||||||
txs.push_back(transaction());
|
txs.push_back(transaction());
|
||||||
if (!parse_and_validate_tx_from_blob(tx, txs.back()))
|
res = pruned ? parse_and_validate_tx_base_from_blob(tx, txs.back()) : parse_and_validate_tx_from_blob(tx, txs.back());
|
||||||
|
if (!res)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Invalid transaction");
|
LOG_ERROR("Invalid transaction");
|
||||||
return false;
|
return false;
|
||||||
@ -5526,6 +5528,6 @@ void Blockchain::cache_block_template(const block &b, const cryptonote::account_
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace cryptonote {
|
namespace cryptonote {
|
||||||
template bool Blockchain::get_transactions(const std::vector<crypto::hash>&, std::vector<transaction>&, std::vector<crypto::hash>&) const;
|
template bool Blockchain::get_transactions(const std::vector<crypto::hash>&, std::vector<transaction>&, std::vector<crypto::hash>&, bool) const;
|
||||||
template bool Blockchain::get_split_transactions_blobs(const std::vector<crypto::hash>&, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>&, std::vector<crypto::hash>&) const;
|
template bool Blockchain::get_split_transactions_blobs(const std::vector<crypto::hash>&, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>&, std::vector<crypto::hash>&) const;
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ namespace cryptonote
|
|||||||
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
bool get_split_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
bool get_split_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
||||||
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
bool get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
bool get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs, bool pruned = false) const;
|
||||||
|
|
||||||
//debug functions
|
//debug functions
|
||||||
|
|
||||||
|
@ -427,9 +427,9 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs) const
|
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs);
|
return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs, pruned);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_split_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>& txs, std::vector<crypto::hash>& missed_txs) const
|
bool core::get_split_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>& txs, std::vector<crypto::hash>& missed_txs) const
|
||||||
@ -443,9 +443,9 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs) const
|
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs, bool pruned) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs);
|
return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs, pruned);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_alternative_blocks(std::vector<block>& blocks) const
|
bool core::get_alternative_blocks(std::vector<block>& blocks) const
|
||||||
@ -1241,7 +1241,7 @@ namespace cryptonote
|
|||||||
std::vector<transaction> txs;
|
std::vector<transaction> txs;
|
||||||
std::vector<crypto::hash> missed_txs;
|
std::vector<crypto::hash> missed_txs;
|
||||||
uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx);
|
uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx);
|
||||||
this->get_transactions(b.tx_hashes, txs, missed_txs);
|
this->get_transactions(b.tx_hashes, txs, missed_txs, true);
|
||||||
uint64_t tx_fee_amount = 0;
|
uint64_t tx_fee_amount = 0;
|
||||||
for(const auto& tx: txs)
|
for(const auto& tx: txs)
|
||||||
{
|
{
|
||||||
|
@ -385,7 +385,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::get_transactions
|
* @note see Blockchain::get_transactions
|
||||||
*/
|
*/
|
||||||
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs) const;
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_transactions
|
* @copydoc Blockchain::get_transactions
|
||||||
@ -399,7 +399,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::get_transactions
|
* @note see Blockchain::get_transactions
|
||||||
*/
|
*/
|
||||||
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs) const;
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_block_by_hash
|
* @copydoc Blockchain::get_block_by_hash
|
||||||
|
Loading…
Reference in New Issue
Block a user