mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Remove mempool global
This commit is contained in:
parent
fa0359c5b3
commit
fafb381af8
8 changed files with 11 additions and 12 deletions
|
@ -302,7 +302,7 @@ void Shutdown(NodeContext& node)
|
|||
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||
globalVerifyHandle.reset();
|
||||
ECC_Stop();
|
||||
node.mempool = nullptr;
|
||||
node.mempool.reset();
|
||||
node.chainman = nullptr;
|
||||
node.scheduler.reset();
|
||||
|
||||
|
@ -1364,7 +1364,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
|||
// Make mempool generally available in the node context. For example the connection manager, wallet, or RPC threads,
|
||||
// which are all started after this, may use it from the node context.
|
||||
assert(!node.mempool);
|
||||
node.mempool = &::mempool;
|
||||
node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator);
|
||||
if (node.mempool) {
|
||||
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
||||
if (ratio != 0) {
|
||||
|
@ -1559,7 +1559,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
|||
chainman.m_total_coinstip_cache = nCoinCacheUsage;
|
||||
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
||||
|
||||
UnloadBlockIndex(node.mempool);
|
||||
UnloadBlockIndex(node.mempool.get());
|
||||
|
||||
// new CBlockTreeDB tries to delete the existing file, which
|
||||
// fails if it's still open from the previous loop. Close it first:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <net.h>
|
||||
#include <net_processing.h>
|
||||
#include <scheduler.h>
|
||||
#include <txmempool.h>
|
||||
|
||||
NodeContext::NodeContext() {}
|
||||
NodeContext::~NodeContext() {}
|
||||
|
|
|
@ -35,7 +35,7 @@ class WalletClient;
|
|||
//! be used without pulling in unwanted dependencies or functionality.
|
||||
struct NodeContext {
|
||||
std::unique_ptr<CConnman> connman;
|
||||
CTxMemPool* mempool{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||
std::unique_ptr<CTxMemPool> mempool;
|
||||
std::unique_ptr<PeerLogicValidation> peer_logic;
|
||||
ChainstateManager* chainman{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||
std::unique_ptr<BanMan> banman;
|
||||
|
|
|
@ -102,7 +102,7 @@ static CTxMemPool* GetMemPool(const util::Ref& context, HTTPRequest* req)
|
|||
RESTERR(req, HTTP_NOT_FOUND, "Mempool disabled or instance not found");
|
||||
return nullptr;
|
||||
}
|
||||
return node->mempool;
|
||||
return node->mempool.get();
|
||||
}
|
||||
|
||||
static RetFormat ParseDataFormat(std::string& param, const std::string& strReq)
|
||||
|
@ -393,7 +393,7 @@ static bool rest_tx(const util::Ref& context, HTTPRequest* req, const std::strin
|
|||
const NodeContext* const node = GetNodeContext(context, req);
|
||||
if (!node) return false;
|
||||
uint256 hashBlock = uint256();
|
||||
const CTransactionRef tx = GetTransaction(/* block_index */ nullptr, node->mempool, hash, Params().GetConsensus(), hashBlock);
|
||||
const CTransactionRef tx = GetTransaction(/* block_index */ nullptr, node->mempool.get(), hash, Params().GetConsensus(), hashBlock);
|
||||
if (!tx) {
|
||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
|
|||
}
|
||||
|
||||
uint256 hash_block;
|
||||
const CTransactionRef tx = GetTransaction(blockindex, node.mempool, hash, Params().GetConsensus(), hash_block);
|
||||
const CTransactionRef tx = GetTransaction(blockindex, node.mempool.get(), hash, Params().GetConsensus(), hash_block);
|
||||
if (!tx) {
|
||||
std::string errmsg;
|
||||
if (blockindex) {
|
||||
|
|
|
@ -141,7 +141,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
|||
|
||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||
|
||||
m_node.mempool = &::mempool;
|
||||
m_node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator);
|
||||
m_node.mempool->setSanityCheck(1.0);
|
||||
|
||||
m_node.chainman = &::g_chainman;
|
||||
|
@ -187,8 +187,8 @@ TestingSetup::~TestingSetup()
|
|||
m_node.connman.reset();
|
||||
m_node.banman.reset();
|
||||
m_node.args = nullptr;
|
||||
UnloadBlockIndex(m_node.mempool);
|
||||
m_node.mempool = nullptr;
|
||||
UnloadBlockIndex(m_node.mempool.get());
|
||||
m_node.mempool.reset();
|
||||
m_node.scheduler.reset();
|
||||
m_node.chainman->Reset();
|
||||
m_node.chainman = nullptr;
|
||||
|
|
|
@ -148,7 +148,6 @@ arith_uint256 nMinimumChainWork;
|
|||
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||
|
||||
CBlockPolicyEstimator feeEstimator;
|
||||
CTxMemPool mempool(&feeEstimator);
|
||||
|
||||
// Internal stuff
|
||||
namespace {
|
||||
|
|
|
@ -113,7 +113,6 @@ enum class SynchronizationState {
|
|||
|
||||
extern RecursiveMutex cs_main;
|
||||
extern CBlockPolicyEstimator feeEstimator;
|
||||
extern CTxMemPool mempool;
|
||||
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||
extern Mutex g_best_block_mutex;
|
||||
extern std::condition_variable g_best_block_cv;
|
||||
|
|
Loading…
Add table
Reference in a new issue