diff options
| author | MarcoFalke <[email protected]> | 2019-11-08 10:29:41 -0500 |
|---|---|---|
| committer | MarcoFalke <[email protected]> | 2019-11-15 13:40:00 -0500 |
| commit | fac07f2038a3ccd5edadc6e6122c02fa30e697bd (patch) | |
| tree | 7f115cb94e2b7486efd531b48b6ce42a7b92a5a7 /src/test/util/setup_common.cpp | |
| parent | Merge #17362: test: speed up wallet_avoidreuse, add logging (diff) | |
| download | discoin-fac07f2038a3ccd5edadc6e6122c02fa30e697bd.tar.xz discoin-fac07f2038a3ccd5edadc6e6122c02fa30e697bd.zip | |
node: Add reference to mempool in NodeContext
Currently it is an alias to the global ::mempool and should be used as
follows.
* Node code (validation and transaction relay) can use either ::mempool
or node.mempool, whichever seems a better fit.
* RPC code should use the added convenience getter EnsureMempool, which
makes sure the mempool exists before use. This prepares the RPC code
to a future where the mempool might be disabled at runtime or compile
time.
* Test code should use m_node.mempool directly, as the mempool is always
initialized for tests.
Diffstat (limited to 'src/test/util/setup_common.cpp')
| -rw-r--r-- | src/test/util/setup_common.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 0c6ecdf69..86c355fdc 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -107,7 +107,6 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha threadGroup.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler)); GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); - mempool.setSanityCheck(1.0); pblocktree.reset(new CBlockTreeDB(1 << 20, true)); g_chainstate = MakeUnique<CChainState>(); ::ChainstateActive().InitCoinsDB( @@ -131,6 +130,8 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha } g_parallel_script_checks = true; + m_node.mempool = &::mempool; + m_node.mempool->setSanityCheck(1.0); m_node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME); m_node.connman = MakeUnique<CConnman>(0x1337, 0x1337); // Deterministic randomness for tests. } @@ -144,6 +145,7 @@ TestingSetup::~TestingSetup() g_rpc_node = nullptr; m_node.connman.reset(); m_node.banman.reset(); + m_node.mempool = nullptr; UnloadBlockIndex(); g_chainstate.reset(); pblocktree.reset(); |