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:
@@ -211,8 +211,6 @@ uint64_t BlockchainDB::add_block( const std::pair<block, blobdata>& blck
|
||||
if (blk.tx_hashes.size() != txs.size())
|
||||
throw std::runtime_error("Inconsistent tx/hashes sizes");
|
||||
|
||||
block_txn_start(false);
|
||||
|
||||
TIME_MEASURE_START(time1);
|
||||
crypto::hash blk_hash = get_block_hash(blk);
|
||||
TIME_MEASURE_FINISH(time1);
|
||||
@@ -252,8 +250,6 @@ uint64_t BlockchainDB::add_block( const std::pair<block, blobdata>& blck
|
||||
|
||||
m_hardfork->add(blk, prev_height);
|
||||
|
||||
block_txn_stop();
|
||||
|
||||
++num_calls;
|
||||
|
||||
return prev_height;
|
||||
|
||||
Reference in New Issue
Block a user