diff options
author | Carl Dong <contact@carldong.me> | 2021-08-18 13:54:08 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-12-06 16:41:58 -0500 |
commit | aad8d597890c3707ae96fdb2b9fadc270ca574dd (patch) | |
tree | 65d313242f40e5070adbd1026ed54753dab5dd5d /src/node | |
parent | b345979a2b03b671c0984edd7e48e0baec2e2f34 (diff) | |
download | bitcoin-aad8d597890c3707ae96fdb2b9fadc270ca574dd.tar.xz |
node/chainstate: Reduce coupling of LogPrintf
...by moving the try/catch out of LoadChainstate
I strongly recommend reviewing with the following git-diff flags:
--color-moved=dimmed_zebra --color-moved-ws=allow-indentation-change
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/chainstate.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 36d10e99d9..99bf3d8e94 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -26,7 +26,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull(); }; - try { + { LOCK(cs_main); chainman.InitializeChainstate(mempool); chainman.m_total_coinstip_cache = nCoinCacheUsage; @@ -113,9 +113,6 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, assert(chainstate->m_chain.Tip() != nullptr); } } - } catch (const std::exception& e) { - LogPrintf("%s\n", e.what()); - return ChainstateLoadingError::ERROR_GENERIC_BLOCKDB_OPEN_FAILED; } if (!fReset) { @@ -141,7 +138,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull(); }; - try { + { LOCK(cs_main); for (CChainState* chainstate : chainman.GetAll()) { @@ -165,9 +162,6 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage } } } - } catch (const std::exception& e) { - LogPrintf("%s\n", e.what()); - return ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE; } return std::nullopt; |