Skip to content

Commit

Permalink
[Refactoring][BUG] Unchecked LoadGenesisBlock return value
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Mar 2, 2021
1 parent 43cc880 commit 4749d52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,9 @@ void ThreadImport(const std::vector<fs::path>& vImportFiles)
fReindex = false;
LogPrintf("Reindexing finished\n");
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
LoadGenesisBlock();
if (!LoadGenesisBlock()) {
throw std::runtime_error("Error initializing block database");
}
}

// hardcoded $DATADIR/bootstrap.dat
Expand Down
4 changes: 3 additions & 1 deletion src/test/test_pivx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ TestingSetup::TestingSetup()
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
LoadGenesisBlock();
if (!LoadGenesisBlock()) {
throw std::runtime_error("Error initializing block database");
}
{
CValidationState state;
bool ok = ActivateBestChain(state);
Expand Down

0 comments on commit 4749d52

Please sign in to comment.