mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-24 14:17:46 +00:00
Add a few read txns to streamline
Slight perf gain, but mainly to reduce spam at loglevel 3
This commit is contained in:
parent
59c9d165f8
commit
dc53e9eef2
3 changed files with 11 additions and 3 deletions
|
@ -561,7 +561,7 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("No existing blocks to check for average block size");
|
LOG_PRINT_L1("No existing blocks to check for average block size");
|
||||||
}
|
}
|
||||||
else if (m_cum_count)
|
else if (m_cum_count >= num_prev_blocks)
|
||||||
{
|
{
|
||||||
avg_block_size = m_cum_size / m_cum_count;
|
avg_block_size = m_cum_size / m_cum_count;
|
||||||
LOG_PRINT_L1("average block size across recent " << m_cum_count << " blocks: " << avg_block_size);
|
LOG_PRINT_L1("average block size across recent " << m_cum_count << " blocks: " << avg_block_size);
|
||||||
|
@ -570,6 +570,9 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MDB_txn *rtxn;
|
||||||
|
mdb_txn_cursors *rcurs;
|
||||||
|
block_rtxn_start(&rtxn, &rcurs);
|
||||||
for (uint64_t block_num = block_start; block_num <= block_stop; ++block_num)
|
for (uint64_t block_num = block_start; block_num <= block_stop; ++block_num)
|
||||||
{
|
{
|
||||||
uint32_t block_size = get_block_size(block_num);
|
uint32_t block_size = get_block_size(block_num);
|
||||||
|
@ -578,6 +581,7 @@ uint64_t BlockchainLMDB::get_estimated_batch_size(uint64_t batch_num_blocks) con
|
||||||
// some blocks were to be skipped for being outliers.
|
// some blocks were to be skipped for being outliers.
|
||||||
++num_blocks_used;
|
++num_blocks_used;
|
||||||
}
|
}
|
||||||
|
block_rtxn_stop();
|
||||||
avg_block_size = total_block_size / num_blocks_used;
|
avg_block_size = total_block_size / num_blocks_used;
|
||||||
LOG_PRINT_L1("average block size across recent " << num_blocks_used << " blocks: " << avg_block_size);
|
LOG_PRINT_L1("average block size across recent " << num_blocks_used << " blocks: " << avg_block_size);
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1004,7 @@ tx_out BlockchainLMDB::output_from_blob(const blobdata& blob) const
|
||||||
|
|
||||||
void BlockchainLMDB::check_open() const
|
void BlockchainLMDB::check_open() const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
// LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
if (!m_open)
|
if (!m_open)
|
||||||
throw0(DB_ERROR("DB operation attempted on a not-open DB instance"));
|
throw0(DB_ERROR("DB operation attempted on a not-open DB instance"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,7 +372,7 @@ private:
|
||||||
uint64_t m_num_txs;
|
uint64_t m_num_txs;
|
||||||
uint64_t m_num_outputs;
|
uint64_t m_num_outputs;
|
||||||
mutable uint64_t m_cum_size; // used in batch size estimation
|
mutable uint64_t m_cum_size; // used in batch size estimation
|
||||||
mutable int m_cum_count;
|
mutable unsigned int m_cum_count;
|
||||||
std::string m_folder;
|
std::string m_folder;
|
||||||
mdb_txn_safe* m_write_txn; // may point to either a short-lived txn or a batch txn
|
mdb_txn_safe* m_write_txn; // may point to either a short-lived txn or a batch txn
|
||||||
mdb_txn_safe* m_write_batch_txn; // persist batch txn outside of BlockchainLMDB
|
mdb_txn_safe* m_write_batch_txn; // persist batch txn outside of BlockchainLMDB
|
||||||
|
|
|
@ -1986,12 +1986,14 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_db->block_txn_start(true);
|
||||||
resp.total_height = get_current_blockchain_height();
|
resp.total_height = get_current_blockchain_height();
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for(size_t i = resp.start_height; i < resp.total_height && count < BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT; i++, count++)
|
for(size_t i = resp.start_height; i < resp.total_height && count < BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT; i++, count++)
|
||||||
{
|
{
|
||||||
resp.m_block_ids.push_back(m_db->get_block_hash_from_height(i));
|
resp.m_block_ids.push_back(m_db->get_block_hash_from_height(i));
|
||||||
}
|
}
|
||||||
|
m_db->block_txn_stop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
@ -2022,6 +2024,7 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_db->block_txn_start(true);
|
||||||
total_height = get_current_blockchain_height();
|
total_height = get_current_blockchain_height();
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for(size_t i = start_height; i < total_height && count < max_count; i++, count++)
|
for(size_t i = start_height; i < total_height && count < max_count; i++, count++)
|
||||||
|
@ -2032,6 +2035,7 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons
|
||||||
get_transactions(blocks.back().first.tx_hashes, blocks.back().second, mis);
|
get_transactions(blocks.back().first.tx_hashes, blocks.back().second, mis);
|
||||||
CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found");
|
CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found");
|
||||||
}
|
}
|
||||||
|
m_db->block_txn_stop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue