From 7991bbbbfdf69f1424393c351df0356bd6642853 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Jun 2025 18:39:43 +0000 Subject: [PATCH 1/7] refactor: disambiguate presence of `cs_main` in global namespace We will do this primarily for Dash-specific code --- src/coinjoin/client.cpp | 2 +- src/coinjoin/coinjoin.cpp | 6 +++--- src/coinjoin/coinjoin.h | 2 +- src/coinjoin/server.cpp | 6 +++--- src/coinjoin/util.cpp | 4 ++-- src/evo/assetlocktx.cpp | 2 +- src/evo/deterministicmns.cpp | 2 +- src/evo/deterministicmns.h | 2 +- src/evo/mnhftx.h | 2 +- src/evo/simplifiedmns.cpp | 2 +- src/evo/specialtxman.cpp | 10 +++++----- src/evo/specialtxman.h | 8 ++++---- src/governance/governance.cpp | 14 ++++++------- src/governance/object.cpp | 8 ++++---- src/governance/object.h | 8 ++++---- src/llmq/blockprocessor.cpp | 20 +++++++++---------- src/llmq/blockprocessor.h | 18 ++++++++--------- src/llmq/chainlocks.cpp | 10 +++++----- src/llmq/commitment.cpp | 2 +- src/llmq/debug.cpp | 2 +- src/llmq/dkgsessionhandler.cpp | 2 +- src/llmq/dkgsessionmgr.cpp | 4 ++-- src/llmq/ehf_signals.cpp | 4 ++-- src/llmq/instantsend.cpp | 14 ++++++------- src/llmq/quorums.cpp | 12 +++++------ src/llmq/snapshot.cpp | 4 ++-- src/rpc/evo.cpp | 32 +++++++++++++++--------------- src/rpc/masternode.cpp | 12 +++++------ src/wallet/test/coinjoin_tests.cpp | 6 +++--- src/wallet/test/wallet_tests.cpp | 8 ++++---- 30 files changed, 114 insertions(+), 114 deletions(-) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index d7fdb87a3911..5c31e1560f3e 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -54,7 +54,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnm vRecv >> dsq; { - LOCK(cs_main); + LOCK(::cs_main); peerman.EraseObjectRequest(peer.GetId(), CInv(MSG_DSQ, dsq.GetHash())); } diff --git a/src/coinjoin/coinjoin.cpp b/src/coinjoin/coinjoin.cpp index 2e226296b930..fafdf4528755 100644 --- a/src/coinjoin/coinjoin.cpp +++ b/src/coinjoin/coinjoin.cpp @@ -257,7 +257,7 @@ bool CCoinJoinBaseSession::IsValidInOuts(CChainState& active_chainstate, const l nFees -= txout.nValue; } - CCoinsViewMemPool viewMemPool(WITH_LOCK(cs_main, return &active_chainstate.CoinsTip()), mempool); + CCoinsViewMemPool viewMemPool(WITH_LOCK(::cs_main, return &active_chainstate.CoinsTip()), mempool); for (const auto& txin : vin) { LogPrint(BCLog::COINJOIN, "CCoinJoinBaseSession::%s -- txin=%s\n", __func__, txin.ToString()); @@ -299,7 +299,7 @@ bool CCoinJoinBaseSession::IsValidInOuts(CChainState& active_chainstate, const l // but CoinJoin still requires ATMP with fee sanity checks so we need to implement them separately bool ATMPIfSaneFee(ChainstateManager& chainman, const CTransactionRef& tx, bool test_accept) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); const MempoolAcceptResult result = chainman.ProcessTransaction(tx, /*test_accept=*/true); if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) { @@ -360,7 +360,7 @@ bool CoinJoin::IsCollateralValid(ChainstateManager& chainman, const llmq::CInsta LogPrint(BCLog::COINJOIN, "CoinJoin::IsCollateralValid -- %s", txCollateral.ToString()); /* Continued */ { - LOCK(cs_main); + LOCK(::cs_main); if (!ATMPIfSaneFee(chainman, MakeTransactionRef(txCollateral), /*test_accept=*/true)) { LogPrint(BCLog::COINJOIN, "CoinJoin::IsCollateralValid -- didn't pass ATMPIfSaneFee()\n"); return false; diff --git a/src/coinjoin/coinjoin.h b/src/coinjoin/coinjoin.h index f9cd1de64bc8..5eac1470be35 100644 --- a/src/coinjoin/coinjoin.h +++ b/src/coinjoin/coinjoin.h @@ -404,6 +404,6 @@ class CDSTXManager }; bool ATMPIfSaneFee(ChainstateManager& chainman, const CTransactionRef& tx, bool test_accept = false) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main); #endif // BITCOIN_COINJOIN_COINJOIN_H diff --git a/src/coinjoin/server.cpp b/src/coinjoin/server.cpp index f5fef56e5f76..01a8266916ee 100644 --- a/src/coinjoin/server.cpp +++ b/src/coinjoin/server.cpp @@ -119,7 +119,7 @@ PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv vRecv >> dsq; { - LOCK(cs_main); + LOCK(::cs_main); Assert(m_peerman)->EraseObjectRequest(peer.GetId(), CInv(MSG_DSQ, dsq.GetHash())); } @@ -327,7 +327,7 @@ void CCoinJoinServer::CommitFinalTransaction() { // See if the transaction is valid - TRY_LOCK(cs_main, lockMain); + TRY_LOCK(::cs_main, lockMain); mempool.PrioritiseTransaction(hashTx, 0.1 * COIN); if (!lockMain || !ATMPIfSaneFee(m_chainman, finalTransaction)) { LogPrint(BCLog::COINJOIN, "CCoinJoinServer::CommitFinalTransaction -- ATMPIfSaneFee() error: Transaction not valid\n"); @@ -460,7 +460,7 @@ void CCoinJoinServer::ChargeRandomFees() const void CCoinJoinServer::ConsumeCollateral(const CTransactionRef& txref) const { - LOCK(cs_main); + LOCK(::cs_main); if (!ATMPIfSaneFee(m_chainman, txref)) { LogPrint(BCLog::COINJOIN, "%s -- ATMPIfSaneFee failed\n", __func__); } else { diff --git a/src/coinjoin/util.cpp b/src/coinjoin/util.cpp index 2537a1cedcb9..d9154465a9d7 100644 --- a/src/coinjoin/util.cpp +++ b/src/coinjoin/util.cpp @@ -273,7 +273,7 @@ bool CTransactionBuilder::Commit(bilingual_str& strResult) CTransactionRef tx; { - LOCK2(m_wallet.cs_wallet, cs_main); + LOCK2(m_wallet.cs_wallet, ::cs_main); FeeCalculation fee_calc_out; if (!CreateTransaction(m_wallet, vecSend, tx, nFeeRet, nChangePosRet, strResult, coinControl, fee_calc_out)) { return false; @@ -312,7 +312,7 @@ bool CTransactionBuilder::Commit(bilingual_str& strResult) } { - LOCK2(m_wallet.cs_wallet, cs_main); + LOCK2(m_wallet.cs_wallet, ::cs_main); m_wallet.CommitTransaction(tx, {}, {}); } diff --git a/src/evo/assetlocktx.cpp b/src/evo/assetlocktx.cpp index d64eb126ffa5..1a985e711511 100644 --- a/src/evo/assetlocktx.cpp +++ b/src/evo/assetlocktx.cpp @@ -184,7 +184,7 @@ bool CheckAssetUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-duplicated-index"); } - if (LOCK(cs_main); blockman.LookupBlockIndex(assetUnlockTx.getQuorumHash()) == nullptr) { + if (LOCK(::cs_main); blockman.LookupBlockIndex(assetUnlockTx.getQuorumHash()) == nullptr) { return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-quorum-hash"); } diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index 897723c7950e..38192ca25539 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -588,7 +588,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, gsl::not_null& updatesRet) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); const auto& consensusParams = Params().GetConsensus(); if (!DeploymentActiveAt(*pindex, consensusParams, Consensus::DEPLOYMENT_DIP0003)) { diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index b2ed24c8b064..5b0c246a0242 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -582,7 +582,7 @@ class CDeterministicMNManager bool ProcessBlock(const CBlock& block, gsl::not_null pindex, BlockValidationState& state, const CCoinsViewCache& view, llmq::CQuorumSnapshotManager& qsnapman, const CDeterministicMNList& newList, std::optional& updatesRet) - EXCLUSIVE_LOCKS_REQUIRED(!cs, cs_main); + EXCLUSIVE_LOCKS_REQUIRED(!cs, ::cs_main); bool UndoBlock(gsl::not_null pindex, std::optional& updatesRet) EXCLUSIVE_LOCKS_REQUIRED(!cs); void UpdatedBlockTip(gsl::not_null pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs); diff --git a/src/evo/mnhftx.h b/src/evo/mnhftx.h index b59cd75dcf1e..8de6ef6c5d59 100644 --- a/src/evo/mnhftx.h +++ b/src/evo/mnhftx.h @@ -146,7 +146,7 @@ class CMNHFManager : public AbstractEHFManager */ void DisconnectManagers() { m_chainman = nullptr; m_qman = nullptr; }; - bool ForceSignalDBUpdate() EXCLUSIVE_LOCKS_REQUIRED(cs_main); + bool ForceSignalDBUpdate() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); private: void AddToCache(const Signals& signals, const CBlockIndex* const pindex); diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp index 979c8e175bc7..04537470c89f 100644 --- a/src/evo/simplifiedmns.cpp +++ b/src/evo/simplifiedmns.cpp @@ -335,7 +335,7 @@ bool BuildSimplifiedMNListDiff(CDeterministicMNManager& dmnman, const Chainstate const llmq::CQuorumManager& qman, const uint256& baseBlockHash, const uint256& blockHash, CSimplifiedMNListDiff& mnListDiffRet, std::string& errorRet, bool extended) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); mnListDiffRet = CSimplifiedMNListDiff(); const CBlockIndex* baseBlockIndex = chainman.ActiveChain().Genesis(); diff --git a/src/evo/specialtxman.cpp b/src/evo/specialtxman.cpp index 8f7de17ab5e5..f4de428ffb1a 100644 --- a/src/evo/specialtxman.cpp +++ b/src/evo/specialtxman.cpp @@ -27,7 +27,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, llmq::CQuorumSn const std::optional& indexes, bool check_sigs, TxValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); if (!tx.HasExtraPayloadField()) return true; @@ -76,7 +76,7 @@ static bool CheckSpecialTxInner(CDeterministicMNManager& dmnman, llmq::CQuorumSn bool CSpecialTxProcessor::CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); return CheckSpecialTxInner(m_dmnman, m_qsnapman, m_chainman, m_qman, tx, pindexPrev, view, std::nullopt, check_sigs, state); } @@ -84,7 +84,7 @@ bool CSpecialTxProcessor::CheckSpecialTx(const CTransaction& tx, const CBlockInd bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerkleRoots, BlockValidationState& state, std::optional& updatesRet) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); try { static int64_t nTimeLoop = 0; @@ -242,7 +242,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB bool CSpecialTxProcessor::UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, std::optional& updatesRet) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); auto bls_legacy_scheme = bls::bls_legacy_scheme.load(); @@ -277,7 +277,7 @@ bool CSpecialTxProcessor::UndoSpecialTxsInBlock(const CBlock& block, const CBloc bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CCbTx& cbTx, BlockValidationState& state) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0008)) return true; if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true; diff --git a/src/evo/specialtxman.h b/src/evo/specialtxman.h index ef1dd819701d..ac497f667432 100644 --- a/src/evo/specialtxman.h +++ b/src/evo/specialtxman.h @@ -64,16 +64,16 @@ class CSpecialTxProcessor } bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main); bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerkleRoots, BlockValidationState& state, std::optional& updatesRet) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main); bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, std::optional& updatesRet) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main); private: bool CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CCbTx& cbTx, - BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); }; #endif // BITCOIN_EVO_SPECIALTXMAN_H diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index 279d3b587a99..8d87a235cb37 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -194,7 +194,7 @@ PeerMsgRet CGovernanceManager::ProcessMessage(CNode& peer, CConnman& connman, Pe return {}; } - LOCK2(cs_main, cs); + LOCK2(::cs_main, cs); if (mapObjects.count(nHash) || mapPostponedObjects.count(nHash) || mapErasedGovernanceObjects.count(nHash)) { // TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE? @@ -312,7 +312,7 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, PeerMana govobj.UpdateSentinelVariables(tip_mn_list); //this sets local vars in object - LOCK2(cs_main, cs); + LOCK2(::cs_main, cs); std::string strError; // MAKE SURE THIS OBJECT IS OK @@ -374,7 +374,7 @@ void CGovernanceManager::CheckAndRemove() const auto tip_mn_list = Assert(m_dmnman)->GetListAtChainTip(); - LOCK2(cs_main, cs); + LOCK2(::cs_main, cs); for (const uint256& nHash : vecDirtyHashes) { auto it = mapObjects.find(nHash); @@ -701,7 +701,7 @@ std::optional CGovernanceManager::CreateGovernanceTrigg if (!sb_opt.has_value()) return std::nullopt; //TODO: Check if nHashParentIn, nRevision and nCollateralHashIn are correct - LOCK2(cs_main, cs); + LOCK2(::cs_main, cs); // Check if identical trigger (equal DataHash()) is already created (signed by other masternode) CGovernanceObject gov_sb(uint256(), 1, GetAdjustedTime(), uint256(), sb_opt.value().GetHexStrData()); @@ -748,7 +748,7 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional& if (!pnode->CanRelay() || (fMasternodeMode && pnode->IsInboundConn())) continue; // stop early to prevent setAskFor overflow { - LOCK(cs_main); + LOCK(::cs_main); size_t nProjectedSize = peerman.GetRequestedObjectCount(pnode->GetId()) + nProjectedVotes; if (nProjectedSize > MAX_INV_SZ) continue; // to early to ask the same node diff --git a/src/governance/object.cpp b/src/governance/object.cpp index 7776fd09fb7c..53c2db8a9761 100644 --- a/src/governance/object.cpp +++ b/src/governance/object.cpp @@ -361,7 +361,7 @@ UniValue CGovernanceObject::ToJson() const void CGovernanceObject::UpdateLocalValidity(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); // THIS DOES NOT CHECK COLLATERAL, THIS IS CHECKED UPON ORIGINAL ARRIVAL fCachedLocalValidity = IsValidLocally(tip_mn_list, chainman, strLocalValidityError, false); } @@ -376,7 +376,7 @@ bool CGovernanceObject::IsValidLocally(const CDeterministicMNList& tip_mn_list, bool CGovernanceObject::IsValidLocally(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); fMissingConfirmations = false; @@ -447,7 +447,7 @@ CAmount CGovernanceObject::GetMinCollateralFee() const bool CGovernanceObject::IsCollateralValid(const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations) const { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); strError = ""; fMissingConfirmations = false; @@ -505,7 +505,7 @@ bool CGovernanceObject::IsCollateralValid(const ChainstateManager& chainman, std // GET CONFIRMATIONS FOR TRANSACTION - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); int nConfirmationsIn = 0; if (nBlockHash != uint256()) { const CBlockIndex* pindex = chainman.m_blockman.LookupBlockIndex(nBlockHash); diff --git a/src/governance/object.h b/src/governance/object.h index 8ced4950f939..66324a75d62b 100644 --- a/src/governance/object.h +++ b/src/governance/object.h @@ -228,15 +228,15 @@ class CGovernanceObject // CORE OBJECT FUNCTIONS - bool IsValidLocally(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman, std::string& strError, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); + bool IsValidLocally(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman, std::string& strError, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); - bool IsValidLocally(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); + bool IsValidLocally(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); /// Check the collateral transaction for the budget proposal/finalized budget - bool IsCollateralValid(const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); + bool IsCollateralValid(const ChainstateManager& chainman, std::string& strError, bool& fMissingConfirmations) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); void UpdateLocalValidity(const CDeterministicMNList& tip_mn_list, const ChainstateManager& chainman) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); + EXCLUSIVE_LOCKS_REQUIRED(::cs_main); void UpdateSentinelVariables(const CDeterministicMNList& tip_mn_list); diff --git a/src/llmq/blockprocessor.cpp b/src/llmq/blockprocessor.cpp index c5b968e5adfd..e554948a7429 100644 --- a/src/llmq/blockprocessor.cpp +++ b/src/llmq/blockprocessor.cpp @@ -85,7 +85,7 @@ MessageProcessingResult CQuorumBlockProcessor::ProcessMessage(const CNode& peer, // Verify that quorumHash is part of the active chain and that it's the first block in the DKG interval const CBlockIndex* pQuorumBaseBlockIndex; { - LOCK(cs_main); + LOCK(::cs_main); pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash); if (pQuorumBaseBlockIndex == nullptr) { LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s -- unknown block %s in commitment, peer=%d\n", __func__, @@ -153,7 +153,7 @@ MessageProcessingResult CQuorumBlockProcessor::ProcessMessage(const CNode& peer, bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, gsl::not_null pindex, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); const auto blockHash = pindex->GetBlockHash(); @@ -222,7 +222,7 @@ static std::tuple BuildInversed bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); const auto& llmq_params_opt = Params().GetLLMQ(qc.llmqType); if (!llmq_params_opt.has_value()) { @@ -315,7 +315,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH bool CQuorumBlockProcessor::UndoBlock(const CBlock& block, gsl::not_null pindex) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); PreComputeQuorumMembers(m_dmnman, m_qsnapman, pindex, /*reset_cache=*/true); @@ -354,7 +354,7 @@ bool CQuorumBlockProcessor::UndoBlock(const CBlock& block, gsl::not_null pindex, std::multimap& ret, BlockValidationState& state) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); const auto& consensus = Params().GetConsensus(); @@ -396,7 +396,7 @@ bool CQuorumBlockProcessor::GetCommitmentsFromBlock(const CBlock& block, gsl::no bool CQuorumBlockProcessor::IsMiningPhase(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); // Note: This function can be called for new blocks assert(nHeight <= active_chain.Height() + 1); @@ -416,7 +416,7 @@ bool CQuorumBlockProcessor::IsMiningPhase(const Consensus::LLMQParams& llmqParam size_t CQuorumBlockProcessor::GetNumCommitmentsRequired(const Consensus::LLMQParams& llmqParams, int nHeight) const { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); if (!IsMiningPhase(llmqParams, m_chainstate.m_chain, nHeight)) return 0; @@ -439,7 +439,7 @@ size_t CQuorumBlockProcessor::GetNumCommitmentsRequired(const Consensus::LLMQPar // WARNING: This method returns uint256() on the first block of the DKG interval (because the block hash is not known yet) uint256 CQuorumBlockProcessor::GetQuorumBlockHash(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight, int quorumIndex) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); int quorumStartHeight = nHeight - (nHeight % llmqParams.dkgInterval) + quorumIndex; @@ -689,7 +689,7 @@ bool CQuorumBlockProcessor::GetMineableCommitmentByHash(const uint256& commitmen // Will return a null commitment if no mineable commitment is known and none was mined yet std::optional> CQuorumBlockProcessor::GetMineableCommitments(const Consensus::LLMQParams& llmqParams, int nHeight) const { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); std::vector ret; @@ -744,7 +744,7 @@ std::optional> CQuorumBlockProcessor::GetMineableC bool CQuorumBlockProcessor::GetMineableCommitmentsTx(const Consensus::LLMQParams& llmqParams, int nHeight, std::vector& ret) const { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); std::optional> qcs = GetMineableCommitments(llmqParams, nHeight); if (!qcs.has_value()) { return false; diff --git a/src/llmq/blockprocessor.h b/src/llmq/blockprocessor.h index ff9dadf7aa4b..170e0007f742 100644 --- a/src/llmq/blockprocessor.h +++ b/src/llmq/blockprocessor.h @@ -55,15 +55,15 @@ class CQuorumBlockProcessor MessageProcessingResult ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv); - bool ProcessBlock(const CBlock& block, gsl::not_null pindex, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - bool UndoBlock(const CBlock& block, gsl::not_null pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + bool ProcessBlock(const CBlock& block, gsl::not_null pindex, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + bool UndoBlock(const CBlock& block, gsl::not_null pindex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); //! it returns hash of commitment if it should be relay, otherwise nullopt std::optional AddMineableCommitment(const CFinalCommitment& fqc); bool HasMineableCommitment(const uint256& hash) const; bool GetMineableCommitmentByHash(const uint256& commitmentHash, CFinalCommitment& ret) const; - std::optional> GetMineableCommitments(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); - bool GetMineableCommitmentsTx(const Consensus::LLMQParams& llmqParams, int nHeight, std::vector& ret) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); + std::optional> GetMineableCommitments(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + bool GetMineableCommitmentsTx(const Consensus::LLMQParams& llmqParams, int nHeight, std::vector& ret) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); bool HasMinedCommitment(Consensus::LLMQType llmqType, const uint256& quorumHash) const; CFinalCommitmentPtr GetMinedCommitment(Consensus::LLMQType llmqType, const uint256& quorumHash, uint256& retMinedBlockHash) const; @@ -74,11 +74,11 @@ class CQuorumBlockProcessor std::vector> GetLastMinedCommitmentsPerQuorumIndexUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, size_t cycle) const; std::optional GetLastMinedCommitmentsByQuorumIndexUntilBlock(Consensus::LLMQType llmqType, const CBlockIndex* pindex, int quorumIndex, size_t cycle) const; private: - static bool GetCommitmentsFromBlock(const CBlock& block, gsl::not_null pindex, std::multimap& ret, BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - bool ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - static bool IsMiningPhase(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main); - size_t GetNumCommitmentsRequired(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(cs_main); - static uint256 GetQuorumBlockHash(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + static bool GetCommitmentsFromBlock(const CBlock& block, gsl::not_null pindex, std::multimap& ret, BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + bool ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, BlockValidationState& state, bool fJustCheck, bool fBLSChecks) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + static bool IsMiningPhase(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + size_t GetNumCommitmentsRequired(const Consensus::LLMQParams& llmqParams, int nHeight) const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + static uint256 GetQuorumBlockHash(const Consensus::LLMQParams& llmqParams, const CChain& active_chain, int nHeight, int quorumIndex) EXCLUSIVE_LOCKS_REQUIRED(::cs_main); }; } // namespace llmq diff --git a/src/llmq/chainlocks.cpp b/src/llmq/chainlocks.cpp index bd49fd0ad6ad..c121588b9202 100644 --- a/src/llmq/chainlocks.cpp +++ b/src/llmq/chainlocks.cpp @@ -121,7 +121,7 @@ MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId fro return {}; } - const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(clsig.getBlockHash())); + const CBlockIndex* pindex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(clsig.getBlockHash())); { LOCK(cs); @@ -237,7 +237,7 @@ void CChainLocksHandler::TrySignChainTip(const llmq::CInstantSendManager& isman) return; } - const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate.m_chain.Tip()); + const CBlockIndex* pindex = WITH_LOCK(::cs_main, return m_chainstate.m_chain.Tip()); if (pindex->pprev == nullptr) { return; @@ -404,7 +404,7 @@ CChainLocksHandler::BlockTxs::mapped_type CChainLocksHandler::GetBlockTxs(const uint32_t blockTime; { - LOCK(cs_main); + LOCK(::cs_main); const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(blockHash); CBlock block; if (!ReadBlockFromDisk(block, pindex, Params().GetConsensus())) { @@ -485,7 +485,7 @@ void CChainLocksHandler::EnforceBestChainLock() LogPrintf("CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, dummy_state.ToString()); return; } - LOCK(cs_main); + LOCK(::cs_main); if (m_chainstate.m_chain.Tip()->GetAncestor(currentBestChainLockBlockIndex->nHeight) != currentBestChainLockBlockIndex) { return; } @@ -619,7 +619,7 @@ void CChainLocksHandler::Cleanup() } } // need mempool.cs due to GetTransaction calls - LOCK2(cs_main, mempool.cs); + LOCK2(::cs_main, mempool.cs); LOCK(cs); for (auto it = blockTxs.begin(); it != blockTxs.end(); ) { diff --git a/src/llmq/commitment.cpp b/src/llmq/commitment.cpp index 3586e2159750..345a113219de 100644 --- a/src/llmq/commitment.cpp +++ b/src/llmq/commitment.cpp @@ -212,7 +212,7 @@ bool CheckLLMQCommitment(CDeterministicMNManager& dmnman, CQuorumSnapshotManager return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-height"); } - const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash)); + const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(qcTx.commitment.quorumHash)); if (pQuorumBaseBlockIndex == nullptr) { return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-qc-quorum-hash"); } diff --git a/src/llmq/debug.cpp b/src/llmq/debug.cpp index 51b1fae24020..0952c3f52192 100644 --- a/src/llmq/debug.cpp +++ b/src/llmq/debug.cpp @@ -26,7 +26,7 @@ UniValue CDKGDebugSessionStatus::ToJson(CDeterministicMNManager& dmnman, CQuorum std::vector dmnMembers; if (detailLevel == 2) { - const CBlockIndex* pindex = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(quorumHash)); + const CBlockIndex* pindex = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(quorumHash)); if (pindex != nullptr) { dmnMembers = utils::GetAllQuorumMembers(llmqType, dmnman, qsnapman, pindex); } diff --git a/src/llmq/dkgsessionhandler.cpp b/src/llmq/dkgsessionhandler.cpp index c823066f7e09..beb111533e9e 100644 --- a/src/llmq/dkgsessionhandler.cpp +++ b/src/llmq/dkgsessionhandler.cpp @@ -535,7 +535,7 @@ void CDKGSessionHandler::HandleDKGRound(CConnman& connman, PeerManager& peerman) pendingPrematureCommitments.Clear(); uint256 curQuorumHash = WITH_LOCK(cs_phase_qhash, return quorumHash); - const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(curQuorumHash)); + const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(curQuorumHash)); if (!InitNewQuorum(pQuorumBaseBlockIndex)) { // should actually never happen diff --git a/src/llmq/dkgsessionmgr.cpp b/src/llmq/dkgsessionmgr.cpp index 43a9f4acd203..f0169b86b713 100644 --- a/src/llmq/dkgsessionmgr.cpp +++ b/src/llmq/dkgsessionmgr.cpp @@ -155,7 +155,7 @@ PeerMsgRet CDKGSessionManager::ProcessMessage(CNode& pfrom, PeerManager& peerman // No luck, try to compute if (quorumIndex == -1) { - CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(quorumHash)); + CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(quorumHash)); if (pQuorumBaseBlockIndex == nullptr) { LogPrintf("CDKGSessionManager -- unknown quorumHash %s\n", quorumHash.ToString()); // NOTE: do not insta-ban for this, we might be lagging behind @@ -408,7 +408,7 @@ void CDKGSessionManager::CleanupOldContributions() const decltype(start) k; pcursor->Seek(start); - LOCK(cs_main); + LOCK(::cs_main); while (pcursor->Valid()) { if (!pcursor->GetKey(k) || std::get<0>(k) != prefix || std::get<1>(k) != params.type) { break; diff --git a/src/llmq/ehf_signals.cpp b/src/llmq/ehf_signals.cpp index c5388e46dd5e..3272acb8a166 100644 --- a/src/llmq/ehf_signals.cpp +++ b/src/llmq/ehf_signals.cpp @@ -101,7 +101,7 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover } MessageProcessingResult ret; - const auto ehfSignals = mnhfman.GetSignalsStage(WITH_LOCK(cs_main, return m_chainman.ActiveTip())); + const auto ehfSignals = mnhfman.GetSignalsStage(WITH_LOCK(::cs_main, return m_chainman.ActiveTip())); MNHFTxPayload mnhfPayload; for (const auto& deployment : Params().GetConsensus().vDeployments) { // skip deployments that do not use dip0023 or that have already been mined @@ -123,7 +123,7 @@ MessageProcessingResult CEHFSignalsHandler::HandleNewRecoveredSig(const CRecover { CTransactionRef tx_to_sent = MakeTransactionRef(std::move(tx)); LogPrintf("CEHFSignalsHandler::HandleNewRecoveredSig Special EHF TX is created hash=%s\n", tx_to_sent->GetHash().ToString()); - LOCK(cs_main); + LOCK(::cs_main); const MempoolAcceptResult result = m_chainman.ProcessTransaction(tx_to_sent); if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) { ret.m_transactions.push_back(tx_to_sent->GetHash()); diff --git a/src/llmq/instantsend.cpp b/src/llmq/instantsend.cpp index 2b52deeb8f3c..425ba7194a5c 100644 --- a/src/llmq/instantsend.cpp +++ b/src/llmq/instantsend.cpp @@ -588,7 +588,7 @@ bool CInstantSendManager::CheckCanLock(const COutPoint& outpoint, bool printDebu const CBlockIndex* pindexMined; int nTxAge; { - LOCK(cs_main); + LOCK(::cs_main); pindexMined = m_chainstate.m_blockman.LookupBlockIndex(hashBlock); nTxAge = m_chainstate.m_chain.Height() - pindexMined->nHeight + 1; } @@ -761,7 +761,7 @@ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom return tl::unexpected{100}; } - const auto blockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); + const auto blockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); if (blockIndex == nullptr) { // Maybe we don't have the block yet or maybe some peer spams invalid values for cycleHash return tl::unexpected{1}; @@ -921,7 +921,7 @@ std::unordered_set CInstantSendManager::ProcessPend continue; } - const auto blockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); + const auto blockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); if (blockIndex == nullptr) { batchVerifier.badSources.emplace(nodeId); continue; @@ -960,7 +960,7 @@ std::unordered_set CInstantSendManager::ProcessPend std::unordered_set badISLocks; if (ban && !batchVerifier.badSources.empty()) { - LOCK(cs_main); + LOCK(::cs_main); for (const auto& nodeId : batchVerifier.badSources) { // Let's not be too harsh, as the peer might simply be unlucky and might have sent us an old lock which // does not validate anymore due to changed quorums @@ -1015,7 +1015,7 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, PeerManager& peerm const CBlockIndex* pindexMined{nullptr}; // we ignore failure here as we must be able to propagate the lock even if we don't have the TX locally if (tx && !hashBlock.IsNull()) { - pindexMined = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(hashBlock)); + pindexMined = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(hashBlock)); // Let's see if the TX that was locked by this islock is already mined in a ChainLocked block. If yes, // we can simply ignore the islock, as the ChainLock implies locking of all TXs in that chain @@ -1434,7 +1434,7 @@ void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const activateBestChain = true; } else { LogPrintf("CInstantSendManager::%s -- resetting block %s\n", __func__, pindex2->GetBlockHash().ToString()); - LOCK(cs_main); + LOCK(::cs_main); m_chainstate.ResetBlockFailureFlags(pindex2); } } @@ -1453,7 +1453,7 @@ void CInstantSendManager::RemoveConflictingLock(const uint256& islockHash, const { LogPrintf("CInstantSendManager::%s -- txid=%s, islock=%s: Removing ISLOCK and its chained children\n", __func__, islock.txid.ToString(), islockHash.ToString()); - int tipHeight = WITH_LOCK(cs_main, return m_chainstate.m_chain.Height()); + int tipHeight = WITH_LOCK(::cs_main, return m_chainstate.m_chain.Height()); auto removedIslocks = db.RemoveChainedInstantSendLocks(islockHash, islock.txid, tipHeight); for (const auto& h : removedIslocks) { diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index 0b01f2a46572..de1b3815c59b 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -527,7 +527,7 @@ bool CQuorumManager::RequestQuorumData(CNode* pfrom, CConnman& connman, CQuorumC std::vector CQuorumManager::ScanQuorums(Consensus::LLMQType llmqType, size_t nCountRequested) const { - const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate.m_chain.Tip()); + const CBlockIndex* pindex = WITH_LOCK(::cs_main, return m_chainstate.m_chain.Tip()); return ScanQuorums(llmqType, pindex, nCountRequested); } @@ -647,7 +647,7 @@ CQuorumCPtr CQuorumManager::GetQuorum(Consensus::LLMQType llmqType, const uint25 // We cannot acquire cs_main if we have cs_quorumBaseBlockIndexCache held const CBlockIndex* pindex; if (!WITH_LOCK(cs_quorumBaseBlockIndexCache, return quorumBaseBlockIndexCache.get(quorumHash, pindex))) { - pindex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(quorumHash)); + pindex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(quorumHash)); if (pindex) { LOCK(cs_quorumBaseBlockIndexCache); quorumBaseBlockIndexCache.insert(quorumHash, pindex); @@ -750,7 +750,7 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& connman, const bool request_limit_exceeded(false); { - LOCK2(cs_main, cs_data_requests); + LOCK2(::cs_main, cs_data_requests); const CQuorumDataRequestKey key(pfrom.GetVerifiedProRegTxHash(), false, request.GetQuorumHash(), request.GetLLMQType()); auto it = mapQuorumDataRequests.find(key); if (it == mapQuorumDataRequests.end()) { @@ -766,7 +766,7 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& connman, const return sendQDATA(CQuorumDataRequest::Errors::QUORUM_TYPE_INVALID, request_limit_exceeded); } - const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(request.GetQuorumHash())); + const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(request.GetQuorumHash())); if (pQuorumBaseBlockIndex == nullptr) { return sendQDATA(CQuorumDataRequest::Errors::QUORUM_BLOCK_NOT_FOUND, request_limit_exceeded); } @@ -815,7 +815,7 @@ PeerMsgRet CQuorumManager::ProcessMessage(CNode& pfrom, CConnman& connman, const vRecv >> request; { - LOCK2(cs_main, cs_data_requests); + LOCK2(::cs_main, cs_data_requests); const CQuorumDataRequestKey key(pfrom.GetVerifiedProRegTxHash(), true, request.GetQuorumHash(), request.GetLLMQType()); auto it = mapQuorumDataRequests.find(key); if (it == mapQuorumDataRequests.end()) { @@ -1214,7 +1214,7 @@ CQuorumCPtr SelectQuorumForSigning(const Consensus::LLMQParams& llmq_params, con CBlockIndex* pindexStart; { - LOCK(cs_main); + LOCK(::cs_main); if (signHeight == -1) { signHeight = active_chain.Height(); } diff --git a/src/llmq/snapshot.cpp b/src/llmq/snapshot.cpp index e2cbf337197d..5ee8ab6bcca7 100644 --- a/src/llmq/snapshot.cpp +++ b/src/llmq/snapshot.cpp @@ -87,7 +87,7 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan const CQuorumBlockProcessor& qblockman, const CGetQuorumRotationInfo& request, bool use_legacy_construction, CQuorumRotationInfo& response, std::string& errorRet) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); std::vector baseBlockIndexes; if (request.baseBlockHashes.size() == 0) { @@ -426,7 +426,7 @@ void CQuorumSnapshotManager::StoreSnapshotForBlock(const Consensus::LLMQType llm { auto snapshotHash = ::SerializeHash(std::make_pair(llmqType, pindex->GetBlockHash())); - // LOCK(cs_main); + // LOCK(::cs_main); AssertLockNotHeld(m_evoDb.cs); LOCK2(snapshotCacheCs, m_evoDb.cs); m_evoDb.GetRawDB().Write(std::make_pair(DB_QUORUM_SNAPSHOT, snapshotHash), snapshot); diff --git a/src/rpc/evo.cpp b/src/rpc/evo.cpp index bd197c04e41c..a4bc4a28afc8 100644 --- a/src/rpc/evo.cpp +++ b/src/rpc/evo.cpp @@ -323,7 +323,7 @@ static void SignSpecialTxPayloadByHash(const CMutableTransaction& tx, SpecialTxP static std::string SignAndSendSpecialTx(const JSONRPCRequest& request, CChainstateHelper& chain_helper, const ChainstateManager& chainman, const CMutableTransaction& tx, bool fSubmit) { { - LOCK(cs_main); + LOCK(::cs_main); TxValidationState state; if (!chain_helper.special_tx->CheckSpecialTx(CTransaction(tx), chainman.ActiveChain().Tip(), chainman.ActiveChainstate().CoinsTip(), true, state)) { @@ -1071,7 +1071,7 @@ static UniValue protx_update_service_common_wrapper(const JSONRPCRequest& reques FundSpecialTx(*wallet, tx, ptx, feeSource); - const bool isV19active = DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), + const bool isV19active = DeploymentActiveAfter(WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19); SignSpecialTxPayloadByHash(tx, ptx, keyOperator, !isV19active); SetTxPayload(tx, ptx); @@ -1245,7 +1245,7 @@ static RPCHelpMan protx_revoke() EnsureWalletIsUnlocked(*pwallet); - const bool isV19active{DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)}; + const bool isV19active{DeploymentActiveAfter(WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)}; CProUpRevTx ptx; ptx.nVersion = CProUpRevTx::GetMaxVersion(/*is_basic_scheme_active=*/isV19active); @@ -1333,11 +1333,11 @@ static UniValue BuildDMNListEntry(const CWallet* const pwallet, const CDetermini if (pindex != nullptr) { if (confirmations > -1) { - confirmations -= WITH_LOCK(cs_main, return chainman.ActiveChain().Height()) - pindex->nHeight; + confirmations -= WITH_LOCK(::cs_main, return chainman.ActiveChain().Height()) - pindex->nHeight; } else { uint256 minedBlockHash; collateralTx = GetTransaction(/* pindex */ nullptr, /* mempool */ nullptr, dmn.collateralOutpoint.hash, Params().GetConsensus(), minedBlockHash); - const CBlockIndex* const pindexMined = WITH_LOCK(cs_main, return chainman.m_blockman.LookupBlockIndex(minedBlockHash)); + const CBlockIndex* const pindexMined = WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(minedBlockHash)); CHECK_NONFATAL(pindexMined != nullptr); CHECK_NONFATAL(pindex->GetAncestor(pindexMined->nHeight) == pindexMined); confirmations = pindex->nHeight - pindexMined->nHeight + 1; @@ -1434,7 +1434,7 @@ static RPCHelpMan protx_list() bool detailed = !request.params[1].isNull() ? ParseBoolV(request.params[1], "detailed") : false; - LOCK2(wallet->cs_wallet, cs_main); + LOCK2(wallet->cs_wallet, ::cs_main); int height = !request.params[2].isNull() ? ParseInt32V(request.params[2], "height") : chainman.ActiveChain().Height(); if (height < 1 || height > chainman.ActiveChain().Height()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid height specified"); @@ -1464,9 +1464,9 @@ static RPCHelpMan protx_list() bool detailed = !request.params[1].isNull() ? ParseBoolV(request.params[1], "detailed") : false; #ifdef ENABLE_WALLET - LOCK2(wallet ? wallet->cs_wallet : cs_main, cs_main); + LOCK2(wallet ? wallet->cs_wallet : ::cs_main, ::cs_main); #else - LOCK(cs_main); + LOCK(::cs_main); #endif int height = !request.params[2].isNull() ? ParseInt32V(request.params[2], "height") : chainman.ActiveChain().Height(); if (height < 1 || height > chainman.ActiveChain().Height()) { @@ -1531,10 +1531,10 @@ static RPCHelpMan protx_info() uint256 proTxHash(ParseHashV(request.params[0], "proTxHash")); if (request.params[1].isNull()) { - LOCK(cs_main); + LOCK(::cs_main); pindex = chainman.ActiveChain().Tip(); } else { - LOCK(cs_main); + LOCK(::cs_main); uint256 blockHash(ParseHashV(request.params[1], "blockHash")); pindex = chainman.m_blockman.LookupBlockIndex(blockHash); if (pindex == nullptr) { @@ -1552,9 +1552,9 @@ static RPCHelpMan protx_info() }; } -static uint256 ParseBlock(const UniValue& v, const ChainstateManager& chainman, const std::string& strName) EXCLUSIVE_LOCKS_REQUIRED(cs_main) +static uint256 ParseBlock(const UniValue& v, const ChainstateManager& chainman, const std::string& strName) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); try { return ParseHashV(v, strName); @@ -1585,7 +1585,7 @@ static RPCHelpMan protx_diff() CDeterministicMNManager& dmnman = *CHECK_NONFATAL(node.dmnman); const LLMQContext& llmq_ctx = *CHECK_NONFATAL(node.llmq_ctx); - LOCK(cs_main); + LOCK(::cs_main); uint256 baseBlockHash = ParseBlock(request.params[0], chainman, "baseBlock"); uint256 blockHash = ParseBlock(request.params[1], chainman, "block"); bool extended = false; @@ -1607,9 +1607,9 @@ static RPCHelpMan protx_diff() }; } -static const CBlockIndex* ParseBlockIndex(const UniValue& v, const ChainstateManager& chainman, const std::string& strName) EXCLUSIVE_LOCKS_REQUIRED(cs_main) +static const CBlockIndex* ParseBlockIndex(const UniValue& v, const ChainstateManager& chainman, const std::string& strName) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { - AssertLockHeld(cs_main); + AssertLockHeld(::cs_main); try { uint256 hash = ParseHashV(v, strName); @@ -1642,7 +1642,7 @@ static RPCHelpMan protx_listdiff() CDeterministicMNManager& dmnman = *CHECK_NONFATAL(node.dmnman); - LOCK(cs_main); + LOCK(::cs_main); UniValue ret(UniValue::VOBJ); const CBlockIndex* pBaseBlockIndex = ParseBlockIndex(request.params[0], chainman, "baseBlock"); diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index a0acb8661ec8..d40ffb596e85 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -237,7 +237,7 @@ static RPCHelpMan masternode_winners() const ChainstateManager& chainman = EnsureChainman(node); const CBlockIndex* pindexTip{nullptr}; { - LOCK(cs_main); + LOCK(::cs_main); pindexTip = chainman.ActiveChain().Tip(); if (!pindexTip) return NullUniValue; } @@ -325,10 +325,10 @@ static RPCHelpMan masternode_payments() } if (request.params[0].isNull()) { - LOCK(cs_main); + LOCK(::cs_main); pindex = chainman.ActiveChain().Tip(); } else { - LOCK(cs_main); + LOCK(::cs_main); uint256 blockHash(ParseHashV(request.params[0], "blockhash")); pindex = chainman.m_blockman.LookupBlockIndex(blockHash); if (pindex == nullptr) { @@ -412,7 +412,7 @@ static RPCHelpMan masternode_payments() vecPayments.push_back(blockObj); if (nCount > 0) { - LOCK(cs_main); + LOCK(::cs_main); pindex = chainman.ActiveChain().Next(pindex); } else { pindex = pindex->pprev; @@ -527,14 +527,14 @@ static RPCHelpMan masternodelist_helper(bool is_composite) return (int)0; } - LOCK(cs_main); + LOCK(::cs_main); const CBlockIndex* pindex = chainman.ActiveChain()[dmn.pdmnState->nLastPaidHeight]; return (int)pindex->nTime; }; const bool showRecentMnsOnly = strMode == "recent"; const bool showEvoOnly = strMode == "evo"; - const int tipHeight = WITH_LOCK(cs_main, return chainman.ActiveChain().Tip()->nHeight); + const int tipHeight = WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip()->nHeight); mnList.ForEachMN(false, [&](auto& dmn) { if (showRecentMnsOnly && dmn.pdmnState->IsBanned()) { if (tipHeight - dmn.pdmnState->GetBannedHeight() > Params().GetConsensus().nSuperblockCycle) { diff --git a/src/wallet/test/coinjoin_tests.cpp b/src/wallet/test/coinjoin_tests.cpp index 64277519196c..e7400c712d23 100644 --- a/src/wallet/test/coinjoin_tests.cpp +++ b/src/wallet/test/coinjoin_tests.cpp @@ -141,7 +141,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup wallet->LoadWallet(); AddWallet(context, wallet); { - LOCK2(wallet->cs_wallet, cs_main); + LOCK2(wallet->cs_wallet, ::cs_main); wallet->GetLegacyScriptPubKeyMan()->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash()); } @@ -172,7 +172,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup blocktx = CMutableTransaction(*it->second.tx); } CreateAndProcessBlock({blocktx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); - LOCK2(wallet->cs_wallet, cs_main); + LOCK2(wallet->cs_wallet, ::cs_main); wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash()); it->second.m_state = TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), /*index=*/1}; return it->second; @@ -195,7 +195,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup FeeCalculation fee_calc_out; BOOST_CHECK(CreateTransaction(*wallet, {{GetScriptForDestination(tallyItem.txdest), nAmount, false}}, tx, nFeeRet, nChangePosRet, strError, coinControl, fee_calc_out)); { - LOCK2(wallet->cs_wallet, cs_main); + LOCK2(wallet->cs_wallet, ::cs_main); wallet->CommitTransaction(tx, {}, {}); } AddTxToChain(tx->GetHash()); diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 6fa7a59b1b2b..d09e8742be70 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -154,7 +154,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) // Prune the older block file. int file_number; { - LOCK(cs_main); + LOCK(::cs_main); file_number = oldTip->GetBlockPos().nFile; Assert(m_node.chainman)->m_blockman.PruneOneBlockFile(file_number); } @@ -182,7 +182,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) // Prune the remaining block file. { - LOCK(cs_main); + LOCK(::cs_main); file_number = newTip->GetBlockPos().nFile; Assert(m_node.chainman)->m_blockman.PruneOneBlockFile(file_number); } @@ -219,7 +219,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup) // Prune the older block file. int file_number; { - LOCK(cs_main); + LOCK(::cs_main); file_number = oldTip->GetBlockPos().nFile; Assert(m_node.chainman)->m_blockman.PruneOneBlockFile(file_number); } @@ -378,7 +378,7 @@ static int64_t AddTx(ChainstateManager& chainman, CWallet& wallet, uint32_t lock SetMockTime(mockTime); CBlockIndex* block = nullptr; if (blockTime > 0) { - LOCK(cs_main); + LOCK(::cs_main); auto inserted = chainman.BlockIndex().emplace(std::piecewise_construct, std::make_tuple(GetRandHash()), std::make_tuple()); assert(inserted.second); const uint256& hash = inserted.first->first; From e89e8a7d557e6873dd9e9a1cc81ec9f86e48f090 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 20 Jun 2025 23:17:58 +0000 Subject: [PATCH 2/7] refactor: move `CBlockFileInfo::ToString` method where class is declared --- src/chain.cpp | 6 ++++++ src/node/blockstorage.cpp | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/chain.cpp b/src/chain.cpp index ae5307d90ed5..2480047d024f 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -4,9 +4,15 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include +std::string CBlockFileInfo::ToString() const +{ + return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast)); +} + std::string CBlockIndex::ToString() const { return strprintf("CBlockIndex(pprev=%p, nHeight=%d, merkle=%s, hashBlock=%s)", diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index d634af2ae888..a9caeee4cf1f 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -479,11 +479,6 @@ void CleanupBlockRevFiles() } } -std::string CBlockFileInfo::ToString() const -{ - return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast)); -} - CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n) { LOCK(cs_LastBlockFile); From 65cfaea4d156e3fa42ebb52d130eb57edbbb729f Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Jun 2025 09:08:15 +0000 Subject: [PATCH 3/7] refactor: add `src/node/context.*` to `node::` namespace Split out as a separate commit as NodeContext is more pervasively used in Dash-specific code --- src/bench/coin_selection.cpp | 2 ++ src/bitcoind.cpp | 2 ++ src/coinjoin/interfaces.cpp | 2 ++ src/context.h | 6 ++++-- src/init.cpp | 2 ++ src/init.h | 14 ++++++++------ src/init/bitcoin-node.cpp | 6 +++--- src/init/bitcoind.cpp | 2 ++ src/interfaces/chain.h | 6 +++--- src/interfaces/coinjoin.h | 4 +++- src/interfaces/init.h | 4 +++- src/interfaces/node.h | 23 ++++++++++++----------- src/interfaces/wallet.h | 7 +++++-- src/node/coin.cpp | 2 ++ src/node/coin.h | 4 +++- src/node/context.cpp | 2 ++ src/node/context.h | 2 ++ src/node/interfaces.cpp | 4 ++-- src/node/miner.cpp | 2 ++ src/node/miner.h | 8 +++++--- src/node/transaction.cpp | 2 ++ src/node/transaction.h | 6 ++++-- src/qt/bitcoin.cpp | 2 ++ src/qt/test/test_main.cpp | 2 ++ src/rest.cpp | 2 ++ src/rpc/blockchain.cpp | 2 ++ src/rpc/blockchain.h | 6 ++++-- src/rpc/coinjoin.cpp | 2 ++ src/rpc/evo.cpp | 2 ++ src/rpc/fees.cpp | 3 ++- src/rpc/governance.cpp | 2 ++ src/rpc/masternode.cpp | 2 ++ src/rpc/mempool.cpp | 2 ++ src/rpc/mining.cpp | 2 ++ src/rpc/misc.cpp | 2 ++ src/rpc/net.cpp | 2 ++ src/rpc/quorums.cpp | 2 ++ src/rpc/rawtransaction.cpp | 2 ++ src/rpc/server_util.cpp | 2 ++ src/rpc/server_util.h | 20 +++++++++++--------- src/test/addrman_tests.cpp | 1 + src/test/evo_utils_tests.cpp | 2 ++ src/test/fuzz/tx_pool.cpp | 2 ++ src/test/util/chainstate.h | 2 +- src/test/util/mining.cpp | 2 ++ src/test/util/mining.h | 8 +++++--- src/test/util/setup_common.cpp | 2 ++ src/test/util/setup_common.h | 6 +++--- src/wallet/context.h | 6 ++++-- src/wallet/init.cpp | 2 ++ src/wallet/interfaces.cpp | 1 + src/wallet/test/ismine_tests.cpp | 1 + src/wallet/test/scriptpubkeyman_tests.cpp | 2 ++ src/walletinitinterface.h | 6 ++++-- 54 files changed, 154 insertions(+), 60 deletions(-) diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index ec61a3f134bd..eec3ab035368 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -11,6 +11,8 @@ #include +using node::NodeContext; + static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector>& wtxs) { static int nextLockTime = 0; diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index f3cc180d4fdd..4706c8457833 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -31,6 +31,8 @@ #include #include +using node::NodeContext; + const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = urlDecode; diff --git a/src/coinjoin/interfaces.cpp b/src/coinjoin/interfaces.cpp index acb9565974e0..71c44871fb2c 100644 --- a/src/coinjoin/interfaces.cpp +++ b/src/coinjoin/interfaces.cpp @@ -17,6 +17,8 @@ #include #include +using node::NodeContext; + namespace coinjoin { namespace { diff --git a/src/context.h b/src/context.h index 39da4ec9a832..292443f10f47 100644 --- a/src/context.h +++ b/src/context.h @@ -13,12 +13,14 @@ class ChainstateManager; class CTxMemPool; class CBlockPolicyEstimator; struct LLMQContext; -struct NodeContext; struct WalletContext; +namespace node { +struct NodeContext; +} // namespace node using CoreContext = std::variant, - std::reference_wrapper, + std::reference_wrapper, std::reference_wrapper, std::reference_wrapper, std::reference_wrapper, diff --git a/src/init.cpp b/src/init.cpp index c2d83174f052..acf6b0745869 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -134,6 +134,8 @@ #include #endif +using node::NodeContext; + static constexpr bool DEFAULT_PROXYRANDOMIZE{true}; static constexpr bool DEFAULT_REST_ENABLE{false}; static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true}; diff --git a/src/init.h b/src/init.h index ef445a7e5926..00450e1f416d 100644 --- a/src/init.h +++ b/src/init.h @@ -17,14 +17,16 @@ static constexpr bool DEFAULT_DAEMON = false; static constexpr bool DEFAULT_DAEMONWAIT = false; class ArgsManager; -struct NodeContext; namespace interfaces { struct BlockAndHeaderTipInfo; } // namespace interfaces +namespace node { +struct NodeContext; +} // namespace node /** Interrupt threads */ -void Interrupt(NodeContext& node); -void Shutdown(NodeContext& node); +void Interrupt(node::NodeContext& node); +void Shutdown(node::NodeContext& node); //!Initialize the logging infrastructure void InitLogging(const ArgsManager& args); //!Parameter interaction: change current parameters depending on various rules @@ -56,14 +58,14 @@ bool AppInitLockDataDirectory(); /** * Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory. */ -bool AppInitInterfaces(NodeContext& node); +bool AppInitInterfaces(node::NodeContext& node); /** * Dash Core main initialization. * @note This should only be done after daemonization. Call Shutdown() if this function fails. * @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called. */ -bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr); -void PrepareShutdown(NodeContext& node); +bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr); +void PrepareShutdown(node::NodeContext& node); /** * Register all arguments with the ArgsManager diff --git a/src/init/bitcoin-node.cpp b/src/init/bitcoin-node.cpp index b64f663a2377..bf7f935d24ed 100644 --- a/src/init/bitcoin-node.cpp +++ b/src/init/bitcoin-node.cpp @@ -22,7 +22,7 @@ const char* EXE_NAME = "dash-node"; class BitcoinNodeInit : public interfaces::Init { public: - BitcoinNodeInit(NodeContext& node, const char* arg0) + BitcoinNodeInit(node::NodeContext& node, const char* arg0) : m_node(node), m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this)) { @@ -41,14 +41,14 @@ class BitcoinNodeInit : public interfaces::Init } std::unique_ptr makeEcho() override { return interfaces::MakeEcho(); } interfaces::Ipc* ipc() override { return m_ipc.get(); } - NodeContext& m_node; + node::NodeContext& m_node; std::unique_ptr m_ipc; }; } // namespace } // namespace init namespace interfaces { -std::unique_ptr MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status) +std::unique_ptr MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status) { auto init = std::make_unique(node, argc > 0 ? argv[0] : ""); // Check if bitcoin-node is being invoked as an IPC server. If so, then diff --git a/src/init/bitcoind.cpp b/src/init/bitcoind.cpp index 4b6f23ded92c..aafb27ddfca9 100644 --- a/src/init/bitcoind.cpp +++ b/src/init/bitcoind.cpp @@ -14,6 +14,8 @@ #include +using node::NodeContext; + namespace init { namespace { class BitcoindInit : public interfaces::Init diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 6a8dd5bbc3c8..0e9f6b3794e7 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -31,9 +31,9 @@ enum class MemPoolRemovalReason; struct bilingual_str; struct CBlockLocator; struct FeeCalculation; +namespace node { struct NodeContext; -enum class MemPoolRemovalReason; - +} // namespace node namespace llmq { class CChainLockSig; struct CInstantSendLock; @@ -339,7 +339,7 @@ class ChainClient }; //! Return implementation of Chain interface. -std::unique_ptr MakeChain(NodeContext& node); +std::unique_ptr MakeChain(node::NodeContext& node); } // namespace interfaces diff --git a/src/interfaces/coinjoin.h b/src/interfaces/coinjoin.h index a96c524080e7..5e167f62b673 100644 --- a/src/interfaces/coinjoin.h +++ b/src/interfaces/coinjoin.h @@ -10,7 +10,9 @@ #include class CWallet; +namespace node { struct NodeContext; +} // namespace node class UniValue; @@ -46,7 +48,7 @@ class Loader }; } // namespace CoinJoin -std::unique_ptr MakeCoinJoinLoader(NodeContext& node); +std::unique_ptr MakeCoinJoinLoader(node::NodeContext& node); } // namespace interfaces diff --git a/src/interfaces/init.h b/src/interfaces/init.h index c1c6edab8148..2679e33d5cb3 100644 --- a/src/interfaces/init.h +++ b/src/interfaces/init.h @@ -7,7 +7,9 @@ #include +namespace node { struct NodeContext; +} // namespace node namespace interfaces { class Chain; @@ -44,7 +46,7 @@ class Init //! status code to exit with. If this returns non-null, the caller can start up //! normally and use the Init object to spawn and connect to other processes //! while it is running. -std::unique_ptr MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status); +std::unique_ptr MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status); //! Return implementation of Init interface for the wallet process. std::unique_ptr MakeWalletInit(int argc, char* argv[], int& exit_status); diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 088423986a02..3f0a28c6e901 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -33,20 +33,21 @@ class Coin; class RPCTimerInterface; class UniValue; class Proxy; -struct bilingual_str; enum class SynchronizationState; enum class TransactionError; +enum vote_signal_enum_t : int; +struct bilingual_str; struct CNodeStateStats; +namespace node { struct NodeContext; - -enum vote_signal_enum_t : int; +} // namespace node namespace interfaces { class Handler; class WalletLoader; namespace CoinJoin { class Loader; -} //namespsace CoinJoin +} // namespace CoinJoin struct BlockTip; //! Interface for the src/evo part of a dash node (dashd process). @@ -55,7 +56,7 @@ class EVO public: virtual ~EVO() {} virtual std::pair getListAtChainTip() = 0; - virtual void setContext(NodeContext* context) {} + virtual void setContext(node::NodeContext* context) {} }; //! Interface for the src/governance part of a dash node (dashd process). @@ -67,7 +68,7 @@ class GOV virtual int32_t getObjAbsYesCount(const CGovernanceObject& obj, vote_signal_enum_t vote_signal) = 0; virtual bool getObjLocalValidity(const CGovernanceObject& obj, std::string& error, bool check_collateral) = 0; virtual bool isEnabled() = 0; - virtual void setContext(NodeContext* context) {} + virtual void setContext(node::NodeContext* context) {} }; //! Interface for the src/llmq part of a dash node (dashd process). @@ -76,7 +77,7 @@ class LLMQ public: virtual ~LLMQ() {} virtual size_t getInstantSentLockCount() = 0; - virtual void setContext(NodeContext* context) {} + virtual void setContext(node::NodeContext* context) {} }; //! Interface for the src/masternode part of a dash node (dashd process). @@ -89,7 +90,7 @@ class Sync virtual bool isBlockchainSynced() = 0; virtual bool isSynced() = 0; virtual std::string getSyncStatus() = 0; - virtual void setContext(NodeContext* context) {} + virtual void setContext(node::NodeContext* context) {} }; } @@ -354,12 +355,12 @@ class Node //! Get and set internal node context. Useful for testing, but not //! accessible across processes. - virtual NodeContext* context() { return nullptr; } - virtual void setContext(NodeContext* context) { } + virtual node::NodeContext* context() { return nullptr; } + virtual void setContext(node::NodeContext* context) { } }; //! Return implementation of Node interface. -std::unique_ptr MakeNode(NodeContext& context); +std::unique_ptr MakeNode(node::NodeContext& context); //! Block tip (could be a header or not, depends on the subscribed signal). struct BlockTip { diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index c0fbd86cfc2f..ceceb3ffa84a 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -35,10 +35,13 @@ enum class FeeReason; enum class TransactionError; enum isminetype : unsigned int; struct CRecipient; -struct NodeContext; struct PartiallySignedTransaction; struct WalletContext; struct bilingual_str; +namespace node { +struct NodeContext; +} // namespace node + using isminefilter = std::underlying_type::type; template @@ -456,7 +459,7 @@ std::unique_ptr MakeWallet(WalletContext& context, const std::shared_ptr //! Return implementation of ChainClient interface for a wallet loader. This //! function will be undefined in builds where ENABLE_WALLET is false. -std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args, NodeContext& node_context, +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args, node::NodeContext& node_context, CoinJoin::Loader& coinjoin_loader); } // namespace interfaces diff --git a/src/node/coin.cpp b/src/node/coin.cpp index 78ab46f2e84d..e3f4ee1d8896 100644 --- a/src/node/coin.cpp +++ b/src/node/coin.cpp @@ -8,6 +8,8 @@ #include #include +using node::NodeContext; + void FindCoins(const NodeContext& node, std::map& coins) { assert(node.mempool); diff --git a/src/node/coin.h b/src/node/coin.h index 908850e2a5ac..9724ca1c49dc 100644 --- a/src/node/coin.h +++ b/src/node/coin.h @@ -9,7 +9,9 @@ class COutPoint; class Coin; +namespace node { struct NodeContext; +} // namespace node /** * Look up unspent output information. Returns coins in the mempool and in the @@ -19,6 +21,6 @@ struct NodeContext; * @param[in] node The node context to use for lookup * @param[in,out] coins map to fill */ -void FindCoins(const NodeContext& node, std::map& coins); +void FindCoins(const node::NodeContext& node, std::map& coins); #endif // BITCOIN_NODE_COIN_H diff --git a/src/node/context.cpp b/src/node/context.cpp index aa63c1301db4..87ead0700582 100644 --- a/src/node/context.cpp +++ b/src/node/context.cpp @@ -29,5 +29,7 @@ #include #include +namespace node { NodeContext::NodeContext() {} NodeContext::~NodeContext() {} +} // namespace node diff --git a/src/node/context.h b/src/node/context.h index 72f6eb9124cb..3ce539df983a 100644 --- a/src/node/context.h +++ b/src/node/context.h @@ -44,6 +44,7 @@ class Loader; } // namspace CoinJoin } // namespace interfaces +namespace node { //! NodeContext struct containing references to chain state and connection //! state. //! @@ -96,5 +97,6 @@ struct NodeContext { NodeContext(); ~NodeContext(); }; +} // namespace node #endif // BITCOIN_NODE_CONTEXT_H diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 64b3b929d6cd..b469b8950901 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -1020,6 +1020,6 @@ class ChainImpl : public Chain } // namespace node namespace interfaces { -std::unique_ptr MakeNode(NodeContext& context) { return std::make_unique(context); } -std::unique_ptr MakeChain(NodeContext& node) { return std::make_unique(node); } +std::unique_ptr MakeNode(node::NodeContext& context) { return std::make_unique(context); } +std::unique_ptr MakeChain(node::NodeContext& node) { return std::make_unique(node); } } // namespace interfaces diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 9b6cb5084012..1eb45dbdc111 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -44,6 +44,8 @@ #include #include +using node::NodeContext; + int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) { int64_t nOldTime = pblock->nTime; diff --git a/src/node/miner.h b/src/node/miner.h index 11ffe0e84498..9e8513aea1f9 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -30,7 +30,6 @@ class CEvoDB; class CMNHFManager; class CScript; struct LLMQContext; -struct NodeContext; namespace Consensus { struct Params; }; namespace llmq { @@ -40,6 +39,9 @@ class CQuorumBlockProcessor; class CQuorumManager; class CQuorumSnapshotManager; } // namespace llmq +namespace node { +struct NodeContext; +} // namespace node static const bool DEFAULT_PRINTPRIORITY = false; @@ -188,8 +190,8 @@ class BlockAssembler CFeeRate blockMinFeeRate; }; - explicit BlockAssembler(CChainState& chainstate, const NodeContext& node, const CTxMemPool* mempool, const CChainParams& params); - explicit BlockAssembler(CChainState& chainstate, const NodeContext& node, const CTxMemPool* mempool, const CChainParams& params, + explicit BlockAssembler(CChainState& chainstate, const node::NodeContext& node, const CTxMemPool* mempool, const CChainParams& params); + explicit BlockAssembler(CChainState& chainstate, const node::NodeContext& node, const CTxMemPool* mempool, const CChainParams& params, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn */ diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp index 88d691628d7a..d03ae062be60 100644 --- a/src/node/transaction.cpp +++ b/src/node/transaction.cpp @@ -17,6 +17,8 @@ #include +using node::NodeContext; + static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out) { err_string_out = state.ToString(); if (state.IsInvalid()) { diff --git a/src/node/transaction.h b/src/node/transaction.h index 98a6b61a2f38..fc8d91708483 100644 --- a/src/node/transaction.h +++ b/src/node/transaction.h @@ -12,10 +12,12 @@ class CBlockIndex; class CTxMemPool; -struct NodeContext; namespace Consensus { struct Params; } +namespace node { +struct NodeContext; +} // namespace node /** Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls. * Also used by the GUI when broadcasting a completed PSBT. @@ -40,7 +42,7 @@ static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10}; * @param[in] wait_callback wait until callbacks have been processed to avoid stale result due to a sequentially RPC. * return error */ -[[nodiscard]] TransactionError BroadcastTransaction(NodeContext& node, CTransactionRef tx, bilingual_str& err_string, const CAmount& highfee, bool relay, bool wait_callback, bool bypass_limits = false); +[[nodiscard]] TransactionError BroadcastTransaction(node::NodeContext& node, CTransactionRef tx, bilingual_str& err_string, const CAmount& highfee, bool relay, bool wait_callback, bool bypass_limits = false); /** * Return transaction with a given hash. diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 8c1ca8c2e379..3b99604d8868 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -81,6 +81,8 @@ Q_DECLARE_METATYPE(CAmount) Q_DECLARE_METATYPE(SynchronizationState) Q_DECLARE_METATYPE(uint256) +using node::NodeContext; + static void RegisterMetaTypes() { // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index b204ac015bbf..d2f56ab891d6 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -45,6 +45,8 @@ Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin) #endif #endif +using node::NodeContext; + const std::function G_TEST_LOG_FUN{}; const std::function()> G_TEST_COMMAND_LINE_ARGUMENTS{}; diff --git a/src/rest.cpp b/src/rest.cpp index bf5703ef34a1..d0878703885d 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -32,6 +32,8 @@ #include +using node::NodeContext; + static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 0888896dd636..6059e2199724 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -64,6 +64,8 @@ #include #include +using node::NodeContext; + struct CUpdatedBlock { uint256 hash; diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index bd0a69381410..8abe9e18a60c 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -21,11 +21,13 @@ class CBlock; class CBlockIndex; class CChainState; class UniValue; -struct NodeContext; namespace llmq { class CChainLocksHandler; class CInstantSendManager; } // namespace llmq +namespace node { +struct NodeContext; +} // namespace node static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5; @@ -54,7 +56,7 @@ void CalculatePercentilesBySize(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], s * @return a UniValue map containing metadata about the snapshot. */ UniValue CreateUTXOSnapshot( - NodeContext& node, + node::NodeContext& node, CChainState& chainstate, CAutoFile& afile, const fs::path& path, diff --git a/src/rpc/coinjoin.cpp b/src/rpc/coinjoin.cpp index cc67eb17ab44..25cc08d5279b 100644 --- a/src/rpc/coinjoin.cpp +++ b/src/rpc/coinjoin.cpp @@ -24,6 +24,8 @@ #include +using node::NodeContext; + #ifdef ENABLE_WALLET namespace { void ValidateCoinJoinArguments() diff --git a/src/rpc/evo.cpp b/src/rpc/evo.cpp index a4bc4a28afc8..1a53b7680c50 100644 --- a/src/rpc/evo.cpp +++ b/src/rpc/evo.cpp @@ -46,6 +46,8 @@ extern RPCHelpMan sendrawtransaction(); class CWallet; #endif//ENABLE_WALLET +using node::NodeContext; + static RPCArg GetRpcArg(const std::string& strParamName) { static const std::map mapParamHelp = { diff --git a/src/rpc/fees.cpp b/src/rpc/fees.cpp index 1146e9256e58..00940a583279 100644 --- a/src/rpc/fees.cpp +++ b/src/rpc/fees.cpp @@ -4,6 +4,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include #include @@ -25,7 +26,7 @@ #include #include -struct NodeContext; +using node::NodeContext; static RPCHelpMan estimatesmartfee() { diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index ff58bde080c0..b677ce92b06c 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -32,6 +32,8 @@ #include #endif // ENABLE_WALLET +using node::NodeContext; + static RPCHelpMan gobject_count() { return RPCHelpMan{"gobject count", diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index d40ffb596e85..69e44c925302 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -34,6 +34,8 @@ #include #include +using node::NodeContext; + static RPCHelpMan masternode_connect() { return RPCHelpMan{"masternode connect", diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp index cd05f91b1270..c090221f0540 100644 --- a/src/rpc/mempool.cpp +++ b/src/rpc/mempool.cpp @@ -19,6 +19,8 @@ #include #include +using node::NodeContext; + static std::vector MempoolEntryDescription() { return { RPCResult{RPCResult::Type::NUM, "vsize", "virtual transaction size. This can be different from actual serialized size for high-sigop transactions."}, RPCResult{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 54cb60ddc7a3..4b0244d9a9c5 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -52,6 +52,8 @@ #include #include +using node::NodeContext; + /** * Return average network hashes per second based on the last 'lookup' blocks, * or from the last difficulty change if 'lookup' is nonpositive. diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 23424abefa32..9023c4b72746 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -41,6 +41,8 @@ #include #endif +using node::NodeContext; + static RPCHelpMan debug() { return RPCHelpMan{"debug", diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index f6a965ffaa5d..c9379156f2f7 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -32,6 +32,8 @@ #include +using node::NodeContext; + const std::vector CONNECTION_TYPE_DOC{ "outbound-full-relay (default automatic connections)", "block-relay-only (does not relay transactions or addresses)", diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index e59b3a1df398..daeb9272e3d7 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -33,6 +33,8 @@ #include #include +using node::NodeContext; + static RPCHelpMan quorum_list() { return RPCHelpMan{"quorum list", diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e903506114f3..60a7f64d0d70 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -60,6 +60,8 @@ #include +using node::NodeContext; + void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry) { LOCK(::cs_main); diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp index 2700a7851f8e..750c2c5967af 100644 --- a/src/rpc/server_util.cpp +++ b/src/rpc/server_util.cpp @@ -19,6 +19,8 @@ #include +using node::NodeContext; + NodeContext& EnsureAnyNodeContext(const CoreContext& context) { auto* const node_context = GetContext(context); diff --git a/src/rpc/server_util.h b/src/rpc/server_util.h index 9bcf1b7d081d..79ad619ece01 100644 --- a/src/rpc/server_util.h +++ b/src/rpc/server_util.h @@ -13,21 +13,23 @@ class CConnman; class CTxMemPool; class ChainstateManager; class PeerManager; -struct NodeContext; struct LLMQContext; +namespace node { +struct NodeContext; +} // namespace node -NodeContext& EnsureAnyNodeContext(const CoreContext& context); -CTxMemPool& EnsureMemPool(const NodeContext& node); +node::NodeContext& EnsureAnyNodeContext(const CoreContext& context); +CTxMemPool& EnsureMemPool(const node::NodeContext& node); CTxMemPool& EnsureAnyMemPool(const CoreContext& context); -ArgsManager& EnsureArgsman(const NodeContext& node); +ArgsManager& EnsureArgsman(const node::NodeContext& node); ArgsManager& EnsureAnyArgsman(const CoreContext& context); -ChainstateManager& EnsureChainman(const NodeContext& node); +ChainstateManager& EnsureChainman(const node::NodeContext& node); ChainstateManager& EnsureAnyChainman(const CoreContext& context); -CBlockPolicyEstimator& EnsureFeeEstimator(const NodeContext& node); +CBlockPolicyEstimator& EnsureFeeEstimator(const node::NodeContext& node); CBlockPolicyEstimator& EnsureAnyFeeEstimator(const CoreContext& context); -LLMQContext& EnsureLLMQContext(const NodeContext& node); +LLMQContext& EnsureLLMQContext(const node::NodeContext& node); LLMQContext& EnsureAnyLLMQContext(const CoreContext& context); -CConnman& EnsureConnman(const NodeContext& node); -PeerManager& EnsurePeerman(const NodeContext& node); +CConnman& EnsureConnman(const node::NodeContext& node); +PeerManager& EnsurePeerman(const node::NodeContext& node); #endif // BITCOIN_RPC_SERVER_UTIL_H diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index c1cbde592ecc..897b4d88705a 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -20,6 +20,7 @@ #include using namespace std::literals; +using node::NodeContext; static NetGroupManager EMPTY_NETGROUPMAN{std::vector()}; static const bool DETERMINISTIC{true}; diff --git a/src/test/evo_utils_tests.cpp b/src/test/evo_utils_tests.cpp index 4d555492469b..b2aeeb85fcdc 100644 --- a/src/test/evo_utils_tests.cpp +++ b/src/test/evo_utils_tests.cpp @@ -13,6 +13,8 @@ #include +using node::NodeContext; + /* TODO: rename this file and test to llmq_options_test */ BOOST_AUTO_TEST_SUITE(evo_utils_tests) diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp index 9849feb1ede7..85c47b8a4e88 100644 --- a/src/test/fuzz/tx_pool.cpp +++ b/src/test/fuzz/tx_pool.cpp @@ -13,6 +13,8 @@ #include #include +using node::NodeContext; + namespace { const TestingSetup* g_setup; diff --git a/src/test/util/chainstate.h b/src/test/util/chainstate.h index 3b6b504ef8b9..5f4a27ca6881 100644 --- a/src/test/util/chainstate.h +++ b/src/test/util/chainstate.h @@ -23,7 +23,7 @@ const auto NoMalleation = [](CAutoFile& file, SnapshotMetadata& meta){}; */ template static bool -CreateAndActivateUTXOSnapshot(NodeContext& node, const fs::path root, F malleation = NoMalleation) +CreateAndActivateUTXOSnapshot(node::NodeContext& node, const fs::path root, F malleation = NoMalleation) { // Write out a snapshot to the test's tempdir. // diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp index 653814db5e7a..6721aa81f58e 100644 --- a/src/test/util/mining.cpp +++ b/src/test/util/mining.cpp @@ -18,6 +18,8 @@ #include #include +using node::NodeContext; + CTxIn generatetoaddress(const NodeContext& node, const std::string& address) { const auto dest = DecodeDestination(address); diff --git a/src/test/util/mining.h b/src/test/util/mining.h index e6cdbfd6d597..09e712cd35c9 100644 --- a/src/test/util/mining.h +++ b/src/test/util/mining.h @@ -13,18 +13,20 @@ class CBlock; class CChainParams; class CScript; class CTxIn; +namespace node { struct NodeContext; +} // namespace node /** Create a blockchain, starting from genesis */ std::vector> CreateBlockChain(size_t total_height, const CChainParams& params); /** Returns the generated coin */ -CTxIn MineBlock(const NodeContext&, const CScript& coinbase_scriptPubKey); +CTxIn MineBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey); /** Prepare a block to be mined */ -std::shared_ptr PrepareBlock(const NodeContext&, const CScript& coinbase_scriptPubKey); +std::shared_ptr PrepareBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey); /** RPC-like helper function, returns the generated coin */ -CTxIn generatetoaddress(const NodeContext&, const std::string& address); +CTxIn generatetoaddress(const node::NodeContext&, const std::string& address); #endif // BITCOIN_TEST_UTIL_MINING_H diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 3800a0e15a70..27a46aa89d9a 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -72,6 +72,8 @@ #include #include +using node::NodeContext; + const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = nullptr; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index 8a5f626e1b3d..c778d7b1e640 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -85,17 +85,17 @@ static constexpr CAmount CENT{1000000}; /** Initialize Dash-specific components during chainstate initialization (NodeContext-friendly aliases) */ void DashChainstateSetup(ChainstateManager& chainman, - NodeContext& node, + node::NodeContext& node, bool fReset, bool fReindexChainState, const Consensus::Params& consensus_params); -void DashChainstateSetupClose(NodeContext& node); +void DashChainstateSetupClose(node::NodeContext& node); /** Basic testing setup. * This just configures logging, data dir and chain parameters. */ struct BasicTestingSetup { - NodeContext m_node; + node::NodeContext m_node; explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector& extra_args = {}); ~BasicTestingSetup(); diff --git a/src/wallet/context.h b/src/wallet/context.h index 4c710018b3dc..b70d65d7a328 100644 --- a/src/wallet/context.h +++ b/src/wallet/context.h @@ -14,7 +14,6 @@ class ArgsManager; class CWallet; -struct NodeContext; namespace interfaces { class Chain; namespace CoinJoin { @@ -22,6 +21,9 @@ class Loader; } // namspace CoinJoin class Wallet; } // namespace interfaces +namespace node { +struct NodeContext; +} // namespace node using LoadWalletFn = std::function wallet)>; @@ -49,7 +51,7 @@ struct WalletContext { // capabilities (even though it is a hard ask sometimes). We should get // rid of this at some point but until then, here's NodeContext. // TODO: Get rid of this. It's not nice. - NodeContext* node_context{nullptr}; + node::NodeContext* node_context{nullptr}; //! Declare default constructor and destructor that are not inline, so code //! instantiating the WalletContext struct doesn't need to #include class diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 02d6c29d6ade..70d3ca433e81 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -31,6 +31,8 @@ #include #include +using node::NodeContext; + class WalletInit : public WalletInitInterface { public: diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index a34ad67ffb94..ec52dcf43cee 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -49,6 +49,7 @@ using interfaces::WalletTx; using interfaces::WalletTxOut; using interfaces::WalletTxStatus; using interfaces::WalletValueMap; +using node::NodeContext; namespace wallet { namespace { diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp index 4d7b487913d8..a44c742025fb 100644 --- a/src/wallet/test/ismine_tests.cpp +++ b/src/wallet/test/ismine_tests.cpp @@ -12,6 +12,7 @@ #include +using node::NodeContext; BOOST_FIXTURE_TEST_SUITE(ismine_tests, BasicTestingSetup) diff --git a/src/wallet/test/scriptpubkeyman_tests.cpp b/src/wallet/test/scriptpubkeyman_tests.cpp index 4bc9e5074172..8cbd334ab94c 100644 --- a/src/wallet/test/scriptpubkeyman_tests.cpp +++ b/src/wallet/test/scriptpubkeyman_tests.cpp @@ -10,6 +10,8 @@ #include +using node::NodeContext; + BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup) // Test LegacyScriptPubKeyMan::CanProvide behavior, making sure it returns true diff --git a/src/walletinitinterface.h b/src/walletinitinterface.h index 62568dc1abbd..9222427a39b5 100644 --- a/src/walletinitinterface.h +++ b/src/walletinitinterface.h @@ -6,13 +6,15 @@ #define BITCOIN_WALLETINITINTERFACE_H class ArgsManager; -struct NodeContext; namespace interfaces { class WalletLoader; namespace CoinJoin { class Loader; } // namespace CoinJoin } // namespace interfaces +namespace node { +struct NodeContext; +} // namespace node class WalletInitInterface { public: @@ -23,7 +25,7 @@ class WalletInitInterface { /** Check wallet parameter interaction */ virtual bool ParameterInteraction() const = 0; /** Add wallets that should be opened to list of chain clients. */ - virtual void Construct(NodeContext& node) const = 0; + virtual void Construct(node::NodeContext& node) const = 0; // Dash Specific WalletInitInterface virtual void AutoLockMasternodeCollaterals(interfaces::WalletLoader& wallet_loader) const = 0; From ddbc294ae471a3b4f90d875f21d878f9259494a7 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Jun 2025 17:51:41 +0000 Subject: [PATCH 4/7] refactor: add `src/node/*` to `node::` namespace This commit will not compile on its own, the commit after adjusts the rest of the codebase around this commit and should be compilable. Some files have been excluded as they're not in the `node::` namespace upstream. --- src/node/blockstorage.cpp | 2 ++ src/node/blockstorage.h | 2 ++ src/node/caches.cpp | 2 ++ src/node/caches.h | 2 ++ src/node/chainstate.cpp | 2 ++ src/node/chainstate.h | 2 ++ src/node/coin.cpp | 4 ++-- src/node/coin.h | 3 ++- src/node/coinstats.cpp | 2 ++ src/node/coinstats.h | 8 ++++++-- src/node/interfaces.cpp | 4 ++-- src/node/miner.cpp | 4 ++-- src/node/miner.h | 5 +++-- src/node/minisketchwrapper.cpp | 2 ++ src/node/minisketchwrapper.h | 2 ++ src/node/psbt.cpp | 3 ++- src/node/psbt.h | 2 ++ src/node/transaction.cpp | 4 ++-- src/node/transaction.h | 3 ++- src/node/utxo_snapshot.h | 2 ++ 20 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index a9caeee4cf1f..e97e4ac6f3c9 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -26,6 +26,7 @@ #include #include +namespace node { std::atomic_bool fImporting(false); std::atomic_bool fReindex(false); bool fPruneMode = false; @@ -923,3 +924,4 @@ void ThreadImport(ChainstateManager& chainman, CDeterministicMNManager& dmnman, chainman.ActiveChainstate().LoadMempool(args); } +} // namespace node diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index 5b7468e79c24..128fb884ac4b 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -35,6 +35,7 @@ namespace Consensus { struct Params; } +namespace node { static constexpr bool DEFAULT_ADDRESSINDEX{false}; static constexpr bool DEFAULT_SPENTINDEX{false}; static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false}; @@ -230,5 +231,6 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex); void ThreadImport(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CDSNotificationInterface& dsnfi, std::vector vImportFiles, CActiveMasternodeManager* const mn_activeman, const ArgsManager& args); +} // namespace node #endif // BITCOIN_NODE_BLOCKSTORAGE_H diff --git a/src/node/caches.cpp b/src/node/caches.cpp index 36254dc71419..f168332ee657 100644 --- a/src/node/caches.cpp +++ b/src/node/caches.cpp @@ -8,6 +8,7 @@ #include #include +namespace node { CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes) { int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20); @@ -30,3 +31,4 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes) sizes.coins = nTotalCache; // the rest goes to in-memory cache return sizes; } +} // namespace node diff --git a/src/node/caches.h b/src/node/caches.h index 200f0b85b8ea..67388b91fd26 100644 --- a/src/node/caches.h +++ b/src/node/caches.h @@ -10,6 +10,7 @@ class ArgsManager; +namespace node { struct CacheSizes { int64_t block_tree_db; int64_t coins_db; @@ -18,5 +19,6 @@ struct CacheSizes { int64_t filter_index; }; CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0); +} // namespace node #endif // BITCOIN_NODE_CACHES_H diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index fbfad427d749..5066eb1ab2eb 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -17,6 +17,7 @@ #include #include +namespace node { std::optional LoadChainstate(bool fReset, ChainstateManager& chainman, CGovernanceManager& govman, @@ -313,3 +314,4 @@ std::optional VerifyLoadedChainstate(ChainstateManage return std::nullopt; } +} // namespace node diff --git a/src/node/chainstate.h b/src/node/chainstate.h index 014b43d164df..54870a8f7bfa 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -29,6 +29,7 @@ namespace Consensus { struct Params; } +namespace node { enum class ChainstateLoadingError { ERROR_LOADING_BLOCK_DB, ERROR_BAD_GENESIS_BLOCK, @@ -146,5 +147,6 @@ std::optional VerifyLoadedChainstate(ChainstateManage int check_level, std::function get_unix_time_seconds, std::function notify_bls_state = nullptr); +} // namespace node #endif // BITCOIN_NODE_CHAINSTATE_H diff --git a/src/node/coin.cpp b/src/node/coin.cpp index e3f4ee1d8896..221854c5f67d 100644 --- a/src/node/coin.cpp +++ b/src/node/coin.cpp @@ -8,8 +8,7 @@ #include #include -using node::NodeContext; - +namespace node { void FindCoins(const NodeContext& node, std::map& coins) { assert(node.mempool); @@ -24,3 +23,4 @@ void FindCoins(const NodeContext& node, std::map& coins) } } } +} // namespace node diff --git a/src/node/coin.h b/src/node/coin.h index 9724ca1c49dc..3d534463e88d 100644 --- a/src/node/coin.h +++ b/src/node/coin.h @@ -9,9 +9,9 @@ class COutPoint; class Coin; + namespace node { struct NodeContext; -} // namespace node /** * Look up unspent output information. Returns coins in the mempool and in the @@ -22,5 +22,6 @@ struct NodeContext; * @param[in,out] coins map to fill */ void FindCoins(const node::NodeContext& node, std::map& coins); +} // namespace node #endif // BITCOIN_NODE_COIN_H diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp index cd8748d17009..c31509e15304 100644 --- a/src/node/coinstats.cpp +++ b/src/node/coinstats.cpp @@ -18,6 +18,7 @@ #include +namespace node { // Database-independent metric indicating the UTXO set size uint64_t GetBogoSize(const CScript& script_pub_key) { @@ -182,3 +183,4 @@ static void FinalizeHash(MuHash3072& muhash, CCoinsStats& stats) stats.hashSerialized = out; } static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {} +} // namespace node diff --git a/src/node/coinstats.h b/src/node/coinstats.h index 57915dea3025..4ca9274db35f 100644 --- a/src/node/coinstats.h +++ b/src/node/coinstats.h @@ -16,9 +16,12 @@ #include #include -class BlockManager; class CCoinsView; +namespace node { +class BlockManager; +} // namespace node +namespace node { enum class CoinStatsHashType { HASH_SERIALIZED, MUHASH, @@ -72,10 +75,11 @@ struct CCoinsStats { }; //! Calculate statistics about the unspent transaction output set -bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const std::function& interruption_point = {}, const CBlockIndex* pindex = nullptr); +bool GetUTXOStats(CCoinsView* view, node::BlockManager& blockman, CCoinsStats& stats, const std::function& interruption_point = {}, const CBlockIndex* pindex = nullptr); uint64_t GetBogoSize(const CScript& script_pub_key); CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin); +} // namespace node #endif // BITCOIN_NODE_COINSTATS_H diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index b469b8950901..251a58fdab9a 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -468,7 +468,7 @@ class NodeImpl : public Node { return m_context->mn_activeman != nullptr; } - bool isLoadingBlocks() override { return ::fReindex || ::fImporting; } + bool isLoadingBlocks() override { return node::fReindex || node::fImporting; } void setNetworkActive(bool active) override { if (m_context->connman) { @@ -938,7 +938,7 @@ class ChainImpl : public Chain LOCK(cs_main); return m_node.chainman->m_blockman.m_have_pruned; } - bool isReadyToBroadcast() override { return !::fImporting && !::fReindex && !isInitialBlockDownload(); } + bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); } bool isInitialBlockDownload() override { return chainman().ActiveChainstate().IsInitialBlockDownload(); } diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 1eb45dbdc111..ad210a3d4c8d 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -44,8 +44,7 @@ #include #include -using node::NodeContext; - +namespace node { int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) { int64_t nOldTime = pblock->nTime; @@ -586,3 +585,4 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele nDescendantsUpdated += UpdatePackagesForAdded(mempool, ancestors, mapModifiedTx); } } +} // namespace node diff --git a/src/node/miner.h b/src/node/miner.h index 9e8513aea1f9..96116c0345f1 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -19,7 +19,6 @@ #include #include -class BlockManager; class CBlockIndex; class CChainParams; class CChainstateHelper; @@ -39,9 +38,10 @@ class CQuorumBlockProcessor; class CQuorumManager; class CQuorumSnapshotManager; } // namespace llmq + namespace node { +class BlockManager; struct NodeContext; -} // namespace node static const bool DEFAULT_PRINTPRIORITY = false; @@ -229,5 +229,6 @@ class BlockAssembler }; int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev); +} // namespace node #endif // BITCOIN_NODE_MINER_H diff --git a/src/node/minisketchwrapper.cpp b/src/node/minisketchwrapper.cpp index 572df63463ab..67e823cb6827 100644 --- a/src/node/minisketchwrapper.cpp +++ b/src/node/minisketchwrapper.cpp @@ -16,6 +16,7 @@ #include #include +namespace node { namespace { static constexpr uint32_t BITS = 32; @@ -75,3 +76,4 @@ Minisketch MakeMinisketch32FP(size_t max_elements, uint32_t fpbits) { return Minisketch::CreateFP(BITS, Minisketch32Implementation(), max_elements, fpbits); } +} // namespace node diff --git a/src/node/minisketchwrapper.h b/src/node/minisketchwrapper.h index 426781d50869..ee108ba14430 100644 --- a/src/node/minisketchwrapper.h +++ b/src/node/minisketchwrapper.h @@ -9,9 +9,11 @@ #include #include +namespace node { /** Wrapper around Minisketch::Minisketch(32, implementation, capacity). */ Minisketch MakeMinisketch32(size_t capacity); /** Wrapper around Minisketch::CreateFP. */ Minisketch MakeMinisketch32FP(size_t max_elements, uint32_t fpbits); +} // namespace node #endif // BITCOIN_NODE_MINISKETCHWRAPPER_H diff --git a/src/node/psbt.cpp b/src/node/psbt.cpp index 0b0a3cd45dcc..1f905b3c44fa 100644 --- a/src/node/psbt.cpp +++ b/src/node/psbt.cpp @@ -11,6 +11,7 @@ #include +namespace node { PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) { // Go through each input and build status @@ -144,4 +145,4 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) return result; } - +} // namespace node diff --git a/src/node/psbt.h b/src/node/psbt.h index c2826e3ea1e8..5b76298b4cda 100644 --- a/src/node/psbt.h +++ b/src/node/psbt.h @@ -7,6 +7,7 @@ #include +namespace node { /** * Holds an analysis of one input from a PSBT */ @@ -49,5 +50,6 @@ struct PSBTAnalysis { * @return A PSBTAnalysis with information about the provided PSBT. */ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx); +} // namespace node #endif // BITCOIN_NODE_PSBT_H diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp index d03ae062be60..a66c036bbfda 100644 --- a/src/node/transaction.cpp +++ b/src/node/transaction.cpp @@ -17,8 +17,7 @@ #include -using node::NodeContext; - +namespace node { static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out) { err_string_out = state.ToString(); if (state.IsInvalid()) { @@ -150,3 +149,4 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe } return nullptr; } +} // namespace node diff --git a/src/node/transaction.h b/src/node/transaction.h index fc8d91708483..3156e841e594 100644 --- a/src/node/transaction.h +++ b/src/node/transaction.h @@ -15,9 +15,9 @@ class CTxMemPool; namespace Consensus { struct Params; } + namespace node { struct NodeContext; -} // namespace node /** Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls. * Also used by the GUI when broadcasting a completed PSBT. @@ -58,5 +58,6 @@ static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10}; * @returns The tx if found, otherwise nullptr */ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock); +} // namespace node #endif // BITCOIN_NODE_TRANSACTION_H diff --git a/src/node/utxo_snapshot.h b/src/node/utxo_snapshot.h index 9b0df96a75f6..401d4baaeb92 100644 --- a/src/node/utxo_snapshot.h +++ b/src/node/utxo_snapshot.h @@ -9,6 +9,7 @@ #include #include +namespace node { //! Metadata describing a serialized version of a UTXO set from which an //! assumeutxo CChainState can be constructed. class SnapshotMetadata @@ -32,5 +33,6 @@ class SnapshotMetadata SERIALIZE_METHODS(SnapshotMetadata, obj) { READWRITE(obj.m_base_blockhash, obj.m_coins_count); } }; +} // namespace node #endif // BITCOIN_NODE_UTXO_SNAPSHOT_H From 81c6880dec63d7a247f5138d4777f9c9b457eec7 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Jun 2025 17:52:15 +0000 Subject: [PATCH 5/7] refactor: complete migration of code to `node::` namespace Continuation of prior commit, should compile successfully. --- src/bench/load_external.cpp | 2 +- src/dummywallet.cpp | 13 +++++++----- src/evo/assetlocktx.cpp | 2 ++ src/evo/assetlocktx.h | 8 ++++--- src/evo/cbtx.cpp | 1 + src/evo/chainhelper.cpp | 2 ++ src/evo/creditpool.cpp | 3 +++ src/evo/creditpool.h | 8 ++++--- src/evo/mnhftx.cpp | 2 ++ src/evo/simplifiedmns.cpp | 2 ++ src/index/base.cpp | 4 ++++ src/index/blockfilterindex.cpp | 2 ++ src/index/coinstatsindex.cpp | 6 ++++++ src/index/coinstatsindex.h | 2 +- src/index/txindex.cpp | 2 ++ src/init.cpp | 21 +++++++++++++++++++ src/interfaces/chain.h | 6 +++--- src/llmq/chainlocks.cpp | 2 ++ src/llmq/instantsend.cpp | 3 +++ src/net_processing.cpp | 5 +++++ src/qt/psbtoperationsdialog.cpp | 3 +++ src/rest.cpp | 2 ++ src/rpc/blockchain.cpp | 14 +++++++++---- src/rpc/blockchain.h | 4 ++-- src/rpc/evo.cpp | 1 + src/rpc/index_util.cpp | 6 +++--- src/rpc/masternode.cpp | 2 ++ src/rpc/mining.cpp | 3 +++ src/rpc/quorums.cpp | 1 + src/rpc/rawtransaction.cpp | 6 +++++- src/rpc/txoutproof.cpp | 3 +++ src/test/block_reward_reallocation_tests.cpp | 3 +++ src/test/blockfilter_index_tests.cpp | 3 +++ src/test/blockmanager_tests.cpp | 3 +++ src/test/coinstatsindex_tests.cpp | 3 +++ .../dynamic_activation_thresholds_tests.cpp | 2 ++ src/test/evo_deterministicmns_tests.cpp | 2 ++ src/test/fuzz/coins_view.cpp | 3 +++ src/test/fuzz/deserialize.cpp | 2 ++ src/test/fuzz/minisketch.cpp | 2 ++ src/test/fuzz/psbt.cpp | 4 ++++ src/test/fuzz/tx_pool.cpp | 1 + src/test/fuzz/utxo_snapshot.cpp | 2 ++ src/test/miner_tests.cpp | 3 +++ src/test/minisketch_tests.cpp | 2 ++ src/test/util/blockfilter.cpp | 3 +++ src/test/util/chainstate.h | 4 ++-- src/test/util/mining.cpp | 1 + src/test/util/setup_common.cpp | 11 ++++++++++ src/test/util/setup_common.h | 2 +- src/test/validation_block_tests.cpp | 2 ++ .../validation_chainstatemanager_tests.cpp | 2 ++ src/test/validation_flush_tests.cpp | 2 ++ src/validation.cpp | 20 ++++++++++++++++++ src/validation.h | 21 ++++++++++--------- src/wallet/test/wallet_tests.cpp | 3 +++ src/zmq/zmqpublishnotifier.cpp | 2 ++ 57 files changed, 210 insertions(+), 39 deletions(-) diff --git a/src/bench/load_external.cpp b/src/bench/load_external.cpp index 6bc359a408a8..68d7895f49b4 100644 --- a/src/bench/load_external.cpp +++ b/src/bench/load_external.cpp @@ -40,7 +40,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench) // "wb+" is "binary, O_RDWR | O_CREAT | O_TRUNC". FILE* file{fsbridge::fopen(blkfile, "wb+")}; // Make the test block file about 128 MB in length. - for (size_t i = 0; i < MAX_BLOCKFILE_SIZE / ss.size(); ++i) { + for (size_t i = 0; i < node::MAX_BLOCKFILE_SIZE / ss.size(); ++i) { if (fwrite(ss.data(), 1, ss.size(), file) != ss.size()) { throw std::runtime_error("write to test file failed\n"); } diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp index 2cadbb003b21..a407ab2b075a 100644 --- a/src/dummywallet.cpp +++ b/src/dummywallet.cpp @@ -17,8 +17,11 @@ class WalletClient; class WalletLoader; namespace CoinJoin { class Loader; -} // namespcae CoinJoin -} +} // namespace CoinJoin +} // namespace interfaces +namespace node { +class NodeContext; +} // namespace node class DummyWalletInit : public WalletInitInterface { public: @@ -26,7 +29,7 @@ class DummyWalletInit : public WalletInitInterface { bool HasWalletSupport() const override {return false;} void AddWalletOptions(ArgsManager& argsman) const override; bool ParameterInteraction() const override {return true;} - void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");} + void Construct(node::NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");} // Dash Specific WalletInitInterface InitCoinJoinSettings void AutoLockMasternodeCollaterals(interfaces::WalletLoader& wallet_loader) const override {} @@ -82,7 +85,7 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit(); namespace interfaces { -std::unique_ptr MakeCoinJoinLoader(NodeContext& node) +std::unique_ptr MakeCoinJoinLoader(node::NodeContext& node) { throw std::logic_error("Wallet function called in non-wallet build."); } @@ -92,7 +95,7 @@ std::unique_ptr MakeWallet(const std::shared_ptr& wallet) throw std::logic_error("Wallet function called in non-wallet build."); } -std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args, NodeContext& node_context, +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args, node::NodeContext& node_context, interfaces::CoinJoin::Loader& coinjoin_loader) { throw std::logic_error("Wallet function called in non-wallet build."); diff --git a/src/evo/assetlocktx.cpp b/src/evo/assetlocktx.cpp index 1a985e711511..61878c447018 100644 --- a/src/evo/assetlocktx.cpp +++ b/src/evo/assetlocktx.cpp @@ -20,6 +20,8 @@ #include +using node::BlockManager; + /** * Common code for Asset Lock and Asset Unlock */ diff --git a/src/evo/assetlocktx.h b/src/evo/assetlocktx.h index 0af346be0a20..2fc44643fa8f 100644 --- a/src/evo/assetlocktx.h +++ b/src/evo/assetlocktx.h @@ -14,13 +14,15 @@ #include -class BlockManager; class CBlockIndex; class CRangesSet; class TxValidationState; namespace llmq { class CQuorumManager; } // namespace llmq +namespace node { +class BlockManager; +} // namespace node class CAssetLockPayload { @@ -150,8 +152,8 @@ class CAssetUnlockPayload }; bool CheckAssetLockTx(const CTransaction& tx, TxValidationState& state); -bool CheckAssetUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null pindexPrev, const std::optional& indexes, TxValidationState& state); -bool CheckAssetLockUnlockTx(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null pindexPrev, const std::optional& indexes, TxValidationState& state); +bool CheckAssetUnlockTx(const node::BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null pindexPrev, const std::optional& indexes, TxValidationState& state); +bool CheckAssetLockUnlockTx(const node::BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, gsl::not_null pindexPrev, const std::optional& indexes, TxValidationState& state); bool GetAssetUnlockFee(const CTransaction& tx, CAmount& txfee, TxValidationState& state); #endif // BITCOIN_EVO_ASSETLOCKTX_H diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index d562877db9bf..9eb014a814b7 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -18,6 +18,7 @@ #include #include +using node::ReadBlockFromDisk; bool CheckCbTx(const CCbTx& cbTx, const CBlockIndex* pindexPrev, TxValidationState& state) { diff --git a/src/evo/chainhelper.cpp b/src/evo/chainhelper.cpp index ca19f850c8e3..d946785ea1b5 100644 --- a/src/evo/chainhelper.cpp +++ b/src/evo/chainhelper.cpp @@ -13,6 +13,8 @@ #include #include +using node::GetTransaction; + CChainstateHelper::CChainstateHelper(CCreditPoolManager& cpoolman, CDeterministicMNManager& dmnman, CMNHFManager& mnhfman, CGovernanceManager& govman, llmq::CInstantSendManager& isman, llmq::CQuorumBlockProcessor& qblockman, llmq::CQuorumSnapshotManager& qsnapman, diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index ea5adf412f63..639aa1b1d5de 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -22,6 +22,9 @@ #include #include +using node::BlockManager; +using node::ReadBlockFromDisk; + // Forward declaration to prevent a new circular dependencies through masternode/payments.h CAmount PlatformShare(const CAmount masternodeReward); diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index 46572f4b39ed..bc6c7e8fc3ae 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -20,7 +20,6 @@ #include #include -class BlockManager; class CBlock; class CBlockIndex; class BlockValidationState; @@ -32,6 +31,9 @@ struct Params; namespace llmq { class CQuorumManager; } // namespace llmq +namespace node { +class BlockManager; +} // namespace node struct CCreditPool { CAmount locked{0}; @@ -86,7 +88,7 @@ class CCreditPoolDiff { * to change amount of credit pool * @return true if transaction can be included in this block */ - bool ProcessLockUnlockTransaction(const BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state); + bool ProcessLockUnlockTransaction(const node::BlockManager& blockman, const llmq::CQuorumManager& qman, const CTransaction& tx, TxValidationState& state); /** * this function returns total amount of credits for the next block @@ -139,7 +141,7 @@ class CCreditPoolManager const Consensus::Params& consensusParams); }; -std::optional GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const BlockManager& blockman, const llmq::CQuorumManager& qman, +std::optional GetCreditPoolDiffForBlock(CCreditPoolManager& cpoolman, const node::BlockManager& blockman, const llmq::CQuorumManager& qman, const CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams, const CAmount blockSubsidy, BlockValidationState& state); diff --git a/src/evo/mnhftx.cpp b/src/evo/mnhftx.cpp index 618a5a640a8f..c1c1e76df740 100644 --- a/src/evo/mnhftx.cpp +++ b/src/evo/mnhftx.cpp @@ -22,6 +22,8 @@ #include #include +using node::ReadBlockFromDisk; + static const std::string MNEHF_REQUESTID_PREFIX = "mnhf"; static const std::string DB_SIGNALS = "mnhf_s"; static const std::string DB_SIGNALS_v2 = "mnhf_s2"; diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp index 04537470c89f..1812f7c811df 100644 --- a/src/evo/simplifiedmns.cpp +++ b/src/evo/simplifiedmns.cpp @@ -27,6 +27,8 @@ #include #include +using node::ReadBlockFromDisk; + CSimplifiedMNListEntry::CSimplifiedMNListEntry(const CDeterministicMN& dmn) : proRegTxHash(dmn.proTxHash), confirmedHash(dmn.pdmnState->confirmedHash), diff --git a/src/index/base.cpp b/src/index/base.cpp index d596ba40025d..eab169708dae 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -13,6 +13,10 @@ #include #include +using node::PruneLockInfo; +using node::ReadBlockFromDisk; +using node::fPruneMode; + constexpr uint8_t DB_BEST_BLOCK{'B'}; constexpr auto SYNC_LOG_INTERVAL{30s}; diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index 5af98dae49bd..f21b8afe4b43 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -10,6 +10,8 @@ #include #include +using node::UndoReadFromDisk; + /* The index database stores three items for each block: the disk location of the encoded filter, * its dSHA256 hash, and the header. Those belonging to blocks on the active chain are indexed by * height, and those belonging to blocks that have been reorganized out of the active chain are diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index b93f760ef889..457590ec9c3f 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -13,6 +13,12 @@ #include #include +using node::CCoinsStats; +using node::GetBogoSize; +using node::ReadBlockFromDisk; +using node::TxOutSer; +using node::UndoReadFromDisk; + static constexpr uint8_t DB_BLOCK_HASH{'s'}; static constexpr uint8_t DB_BLOCK_HEIGHT{'t'}; static constexpr uint8_t DB_MUHASH{'M'}; diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h index e93c2316a439..0eb42b1ca35d 100644 --- a/src/index/coinstatsindex.h +++ b/src/index/coinstatsindex.h @@ -56,7 +56,7 @@ class CoinStatsIndex final : public BaseIndex explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false); // Look up stats for a specific block using CBlockIndex - bool LookUpStats(const CBlockIndex* block_index, CCoinsStats& coins_stats) const; + bool LookUpStats(const CBlockIndex* block_index, node::CCoinsStats& coins_stats) const; }; /// The global UTXO set hash object. diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 637e4d9565bd..75e8bea7033f 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -9,6 +9,8 @@ #include #include +using node::OpenBlockFile; + constexpr uint8_t DB_TXINDEX{'t'}; std::unique_ptr g_txindex; diff --git a/src/init.cpp b/src/init.cpp index acf6b0745869..f1fb8c879e15 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -134,7 +134,28 @@ #include #endif +using node::CacheSizes; +using node::CalculateCacheSizes; +using node::CCoinsStats; +using node::CoinStatsHashType; +using node::ChainstateLoadingError; +using node::ChainstateLoadVerifyError; +using node::DashChainstateSetupClose; +using node::DEFAULT_ADDRESSINDEX; +using node::DEFAULT_PRINTPRIORITY; +using node::DEFAULT_SPENTINDEX; +using node::DEFAULT_STOPAFTERBLOCKIMPORT; +using node::DEFAULT_TIMESTAMPINDEX; +using node::LoadChainstate; using node::NodeContext; +using node::ThreadImport; +using node::VerifyLoadedChainstate; +using node::fAddressIndex; +using node::fPruneMode; +using node::fReindex; +using node::fSpentIndex; +using node::fTimestampIndex; +using node::nPruneTarget; static constexpr bool DEFAULT_PROXYRANDOMIZE{true}; static constexpr bool DEFAULT_REST_ENABLE{false}; diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 0e9f6b3794e7..bb5058f8ea80 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -31,13 +31,13 @@ enum class MemPoolRemovalReason; struct bilingual_str; struct CBlockLocator; struct FeeCalculation; -namespace node { -struct NodeContext; -} // namespace node namespace llmq { class CChainLockSig; struct CInstantSendLock; } // namespace llmq +namespace node { +struct NodeContext; +} // namespace node typedef std::shared_ptr CTransactionRef; diff --git a/src/llmq/chainlocks.cpp b/src/llmq/chainlocks.cpp index c121588b9202..3364fa3b6637 100644 --- a/src/llmq/chainlocks.cpp +++ b/src/llmq/chainlocks.cpp @@ -24,6 +24,8 @@ #include #include +using node::ReadBlockFromDisk; + static bool ChainLocksSigningEnabled(const CSporkManager& sporkman) { return sporkman.GetSporkValue(SPORK_19_CHAINLOCKS_ENABLED) == 0; diff --git a/src/llmq/instantsend.cpp b/src/llmq/instantsend.cpp index 425ba7194a5c..a700605a00ea 100644 --- a/src/llmq/instantsend.cpp +++ b/src/llmq/instantsend.cpp @@ -28,6 +28,9 @@ #include +using node::fImporting; +using node::fReindex; + namespace llmq { diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 68fe4f5f06df..03a6d83a2117 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -77,6 +77,11 @@ #include +using node::ReadBlockFromDisk; +using node::fImporting; +using node::fPruneMode; +using node::fReindex; + /** Maximum number of in-flight objects from a peer */ static constexpr int32_t MAX_PEER_OBJECT_IN_FLIGHT = 100; /** Maximum number of announced objects from a peer */ diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp index d8b23ee57f88..5e817cdc4f6f 100644 --- a/src/qt/psbtoperationsdialog.cpp +++ b/src/qt/psbtoperationsdialog.cpp @@ -20,6 +20,9 @@ #include #include +using node::AnalyzePSBT; +using node::DEFAULT_MAX_RAW_TX_FEE_RATE; +using node::PSBTAnalysis; PSBTOperationsDialog::PSBTOperationsDialog( QWidget* parent, WalletModel* wallet_model, ClientModel* client_model) : QDialog(parent, GUIUtil::dialog_flags), diff --git a/src/rest.cpp b/src/rest.cpp index d0878703885d..39be8e6e3eb1 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -32,7 +32,9 @@ #include +using node::GetTransaction; using node::NodeContext; +using node::ReadBlockFromDisk; static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6059e2199724..0da3c8583e99 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -64,7 +64,13 @@ #include #include +using node::BlockManager; +using node::CCoinsStats; +using node::CoinStatsHashType; using node::NodeContext; +using node::ReadBlockFromDisk; +using node::SnapshotMetadata; +using node::UndoReadFromDisk; struct CUpdatedBlock { @@ -1042,7 +1048,7 @@ static RPCHelpMan pruneblockchain() }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { - if (!fPruneMode) + if (!node::fPruneMode) throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode."); ChainstateManager& chainman = EnsureAnyChainman(request.context); @@ -1518,15 +1524,15 @@ RPCHelpMan getblockchaininfo() obj.pushKV("initialblockdownload", active_chainstate.IsInitialBlockDownload()); obj.pushKV("chainwork", tip.nChainWork.GetHex()); obj.pushKV("size_on_disk", chainman.m_blockman.CalculateCurrentUsage()); - obj.pushKV("pruned", fPruneMode); - if (fPruneMode) { + obj.pushKV("pruned", node::fPruneMode); + if (node::fPruneMode) { obj.pushKV("pruneheight", chainman.m_blockman.GetFirstStoredBlock(tip)->nHeight); // if 0, execution bypasses the whole if block. bool automatic_pruning{args.GetIntArg("-prune", 0) != 1}; obj.pushKV("automatic_pruning", automatic_pruning); if (automatic_pruning) { - obj.pushKV("prune_target_size", nPruneTarget); + obj.pushKV("prune_target_size", node::nPruneTarget); } } diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 8abe9e18a60c..6438cfcf6a02 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -16,7 +16,6 @@ extern RecursiveMutex cs_main; -class BlockManager; class CBlock; class CBlockIndex; class CChainState; @@ -26,6 +25,7 @@ class CChainLocksHandler; class CInstantSendManager; } // namespace llmq namespace node { +class BlockManager; struct NodeContext; } // namespace node @@ -43,7 +43,7 @@ double GetDifficulty(const CBlockIndex* blockindex); void RPCNotifyBlockChange(const CBlockIndex*); /** Block description to JSON */ -UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main); +UniValue blockToJSON(node::BlockManager& blockman, const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, TxVerbosity verbosity) LOCKS_EXCLUDED(cs_main); /** Block header to JSON */ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex, const llmq::CChainLocksHandler& clhandler) LOCKS_EXCLUDED(cs_main); diff --git a/src/rpc/evo.cpp b/src/rpc/evo.cpp index 1a53b7680c50..c97686df6318 100644 --- a/src/rpc/evo.cpp +++ b/src/rpc/evo.cpp @@ -46,6 +46,7 @@ extern RPCHelpMan sendrawtransaction(); class CWallet; #endif//ENABLE_WALLET +using node::GetTransaction; using node::NodeContext; static RPCArg GetRpcArg(const std::string& strParamName) diff --git a/src/rpc/index_util.cpp b/src/rpc/index_util.cpp index 30ca50caa10c..e5e6960f311e 100644 --- a/src/rpc/index_util.cpp +++ b/src/rpc/index_util.cpp @@ -14,7 +14,7 @@ static void EnsureAddressIndexAvailable() { - if (!fAddressIndex) { + if (!node::fAddressIndex) { throw JSONRPCError(RPC_INVALID_REQUEST, "Address index is disabled. You should run Dash Core with -addressindex (requires reindex)"); } } @@ -77,7 +77,7 @@ bool GetSpentIndex(CBlockTreeDB& block_tree_db, const CTxMemPool& mempool, const { AssertLockHeld(::cs_main); - if (!fSpentIndex) { + if (!node::fSpentIndex) { throw JSONRPCError(RPC_INVALID_REQUEST, "Spent index is disabled. You should run Dash Core with -spentindex (requires reindex)"); } @@ -95,7 +95,7 @@ bool GetTimestampIndex(CBlockTreeDB& block_tree_db, const uint32_t high, const u { AssertLockHeld(::cs_main); - if (!fTimestampIndex) { + if (!node::fTimestampIndex) { throw JSONRPCError(RPC_INVALID_REQUEST, "Timestamp index is disabled. You should run Dash Core with -timestampindex (requires reindex)"); } diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 69e44c925302..9e89d658f5c7 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -34,7 +34,9 @@ #include #include +using node::GetTransaction; using node::NodeContext; +using node::ReadBlockFromDisk; static RPCHelpMan masternode_connect() { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 4b0244d9a9c5..963372066621 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -52,7 +52,10 @@ #include #include +using node::BlockAssembler; +using node::CBlockTemplate; using node::NodeContext; +using node::UpdateTime; /** * Return average network hashes per second based on the last 'lookup' blocks, diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index daeb9272e3d7..5001246f6b9a 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -33,6 +33,7 @@ #include #include +using node::GetTransaction; using node::NodeContext; static RPCHelpMan quorum_list() diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 60a7f64d0d70..3f6ec00219e2 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -60,7 +60,11 @@ #include +using node::AnalyzePSBT; +using node::DEFAULT_MAX_RAW_TX_FEE_RATE; +using node::GetTransaction; using node::NodeContext; +using node::PSBTAnalysis; void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool& mempool, const CChainState& active_chainstate, const llmq::CChainLocksHandler& clhandler, const llmq::CInstantSendManager& isman, UniValue& entry) { @@ -77,7 +81,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, const CTxMemPool // Add spent information if spentindex is enabled CSpentIndexTxInfo txSpentInfo; - if (fSpentIndex) { + if (node::fSpentIndex) { txSpentInfo = CSpentIndexTxInfo{}; for (const auto& txin : tx.vin) { if (!tx.IsCoinBase()) { diff --git a/src/rpc/txoutproof.cpp b/src/rpc/txoutproof.cpp index 13fe376dc472..78300720306c 100644 --- a/src/rpc/txoutproof.cpp +++ b/src/rpc/txoutproof.cpp @@ -17,6 +17,9 @@ #include #include +using node::GetTransaction; +using node::ReadBlockFromDisk; + static RPCHelpMan gettxoutproof() { return RPCHelpMan{"gettxoutproof", diff --git a/src/test/block_reward_reallocation_tests.cpp b/src/test/block_reward_reallocation_tests.cpp index a19431ff6210..f77410b697b5 100644 --- a/src/test/block_reward_reallocation_tests.cpp +++ b/src/test/block_reward_reallocation_tests.cpp @@ -30,6 +30,9 @@ #include #include +using node::BlockAssembler; +using node::GetTransaction; + using SimpleUTXOMap = std::map>; struct TestChainBRRBeforeActivationSetup : public TestChainSetup diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp index 7ffa28eec5c8..a94bb2fe74e5 100644 --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -18,6 +18,9 @@ #include +using node::BlockAssembler; +using node::CBlockTemplate; + BOOST_AUTO_TEST_SUITE(blockfilter_index_tests) struct BuildChainTestingSetup : public TestChain100Setup { diff --git a/src/test/blockmanager_tests.cpp b/src/test/blockmanager_tests.cpp index a9ce570a3df5..dd7c32cc46c0 100644 --- a/src/test/blockmanager_tests.cpp +++ b/src/test/blockmanager_tests.cpp @@ -10,6 +10,9 @@ #include #include +using node::BlockManager; +using node::BLOCK_SERIALIZATION_HEADER_SIZE; + // use BasicTestingSetup here for the data directory configuration, setup, and cleanup BOOST_FIXTURE_TEST_SUITE(blockmanager_tests, BasicTestingSetup) diff --git a/src/test/coinstatsindex_tests.cpp b/src/test/coinstatsindex_tests.cpp index ef9beae6da22..769935c284e0 100644 --- a/src/test/coinstatsindex_tests.cpp +++ b/src/test/coinstatsindex_tests.cpp @@ -12,6 +12,9 @@ #include +using node::CCoinsStats; +using node::CoinStatsHashType; + BOOST_AUTO_TEST_SUITE(coinstatsindex_tests) BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup) diff --git a/src/test/dynamic_activation_thresholds_tests.cpp b/src/test/dynamic_activation_thresholds_tests.cpp index 792a60ae1aa1..f8684be042b8 100644 --- a/src/test/dynamic_activation_thresholds_tests.cpp +++ b/src/test/dynamic_activation_thresholds_tests.cpp @@ -15,6 +15,8 @@ #include +using node::BlockAssembler; + const auto deployment_id = Consensus::DEPLOYMENT_TESTDUMMY; constexpr int window{100}, th_start{80}, th_end{60}; diff --git a/src/test/evo_deterministicmns_tests.cpp b/src/test/evo_deterministicmns_tests.cpp index 73ffb54dbf88..018b1cb15161 100644 --- a/src/test/evo_deterministicmns_tests.cpp +++ b/src/test/evo_deterministicmns_tests.cpp @@ -28,6 +28,8 @@ #include +using node::GetTransaction; + using SimpleUTXOMap = std::map>; static SimpleUTXOMap BuildSimpleUtxoMap(const std::vector& txs) diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp index 96c2db213ca8..a8ba484f610d 100644 --- a/src/test/fuzz/coins_view.cpp +++ b/src/test/fuzz/coins_view.cpp @@ -27,6 +27,9 @@ #include #include +using node::CCoinsStats; +using node::CoinStatsHashType; + namespace { const TestingSetup* g_setup; const Coin EMPTY_COIN{}; diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp index a9967ecbe323..d34cbb25fea3 100644 --- a/src/test/fuzz/deserialize.cpp +++ b/src/test/fuzz/deserialize.cpp @@ -35,6 +35,8 @@ #include +using node::SnapshotMetadata; + namespace { const BasicTestingSetup* g_setup; } // namespace diff --git a/src/test/fuzz/minisketch.cpp b/src/test/fuzz/minisketch.cpp index 93954bd3cf24..a17be73f6c80 100644 --- a/src/test/fuzz/minisketch.cpp +++ b/src/test/fuzz/minisketch.cpp @@ -12,6 +12,8 @@ #include #include +using node::MakeMinisketch32; + FUZZ_TARGET(minisketch) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; diff --git a/src/test/fuzz/psbt.cpp b/src/test/fuzz/psbt.cpp index f4e126ae701f..81d0b953413c 100644 --- a/src/test/fuzz/psbt.cpp +++ b/src/test/fuzz/psbt.cpp @@ -18,6 +18,10 @@ #include #include +using node::AnalyzePSBT; +using node::PSBTAnalysis; +using node::PSBTInputAnalysis; + FUZZ_TARGET(psbt) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp index 85c47b8a4e88..7940c4a3b467 100644 --- a/src/test/fuzz/tx_pool.cpp +++ b/src/test/fuzz/tx_pool.cpp @@ -13,6 +13,7 @@ #include #include +using node::BlockAssembler; using node::NodeContext; namespace { diff --git a/src/test/fuzz/utxo_snapshot.cpp b/src/test/fuzz/utxo_snapshot.cpp index 388ce6a4d58a..a587cf919fb9 100644 --- a/src/test/fuzz/utxo_snapshot.cpp +++ b/src/test/fuzz/utxo_snapshot.cpp @@ -13,6 +13,8 @@ #include #include +using node::SnapshotMetadata; + namespace { const std::vector>* g_chain; diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index a303b617e4a5..3dd4d3482835 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -31,6 +31,9 @@ #include +using node::BlockAssembler; +using node::CBlockTemplate; + namespace miner_tests { struct MinerTestingSetup : public TestingSetup { void TestPackageSelection(const CChainParams& chainparams, const CScript& scriptPubKey, const std::vector& txFirst) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, m_node.mempool->cs); diff --git a/src/test/minisketch_tests.cpp b/src/test/minisketch_tests.cpp index d07924d18b8e..81f2aad62309 100644 --- a/src/test/minisketch_tests.cpp +++ b/src/test/minisketch_tests.cpp @@ -11,6 +11,8 @@ #include +using node::MakeMinisketch32; + BOOST_AUTO_TEST_SUITE(minisketch_tests) BOOST_AUTO_TEST_CASE(minisketch_test) diff --git a/src/test/util/blockfilter.cpp b/src/test/util/blockfilter.cpp index b8f3e462334d..3ae22921b9c2 100644 --- a/src/test/util/blockfilter.cpp +++ b/src/test/util/blockfilter.cpp @@ -8,6 +8,9 @@ #include #include +using node::ReadBlockFromDisk; +using node::UndoReadFromDisk; + bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex* block_index, BlockFilter& filter) { LOCK(::cs_main); diff --git a/src/test/util/chainstate.h b/src/test/util/chainstate.h index 5f4a27ca6881..b82368aa7051 100644 --- a/src/test/util/chainstate.h +++ b/src/test/util/chainstate.h @@ -15,7 +15,7 @@ #include -const auto NoMalleation = [](CAutoFile& file, SnapshotMetadata& meta){}; +const auto NoMalleation = [](CAutoFile& file, node::SnapshotMetadata& meta){}; /** * Create and activate a UTXO snapshot, optionally providing a function to @@ -42,7 +42,7 @@ CreateAndActivateUTXOSnapshot(node::NodeContext& node, const fs::path root, F ma // FILE* infile{fsbridge::fopen(snapshot_path, "rb")}; CAutoFile auto_infile{infile, SER_DISK, CLIENT_VERSION}; - SnapshotMetadata metadata; + node::SnapshotMetadata metadata; auto_infile >> metadata; malleation(auto_infile, metadata); diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp index 6721aa81f58e..e98eed3f8fd9 100644 --- a/src/test/util/mining.cpp +++ b/src/test/util/mining.cpp @@ -18,6 +18,7 @@ #include #include +using node::BlockAssembler; using node::NodeContext; CTxIn generatetoaddress(const NodeContext& node, const std::string& address) diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 27a46aa89d9a..8e4b054caf3c 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -72,7 +72,18 @@ #include #include +using node::BlockAssembler; +using node::CalculateCacheSizes; +using node::DashChainstateSetup; +using node::DashChainstateSetupClose; +using node::DEFAULT_ADDRESSINDEX; +using node::DEFAULT_SPENTINDEX; +using node::DEFAULT_TIMESTAMPINDEX; +using node::LoadChainstate; using node::NodeContext; +using node::VerifyLoadedChainstate; +using node::fPruneMode; +using node::fReindex; const std::function G_TRANSLATION_FUN = nullptr; UrlDecodeFn* const URL_DECODE = nullptr; diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h index c778d7b1e640..e072e9ac204a 100644 --- a/src/test/util/setup_common.h +++ b/src/test/util/setup_common.h @@ -109,7 +109,7 @@ struct BasicTestingSetup { * initialization behaviour. */ struct ChainTestingSetup : public BasicTestingSetup { - CacheSizes m_cache_sizes{}; + node::CacheSizes m_cache_sizes{}; explicit ChainTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector& extra_args = {}); ~ChainTestingSetup(); diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index d87929767e33..99a6109fee68 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -20,6 +20,8 @@ #include +using node::BlockAssembler; + namespace validation_block_tests { struct MinerTestingSetup : public RegTestingSetup { std::shared_ptr Block(const uint256& prev_hash); diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp index 7e2ad79cafa7..2de98a6fc65b 100644 --- a/src/test/validation_chainstatemanager_tests.cpp +++ b/src/test/validation_chainstatemanager_tests.cpp @@ -26,6 +26,8 @@ #include +using node::SnapshotMetadata; + BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup) //! Basic tests for ChainstateManager. diff --git a/src/test/validation_flush_tests.cpp b/src/test/validation_flush_tests.cpp index 1e78f0c73e84..e06afa93bbd0 100644 --- a/src/test/validation_flush_tests.cpp +++ b/src/test/validation_flush_tests.cpp @@ -10,6 +10,8 @@ #include +using node::BlockManager; + BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup) //! Test utilities for detecting when we need to flush the coins cache based diff --git a/src/validation.cpp b/src/validation.cpp index 30ef488288c5..bc9b2acbbf10 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -68,6 +68,26 @@ #include #include +using node::BlockManager; +using node::BlockMap; +using node::CBlockIndexHeightOnlyComparator; +using node::CBlockIndexWorkComparator; +using node::CCoinsStats; +using node::CoinStatsHashType; +using node::DEFAULT_ADDRESSINDEX; +using node::DEFAULT_SPENTINDEX; +using node::DEFAULT_TIMESTAMPINDEX; +using node::fAddressIndex; +using node::fImporting; +using node::fPruneMode; +using node::fReindex; +using node::fSpentIndex; +using node::fTimestampIndex; +using node::ReadBlockFromDisk; +using node::SnapshotMetadata; +using node::UndoReadFromDisk; +using node::UnlinkPrunedFiles; + #define MICRO 0.000001 #define MILLI 0.001 diff --git a/src/validation.h b/src/validation.h index 7e931955c2cb..3c3815357678 100644 --- a/src/validation.h +++ b/src/validation.h @@ -51,12 +51,13 @@ class TxValidationState; class CChainstateHelper; class ChainstateManager; struct PrecomputedTransactionData; -class SnapshotMetadata; struct ChainTxData; struct DisconnectedBlockTransactions; struct LockPoints; struct AssumeutxoData; - +namespace node { +class SnapshotMetadata; +} // namespace node namespace llmq { class CChainLocksHandler; } // namespace llmq @@ -487,7 +488,7 @@ class CChainState public: //! Reference to a BlockManager instance which itself is shared across all //! CChainState instances. - BlockManager& m_blockman; + node::BlockManager& m_blockman; /** Chain parameters for this chainstate */ const CChainParams& m_params; @@ -498,7 +499,7 @@ class CChainState ChainstateManager& m_chainman; explicit CChainState(CTxMemPool* mempool, - BlockManager& blockman, + node::BlockManager& blockman, ChainstateManager& chainman, CEvoDB& evoDb, const std::unique_ptr& chain_helper, @@ -549,7 +550,7 @@ class CChainState * chainstates) 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. */ - std::set setBlockIndexCandidates; + std::set setBlockIndexCandidates; CChainstateHelper& ChainHelper() { @@ -872,7 +873,7 @@ class ChainstateManager [[nodiscard]] bool PopulateAndValidateSnapshot( CChainState& snapshot_chainstate, CAutoFile& coins_file, - const SnapshotMetadata& metadata); + const node::SnapshotMetadata& metadata); /** * If a block header hasn't already been seen, call CheckBlockHeader on it, ensure @@ -889,7 +890,7 @@ class ChainstateManager std::thread m_load_block; //! A single BlockManager instance is shared across each constructed //! chainstate to avoid duplicating block metadata. - BlockManager m_blockman; + node::BlockManager m_blockman; /** * In order to efficiently track invalidity of headers, we keep the set of @@ -953,7 +954,7 @@ class ChainstateManager //! - Move the new chainstate to `m_snapshot_chainstate` and make it our //! ChainstateActive(). [[nodiscard]] bool ActivateSnapshot( - CAutoFile& coins_file, const SnapshotMetadata& metadata, bool in_memory); + CAutoFile& coins_file, const node::SnapshotMetadata& metadata, bool in_memory); //! The most-work chain. CChainState& ActiveChainstate() const; @@ -961,13 +962,13 @@ class ChainstateManager int ActiveHeight() const { return ActiveChain().Height(); } CBlockIndex* ActiveTip() const { return ActiveChain().Tip(); } - BlockMap& BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) + node::BlockMap& BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { AssertLockHeld(::cs_main); return m_blockman.m_block_index; } - PrevBlockMap& PrevBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) + node::PrevBlockMap& PrevBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return m_blockman.m_prev_block_index; } diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index d09e8742be70..558b7826ce81 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -35,6 +35,9 @@ #include #include +using node::MAX_BLOCKFILE_SIZE; +using node::UnlinkPrunedFiles; + RPCHelpMan importmulti(); RPCHelpMan dumpwallet(); RPCHelpMan importwallet(); diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index bd02ae01dd80..11a5344506c0 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -27,6 +27,8 @@ #include #include +using node::ReadBlockFromDisk; + static std::multimap mapPublishNotifiers; static const char *MSG_HASHBLOCK = "hashblock"; From 1c2d5292af65e622ce880dd1f5e50a55554ee763 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 21 Jun 2025 14:36:12 +0000 Subject: [PATCH 6/7] refactor: add `src/wallet/*` code to `wallet::` namespace This commit will not compile on its own, the commit after adjusts the rest of the codebase around this commit and should be compilable. Some files have been excluded as they're not a good fit for the namespace (particularly BIP39-specific code). --- src/wallet/bdb.cpp | 2 ++ src/wallet/bdb.h | 2 ++ src/wallet/coincontrol.cpp | 2 ++ src/wallet/coincontrol.h | 2 ++ src/wallet/coinjoin.cpp | 2 ++ src/wallet/coinjoin.h | 10 +++--- src/wallet/coinselection.cpp | 2 ++ src/wallet/coinselection.h | 2 ++ src/wallet/context.cpp | 2 ++ src/wallet/context.h | 5 ++- src/wallet/crypter.cpp | 2 ++ src/wallet/crypter.h | 3 +- src/wallet/db.cpp | 2 ++ src/wallet/db.h | 2 ++ src/wallet/dump.cpp | 2 ++ src/wallet/dump.h | 6 ++-- src/wallet/fees.cpp | 3 +- src/wallet/fees.h | 7 ++-- src/wallet/hdchain.cpp | 2 ++ src/wallet/hdchain.h | 2 ++ src/wallet/init.cpp | 6 ++-- src/wallet/interfaces.cpp | 2 +- src/wallet/ismine.h | 5 ++- src/wallet/load.cpp | 2 ++ src/wallet/load.h | 5 ++- src/wallet/receive.cpp | 2 ++ src/wallet/receive.h | 2 ++ src/wallet/rpc/addresses.cpp | 3 +- src/wallet/rpc/backup.cpp | 2 ++ src/wallet/rpc/coins.cpp | 2 ++ src/wallet/rpc/encrypt.cpp | 2 ++ src/wallet/rpc/signmessage.cpp | 2 ++ src/wallet/rpc/spend.cpp | 2 ++ src/wallet/rpc/transactions.cpp | 2 ++ src/wallet/rpc/util.cpp | 2 ++ src/wallet/rpc/util.h | 9 +++-- src/wallet/rpc/wallet.cpp | 2 ++ src/wallet/rpc/wallet.h | 2 ++ src/wallet/salvage.cpp | 2 ++ src/wallet/salvage.h | 2 ++ src/wallet/scriptpubkeyman.cpp | 2 ++ src/wallet/scriptpubkeyman.h | 2 ++ src/wallet/spend.cpp | 2 ++ src/wallet/spend.h | 2 ++ src/wallet/sqlite.cpp | 2 ++ src/wallet/sqlite.h | 3 ++ src/wallet/test/bip39_tests.cpp | 2 ++ src/wallet/test/coinjoin_tests.cpp | 2 ++ src/wallet/test/coinselector_tests.cpp | 2 ++ src/wallet/test/db_tests.cpp | 2 ++ src/wallet/test/fuzz/notifications.cpp | 2 ++ src/wallet/test/init_test_fixture.cpp | 2 ++ src/wallet/test/init_test_fixture.h | 3 +- src/wallet/test/init_tests.cpp | 2 ++ src/wallet/test/ismine_tests.cpp | 2 ++ src/wallet/test/psbt_wallet_tests.cpp | 2 ++ src/wallet/test/scriptpubkeyman_tests.cpp | 2 ++ src/wallet/test/spend_tests.cpp | 2 ++ src/wallet/test/util.cpp | 2 ++ src/wallet/test/util.h | 5 ++- src/wallet/test/wallet_crypto_tests.cpp | 2 ++ src/wallet/test/wallet_test_fixture.cpp | 2 ++ src/wallet/test/wallet_test_fixture.h | 2 ++ src/wallet/test/wallet_tests.cpp | 6 ++-- src/wallet/test/wallet_transaction_tests.cpp | 2 ++ src/wallet/test/walletdb_tests.cpp | 2 ++ src/wallet/transaction.cpp | 2 ++ src/wallet/transaction.h | 2 ++ src/wallet/wallet.cpp | 2 ++ src/wallet/wallet.h | 15 +++++---- src/wallet/walletdb.cpp | 2 ++ src/wallet/walletdb.h | 35 ++++++++++---------- src/wallet/wallettool.cpp | 2 ++ src/wallet/wallettool.h | 2 ++ src/wallet/walletutil.cpp | 2 ++ src/wallet/walletutil.h | 2 ++ 76 files changed, 200 insertions(+), 47 deletions(-) diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 877a28e86f0a..c89c3f1ad9d6 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -24,6 +24,7 @@ #endif #endif +namespace wallet { namespace { Span SpanFromDbt(const BerkeleyBatch::SafeDbt& dbt) { @@ -861,3 +862,4 @@ std::unique_ptr MakeBerkeleyDatabase(const fs::path& path, con status = DatabaseStatus::SUCCESS; return db; } +} // namespace wallet diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index d1566410aed5..8a4feb696bc8 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -30,6 +30,7 @@ struct bilingual_str; #pragma GCC diagnostic pop #endif +namespace wallet { struct WalletDatabaseFileId { uint8_t value[DB_FILE_ID_LEN]; bool operator==(const WalletDatabaseFileId& rhs) const; @@ -230,5 +231,6 @@ bool BerkeleyDatabaseSanityCheck(); //! Return object giving access to Berkeley database at specified path. std::unique_ptr MakeBerkeleyDatabase(const fs::path& path, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error); +} // namespace wallet #endif // BITCOIN_WALLET_BDB_H diff --git a/src/wallet/coincontrol.cpp b/src/wallet/coincontrol.cpp index 97fcb8b6b355..57c7f0a4459c 100644 --- a/src/wallet/coincontrol.cpp +++ b/src/wallet/coincontrol.cpp @@ -6,8 +6,10 @@ #include +namespace wallet { CCoinControl::CCoinControl(CoinType coinType) : nCoinType(coinType) { m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS); } +} // namespace wallet diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index 1379366283e4..851c37838278 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -13,6 +13,7 @@ #include +namespace wallet { enum class CoinType : uint8_t { ALL_COINS, @@ -116,5 +117,6 @@ class CCoinControl private: std::set setSelected; }; +} // namespace wallet #endif // BITCOIN_WALLET_COINCONTROL_H diff --git a/src/wallet/coinjoin.cpp b/src/wallet/coinjoin.cpp index 0c641abde0f5..5900d416c00d 100644 --- a/src/wallet/coinjoin.cpp +++ b/src/wallet/coinjoin.cpp @@ -14,6 +14,7 @@ #include #include +namespace wallet { void CWallet::InitCJSaltFromDb() { assert(nCoinJoinSalt.IsNull()); @@ -573,3 +574,4 @@ CoinJoinCredits CachedTxGetAvailableCoinJoinCredits(const CWallet& wallet, const } return ret; } +} // namespace wallet diff --git a/src/wallet/coinjoin.h b/src/wallet/coinjoin.h index ae2f785d6eae..44512b4ca57e 100644 --- a/src/wallet/coinjoin.h +++ b/src/wallet/coinjoin.h @@ -10,10 +10,6 @@ #include #include -class CCoinControl; -class CWallet; -class CWalletTx; - // Use a macro instead of a function for conditional logging to prevent // evaluating arguments when logging for the category is not enabled. #define WalletCJLogPrint(wallet, ...) \ @@ -23,6 +19,11 @@ class CWalletTx; } \ } while (0) +namespace wallet { +class CCoinControl; +class CWallet; +class CWalletTx; + CAmount GetBalanceAnonymized(const CWallet& wallet, const CCoinControl& coinControl); CAmount CachedTxGetAnonymizedCredit(const CWallet& wallet, const CWalletTx& wtx, const CCoinControl& coinControl) @@ -37,5 +38,6 @@ struct CoinJoinCredits CoinJoinCredits CachedTxGetAvailableCoinJoinCredits(const CWallet& wallet, const CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); +} // namespace wallet #endif // BITCOIN_WALLET_COINJOIN_H diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 7d66d9dfa892..0f6588c1f06f 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -14,6 +14,7 @@ #include #include +namespace wallet { // Descending order comparator struct { bool operator()(const OutputGroup& a, const OutputGroup& b) const @@ -544,3 +545,4 @@ std::string GetAlgorithmName(const SelectionAlgorithm algo) } assert(false); } +} // namespace wallet diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index c5fc194d1657..3afbcb64955d 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -12,6 +12,7 @@ #include +namespace wallet { //! lower bound for randomly-chosen target change amount static constexpr CAmount CHANGE_LOWER{50000}; //! upper bound for randomly-chosen target change amount @@ -299,5 +300,6 @@ std::optional SelectCoinsSRD(const std::vector& ut // Original coin selection algorithm as a fallback std::optional KnapsackSolver(std::vector& groups, const CAmount& nTargetValue, CAmount change_target, FastRandomContext& rng, bool fFullyMixedOnly, CAmount maxTxFee); +} // namespace wallet #endif // BITCOIN_WALLET_COINSELECTION_H diff --git a/src/wallet/context.cpp b/src/wallet/context.cpp index 09b2f3046709..800aa5bf9c46 100644 --- a/src/wallet/context.cpp +++ b/src/wallet/context.cpp @@ -4,5 +4,7 @@ #include +namespace wallet { WalletContext::WalletContext() {} WalletContext::~WalletContext() {} +} // namespace wallet diff --git a/src/wallet/context.h b/src/wallet/context.h index b70d65d7a328..269b24e82cda 100644 --- a/src/wallet/context.h +++ b/src/wallet/context.h @@ -13,7 +13,6 @@ #include class ArgsManager; -class CWallet; namespace interfaces { class Chain; namespace CoinJoin { @@ -25,6 +24,9 @@ namespace node { struct NodeContext; } // namespace node +namespace wallet { +class CWallet; + using LoadWalletFn = std::function wallet)>; //! WalletContext struct containing references to state shared between CWallet @@ -59,5 +61,6 @@ struct WalletContext { WalletContext(); ~WalletContext(); }; +} // namespace wallet #endif // BITCOIN_WALLET_CONTEXT_H diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index d4dc17aaf2a0..4918944af24f 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -10,6 +10,7 @@ #include +namespace wallet { int CCrypter::BytesToKeySHA512AES(const std::vector& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const { // This mimics the behavior of openssl's EVP_BytesToKey with an aes256cbc @@ -181,3 +182,4 @@ bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector #include