aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/validation.cpp8
-rw-r--r--src/validation.h11
2 files changed, 16 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index a5b68e4ebd..31b78380af 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1244,7 +1244,9 @@ void CoinsViews::InitCache()
// NOTE: for now m_blockman is set to a global, but this will be changed
// in a future commit.
-CChainState::CChainState() : m_blockman(g_blockman) {}
+CChainState::CChainState(uint256 from_snapshot_blockhash)
+ : m_blockman(g_blockman),
+ m_from_snapshot_blockhash(from_snapshot_blockhash) {}
void CChainState::InitCoinsDB(
@@ -1253,6 +1255,10 @@ void CChainState::InitCoinsDB(
bool should_wipe,
std::string leveldb_name)
{
+ if (!m_from_snapshot_blockhash.IsNull()) {
+ leveldb_name += "_" + m_from_snapshot_blockhash.ToString();
+ }
+
m_coins_views = MakeUnique<CoinsViews>(
leveldb_name, cache_size_bytes, in_memory, should_wipe);
}
diff --git a/src/validation.h b/src/validation.h
index a5335edc43..07d90ab110 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -591,8 +591,8 @@ private:
std::unique_ptr<CoinsViews> m_coins_views;
public:
- CChainState(BlockManager& blockman) : m_blockman(blockman) {}
- CChainState();
+ explicit CChainState(BlockManager& blockman) : m_blockman(blockman) {}
+ explicit CChainState(uint256 from_snapshot_blockhash = uint256());
/**
* Initialize the CoinsViews UTXO set database management data structures. The in-memory
@@ -621,6 +621,13 @@ public:
CChain m_chain;
/**
+ * The blockhash which is the base of the snapshot this chainstate was created from.
+ *
+ * IsNull() if this chainstate was not created from a snapshot.
+ */
+ const uint256 m_from_snapshot_blockhash{};
+
+ /**
* The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and
* as good as our current tip or better. Entries may be failed, though, and pruning nodes may be
* missing the data for the block.