diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -184,7 +184,7 @@ /// locked. Be sure that anything that writes files or flushes caches only /// does this if the respective module was initialized. RenameThread("bitcoin-shutoff"); - mempool.AddTransactionsUpdated(1); + g_mempool.AddTransactionsUpdated(1); StopHTTPRPC(); StopREST(); @@ -215,7 +215,7 @@ CAutoFile est_fileout(fsbridge::fopen(est_path, "wb"), SER_DISK, CLIENT_VERSION); if (!est_fileout.IsNull()) { - mempool.WriteFeeEstimates(est_fileout); + g_mempool.WriteFeeEstimates(est_fileout); } else { LogPrintf("%s: Failed to write fee estimates to %s\n", __func__, est_path.string()); @@ -1474,7 +1474,7 @@ 0), 1000000); if (ratio != 0) { - mempool.setSanityCheck(1.0 / ratio); + g_mempool.setSanityCheck(1.0 / ratio); } fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks()); @@ -2194,7 +2194,7 @@ CLIENT_VERSION); // Allowed to fail as this file IS missing on first startup. if (!est_filein.IsNull()) { - mempool.ReadFeeEstimates(est_filein); + g_mempool.ReadFeeEstimates(est_filein); } fFeeEstimatesInitialized = true; diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -141,7 +141,7 @@ // Add dummy coinbase tx as first transaction. It is updated at the end. pblocktemplate->entries.emplace_back(CTransactionRef(), -SATOSHI, -1); - LOCK2(cs_main, mempool.cs); + LOCK2(cs_main, g_mempool.cs); CBlockIndex *pindexPrev = chainActive.Tip(); nHeight = pindexPrev->nHeight + 1; @@ -245,7 +245,7 @@ } bool BlockAssembler::isStillDependent(CTxMemPool::txiter iter) { - for (CTxMemPool::txiter parent : mempool.GetMemPoolParents(iter)) { + for (CTxMemPool::txiter parent : g_mempool.GetMemPoolParents(iter)) { if (!inBlock.count(parent)) { return true; } @@ -363,7 +363,7 @@ if (fPrintPriority) { double dPriority = iter->GetPriority(nHeight); Amount dummy; - mempool.ApplyDeltas(iter->GetTx().GetId(), dPriority, dummy); + g_mempool.ApplyDeltas(iter->GetTx().GetId(), dPriority, dummy); LogPrintf( "priority %.1f fee %s txid %s\n", dPriority, CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(), @@ -377,7 +377,7 @@ int nDescendantsUpdated = 0; for (const CTxMemPool::txiter it : alreadyAdded) { CTxMemPool::setEntries descendants; - mempool.CalculateDescendants(it, descendants); + g_mempool.CalculateDescendants(it, descendants); // Insert all descendants (not yet in block) into the modified set. for (CTxMemPool::txiter desc : descendants) { if (alreadyAdded.count(desc)) { @@ -413,7 +413,7 @@ bool BlockAssembler::SkipMapTxEntry( CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx) { - assert(it != mempool.mapTx.end()); + assert(it != g_mempool.mapTx.end()); return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it); } @@ -461,7 +461,7 @@ UpdatePackagesForAdded(inBlock, mapModifiedTx); CTxMemPool::indexed_transaction_set::index::type::iterator - mi = mempool.mapTx.get().begin(); + mi = g_mempool.mapTx.get().begin(); CTxMemPool::txiter iter; // Limit the number of attempts to add transactions to the block when it is @@ -470,11 +470,11 @@ const int64_t MAX_CONSECUTIVE_FAILURES = 1000; int64_t nConsecutiveFailed = 0; - while (mi != mempool.mapTx.get().end() || + while (mi != g_mempool.mapTx.get().end() || !mapModifiedTx.empty()) { // First try to find a new transaction in mapTx to evaluate. - if (mi != mempool.mapTx.get().end() && - SkipMapTxEntry(mempool.mapTx.project<0>(mi), mapModifiedTx, + if (mi != g_mempool.mapTx.get().end() && + SkipMapTxEntry(g_mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) { ++mi; continue; @@ -485,13 +485,13 @@ bool fUsingModified = false; modtxscoreiter modit = mapModifiedTx.get().begin(); - if (mi == mempool.mapTx.get().end()) { + if (mi == g_mempool.mapTx.get().end()) { // We're out of entries in mapTx; use the entry from mapModifiedTx iter = modit->iter; fUsingModified = true; } else { // Try to compare the mapTx entry to the mapModifiedTx entry. - iter = mempool.mapTx.project<0>(mi); + iter = g_mempool.mapTx.project<0>(mi); if (modit != mapModifiedTx.get().end() && CompareModifiedEntry()(*modit, CTxMemPoolModifiedEntry(iter))) { // The best entry in mapModifiedTx has higher score than the one @@ -547,8 +547,9 @@ CTxMemPool::setEntries ancestors; uint64_t nNoLimit = std::numeric_limits::max(); std::string dummy; - mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, nNoLimit, - nNoLimit, nNoLimit, dummy, false); + g_mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, + nNoLimit, nNoLimit, nNoLimit, dummy, + false); onlyUnconfirmed(ancestors); ancestors.insert(iter); @@ -601,13 +602,13 @@ CTxMemPool::CompareIteratorByHash>::iterator waitPriIter; double actualPriority = -1; - vecPriority.reserve(mempool.mapTx.size()); + vecPriority.reserve(g_mempool.mapTx.size()); for (CTxMemPool::indexed_transaction_set::iterator mi = - mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) { + g_mempool.mapTx.begin(); + mi != g_mempool.mapTx.end(); ++mi) { double dPriority = mi->GetPriority(nHeight); Amount dummy; - mempool.ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); + g_mempool.ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); vecPriority.push_back(TxCoinAgePriority(dPriority, mi)); } std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer); @@ -663,7 +664,7 @@ // This tx was successfully added, so add transactions that depend // on this one to the priority queue to try again. - for (CTxMemPool::txiter child : mempool.GetMemPoolChildren(iter)) { + for (CTxMemPool::txiter child : g_mempool.GetMemPoolChildren(iter)) { waitPriIter wpiter = waitPriMap.find(child); if (wpiter == waitPriMap.end()) { continue; diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -395,7 +395,8 @@ state->vBlocksInFlight.end(), {hash, pindex, pindex != nullptr, std::unique_ptr( - pit ? new PartiallyDownloadedBlock(config, &mempool) : nullptr)}); + pit ? new PartiallyDownloadedBlock(config, &g_mempool) + : nullptr)}); state->nBlocksInFlight++; state->nBlocksInFlightValidHeaders += it->fValidatedHeaders; if (state->nBlocksInFlight == 1) { @@ -1144,7 +1145,7 @@ // output 0 and 1. This works well enough in practice and we get // diminishing returns with 2 onward. return recentRejects->contains(inv.hash) || - mempool.exists(inv.hash) || + g_mempool.exists(inv.hash) || mapOrphanTransactions.count(inv.hash) || pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 0)) || pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1)); @@ -1395,7 +1396,7 @@ msgMaker.Make(nSendFlags, NetMsgType::TX, *mi->second)); push = true; } else if (pfrom->timeLastMempoolReq) { - auto txinfo = mempool.info(inv.hash); + auto txinfo = g_mempool.info(inv.hash); // To protect privacy, do not answer getdata using the // mempool when that TX couldn't have been INVed in reply to // a MEMPOOL request. @@ -2412,9 +2413,10 @@ pfrom->setAskFor.erase(inv.hash); mapAlreadyAskedFor.erase(inv.hash); - if (!AlreadyHave(inv) && AcceptToMemoryPool(config, mempool, state, ptx, - true, &fMissingInputs)) { - mempool.check(pcoinsTip.get()); + if (!AlreadyHave(inv) && + AcceptToMemoryPool(config, g_mempool, state, ptx, true, + &fMissingInputs)) { + g_mempool.check(pcoinsTip.get()); RelayTransaction(tx, connman); for (size_t i = 0; i < tx.vout.size(); i++) { vWorkQueue.emplace_back(inv.hash, i); @@ -2424,8 +2426,8 @@ LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s " "(poolsz %u txn, %u kB)\n", - pfrom->GetId(), tx.GetId().ToString(), mempool.size(), - mempool.DynamicMemoryUsage() / 1000); + pfrom->GetId(), tx.GetId().ToString(), g_mempool.size(), + g_mempool.DynamicMemoryUsage() / 1000); // Recursively process any orphan transactions that depended on this // one @@ -2453,7 +2455,7 @@ if (setMisbehaving.count(fromPeer)) { continue; } - if (AcceptToMemoryPool(config, mempool, stateDummy, + if (AcceptToMemoryPool(config, g_mempool, stateDummy, porphanTx, true, &fMissingInputs2)) { LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanId.ToString()); @@ -2487,7 +2489,7 @@ recentRejects->insert(orphanId); } } - mempool.check(pcoinsTip.get()); + g_mempool.check(pcoinsTip.get()); } } @@ -2724,7 +2726,7 @@ (*queuedBlockIt) ->partialBlock.reset( new PartiallyDownloadedBlock(config, - &mempool)); + &g_mempool)); } else { // The block was already in flight using compact // blocks from the same peer. @@ -2778,7 +2780,7 @@ // peer, or this peer has too many blocks outstanding to // download from. Optimistically try to reconstruct anyway // since we might be able to without any round trips. - PartiallyDownloadedBlock tempBlock(config, &mempool); + PartiallyDownloadedBlock tempBlock(config, &g_mempool); ReadStatus status = tempBlock.InitData(cmpctblock, vExtraTxnForCompact); if (status != READ_STATUS_OK) { @@ -3948,7 +3950,7 @@ // Respond to BIP35 mempool requests if (fSendTrickle && pto->fSendMempool) { - auto vtxinfo = mempool.infoAll(); + auto vtxinfo = g_mempool.infoAll(); pto->fSendMempool = false; Amount filterrate = Amount::zero(); { @@ -3999,7 +4001,7 @@ // Topologically and fee-rate sort the inventory we send for privacy // and priority reasons. A heap is used so that not all items need // sorting if only a few are being sent. - CompareInvMempoolOrder compareInvMempoolOrder(&mempool); + CompareInvMempoolOrder compareInvMempoolOrder(&g_mempool); std::make_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); // No reason to drain out at many times the network's capacity, @@ -4024,7 +4026,7 @@ continue; } // Not in the mempool anymore? don't bother sending it. - auto txinfo = mempool.info(hash); + auto txinfo = g_mempool.info(hash); if (!txinfo.tx) { continue; } @@ -4211,7 +4213,7 @@ gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY))) { Amount currentFilter = - mempool + g_mempool .GetMinFee( gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -97,11 +97,11 @@ } long ClientModel::getMempoolSize() const { - return mempool.size(); + return g_mempool.size(); } size_t ClientModel::getMempoolDynamicUsage() const { - return mempool.DynamicMemoryUsage(); + return g_mempool.DynamicMemoryUsage(); } double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const { diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -545,7 +545,7 @@ } // Fee - nPayFee = GetMinimumFee(nBytes, nTxConfirmTarget, mempool); + nPayFee = GetMinimumFee(nBytes, nTxConfirmTarget, g_mempool); if (nPayFee > Amount::zero() && coinControl->nMinimumTotalFee > nPayFee) { nPayFee = coinControl->nMinimumTotalFee; @@ -639,7 +639,7 @@ "than the current dust threshold."); // how many satoshis the estimated fee can vary per byte we guess wrong - double dFeeVary = GetMinimumFee(1000, 2, mempool) / (1000 * SATOSHI); + double dFeeVary = GetMinimumFee(1000, 2, g_mempool) / (1000 * SATOSHI); QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -222,7 +222,7 @@ connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, SLOT(coinControlUpdateLabels())); - ui->customFee->setSingleStep(GetMinimumFee(1000, 2, mempool)); + ui->customFee->setSingleStep(GetMinimumFee(1000, 2, g_mempool)); updateFeeSectionControls(); updateMinFeeLabel(); updateSmartFeeLabel(); @@ -665,7 +665,7 @@ void SendCoinsDialog::setMinimumFee() { ui->radioCustomPerKilobyte->setChecked(true); - ui->customFee->setValue(GetMinimumFee(1000, 2, mempool)); + ui->customFee->setValue(GetMinimumFee(1000, 2, g_mempool)); } void SendCoinsDialog::updateFeeSectionControls() { @@ -738,7 +738,7 @@ tr("Pay only the required fee of %1") .arg(BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), - GetMinimumFee(1000, 2, mempool)) + + GetMinimumFee(1000, 2, g_mempool)) + "/kB")); } @@ -749,14 +749,14 @@ ui->sliderSmartFee->maximum() - ui->sliderSmartFee->value() + 2; int estimateFoundAtBlocks = nBlocksToConfirm; CFeeRate feeRate = - mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks); + g_mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks); // not enough data => minfee if (feeRate <= CFeeRate(Amount::zero())) { ui->labelSmartFee->setText( BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), std::max(CWallet::fallbackFee.GetFeePerK(), - GetMinimumFee(1000, 2, mempool))) + + GetMinimumFee(1000, 2, g_mempool))) + "/kB"); // (Smart fee not initialized yet. This usually takes a few blocks...) ui->labelSmartFee2->show(); @@ -766,7 +766,7 @@ BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), std::max(feeRate.GetFeePerK(), - GetMinimumFee(1000, 2, mempool))) + + GetMinimumFee(1000, 2, g_mempool))) + "/kB"); ui->labelSmartFee2->hide(); ui->labelFeeEstimation->setText( diff --git a/src/rest.cpp b/src/rest.cpp --- a/src/rest.cpp +++ b/src/rest.cpp @@ -563,13 +563,13 @@ std::vector hits; bitmap.resize((vOutPoints.size() + 7) / 8); { - LOCK2(cs_main, mempool.cs); + LOCK2(cs_main, g_mempool.cs); CCoinsView viewDummy; CCoinsViewCache view(&viewDummy); CCoinsViewCache &viewChain = *pcoinsTip; - CCoinsViewMemPool viewMempool(&viewChain, mempool); + CCoinsViewMemPool viewMempool(&viewChain, g_mempool); if (fCheckMemPool) { // switch cache backend to db+mempool in case user likes to query @@ -581,7 +581,7 @@ Coin coin; bool hit = false; if (view.GetCoin(vOutPoints[i], coin) && - !mempool.isSpent(vOutPoints[i])) { + !g_mempool.isSpent(vOutPoints[i])) { hit = true; outs.emplace_back(std::move(coin)); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -414,7 +414,7 @@ } void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) { - AssertLockHeld(mempool.cs); + AssertLockHeld(g_mempool.cs); info.pushKV("size", (int)e.GetTxSize()); info.pushKV("fee", ValueFromAmount(e.GetFee())); @@ -432,7 +432,7 @@ const CTransaction &tx = e.GetTx(); std::set setDepends; for (const CTxIn &txin : tx.vin) { - if (mempool.exists(txin.prevout.GetTxId())) { + if (g_mempool.exists(txin.prevout.GetTxId())) { setDepends.insert(txin.prevout.GetTxId().ToString()); } } @@ -447,9 +447,9 @@ UniValue mempoolToJSON(bool fVerbose = false) { if (fVerbose) { - LOCK(mempool.cs); + LOCK(g_mempool.cs); UniValue o(UniValue::VOBJ); - for (const CTxMemPoolEntry &e : mempool.mapTx) { + for (const CTxMemPoolEntry &e : g_mempool.mapTx) { const uint256 &txid = e.GetTx().GetId(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); @@ -458,7 +458,7 @@ return o; } else { std::vector vtxids; - mempool.queryHashes(vtxids); + g_mempool.queryHashes(vtxids); UniValue a(UniValue::VARR); for (const uint256 &txid : vtxids) { @@ -536,10 +536,10 @@ uint256 hash = ParseHashV(request.params[0], "parameter 1"); - LOCK(mempool.cs); + LOCK(g_mempool.cs); - CTxMemPool::txiter it = mempool.mapTx.find(hash); - if (it == mempool.mapTx.end()) { + CTxMemPool::txiter it = g_mempool.mapTx.find(hash); + if (it == g_mempool.mapTx.end()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); } @@ -547,8 +547,8 @@ CTxMemPool::setEntries setAncestors; uint64_t noLimit = std::numeric_limits::max(); std::string dummy; - mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, - noLimit, noLimit, dummy, false); + g_mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, + noLimit, noLimit, dummy, false); if (!fVerbose) { UniValue o(UniValue::VARR); @@ -603,16 +603,16 @@ uint256 hash = ParseHashV(request.params[0], "parameter 1"); - LOCK(mempool.cs); + LOCK(g_mempool.cs); - CTxMemPool::txiter it = mempool.mapTx.find(hash); - if (it == mempool.mapTx.end()) { + CTxMemPool::txiter it = g_mempool.mapTx.find(hash); + if (it == g_mempool.mapTx.end()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); } CTxMemPool::setEntries setDescendants; - mempool.CalculateDescendants(it, setDescendants); + g_mempool.CalculateDescendants(it, setDescendants); // CTxMemPool::CalculateDescendants will include the given tx setDescendants.erase(it); @@ -654,10 +654,10 @@ uint256 hash = ParseHashV(request.params[0], "parameter 1"); - LOCK(mempool.cs); + LOCK(g_mempool.cs); - CTxMemPool::txiter it = mempool.mapTx.find(hash); - if (it == mempool.mapTx.end()) { + CTxMemPool::txiter it = g_mempool.mapTx.find(hash); + if (it == g_mempool.mapTx.end()) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); } @@ -1120,9 +1120,9 @@ Coin coin; if (fMempool) { - LOCK(mempool.cs); - CCoinsViewMemPool view(pcoinsTip.get(), mempool); - if (!view.GetCoin(out, coin) || mempool.isSpent(out)) { + LOCK(g_mempool.cs); + CCoinsViewMemPool view(pcoinsTip.get(), g_mempool); + if (!view.GetCoin(out, coin) || g_mempool.isSpent(out)) { // TODO: this should be done by the CCoinsViewMemPool return NullUniValue; } @@ -1435,14 +1435,14 @@ UniValue mempoolInfoToJSON() { UniValue ret(UniValue::VOBJ); - ret.pushKV("size", (int64_t)mempool.size()); - ret.pushKV("bytes", (int64_t)mempool.GetTotalTxSize()); - ret.pushKV("usage", (int64_t)mempool.DynamicMemoryUsage()); + ret.pushKV("size", (int64_t)g_mempool.size()); + ret.pushKV("bytes", (int64_t)g_mempool.GetTotalTxSize()); + ret.pushKV("usage", (int64_t)g_mempool.DynamicMemoryUsage()); size_t maxmempool = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; ret.pushKV("maxmempool", (int64_t)maxmempool); ret.pushKV("mempoolminfee", - ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK())); + ValueFromAmount(g_mempool.GetMinFee(maxmempool).GetFeePerK())); return ret; } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -257,7 +257,7 @@ DEFAULT_BLOCK_PRIORITY_PERCENTAGE))); obj.pushKV("errors", GetWarnings("statusbar")); obj.pushKV("networkhashps", getnetworkhashps(config, request)); - obj.pushKV("pooledtx", uint64_t(mempool.size())); + obj.pushKV("pooledtx", uint64_t(g_mempool.size())); obj.pushKV("chain", config.GetChainParams().NetworkIDString()); return obj; } @@ -297,8 +297,8 @@ uint256 hash = ParseHashStr(request.params[0].get_str(), "txid"); Amount nAmount = request.params[2].get_int64() * SATOSHI; - mempool.PrioritiseTransaction(hash, request.params[0].get_str(), - request.params[1].get_real(), nAmount); + g_mempool.PrioritiseTransaction(hash, request.params[0].get_str(), + request.params[1].get_real(), nAmount); return true; } @@ -550,7 +550,7 @@ if (g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout) { // Timeout: Check transactions for update - if (mempool.GetTransactionsUpdated() != + if (g_mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP) { break; } @@ -572,14 +572,14 @@ static int64_t nStart; static std::unique_ptr pblocktemplate; if (pindexPrev != chainActive.Tip() || - (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && + (g_mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { // Clear pindexPrev so future calls make a new block, despite any // failures from here on pindexPrev = nullptr; // Store the pindexBest used before CreateNewBlock, to avoid races - nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); + nTransactionsUpdatedLast = g_mempool.GetTransactionsUpdated(); CBlockIndex *pindexPrevNew = chainActive.Tip(); nStart = GetTime(); @@ -802,7 +802,7 @@ nBlocks = 1; } - CFeeRate feeRate = mempool.estimateFee(nBlocks); + CFeeRate feeRate = g_mempool.estimateFee(nBlocks); if (feeRate == CFeeRate(Amount::zero())) { return -1.0; } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -774,9 +774,9 @@ CCoinsViewCache view(&viewDummy); { LOCK(cs_main); - LOCK(mempool.cs); + LOCK(g_mempool.cs); CCoinsViewCache &viewChain = *pcoinsTip; - CCoinsViewMemPool viewMempool(&viewChain, mempool); + CCoinsViewMemPool viewMempool(&viewChain, g_mempool); // temporarily switch cache backend to db+mempool view view.SetBackend(viewMempool); @@ -939,9 +939,9 @@ CCoinsView viewDummy; CCoinsViewCache view(&viewDummy); { - LOCK(mempool.cs); + LOCK(g_mempool.cs); CCoinsViewCache &viewChain = *pcoinsTip; - CCoinsViewMemPool viewMempool(&viewChain, mempool); + CCoinsViewMemPool viewMempool(&viewChain, g_mempool); // Temporarily switch cache backend to db+mempool view. view.SetBackend(viewMempool); @@ -1219,12 +1219,12 @@ fHaveChain = !existingCoin.IsSpent(); } - bool fHaveMempool = mempool.exists(txid); + bool fHaveMempool = g_mempool.exists(txid); if (!fHaveMempool && !fHaveChain) { // Push to local node and sync with wallets. CValidationState state; bool fMissingInputs; - if (!AcceptToMemoryPool(config, mempool, state, std::move(tx), + if (!AcceptToMemoryPool(config, g_mempool, state, std::move(tx), fLimitFree, &fMissingInputs, false, nMaxRawTxFee)) { if (state.IsInvalid()) { diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -73,7 +73,7 @@ } bool TestSequenceLocks(const CTransaction &tx, int flags) { - LOCK(mempool.cs); + LOCK(g_mempool.cs); return CheckSequenceLocks(tx, flags); } @@ -100,32 +100,32 @@ // This tx has a low fee: 1000 satoshis. // Save this txid for later use. TxId parentTxId = tx.GetId(); - mempool.addUnchecked(parentTxId, - entry.Fee(1000 * SATOSHI) - .Time(GetTime()) - .SpendsCoinbase(true) - .FromTx(tx)); + g_mempool.addUnchecked(parentTxId, + entry.Fee(1000 * SATOSHI) + .Time(GetTime()) + .SpendsCoinbase(true) + .FromTx(tx)); // This tx has a medium fee: 10000 satoshis. tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0); tx.vout[0].nValue = int64_t(5000000000LL - 10000) * SATOSHI; TxId mediumFeeTxId = tx.GetId(); - mempool.addUnchecked(mediumFeeTxId, - entry.Fee(10000 * SATOSHI) - .Time(GetTime()) - .SpendsCoinbase(true) - .FromTx(tx)); + g_mempool.addUnchecked(mediumFeeTxId, + entry.Fee(10000 * SATOSHI) + .Time(GetTime()) + .SpendsCoinbase(true) + .FromTx(tx)); // This tx has a high fee, but depends on the first transaction. tx.vin[0].prevout = COutPoint(parentTxId, 0); // 50k satoshi fee. tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; TxId highFeeTxId = tx.GetId(); - mempool.addUnchecked(highFeeTxId, - entry.Fee(50000 * SATOSHI) - .Time(GetTime()) - .SpendsCoinbase(false) - .FromTx(tx)); + g_mempool.addUnchecked(highFeeTxId, + entry.Fee(50000 * SATOSHI) + .Time(GetTime()) + .SpendsCoinbase(false) + .FromTx(tx)); std::unique_ptr pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey); @@ -138,7 +138,7 @@ // 0 fee. tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI; TxId freeTxId = tx.GetId(); - mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx)); + g_mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx)); size_t freeTxSize = CTransaction(tx).GetBillableSize(); // Calculate a fee on child transaction that will put the package just @@ -149,7 +149,7 @@ tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI - feeToUse; TxId lowFeeTxId = tx.GetId(); - mempool.addUnchecked(lowFeeTxId, entry.Fee(feeToUse).FromTx(tx)); + g_mempool.addUnchecked(lowFeeTxId, entry.Fee(feeToUse).FromTx(tx)); pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey); // Verify that the free tx and the low fee tx didn't get selected. for (const auto &txn : pblocktemplate->block.vtx) { @@ -160,12 +160,12 @@ // Test that packages above the min relay fee do get included, even if one // of the transactions is below the min relay fee. Remove the low fee // transaction and replace with a higher fee transaction - mempool.removeRecursive(CTransaction(tx)); + g_mempool.removeRecursive(CTransaction(tx)); // Now we should be just over the min relay fee. tx.vout[0].nValue -= 2 * SATOSHI; lowFeeTxId = tx.GetId(); - mempool.addUnchecked(lowFeeTxId, - entry.Fee(feeToUse + 2 * SATOSHI).FromTx(tx)); + g_mempool.addUnchecked(lowFeeTxId, + entry.Fee(feeToUse + 2 * SATOSHI).FromTx(tx)); pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey); BOOST_CHECK(pblocktemplate->block.vtx[4]->GetId() == freeTxId); BOOST_CHECK(pblocktemplate->block.vtx[5]->GetId() == lowFeeTxId); @@ -179,7 +179,7 @@ // 1BCC output. tx.vout[1].nValue = 100000000 * SATOSHI; TxId freeTxId2 = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( freeTxId2, entry.Fee(Amount::zero()).SpendsCoinbase(true).FromTx(tx)); // This tx can't be mined by itself. @@ -188,8 +188,8 @@ feeToUse = blockMinFeeRate.GetFee(freeTxSize); tx.vout[0].nValue = int64_t(5000000000LL - 100000000) * SATOSHI - feeToUse; TxId lowFeeTxId2 = tx.GetId(); - mempool.addUnchecked(lowFeeTxId2, - entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); + g_mempool.addUnchecked( + lowFeeTxId2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey); // Verify that this tx isn't selected. @@ -203,7 +203,7 @@ tx.vin[0].prevout = COutPoint(freeTxId2, 1); // 10k satoshi fee. tx.vout[0].nValue = (100000000 - 10000) * SATOSHI; - mempool.addUnchecked(tx.GetId(), entry.Fee(10000 * SATOSHI).FromTx(tx)); + g_mempool.addUnchecked(tx.GetId(), entry.Fee(10000 * SATOSHI).FromTx(tx)); pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey); BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == lowFeeTxId2); } @@ -325,16 +325,16 @@ bool spendsCoinbase = (i == 0) ? true : false; // If we don't set the # of sig ops in the CTxMemPoolEntry, template // creation fails. - mempool.addUnchecked(hash, - entry.Fee(LOWFEE) - .Time(GetTime()) - .SpendsCoinbase(spendsCoinbase) - .FromTx(tx)); + g_mempool.addUnchecked(hash, + entry.Fee(LOWFEE) + .Time(GetTime()) + .SpendsCoinbase(spendsCoinbase) + .FromTx(tx)); tx.vin[0].prevout = COutPoint(hash, 0); } BOOST_CHECK_THROW(BlockAssembler(config).CreateNewBlock(scriptPubKey), std::runtime_error); - mempool.clear(); + g_mempool.clear(); tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); tx.vout[0].nValue = BLOCKSUBSIDY; @@ -345,17 +345,17 @@ bool spendsCoinbase = (i == 0) ? true : false; // If we do set the # of sig ops in the CTxMemPoolEntry, template // creation passes. - mempool.addUnchecked(hash, - entry.Fee(LOWFEE) - .Time(GetTime()) - .SpendsCoinbase(spendsCoinbase) - .SigOpsCost(80) - .FromTx(tx)); + g_mempool.addUnchecked(hash, + entry.Fee(LOWFEE) + .Time(GetTime()) + .SpendsCoinbase(spendsCoinbase) + .SigOpsCost(80) + .FromTx(tx)); tx.vin[0].prevout = COutPoint(hash, 0); } BOOST_CHECK(pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey)); - mempool.clear(); + g_mempool.clear(); // block size > limit tx.vin[0].scriptSig = CScript(); @@ -373,30 +373,30 @@ hash = tx.GetId(); // Only first tx spends coinbase. bool spendsCoinbase = (i == 0) ? true : false; - mempool.addUnchecked(hash, - entry.Fee(LOWFEE) - .Time(GetTime()) - .SpendsCoinbase(spendsCoinbase) - .FromTx(tx)); + g_mempool.addUnchecked(hash, + entry.Fee(LOWFEE) + .Time(GetTime()) + .SpendsCoinbase(spendsCoinbase) + .FromTx(tx)); tx.vin[0].prevout = COutPoint(hash, 0); } BOOST_CHECK(pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey)); - mempool.clear(); + g_mempool.clear(); // Orphan in mempool, template creation fails. hash = tx.GetId(); - mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx)); + g_mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx)); BOOST_CHECK_THROW(BlockAssembler(config).CreateNewBlock(scriptPubKey), std::runtime_error); - mempool.clear(); + g_mempool.clear(); // Child with higher priority than parent. tx.vin[0].scriptSig = CScript() << OP_1; tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0); tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vin[0].prevout = COutPoint(hash, 0); @@ -406,12 +406,12 @@ // First txn output + fresh coinbase - new txn fee. tx.vout[0].nValue = tx.vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); BOOST_CHECK(pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptPubKey)); - mempool.clear(); + g_mempool.clear(); // Coinbase in mempool, template creation fails. tx.vin.resize(1); @@ -420,12 +420,12 @@ tx.vout[0].nValue = Amount::zero(); hash = tx.GetId(); // Give it a fee so it'll get mined. - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); BOOST_CHECK_THROW(BlockAssembler(config).CreateNewBlock(scriptPubKey), std::runtime_error); - mempool.clear(); + g_mempool.clear(); // Invalid (pre-p2sh) txn in mempool, template creation fails. std::array times; @@ -444,7 +444,7 @@ script = CScript() << OP_0; tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script)); hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vin[0].prevout = COutPoint(hash, 0); @@ -452,12 +452,12 @@ << std::vector(script.begin(), script.end()); tx.vout[0].nValue -= LOWFEE; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); BOOST_CHECK_THROW(BlockAssembler(config).CreateNewBlock(scriptPubKey), std::runtime_error); - mempool.clear(); + g_mempool.clear(); for (int i = 0; i < CBlockIndex::nMedianTimeSpan; i++) { // Restore the MedianTimePast. chainActive.Tip()->GetAncestor(chainActive.Tip()->nHeight - i)->nTime = @@ -470,17 +470,17 @@ tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE; tx.vout[0].scriptPubKey = CScript() << OP_1; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vout[0].scriptPubKey = CScript() << OP_2; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); BOOST_CHECK_THROW(BlockAssembler(config).CreateNewBlock(scriptPubKey), std::runtime_error); - mempool.clear(); + g_mempool.clear(); // Subsidy changing. int nHeight = chainActive.Height(); @@ -540,7 +540,7 @@ tx.vout[0].scriptPubKey = CScript() << OP_1; tx.nLockTime = 0; hash = tx.GetId(); - mempool.addUnchecked( + g_mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -568,7 +568,7 @@ 1); prevheights[0] = baseheight + 2; hash = tx.GetId(); - mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); + g_mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { // Locktime passes. @@ -601,7 +601,7 @@ prevheights[0] = baseheight + 3; tx.nLockTime = chainActive.Tip()->nHeight + 1; hash = tx.GetId(); - mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); + g_mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { // Locktime fails. @@ -629,7 +629,7 @@ prevheights.resize(1); prevheights[0] = baseheight + 4; hash = tx.GetId(); - mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); + g_mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { // Locktime fails. @@ -700,7 +700,7 @@ chainActive.Tip()->nHeight--; SetMockTime(0); - mempool.clear(); + g_mempool.clear(); TestPackageSelection(config, scriptPubKey, txFirst); diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -97,7 +97,7 @@ // our unit tests aren't testing multiple parts of the code at once. GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); - mempool.setSanityCheck(1.0); + g_mempool.setSanityCheck(1.0); pblocktree.reset(new CBlockTreeDB(1 << 20, true)); pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -27,7 +27,7 @@ LOCK(cs_main); CValidationState state; - return AcceptToMemoryPool(GetConfig(), mempool, state, + return AcceptToMemoryPool(GetConfig(), g_mempool, state, MakeTransactionRef(tx), false, nullptr, true, Amount::zero()); } @@ -70,13 +70,13 @@ BOOST_CHECK(ToMemPool(spends[0])); block = CreateAndProcessBlock(spends, scriptPubKey); BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); - mempool.clear(); + g_mempool.clear(); // Test 3: ... and should be rejected if spend2 is in the memory pool BOOST_CHECK(ToMemPool(spends[1])); block = CreateAndProcessBlock(spends, scriptPubKey); BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); - mempool.clear(); + g_mempool.clear(); // Final sanity test: first spend in mempool, second in block, that's OK: std::vector oneSpend; @@ -86,7 +86,7 @@ BOOST_CHECK(chainActive.Tip()->GetBlockHash() == block.GetHash()); // spends[1] should have been removed from the mempool when the block with // spends[0] is accepted: - BOOST_CHECK_EQUAL(mempool.size(), 0); + BOOST_CHECK_EQUAL(g_mempool.size(), 0); } // Run CheckInputs (using pcoinsTip) on the given transaction, for all script diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1352,7 +1352,7 @@ // Drop the earliest entry, and remove its children from the // mempool. auto it = queuedTx.get().begin(); - mempool.removeRecursive(**it, MemPoolRemovalReason::REORG); + g_mempool.removeRecursive(**it, MemPoolRemovalReason::REORG); removeEntry(it); } } @@ -1373,12 +1373,12 @@ // ignore validation errors in resurrected transactions CValidationState stateDummy; if (!fAddToMempool || tx->IsCoinBase() || - !AcceptToMemoryPool(config, mempool, stateDummy, tx, false, nullptr, - true)) { + !AcceptToMemoryPool(config, g_mempool, stateDummy, tx, false, + nullptr, true)) { // If the transaction doesn't make it in to the mempool, remove any // transactions that depend on it (which would now be orphans). - mempool.removeRecursive(*tx, MemPoolRemovalReason::REORG); - } else if (mempool.exists(tx->GetId())) { + g_mempool.removeRecursive(*tx, MemPoolRemovalReason::REORG); + } else if (g_mempool.exists(tx->GetId())) { txidsUpdate.push_back(tx->GetId()); } } @@ -1390,15 +1390,15 @@ // previously-confirmed transactions back to the mempool. // UpdateTransactionsFromBlock finds descendants of any transactions in the // disconnectpool that were added back and cleans up the mempool state. - mempool.UpdateTransactionsFromBlock(txidsUpdate); + g_mempool.UpdateTransactionsFromBlock(txidsUpdate); // We also need to remove any now-immature transactions - mempool.removeForReorg(config, pcoinsTip.get(), - chainActive.Tip()->nHeight + 1, - STANDARD_LOCKTIME_VERIFY_FLAGS); + g_mempool.removeForReorg(config, pcoinsTip.get(), + chainActive.Tip()->nHeight + 1, + STANDARD_LOCKTIME_VERIFY_FLAGS); // Re-limit mempool size, in case we added any transactions - mempool.LimitSize( + g_mempool.LimitSize( gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); } diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -198,7 +198,7 @@ extern CScript COINBASE_FLAGS; extern CCriticalSection cs_main; -extern CTxMemPool mempool; +extern CTxMemPool g_mempool; extern uint64_t nLastBlockTx; extern uint64_t nLastBlockSize; extern const std::string strMessageMagic; diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -86,7 +86,7 @@ Amount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; -CTxMemPool mempool; +CTxMemPool g_mempool; static void CheckBlockIndex(const Consensus::Params &consensusParams); @@ -210,7 +210,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints) { AssertLockHeld(cs_main); - AssertLockHeld(mempool.cs); + AssertLockHeld(g_mempool.cs); CBlockIndex *tip = chainActive.Tip(); CBlockIndex index; @@ -229,7 +229,7 @@ lockPair.second = lp->time; } else { // pcoinsTip contains the UTXO set for chainActive.Tip() - CCoinsViewMemPool viewMemPool(pcoinsTip.get(), mempool); + CCoinsViewMemPool viewMemPool(pcoinsTip.get(), g_mempool); std::vector prevheights; prevheights.resize(tx.vin.size()); for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { @@ -768,7 +768,7 @@ LOCK(cs_main); - CTransactionRef ptx = mempool.get(txid); + CTransactionRef ptx = g_mempool.get(txid); if (ptx) { txOut = ptx; return true; @@ -1884,7 +1884,7 @@ // the mempool. if (IsReplayProtectionEnabled(config, pindex) && !IsReplayProtectionEnabled(config, pindex->pprev)) { - mempool.clear(); + g_mempool.clear(); } return true; @@ -1899,7 +1899,7 @@ static bool FlushStateToDisk(const CChainParams &chainparams, CValidationState &state, FlushStateMode mode, int nManualPruneHeight) { - int64_t nMempoolUsage = mempool.DynamicMemoryUsage(); + int64_t nMempoolUsage = g_mempool.DynamicMemoryUsage(); LOCK(cs_main); static int64_t nLastWrite = 0; static int64_t nLastFlush = 0; @@ -2070,7 +2070,7 @@ chainActive.SetTip(pindexNew); // New best block - mempool.AddTransactionsUpdated(1); + g_mempool.AddTransactionsUpdated(1); { LOCK(g_best_block_mutex); @@ -2191,7 +2191,7 @@ !IsMagneticAnomalyEnabled(config, pindexDelete->pprev))) { LogPrint(BCLog::MEMPOOL, "Clearing mempool for reorg"); - mempool.clear(); + g_mempool.clear(); // While not strictly necessary, clearing the disconnect pool is also // beneficial so we don't try to reuse its content at the end of the // reorg, which we know will fail. @@ -2408,7 +2408,7 @@ (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001); // Remove conflicting transactions from the mempool.; - mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); + g_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); disconnectpool.removeForBlock(blockConnecting.vtx); // Update chainActive & related variables. UpdateTip(config, pindexNew); @@ -2682,7 +2682,7 @@ disconnectpool.updateMempoolForReorg(config, true); } - mempool.check(pcoinsTip.get()); + g_mempool.check(pcoinsTip.get()); // Callbacks/notifications for a new best chain. if (fInvalidFound) { @@ -2737,7 +2737,7 @@ LOCK(cs_main); // Destructed before cs_main is unlocked. - ConnectTrace connectTrace(mempool); + ConnectTrace connectTrace(g_mempool); CBlockIndex *pindexOldTip = chainActive.Tip(); if (pindexMostWork == nullptr) { @@ -4723,7 +4723,7 @@ pindexBestInvalid = nullptr; pindexBestParked = nullptr; pindexBestHeader = nullptr; - mempool.clear(); + g_mempool.clear(); mapBlocksUnlinked.clear(); vinfoBlockFile.clear(); nLastBlockFile = 0; @@ -5335,14 +5335,14 @@ Amount amountdelta = nFeeDelta * SATOSHI; if (amountdelta != Amount::zero()) { - mempool.PrioritiseTransaction(tx->GetId(), - tx->GetId().ToString(), - prioritydummy, amountdelta); + g_mempool.PrioritiseTransaction(tx->GetId(), + tx->GetId().ToString(), + prioritydummy, amountdelta); } CValidationState state; if (nTime + nExpiryTimeout > nNow) { LOCK(cs_main); - AcceptToMemoryPoolWithTime(config, mempool, state, tx, true, + AcceptToMemoryPoolWithTime(config, g_mempool, state, tx, true, nullptr, nTime); if (state.IsValid()) { ++count; @@ -5361,8 +5361,8 @@ file >> mapDeltas; for (const auto &i : mapDeltas) { - mempool.PrioritiseTransaction(i.first, i.first.ToString(), - prioritydummy, i.second); + g_mempool.PrioritiseTransaction(i.first, i.first.ToString(), + prioritydummy, i.second); } } catch (const std::exception &e) { LogPrintf("Failed to deserialize mempool data on disk: %s. Continuing " @@ -5384,12 +5384,12 @@ std::vector vinfo; { - LOCK(mempool.cs); - for (const auto &i : mempool.mapDeltas) { + LOCK(g_mempool.cs); + for (const auto &i : g_mempool.mapDeltas) { mapDeltas[i.first] = i.second.second; } - vinfo = mempool.infoAll(); + vinfo = g_mempool.infoAll(); } int64_t mid = GetTimeMicros(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1761,7 +1761,7 @@ for (std::pair &item : mapSorted) { CWalletTx &wtx = *(item.second); - LOCK(mempool.cs); + LOCK(g_mempool.cs); CValidationState state; wtx.AcceptToMemoryPool(maxTxFee, state); } @@ -1964,8 +1964,8 @@ } bool CWalletTx::InMempool() const { - LOCK(mempool.cs); - if (mempool.exists(GetId())) { + LOCK(g_mempool.cs); + if (g_mempool.exists(GetId())) { return true; } @@ -2415,8 +2415,8 @@ continue; } - if (!mempool.TransactionWithinChainLimit(pcoin->GetId(), - nMaxAncestors)) { + if (!g_mempool.TransactionWithinChainLimit(pcoin->GetId(), + nMaxAncestors)) { continue; } @@ -2941,7 +2941,7 @@ } Amount nFeeNeeded = - GetMinimumFee(nBytes, currentConfirmationTarget, mempool); + GetMinimumFee(nBytes, currentConfirmationTarget, g_mempool); if (coinControl && nFeeNeeded > Amount::zero() && coinControl->nMinimumTotalFee > nFeeNeeded) { nFeeNeeded = coinControl->nMinimumTotalFee; @@ -3058,7 +3058,7 @@ DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000; std::string errString; - if (!mempool.CalculateMemPoolAncestors( + if (!g_mempool.CalculateMemPoolAncestors( entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) { strFailReason = _("Transaction has too long of a mempool chain"); @@ -4266,6 +4266,6 @@ bool CMerkleTx::AcceptToMemoryPool(const Amount nAbsurdFee, CValidationState &state) { - return ::AcceptToMemoryPool(GetConfig(), mempool, state, tx, true, nullptr, - false, nAbsurdFee); + return ::AcceptToMemoryPool(GetConfig(), g_mempool, state, tx, true, + nullptr, false, nAbsurdFee); }