Update Blockchain::get_db() to return reference instead of pointer
Where this method is used, a BlockchainDB object is always expected, so a pointer is unnecessary and less safe.
This commit is contained in:
parent
0386e9925b
commit
4bedd68d2c
|
@ -148,7 +148,7 @@ void BlockchainExport::write_block(block& block)
|
|||
#if SOURCE_DB == DB_MEMORY
|
||||
const transaction* cb_tx_full = m_blockchain_storage->get_tx(coinbase_tx_hash);
|
||||
#else
|
||||
transaction cb_tx_full = m_blockchain_storage->get_db()->get_tx(coinbase_tx_hash);
|
||||
transaction cb_tx_full = m_blockchain_storage->get_db().get_tx(coinbase_tx_hash);
|
||||
#endif
|
||||
|
||||
#if SOURCE_DB == DB_MEMORY
|
||||
|
@ -167,7 +167,7 @@ void BlockchainExport::write_block(block& block)
|
|||
#if SOURCE_DB == DB_MEMORY
|
||||
const transaction* tx = m_blockchain_storage->get_tx(tx_id);
|
||||
#else
|
||||
transaction tx = m_blockchain_storage->get_db()->get_tx(tx_id);
|
||||
transaction tx = m_blockchain_storage->get_db().get_tx(tx_id);
|
||||
#endif
|
||||
|
||||
#if SOURCE_DB == DB_MEMORY
|
||||
|
@ -205,18 +205,18 @@ void BlockchainExport::write_block(block& block)
|
|||
#if SOURCE_DB == DB_MEMORY
|
||||
size_t block_size = m_blockchain_storage->get_block_size(block_height);
|
||||
#else
|
||||
size_t block_size = m_blockchain_storage->get_db()->get_block_size(block_height);
|
||||
size_t block_size = m_blockchain_storage->get_db().get_block_size(block_height);
|
||||
#endif
|
||||
#if SOURCE_DB == DB_MEMORY
|
||||
difficulty_type cumulative_difficulty = m_blockchain_storage->get_block_cumulative_difficulty(block_height);
|
||||
#else
|
||||
difficulty_type cumulative_difficulty = m_blockchain_storage->get_db()->get_block_cumulative_difficulty(block_height);
|
||||
difficulty_type cumulative_difficulty = m_blockchain_storage->get_db().get_block_cumulative_difficulty(block_height);
|
||||
#endif
|
||||
#if SOURCE_DB == DB_MEMORY
|
||||
uint64_t coins_generated = m_blockchain_storage->get_block_coins_generated(block_height);
|
||||
#else
|
||||
// TODO TEST to verify that this is the equivalent. make sure no off-by-one error with block height vs block number
|
||||
uint64_t coins_generated = m_blockchain_storage->get_db()->get_block_already_generated_coins(block_height);
|
||||
uint64_t coins_generated = m_blockchain_storage->get_db().get_block_already_generated_coins(block_height);
|
||||
#endif
|
||||
|
||||
*m_raw_archive << block_size;
|
||||
|
|
|
@ -214,7 +214,7 @@ int import_from_file(FakeCore& simple_core, std::string& import_file_path)
|
|||
// Reset stats, in case we're using newly created db, accumulating stats
|
||||
// from addition of genesis block.
|
||||
// This aligns internal db counts with importer counts.
|
||||
simple_core.m_storage.get_db()->reset_stats();
|
||||
simple_core.m_storage.get_db().reset_stats();
|
||||
}
|
||||
#endif
|
||||
boost::filesystem::path raw_file_path(import_file_path);
|
||||
|
@ -497,7 +497,7 @@ int import_from_file(FakeCore& simple_core, std::string& import_file_path)
|
|||
simple_core.batch_start();
|
||||
std::cout << ENDL;
|
||||
#if !defined(BLOCKCHAIN_DB) || (BLOCKCHAIN_DB == DB_LMDB)
|
||||
simple_core.m_storage.get_db()->show_stats();
|
||||
simple_core.m_storage.get_db().show_stats();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ int import_from_file(FakeCore& simple_core, std::string& import_file_path)
|
|||
simple_core.batch_stop();
|
||||
}
|
||||
#if !defined(BLOCKCHAIN_DB) || (BLOCKCHAIN_DB == DB_LMDB)
|
||||
simple_core.m_storage.get_db()->show_stats();
|
||||
simple_core.m_storage.get_db().show_stats();
|
||||
#endif
|
||||
if (h > 0)
|
||||
LOG_PRINT_L0("Finished at height: " << h << " block: " << h-1);
|
||||
|
|
|
@ -55,7 +55,7 @@ struct fake_core_lmdb
|
|||
m_pool.init(path.string());
|
||||
m_storage.init(path.string(), use_testnet, mdb_flags);
|
||||
if (do_batch)
|
||||
m_storage.get_db()->set_batch_transactions(do_batch);
|
||||
m_storage.get_db().set_batch_transactions(do_batch);
|
||||
support_batch = true;
|
||||
support_add_block = true;
|
||||
}
|
||||
|
@ -71,17 +71,17 @@ struct fake_core_lmdb
|
|||
, const std::vector<transaction>& txs
|
||||
)
|
||||
{
|
||||
return m_storage.get_db()->add_block(blk, block_size, cumulative_difficulty, coins_generated, txs);
|
||||
return m_storage.get_db().add_block(blk, block_size, cumulative_difficulty, coins_generated, txs);
|
||||
}
|
||||
|
||||
void batch_start()
|
||||
{
|
||||
m_storage.get_db()->batch_start();
|
||||
m_storage.get_db().batch_start();
|
||||
}
|
||||
|
||||
void batch_stop()
|
||||
{
|
||||
m_storage.get_db()->batch_stop();
|
||||
m_storage.get_db().batch_stop();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -145,9 +145,9 @@ namespace cryptonote
|
|||
void set_enforce_dns_checkpoints(bool enforce);
|
||||
bool update_checkpoints(const std::string& file_path, bool check_dns);
|
||||
|
||||
BlockchainDB* get_db()
|
||||
BlockchainDB& get_db()
|
||||
{
|
||||
return m_db;
|
||||
return *m_db;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue