Skip to content

Commit 6888886

Browse files
author
MarcoFalke
committed
Remove Chainstate::LoadMempool
The 3-line function is only called once outside of tests, so it is clearer to inline it.
1 parent b713825 commit 6888886

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/init.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
#endif
116116

117117
using kernel::DumpMempool;
118+
using kernel::LoadMempool;
118119
using kernel::ValidationCacheSizes;
119120

120121
using node::ApplyArgsManOptions;
@@ -1675,7 +1676,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
16751676
return;
16761677
}
16771678
// Load mempool from disk
1678-
chainman.ActiveChainstate().LoadMempool(ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{});
1679+
if (auto* pool{chainman.ActiveChainstate().GetMempool()}) {
1680+
LoadMempool(*pool, ShouldPersistMempool(args) ? MempoolPath(args) : fs::path{}, chainman.ActiveChainstate());
1681+
pool->SetLoadTried(!chainman.m_interrupt);
1682+
}
16791683
});
16801684

16811685
// Wait for genesis block to be processed

src/test/fuzz/validation_load_mempool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <vector>
2121

2222
using kernel::DumpMempool;
23+
using kernel::LoadMempool;
2324

2425
using node::MempoolPath;
2526

@@ -47,6 +48,7 @@ FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)
4748
auto fuzzed_fopen = [&](const fs::path&, const char*) {
4849
return fuzzed_file_provider.open();
4950
};
50-
(void)chainstate.LoadMempool(MempoolPath(g_setup->m_args), fuzzed_fopen);
51+
(void)LoadMempool(pool, MempoolPath(g_setup->m_args), chainstate, fuzzed_fopen);
52+
pool.SetLoadTried(true);
5153
(void)DumpMempool(pool, MempoolPath(g_setup->m_args), fuzzed_fopen, true);
5254
}

src/validation.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
using kernel::CCoinsStats;
7070
using kernel::CoinStatsHashType;
7171
using kernel::ComputeUTXOStats;
72-
using kernel::LoadMempool;
7372
using kernel::Notifications;
7473

7574
using fsbridge::FopenFn;
@@ -4126,13 +4125,6 @@ void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight
41264125
}
41274126
}
41284127

4129-
void Chainstate::LoadMempool(const fs::path& load_path, FopenFn mockable_fopen_function)
4130-
{
4131-
if (!m_mempool) return;
4132-
::LoadMempool(*m_mempool, load_path, *this, mockable_fopen_function);
4133-
m_mempool->SetLoadTried(!m_chainman.m_interrupt);
4134-
}
4135-
41364128
bool Chainstate::LoadChainTip()
41374129
{
41384130
AssertLockHeld(cs_main);

src/validation.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,6 @@ class Chainstate
712712
/** Find the last common block of this chain and a locator. */
713713
const CBlockIndex* FindForkInGlobalIndex(const CBlockLocator& locator) const EXCLUSIVE_LOCKS_REQUIRED(cs_main);
714714

715-
/** Load the persisted mempool from disk */
716-
void LoadMempool(const fs::path& load_path, fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen);
717-
718715
/** Update the chain tip based on database information, i.e. CoinsTip()'s best block. */
719716
bool LoadChainTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
720717

0 commit comments

Comments
 (0)