Skip to content

Commit 8e2ecfe

Browse files
committed
validation: add CChainState.m_from_snapshot_blockhash
This parameter is unused, but in future commits will allow ChainstateManager to differentiate between chainstates created from a UTXO snapshot from those that weren't.
1 parent d2d0a04 commit 8e2ecfe

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/validation.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,9 @@ void CoinsViews::InitCache()
12441244

12451245
// NOTE: for now m_blockman is set to a global, but this will be changed
12461246
// in a future commit.
1247-
CChainState::CChainState() : m_blockman(g_blockman) {}
1247+
CChainState::CChainState(uint256 from_snapshot_blockhash)
1248+
: m_blockman(g_blockman),
1249+
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
12481250

12491251

12501252
void CChainState::InitCoinsDB(
@@ -1253,6 +1255,10 @@ void CChainState::InitCoinsDB(
12531255
bool should_wipe,
12541256
std::string leveldb_name)
12551257
{
1258+
if (!m_from_snapshot_blockhash.IsNull()) {
1259+
leveldb_name += "_" + m_from_snapshot_blockhash.ToString();
1260+
}
1261+
12561262
m_coins_views = MakeUnique<CoinsViews>(
12571263
leveldb_name, cache_size_bytes, in_memory, should_wipe);
12581264
}

src/validation.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ class CChainState {
591591
std::unique_ptr<CoinsViews> m_coins_views;
592592

593593
public:
594-
CChainState(BlockManager& blockman) : m_blockman(blockman) {}
595-
CChainState();
594+
explicit CChainState(BlockManager& blockman) : m_blockman(blockman) {}
595+
explicit CChainState(uint256 from_snapshot_blockhash = uint256());
596596

597597
/**
598598
* Initialize the CoinsViews UTXO set database management data structures. The in-memory
@@ -620,6 +620,13 @@ class CChainState {
620620
//! @see CChain, CBlockIndex.
621621
CChain m_chain;
622622

623+
/**
624+
* The blockhash which is the base of the snapshot this chainstate was created from.
625+
*
626+
* IsNull() if this chainstate was not created from a snapshot.
627+
*/
628+
const uint256 m_from_snapshot_blockhash{};
629+
623630
/**
624631
* The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and
625632
* as good as our current tip or better. Entries may be failed, though, and pruning nodes may be

0 commit comments

Comments
 (0)