You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3e6ac5b refactor: validation: mark CheckBlockIndex as const (stickies-v)
61a51ec validation: don't use GetAll() in CheckBlockIndex() (stickies-v)
d05481d refactor: validation: mark SnapshotBase as const (stickies-v)
Pull request description:
While reviewing another PR, I [noticed](bitcoin/bitcoin#31405 (comment)) that `ChainstateManager::CheckBlockIndex()` is not a `const` method. To try and assert that this method was not causing any side-effects, I modified the method to make it `const`. It did not surface any errors, but I think it would be good to merge this change regardless, even if `CheckBlockIndex` is only used in regtest.
This PR removes `CheckBlockIndex()`'s calls to non-const `ChainstateManager` methods by marking `SnapshotBase` `const` and ~inlining the `GetAll()` calls (thereby also performing consistency checks on invalid or fully validated `m_disabled==true` chainstates, as slight behaviour change), and finally marks `CheckBlockIndex()` as `const`.
ACKs for top commit:
achow101:
ACK 3e6ac5b
mzumsande:
Code Review ACK 3e6ac5b
TheCharlatan:
ACK 3e6ac5b
Tree-SHA512: 3d3cd351f5af1fab9a9498218ec62dba6e397fc7b5f4868ae0a77dc2b7c813d12c4f53f253f209101a3f6523695014e20c82dfac27cf0035611d5dd29feb80b5
// Iterate over the entire block tree, using depth-first search.
5262
5262
// Along the way, remember whether there are blocks on the path from genesis
5263
5263
// block being explored which are the first to have certain properties.
5264
5264
size_t nNodes = 0;
5265
5265
int nHeight = 0;
5266
-
CBlockIndex* pindexFirstInvalid = nullptr; // Oldest ancestor of pindex which is invalid.
5267
-
CBlockIndex* pindexFirstMissing = nullptr; // Oldest ancestor of pindex which does not have BLOCK_HAVE_DATA, since assumeutxo snapshot if used.
5268
-
CBlockIndex* pindexFirstNeverProcessed = nullptr; // Oldest ancestor of pindex for which nTx == 0, since assumeutxo snapshot if used.
5269
-
CBlockIndex* pindexFirstNotTreeValid = nullptr; // Oldest ancestor of pindex which does not have BLOCK_VALID_TREE (regardless of being valid or not).
5270
-
CBlockIndex* pindexFirstNotTransactionsValid = nullptr; // Oldest ancestor of pindex which does not have BLOCK_VALID_TRANSACTIONS (regardless of being valid or not), since assumeutxo snapshot if used.
5271
-
CBlockIndex* pindexFirstNotChainValid = nullptr; // Oldest ancestor of pindex which does not have BLOCK_VALID_CHAIN (regardless of being valid or not), since assumeutxo snapshot if used.
5272
-
CBlockIndex* pindexFirstNotScriptsValid = nullptr; // Oldest ancestor of pindex which does not have BLOCK_VALID_SCRIPTS (regardless of being valid or not), since assumeutxo snapshot if used.
5266
+
constCBlockIndex* pindexFirstInvalid = nullptr;// Oldest ancestor of pindex which is invalid.
5267
+
constCBlockIndex* pindexFirstMissing = nullptr;// Oldest ancestor of pindex which does not have BLOCK_HAVE_DATA, since assumeutxo snapshot if used.
5268
+
constCBlockIndex* pindexFirstNeverProcessed = nullptr;// Oldest ancestor of pindex for which nTx == 0, since assumeutxo snapshot if used.
5269
+
constCBlockIndex* pindexFirstNotTreeValid = nullptr;// Oldest ancestor of pindex which does not have BLOCK_VALID_TREE (regardless of being valid or not).
5270
+
constCBlockIndex* pindexFirstNotTransactionsValid = nullptr; // Oldest ancestor of pindex which does not have BLOCK_VALID_TRANSACTIONS (regardless of being valid or not), since assumeutxo snapshot if used.
5271
+
constCBlockIndex* pindexFirstNotChainValid = nullptr;// Oldest ancestor of pindex which does not have BLOCK_VALID_CHAIN (regardless of being valid or not), since assumeutxo snapshot if used.
5272
+
constCBlockIndex* pindexFirstNotScriptsValid = nullptr;// Oldest ancestor of pindex which does not have BLOCK_VALID_SCRIPTS (regardless of being valid or not), since assumeutxo snapshot if used.
5273
5273
5274
5274
// After checking an assumeutxo snapshot block, reset pindexFirst pointers
5275
5275
// to earlier blocks that have not been downloaded or validated yet, so
5276
5276
// checks for later blocks can assume the earlier blocks were validated and
0 commit comments