Skip to content

Commit 79ff48a

Browse files
knstMacroFake
andcommitted
Merge bitcoin#25607: [kernel 3d/n] Misc ChainstateManager::Options fixups
BACKPORT NOTE: changes in src/test/validation_chainstate_tests.cpp is skipped as relevant code is removed by bitcoin#25815 ce8b0f9 Use designated initializers for ChainstateManager::Options (Carl Dong) 3837700 Move ChainstateManagerOpts into kernel:: namespace (Carl Dong) Pull request description: This is part of the `libbitcoinkernel` project: bitcoin#24303, https://github.com/bitcoin/bitcoin/projects/18 This PR is **_NOT_** dependent on any other PRs. ----- Places `ChainstateManager::Options` into the `kernel::` namespace and use designated initializers for construction. ACKs for top commit: ryanofsky: Code review ACK ce8b0f9 Tree-SHA512: 16a11b5051a2432ca4b6fa7b253376606fef619ace499dfe64d033c8fbe3e1a1875a7c946d7cd54bd908363886244ddf3a192e2f0c801ffbed40d60aad65e442 Co-authored-by: MacroFake <falke.marco@gmail.com>
1 parent 6d74b31 commit 79ff48a

5 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/bitcoin-chainstate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ int main(int argc, char* argv[])
8787

8888
// SETUP: Chainstate
8989
const ChainstateManager::Options chainman_opts{
90-
chainparams,
91-
static_cast<int64_t(*)()>(GetTime),
90+
.chainparams = chainparams,
91+
.adjusted_time_callback = static_cast<int64_t (*)()>(GetTime),
9292
};
9393
ChainstateManager chainman{chainman_opts};
9494

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
20072007
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
20082008

20092009
const ChainstateManager::Options chainman_opts{
2010-
chainparams,
2011-
GetAdjustedTime,
2010+
.chainparams = chainparams,
2011+
.adjusted_time_callback = GetAdjustedTime,
20122012
};
20132013
node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
20142014
ChainstateManager& chainman = *node.chainman;

src/kernel/chainstatemanager_opts.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
class CChainParams;
1212

13+
namespace kernel {
14+
1315
/**
1416
* An options struct for `ChainstateManager`, more ergonomically referred to as
1517
* `ChainstateManager::Options` due to the using-declaration in
@@ -20,4 +22,6 @@ struct ChainstateManagerOpts {
2022
const std::function<int64_t()> adjusted_time_callback{nullptr};
2123
};
2224

25+
} // namespace kernel
26+
2327
#endif // BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H

src/test/util/setup_common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
282282
m_cache_sizes = CalculateCacheSizes(m_args);
283283

284284
const ChainstateManager::Options chainman_opts{
285-
chainparams,
286-
GetAdjustedTime,
285+
.chainparams = chainparams,
286+
.adjusted_time_callback = GetAdjustedTime,
287287
};
288288
m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
289289
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ class ChainstateManager
924924
std::array<ThresholdConditionCache, VERSIONBITS_NUM_BITS> m_warningcache GUARDED_BY(::cs_main);
925925

926926
public:
927-
using Options = ChainstateManagerOpts;
927+
using Options = kernel::ChainstateManagerOpts;
928928

929929
explicit ChainstateManager(const Options& opts)
930930
: m_chainparams{opts.chainparams},

0 commit comments

Comments
 (0)