mirror of
https://github.com/monero-project/monero.git
synced 2025-08-02 16:26:17 -04:00
BlockchainDB/LMDB: Refactor block-scope DB txn handling for add block
Move block-scope txn start and stop from BlockchainLMDB to BlockchainDB.
This commit is contained in:
parent
f3a6000094
commit
fd46c96dce
2 changed files with 10 additions and 20 deletions
|
@ -99,6 +99,8 @@ uint64_t BlockchainDB::add_block( const block& blk
|
|||
, const std::vector<transaction>& txs
|
||||
)
|
||||
{
|
||||
block_txn_start();
|
||||
|
||||
TIME_MEASURE_START(time1);
|
||||
crypto::hash blk_hash = get_block_hash(blk);
|
||||
TIME_MEASURE_FINISH(time1);
|
||||
|
@ -125,9 +127,15 @@ uint64_t BlockchainDB::add_block( const block& blk
|
|||
TIME_MEASURE_FINISH(time1);
|
||||
time_add_transaction += time1;
|
||||
|
||||
// DB's new height based on this added block is only incremented after this
|
||||
// function returns, so height() here returns the new previous height.
|
||||
uint64_t prev_height = height();
|
||||
|
||||
block_txn_stop();
|
||||
|
||||
++num_calls;
|
||||
|
||||
return height();
|
||||
return prev_height;
|
||||
}
|
||||
|
||||
void BlockchainDB::pop_block(block& blk, std::vector<transaction>& txs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue