Skip to content

Commit

Permalink
Check if the SQL DB is present for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Doy-lee committed Nov 21, 2024
1 parent 9a2c77d commit f8a6cdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3308,10 +3308,6 @@ hf Blockchain::get_network_version(std::optional<uint64_t> height) const {
return cryptonote::get_network_version(m_nettype, *height);
}

cryptonote::BlockchainSQLite& Blockchain::sqlite_db() {
return *m_sqlite_db;
}

//------------------------------------------------------------------
void Blockchain::flush_invalid_blocks() {
log::trace(logcat, "Blockchain::{}", __func__);
Expand Down
5 changes: 4 additions & 1 deletion src/cryptonote_core/blockchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,10 @@ class Blockchain {

const ons::name_system_db& name_system_db() const { return m_ons_db; }

cryptonote::BlockchainSQLite& sqlite_db();
cryptonote::BlockchainSQLite& sqlite_db() { return *m_sqlite_db; }

/// SQLite DB can be nullptr in some unit tests
cryptonote::BlockchainSQLite* maybe_sqlite_db() { return m_sqlite_db.get(); }

/// NOTE: unchecked access; should only be called in service node more where this is guaranteed
/// to be set.
Expand Down
3 changes: 2 additions & 1 deletion src/cryptonote_core/service_node_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,8 @@ void service_node_list::block_add(
}

// NOTE: Add block to SQL in lock-step with SNL
blockchain.sqlite_db().add_block(block, m_state);
if (auto* sql_db = blockchain.maybe_sqlite_db())
sql_db->add_block(block, m_state);
}

static std::mt19937_64 quorum_rng(hf hf_version, crypto::hash const& hash, quorum_type type) {
Expand Down

0 comments on commit f8a6cdb

Please sign in to comment.