diff --git a/src/minerfund.cpp b/src/minerfund.cpp --- a/src/minerfund.cpp +++ b/src/minerfund.cpp @@ -9,7 +9,6 @@ #include #include // For DecodeDestination #include -#include // For VersionBitsBlockState /** * Percentage of the block reward to be sent to the fund. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1466,8 +1466,8 @@ } 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"); @@ -1490,11 +1490,13 @@ } 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); diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -375,29 +375,6 @@ nSigChecksTxLimiter, nullptr, nullptr); } -/** Get the BIP9 state for a given deployment at the current tip. */ -ThresholdState VersionBitsTipState(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos); - -/** Get the BIP9 state for a given deployment at a given block. */ -ThresholdState VersionBitsBlockState(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos, - const CBlockIndex *pindex); - -/** - * Get the numerical statistics for the BIP9 state for a given deployment at the - * current tip. - */ -BIP9Stats VersionBitsTipStatistics(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos); - -/** - * Get the block height at which the BIP9 deployment switched into the state for - * the block building on the current tip. - */ -int VersionBitsTipStateSinceHeight(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos); - /** * Mark all the coins corresponding to a given transaction inputs as spent. */ @@ -1290,6 +1267,8 @@ */ extern std::unique_ptr pblocktree; +extern VersionBitsCache versionbitscache; + /** * Determine what nVersion a new block should use. */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5844,39 +5844,6 @@ return &vinfoBlockFile.at(n); } -static ThresholdState VersionBitsStateImpl(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos, - const CBlockIndex *pindex) - EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - return VersionBitsState(pindex, params, pos, versionbitscache); -} - -ThresholdState VersionBitsTipState(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos) { - LOCK(cs_main); - return VersionBitsStateImpl(params, pos, ::ChainActive().Tip()); -} - -ThresholdState VersionBitsBlockState(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos, - const CBlockIndex *pindex) { - LOCK(cs_main); - return VersionBitsStateImpl(params, pos, pindex); -} - -BIP9Stats VersionBitsTipStatistics(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos) { - LOCK(cs_main); - return VersionBitsStatistics(::ChainActive().Tip(), params, pos); -} - -int VersionBitsTipStateSinceHeight(const Consensus::Params ¶ms, - Consensus::DeploymentPos pos) { - LOCK(cs_main); - return VersionBitsStateSinceHeight(::ChainActive().Tip(), params, pos, - versionbitscache); -} - static const uint64_t MEMPOOL_DUMP_VERSION = 1; bool LoadMempool(const Config &config, CTxMemPool &pool, diff --git a/src/versionbits.h b/src/versionbits.h --- a/src/versionbits.h +++ b/src/versionbits.h @@ -113,13 +113,22 @@ void Clear(); }; +/** Get the BIP9 state for a given deployment at the current tip. */ ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache); +/** + * Get the numerical statistics for the BIP9 state for a given deployment at the + * current tip. + */ BIP9Stats VersionBitsStatistics(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos); +/** + * Get the block height at which the BIP9 deployment switched into the state for + * the block building on the current tip. + */ int VersionBitsStateSinceHeight(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -25,7 +25,6 @@ "avalanche/processor -> validation -> avalanche/processor" "chainparams -> protocol -> chainparams" "chainparamsbase -> util/system -> chainparamsbase" - "minerfund -> validation -> minerfund" "script/scriptcache -> validation -> script/scriptcache" "seeder/bitcoin -> seeder/db -> seeder/bitcoin" "chainparams -> protocol -> config -> chainparams"