aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/blockchain.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2021-03-04 14:55:43 +0100
committerWladimir J. van der Laan <laanwj@protonmail.com>2021-03-04 14:55:47 +0100
commit702cfc8c531d9ab42aa6975c4fc3cacfd1ddfd8f (patch)
tree2b03ff50e16c585424d11fabe8b72766009d52e8 /src/rpc/blockchain.cpp
parent83bdbbd300bb17bef07bc63735a84a0b0ce59958 (diff)
parente11b6496506246882df450586acf735dabedf731 (diff)
downloadbitcoin-702cfc8c531d9ab42aa6975c4fc3cacfd1ddfd8f.tar.xz
Merge #21055: [Bundle 3/n] Prune remaining g_chainman usage in validation functions
e11b6496506246882df450586acf735dabedf731 validation: CVerifyDB::VerifyDB: Use locking annotation (Carl Dong) 03f75c42e12a272057adccb6f0077e71f971eeef validation: Use existing chain member in CChainState::LoadGenesisBlock (Carl Dong) 5e4af773809415b71a10e3120cc44854d61c4c19 validation: Use existing chain member in CChainState::AcceptBlock (Carl Dong) fee73347c0015e4c24595c9708831d76cd6eec8c validation: Pass in chain to FindBlockPos+SaveBlockToDisk (Carl Dong) a9d28bcd8d8f71d089322b1d631390352e31ee2b validation: Use *this in CChainState::ActivateBestChainStep (Carl Dong) 4744efc9bae8b22efb76152a3c045d054c880399 validation: Pass in chainstate to CTxMemPool::check (Carl Dong) 1fb7b2c59505a6b9768789f6caad215a0a22ef16 validation: Use *this in CChainState::InvalidateBlock (Carl Dong) 8cdb2f7e58dfd9a631a8cbb8f0ee7e8c0c304eb4 validation: Move LoadBlockIndexDB to CChainState (Carl Dong) 8b99efbcc08ab41caf657c6d730a27e6a91bc356 validation: Move invalid block handling to CChainState (Carl Dong) 2bdf37fe187ba6f090a0f5299b74d5d82cde4697 validation: Pass in chainstate to CVerifyDB::VerifyDB (Carl Dong) 31eac50c721dd3b0bd2347e76196bf16913e9be9 validation: Remove global ::VersionBitsTip{State,SinceHeight,Statistics} (Carl Dong) 63e4c7316a537900f525e221d8042587b443cc3d validation: Pass in chainstate to ::PruneBlockFilesManual (Carl Dong) 4bada76237d734c1de38d3bd58689caeefd5e8cb validation: Pass in chainstate to UpdateTip (Carl Dong) a3ba08ba7dec0b016e42233cd4a061ba1a0e86c1 validation: Remove global ::{{Precious,Invalidate}Block,ResetBlockFailureFlags} (Carl Dong) 4927c9e6991b09a36a41aab93a0e05332d899611 validation: Remove global ::LoadGenesisBlock (Carl Dong) 9da106be4db692fa5db7b4de79f9cf7bfef37075 validation: Check chain tip is non-null in CheckFinalTx (Carl Dong) Pull request description: Overall PR: #20158 (tree-wide: De-globalize ChainstateManager) Based on: - [x] #20750 | [Bundle 2/n] Prune g_chainman usage in mempool-related validation functions Note to reviewers: 1. This bundle may _apparently_ introduce usage of `g_chainman` or `::Chain(state|)Active()` globals, but these are resolved later on in the overall PR. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 2. There may be seemingly obvious local references to `ChainstateManager` or other validation objects which are not being used in callers of the current function in question, this is done intentionally to **_keep each commit centered around one function/method_** to ease review and to make the overall change systematic. We don't assume anything about our callers. Rest assured that once we are considering that particular caller in later commits, we will use the obvious local references. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 3. When changing a function/method that has many callers (e.g. `LookupBlockIndex` with 55 callers), it is sometimes easier (and less error-prone) to use a scripted-diff. When doing so, there will be 3 commits in sequence so that every commit compiles like so: 1. Add `new_function`, make `old_function` a wrapper of `new_function`, divert all calls to `old_function` to `new_function` **in the local module only** 2. Scripted-diff to divert all calls to `old_function` to `new_function` **in the rest of the codebase** 3. Remove `old_function` Note to self: - [x] Address: https://github.com/bitcoin/bitcoin/pull/20750#discussion_r579400663 ACKs for top commit: laanwj: Code review ACK e11b6496506246882df450586acf735dabedf731 Tree-SHA512: 205a451a741e32f17d5966de289f2f5a3f0817738c0087b70ff4755ddd217b53d01050ed396669bda2b1d216a88d927b9778777f9ff95ab1fe20e59c5f341776
Diffstat (limited to 'src/rpc/blockchain.cpp')
-rw-r--r--src/rpc/blockchain.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index c71d2cbe49..ab0c0b8385 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -1015,7 +1015,7 @@ static RPCHelpMan pruneblockchain()
height = chainHeight - MIN_BLOCKS_TO_KEEP;
}
- PruneBlockFilesManual(height);
+ PruneBlockFilesManual(::ChainstateActive(), height);
const CBlockIndex* block = ::ChainActive().Tip();
CHECK_NONFATAL(block);
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
@@ -1200,7 +1200,7 @@ static RPCHelpMan verifychain()
LOCK(cs_main);
- return CVerifyDB().VerifyDB(Params(), &::ChainstateActive().CoinsTip(), check_level, check_depth);
+ return CVerifyDB().VerifyDB(Params(), ::ChainstateActive(), &::ChainstateActive().CoinsTip(), check_level, check_depth);
},
};
}
@@ -1232,7 +1232,7 @@ static void BIP9SoftForkDescPushBack(UniValue& softforks, const std::string &nam
if (consensusParams.vDeployments[id].nTimeout <= 1230768000) return;
UniValue bip9(UniValue::VOBJ);
- const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
+ const ThresholdState thresholdState = VersionBitsState(::ChainActive().Tip(), consensusParams, id, versionbitscache);
switch (thresholdState) {
case ThresholdState::DEFINED: bip9.pushKV("status", "defined"); break;
case ThresholdState::STARTED: bip9.pushKV("status", "started"); break;
@@ -1246,12 +1246,12 @@ static void BIP9SoftForkDescPushBack(UniValue& softforks, const std::string &nam
}
bip9.pushKV("start_time", consensusParams.vDeployments[id].nStartTime);
bip9.pushKV("timeout", consensusParams.vDeployments[id].nTimeout);
- int64_t since_height = VersionBitsTipStateSinceHeight(consensusParams, id);
+ int64_t since_height = VersionBitsStateSinceHeight(::ChainActive().Tip(), consensusParams, id, versionbitscache);
bip9.pushKV("since", since_height);
if (ThresholdState::STARTED == thresholdState)
{
UniValue statsUV(UniValue::VOBJ);
- BIP9Stats statsStruct = VersionBitsTipStatistics(consensusParams, id);
+ BIP9Stats statsStruct = VersionBitsStatistics(::ChainActive().Tip(), consensusParams, id);
statsUV.pushKV("period", statsStruct.period);
statsUV.pushKV("threshold", statsStruct.threshold);
statsUV.pushKV("elapsed", statsStruct.elapsed);
@@ -1562,7 +1562,7 @@ static RPCHelpMan preciousblock()
}
BlockValidationState state;
- PreciousBlock(state, Params(), pblockindex);
+ ::ChainstateActive().PreciousBlock(state, Params(), pblockindex);
if (!state.IsValid()) {
throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
@@ -1598,7 +1598,7 @@ static RPCHelpMan invalidateblock()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
}
- InvalidateBlock(state, Params(), pblockindex);
+ ::ChainstateActive().InvalidateBlock(state, Params(), pblockindex);
if (state.IsValid()) {
::ChainstateActive().ActivateBestChain(state, Params());
@@ -1637,7 +1637,7 @@ static RPCHelpMan reconsiderblock()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
}
- ResetBlockFailureFlags(pblockindex);
+ ::ChainstateActive().ResetBlockFailureFlags(pblockindex);
}
BlockValidationState state;