diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2023-10-03 00:22:37 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2023-10-06 18:12:31 +0200 |
commit | a47fbe7d49e8921214ac159c558ff4ca19f98dce (patch) | |
tree | cadc331ce264d86b25fdb8ff35ed59e051492583 /src | |
parent | 0a39b8cbd88e9a496823b36feed77d137ccd894c (diff) |
doc: Add and edit some comments around assumeutxo
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 2 | ||||
-rw-r--r-- | src/node/blockstorage.cpp | 5 | ||||
-rw-r--r-- | src/validation.cpp | 4 | ||||
-rw-r--r-- | src/validation.h | 18 |
4 files changed, 15 insertions, 14 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a8d1553eed..bebbc66444 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1937,6 +1937,8 @@ void PeerManagerImpl::BlockConnected( } } + // The following task can be skipped since we don't maintain a mempool for + // the ibd/background chainstate. if (role == ChainstateRole::BACKGROUND) { return; } diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 706b62ea9b..6e4e018b4a 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -761,9 +761,10 @@ bool BlockManager::FlushChainstateBlockFile(int tip_height) { LOCK(cs_LastBlockFile); auto& cursor = m_blockfile_cursors[BlockfileTypeForHeight(tip_height)]; + // If the cursor does not exist, it means an assumeutxo snapshot is loaded, + // but no blocks past the snapshot height have been written yet, so there + // is no data associated with the chainstate, and it is safe not to flush. if (cursor) { - // The cursor may not exist after a snapshot has been loaded but before any - // blocks have been downloaded. return FlushBlockFile(cursor->file_num, /*fFinalize=*/false, /*finalize_undo=*/false); } return false; diff --git a/src/validation.cpp b/src/validation.cpp index 27e1a9785b..07e8b9152b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -68,8 +68,8 @@ #include <numeric> #include <optional> #include <string> -#include <utility> #include <tuple> +#include <utility> using kernel::CCoinsStats; using kernel::CoinStatsHashType; @@ -5367,7 +5367,7 @@ bool ChainstateManager::PopulateAndValidateSnapshot( // ActivateSnapshot(), but is done so that we avoid doing the long work of staging // a snapshot that isn't actually usable. if (WITH_LOCK(::cs_main, return !CBlockIndexWorkComparator()(ActiveTip(), snapshot_start_block))) { - LogPrintf("[snapshot] activation failed - height does not exceed active chainstate\n"); + LogPrintf("[snapshot] activation failed - work does not exceed active chainstate\n"); return false; } diff --git a/src/validation.h b/src/validation.h index 33d97f0b20..7ce60da634 100644 --- a/src/validation.h +++ b/src/validation.h @@ -836,9 +836,10 @@ private: //! Once this pointer is set to a corresponding chainstate, it will not //! be reset until init.cpp:Shutdown(). //! - //! This is especially important when, e.g., calling ActivateBestChain() - //! on all chainstates because we are not able to hold ::cs_main going into - //! that call. + //! It is important for the pointer to not be deleted until shutdown, + //! because cs_main is not always held when the pointer is accessed, for + //! example when calling ActivateBestChain, so there's no way you could + //! prevent code from using the pointer while deleting it. std::unique_ptr<Chainstate> m_ibd_chainstate GUARDED_BY(::cs_main); //! A chainstate initialized on the basis of a UTXO snapshot. If this is @@ -847,17 +848,14 @@ private: //! Once this pointer is set to a corresponding chainstate, it will not //! be reset until init.cpp:Shutdown(). //! - //! This is especially important when, e.g., calling ActivateBestChain() - //! on all chainstates because we are not able to hold ::cs_main going into - //! that call. + //! It is important for the pointer to not be deleted until shutdown, + //! because cs_main is not always held when the pointer is accessed, for + //! example when calling ActivateBestChain, so there's no way you could + //! prevent code from using the pointer while deleting it. std::unique_ptr<Chainstate> m_snapshot_chainstate GUARDED_BY(::cs_main); //! Points to either the ibd or snapshot chainstate; indicates our //! most-work chain. - //! - //! This is especially important when, e.g., calling ActivateBestChain() - //! on all chainstates because we are not able to hold ::cs_main going into - //! that call. Chainstate* m_active_chainstate GUARDED_BY(::cs_main) {nullptr}; CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr}; |