mirror of
https://github.com/monero-project/monero.git
synced 2025-05-02 15:46:08 -04:00
blockchain_db: fix db txn ending too early
The db txn in add_block ending caused the entire overarching batch txn to stop. Also add a new guard class so a db txn can be stopped in the face of exceptions. Also use a read only db txn in init when the db itself is read only, and do not save the max tx size in that case.
This commit is contained in:
parent
37345921ec
commit
5e673c03fe
9 changed files with 144 additions and 95 deletions
|
@ -266,11 +266,9 @@ bool HardFork::reorganize_from_chain_height(uint64_t height)
|
|||
bool HardFork::rescan_from_block_height(uint64_t height)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
db.block_txn_start(true);
|
||||
if (height >= db.height()) {
|
||||
db.block_txn_stop();
|
||||
db_rtxn_guard rtxn_guard(&db);
|
||||
if (height >= db.height())
|
||||
return false;
|
||||
}
|
||||
|
||||
versions.clear();
|
||||
|
||||
|
@ -293,8 +291,6 @@ bool HardFork::rescan_from_block_height(uint64_t height)
|
|||
current_fork_index = voted;
|
||||
}
|
||||
|
||||
db.block_txn_stop();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue