aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index/base.cpp10
-rw-r--r--src/index/base.h4
-rw-r--r--src/init.cpp12
-rw-r--r--src/test/blockfilter_index_tests.cpp2
-rw-r--r--src/test/coinstatsindex_tests.cpp2
-rw-r--r--src/test/txindex_tests.cpp2
6 files changed, 18 insertions, 14 deletions
diff --git a/src/index/base.cpp b/src/index/base.cpp
index 0ab49f8a37..4079fc4569 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -98,9 +98,7 @@ bool BaseIndex::Init()
}
}
if (prune_violation) {
- // throw error and graceful shutdown if we can't build the index
- FatalError("%s: %s best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)", __func__, GetName());
- return false;
+ return InitError(strprintf(Untranslated("%s best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)"), GetName()));
}
}
return true;
@@ -339,17 +337,17 @@ void BaseIndex::Interrupt()
m_interrupt();
}
-void BaseIndex::Start()
+bool BaseIndex::Start()
{
// Need to register this ValidationInterface before running Init(), so that
// callbacks are not missed if Init sets m_synced to true.
RegisterValidationInterface(this);
if (!Init()) {
- FatalError("%s: %s failed to initialize", __func__, GetName());
- return;
+ return false;
}
m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { ThreadSync(); });
+ return true;
}
void BaseIndex::Stop()
diff --git a/src/index/base.h b/src/index/base.h
index d887620524..59eefab29e 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -84,7 +84,7 @@ protected:
const CBlockIndex* CurrentIndex() { return m_best_block_index.load(); };
/// Initialize internal state from the database and block index.
- virtual bool Init();
+ [[nodiscard]] virtual bool Init();
/// Write update index entries for a newly connected block.
virtual bool WriteBlock(const CBlock& block, const CBlockIndex* pindex) { return true; }
@@ -117,7 +117,7 @@ public:
/// Start initializes the sync state and registers the instance as a
/// ValidationInterface so that it stays in sync with blockchain updates.
- void Start();
+ [[nodiscard]] bool Start();
/// Stops the instance from staying in sync with blockchain updates.
void Stop();
diff --git a/src/init.cpp b/src/init.cpp
index 481c3c7d63..89e152e56f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1550,17 +1550,23 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
// ********************************************************* Step 8: start indexers
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
g_txindex = std::make_unique<TxIndex>(nTxIndexCache, false, fReindex);
- g_txindex->Start();
+ if (!g_txindex->Start()) {
+ return false;
+ }
}
for (const auto& filter_type : g_enabled_filter_types) {
InitBlockFilterIndex(filter_type, filter_index_cache, false, fReindex);
- GetBlockFilterIndex(filter_type)->Start();
+ if (!GetBlockFilterIndex(filter_type)->Start()) {
+ return false;
+ }
}
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) {
g_coin_stats_index = std::make_unique<CoinStatsIndex>(/* cache size */ 0, false, fReindex);
- g_coin_stats_index->Start();
+ if (!g_coin_stats_index->Start()) {
+ return false;
+ }
}
// ********************************************************* Step 9: load wallet
diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp
index 9903ba75cb..1cb1c002f4 100644
--- a/src/test/blockfilter_index_tests.cpp
+++ b/src/test/blockfilter_index_tests.cpp
@@ -131,7 +131,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
// BlockUntilSyncedToCurrentChain should return false before index is started.
BOOST_CHECK(!filter_index.BlockUntilSyncedToCurrentChain());
- filter_index.Start();
+ BOOST_REQUIRE(filter_index.Start());
// Allow filter index to catch up with the block index.
constexpr int64_t timeout_ms = 10 * 1000;
diff --git a/src/test/coinstatsindex_tests.cpp b/src/test/coinstatsindex_tests.cpp
index 3fc7b72077..bf7a80ae5c 100644
--- a/src/test/coinstatsindex_tests.cpp
+++ b/src/test/coinstatsindex_tests.cpp
@@ -32,7 +32,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
// is started.
BOOST_CHECK(!coin_stats_index.BlockUntilSyncedToCurrentChain());
- coin_stats_index.Start();
+ BOOST_REQUIRE(coin_stats_index.Start());
// Allow the CoinStatsIndex to catch up with the block index that is syncing
// in a background thread.
diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp
index 5fc172ee86..082655d811 100644
--- a/src/test/txindex_tests.cpp
+++ b/src/test/txindex_tests.cpp
@@ -27,7 +27,7 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
// BlockUntilSyncedToCurrentChain should return false before txindex is started.
BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
- txindex.Start();
+ BOOST_REQUIRE(txindex.Start());
// Allow tx index to catch up with the block index.
constexpr int64_t timeout_ms = 10 * 1000;