From 91cee86e64aa2a4c045a41b208887c5a5514e312 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 28 Oct 2022 15:19:05 -0400 Subject: [PATCH] Merge bitcoin/bitcoin#26409: refactor: Silence GCC Wmissing-field-initializers in ChainstateManagerOpts fa29ef00adac6f0842acdd38344820a1ce0e3087 refactor: Silence GCC Wmissing-field-initializers in ChainstateManagerOpts (MacroFake) Pull request description: The `std::optional` fields in the struct that fall back to chain param defaults if not provided should be initialized to `std::nullopt`. This already happens with the current code. However, for consistency with `check_block_index` and to silence a GCC warning, add the "missing" `{}`. ACKs for top commit: achow101: ACK fa29ef00adac6f0842acdd38344820a1ce0e3087 hebasto: ACK fa29ef00adac6f0842acdd38344820a1ce0e3087, tested on Ubuntu 22.04 + GCC 11.3. jonatack: ACK fa29ef00adac6f0842acdd38344820a1ce0e3087 Tree-SHA512: bdec9c56df5d601a5616e107fed48737b13b0a7242b6526092fb682b5016544a4bc08666b60304c668d44c6f7ac69d3788093d921382c1d6c577c1f9fe31fc50 --- src/kernel/chainstatemanager_opts.h | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/kernel/chainstatemanager_opts.h diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h new file mode 100644 index 000000000000..226bb6031e1d --- /dev/null +++ b/src/kernel/chainstatemanager_opts.h @@ -0,0 +1,43 @@ +// Copyright (c) 2022 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H +#define BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H + +#include +#include +#include + +#include +#include +#include + +class CChainParams; + +static constexpr bool DEFAULT_CHECKPOINTS_ENABLED{true}; +static constexpr auto DEFAULT_MAX_TIP_AGE{24h}; + +namespace kernel { + +/** + * An options struct for `ChainstateManager`, more ergonomically referred to as + * `ChainstateManager::Options` due to the using-declaration in + * `ChainstateManager`. + */ +struct ChainstateManagerOpts { + const CChainParams& chainparams; + const std::function adjusted_time_callback{nullptr}; + std::optional check_block_index{}; + bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED}; + //! If set, it will override the minimum work we will assume exists on some valid chain. + std::optional minimum_chain_work{}; + //! If set, it will override the block hash whose ancestors we will assume to have valid scripts without checking them. + std::optional assumed_valid_block{}; + //! If the tip is older than this, the node is considered to be in initial block download. + std::chrono::seconds max_tip_age{DEFAULT_MAX_TIP_AGE}; +}; + +} // namespace kernel + +#endif // BITCOIN_KERNEL_CHAINSTATEMANAGER_OPTS_H