mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +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();
|
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||||
globalVerifyHandle.reset();
|
globalVerifyHandle.reset();
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
node.mempool = nullptr;
|
node.mempool.reset();
|
||||||
node.chainman = nullptr;
|
node.chainman = nullptr;
|
||||||
node.scheduler.reset();
|
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,
|
// 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.
|
// which are all started after this, may use it from the node context.
|
||||||
assert(!node.mempool);
|
assert(!node.mempool);
|
||||||
node.mempool = &::mempool;
|
node.mempool = MakeUnique<CTxMemPool>(&::feeEstimator);
|
||||||
if (node.mempool) {
|
if (node.mempool) {
|
||||||
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
||||||
if (ratio != 0) {
|
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_coinstip_cache = nCoinCacheUsage;
|
||||||
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
||||||
|
|
||||||
UnloadBlockIndex(node.mempool);
|
UnloadBlockIndex(node.mempool.get());
|
||||||
|
|
||||||
// new CBlockTreeDB tries to delete the existing file, which
|
// new CBlockTreeDB tries to delete the existing file, which
|
||||||
// fails if it's still open from the previous loop. Close it first:
|
// fails if it's still open from the previous loop. Close it first:
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <net_processing.h>
|
#include <net_processing.h>
|
||||||
#include <scheduler.h>
|
#include <scheduler.h>
|
||||||
|
#include <txmempool.h>
|
||||||
|
|
||||||
NodeContext::NodeContext() {}
|
NodeContext::NodeContext() {}
|
||||||
NodeContext::~NodeContext() {}
|
NodeContext::~NodeContext() {}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class WalletClient;
|
||||||
//! be used without pulling in unwanted dependencies or functionality.
|
//! be used without pulling in unwanted dependencies or functionality.
|
||||||
struct NodeContext {
|
struct NodeContext {
|
||||||
std::unique_ptr<CConnman> connman;
|
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;
|
std::unique_ptr<PeerLogicValidation> peer_logic;
|
||||||
ChainstateManager* chainman{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
ChainstateManager* chainman{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
|
||||||
std::unique_ptr<BanMan> banman;
|
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");
|
RESTERR(req, HTTP_NOT_FOUND, "Mempool disabled or instance not found");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return node->mempool;
|
return node->mempool.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static RetFormat ParseDataFormat(std::string& param, const std::string& strReq)
|
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);
|
const NodeContext* const node = GetNodeContext(context, req);
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
uint256 hashBlock = uint256();
|
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) {
|
if (!tx) {
|
||||||
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 hash_block;
|
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) {
|
if (!tx) {
|
||||||
std::string errmsg;
|
std::string errmsg;
|
||||||
if (blockindex) {
|
if (blockindex) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||||
|
|
||||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
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.mempool->setSanityCheck(1.0);
|
||||||
|
|
||||||
m_node.chainman = &::g_chainman;
|
m_node.chainman = &::g_chainman;
|
||||||
|
@ -187,8 +187,8 @@ TestingSetup::~TestingSetup()
|
||||||
m_node.connman.reset();
|
m_node.connman.reset();
|
||||||
m_node.banman.reset();
|
m_node.banman.reset();
|
||||||
m_node.args = nullptr;
|
m_node.args = nullptr;
|
||||||
UnloadBlockIndex(m_node.mempool);
|
UnloadBlockIndex(m_node.mempool.get());
|
||||||
m_node.mempool = nullptr;
|
m_node.mempool.reset();
|
||||||
m_node.scheduler.reset();
|
m_node.scheduler.reset();
|
||||||
m_node.chainman->Reset();
|
m_node.chainman->Reset();
|
||||||
m_node.chainman = nullptr;
|
m_node.chainman = nullptr;
|
||||||
|
|
|
@ -148,7 +148,6 @@ arith_uint256 nMinimumChainWork;
|
||||||
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||||
|
|
||||||
CBlockPolicyEstimator feeEstimator;
|
CBlockPolicyEstimator feeEstimator;
|
||||||
CTxMemPool mempool(&feeEstimator);
|
|
||||||
|
|
||||||
// Internal stuff
|
// Internal stuff
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -113,7 +113,6 @@ enum class SynchronizationState {
|
||||||
|
|
||||||
extern RecursiveMutex cs_main;
|
extern RecursiveMutex cs_main;
|
||||||
extern CBlockPolicyEstimator feeEstimator;
|
extern CBlockPolicyEstimator feeEstimator;
|
||||||
extern CTxMemPool mempool;
|
|
||||||
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||||
extern Mutex g_best_block_mutex;
|
extern Mutex g_best_block_mutex;
|
||||||
extern std::condition_variable g_best_block_cv;
|
extern std::condition_variable g_best_block_cv;
|
||||||
|
|
Loading…
Add table
Reference in a new issue