aboutsummaryrefslogtreecommitdiff
path: root/src/index/base.h
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2019-09-23 14:44:54 -0400
committerJames O'Beirne <james.obeirne@pm.me>2023-09-30 06:38:47 -0400
commit373cf91531b84bfdd06fdf8abf4dca228029ce6b (patch)
tree0038ed40c747e33d8cca9a905fdb07cb539ee5ac /src/index/base.h
parent1fffdd76a1bca908f55d73b64983655b14cf7432 (diff)
downloadbitcoin-373cf91531b84bfdd06fdf8abf4dca228029ce6b.tar.xz
validation: indexing changes for assumeutxo
When using an assumedvalid chainstate, only process validationinterface callbacks from the background chainstate within indexes. This ensures that all indexes are built in-order. Later, we can possibly designate indexes which can be built out of order and continue their operation during snapshot use. Once the background sync has completed, restart the indexes so that they continue to index the now-validated snapshot chainstate.
Diffstat (limited to 'src/index/base.h')
-rw-r--r--src/index/base.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/index/base.h b/src/index/base.h
index b93103eb36..154061fb19 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -15,6 +15,7 @@
class CBlock;
class CBlockIndex;
class Chainstate;
+class ChainstateManager;
namespace interfaces {
class Chain;
} // namespace interfaces
@@ -30,6 +31,11 @@ struct IndexSummary {
* Base class for indices of blockchain data. This implements
* CValidationInterface and ensures blocks are indexed sequentially according
* to their position in the active chain.
+ *
+ * In the presence of multiple chainstates (i.e. if a UTXO snapshot is loaded),
+ * only the background "IBD" chainstate will be indexed to avoid building the
+ * index out of order. When the background chainstate completes validation, the
+ * index will be reinitialized and indexing will continue.
*/
class BaseIndex : public CValidationInterface
{
@@ -122,9 +128,6 @@ protected:
virtual DB& GetDB() const = 0;
- /// Get the name of the index for display in logs.
- const std::string& GetName() const LIFETIMEBOUND { return m_name; }
-
/// Update the internal best block index as well as the prune lock.
void SetBestBlockIndex(const CBlockIndex* block);
@@ -133,6 +136,9 @@ public:
/// Destructor interrupts sync thread if running and blocks until it exits.
virtual ~BaseIndex();
+ /// Get the name of the index for display in logs.
+ const std::string& GetName() const LIFETIMEBOUND { return m_name; }
+
/// Blocks the current thread until the index is caught up to the current
/// state of the block chain. This only blocks if the index has gotten in
/// sync once and only needs to process blocks in the ValidationInterface