mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
refactor: post Optional<> removal cleanups
This commit is contained in:
parent
57e980d13c
commit
ebc4ab721b
@ -5,13 +5,14 @@
|
||||
#include <bench/bench.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <node/context.h>
|
||||
#include <optional>
|
||||
#include <test/util/mining.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/wallet.h>
|
||||
#include <validationinterface.h>
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_watchonly, const bool add_mine)
|
||||
{
|
||||
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <clientversion.h>
|
||||
#include <optional>
|
||||
#include <rpc/client.h>
|
||||
#include <rpc/mining.h>
|
||||
#include <rpc/protocol.h>
|
||||
@ -24,6 +23,7 @@
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <util/url.h>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
UrlDecodeFn* const URL_DECODE = urlDecode;
|
||||
|
@ -5,12 +5,12 @@
|
||||
#ifndef BITCOIN_INTERFACES_CHAIN_H
|
||||
#define BITCOIN_INTERFACES_CHAIN_H
|
||||
|
||||
#include <optional> // For Optional and nullopt
|
||||
#include <primitives/transaction.h> // For CTransactionRef
|
||||
#include <util/settings.h> // For util::SettingsValue
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
@ -96,9 +96,6 @@ void BlockAssembler::resetBlock()
|
||||
nFees = 0;
|
||||
}
|
||||
|
||||
std::optional<int64_t> BlockAssembler::m_last_block_num_txs{std::nullopt};
|
||||
std::optional<int64_t> BlockAssembler::m_last_block_weight{std::nullopt};
|
||||
|
||||
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn)
|
||||
{
|
||||
int64_t nTimeStart = GetTimeMicros();
|
||||
|
@ -6,12 +6,12 @@
|
||||
#ifndef BITCOIN_MINER_H
|
||||
#define BITCOIN_MINER_H
|
||||
|
||||
#include <optional>
|
||||
#include <primitives/block.h>
|
||||
#include <txmempool.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
@ -160,8 +160,8 @@ public:
|
||||
/** Construct a new block template with coinbase to scriptPubKeyIn */
|
||||
std::unique_ptr<CBlockTemplate> CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn);
|
||||
|
||||
static std::optional<int64_t> m_last_block_num_txs;
|
||||
static std::optional<int64_t> m_last_block_weight;
|
||||
inline static std::optional<int64_t> m_last_block_num_txs{};
|
||||
inline static std::optional<int64_t> m_last_block_weight{};
|
||||
|
||||
private:
|
||||
// utility functions
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <net_permissions.h>
|
||||
#include <netbase.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <optional>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
#include <scheduler.h>
|
||||
@ -39,6 +38,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <math.h>
|
||||
@ -752,7 +752,7 @@ std::optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono
|
||||
LogPrint(BCLog::NET, "HEADER ERROR - COMMAND (%s, %u bytes), peer=%d\n",
|
||||
hdr.GetCommand(), msg->m_message_size, m_node_id);
|
||||
out_err_raw_size = msg->m_raw_message_size;
|
||||
msg = std::nullopt;
|
||||
msg.reset();
|
||||
}
|
||||
|
||||
// Always reset the network deserializer (prepare for the next message)
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <net_permissions.h>
|
||||
#include <netaddress.h>
|
||||
#include <netbase.h>
|
||||
#include <optional>
|
||||
#include <policy/feerate.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
@ -35,6 +34,7 @@
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <validation.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <typeinfo>
|
||||
|
||||
/** How long to cache transactions in mapRelay for normal relay */
|
||||
|
@ -50,6 +50,7 @@
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
using interfaces::BlockTip;
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <psbt.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
* Holds an analysis of one input from a PSBT
|
||||
*/
|
||||
@ -28,9 +30,9 @@ struct PSBTAnalysis {
|
||||
std::optional<size_t> estimated_vsize; //!< Estimated weight of the transaction
|
||||
std::optional<CFeeRate> estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction
|
||||
std::optional<CAmount> fee; //!< Amount of fee being paid by the transaction
|
||||
std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction
|
||||
PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next
|
||||
std::string error; //!< Error message
|
||||
std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction
|
||||
PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next
|
||||
std::string error; //!< Error message
|
||||
|
||||
void SetInvalid(std::string err_msg)
|
||||
{
|
||||
|
@ -7,13 +7,14 @@
|
||||
|
||||
#include <attributes.h>
|
||||
#include <node/transaction.h>
|
||||
#include <optional>
|
||||
#include <policy/feerate.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/sign.h>
|
||||
#include <script/signingprovider.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
// Magic bytes
|
||||
static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <util/vector.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
#ifndef BITCOIN_SCRIPT_DESCRIPTOR_H
|
||||
#define BITCOIN_SCRIPT_DESCRIPTOR_H
|
||||
|
||||
#include <optional>
|
||||
#include <outputtype.h>
|
||||
#include <script/script.h>
|
||||
#include <script/sign.h>
|
||||
#include <script/signingprovider.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
using ExtPubKeyMap = std::unordered_map<uint32_t, CExtPubKey>;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <net.h>
|
||||
#include <netbase.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <optional>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <psbt.h>
|
||||
@ -26,6 +25,7 @@
|
||||
#include <version.h>
|
||||
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <net.h>
|
||||
#include <net_permissions.h>
|
||||
#include <netaddress.h>
|
||||
#include <optional>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
@ -17,6 +16,7 @@
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
void initialize_p2p_transport_deserializer()
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <test/fuzz/fuzz.h>
|
||||
|
||||
#include <node/psbt.h>
|
||||
#include <optional>
|
||||
#include <psbt.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
@ -13,6 +12,7 @@
|
||||
#include <version.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <optional>
|
||||
#include <pubkey.h>
|
||||
#include <script/descriptor.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
@ -10,6 +9,7 @@
|
||||
#include <test/fuzz/util.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <cstdint>
|
||||
#include <net.h>
|
||||
#include <netbase.h>
|
||||
#include <optional>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
@ -24,6 +23,7 @@
|
||||
#include <algorithm>
|
||||
#include <ios>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
using namespace std::literals;
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <clientversion.h>
|
||||
#include <hash.h> // For Hash()
|
||||
#include <key.h> // For CKey
|
||||
#include <optional>
|
||||
#include <sync.h>
|
||||
#include <test/util/logging.h>
|
||||
#include <test/util/setup_common.h>
|
||||
@ -23,6 +22,7 @@
|
||||
#include <util/vector.h>
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <thread>
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <consensus/consensus.h>
|
||||
#include <consensus/tx_verify.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <optional>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/settings.h>
|
||||
@ -19,6 +18,8 @@
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFee,
|
||||
int64_t _nTime, unsigned int _entryHeight,
|
||||
bool _spendsCoinbase, int64_t _sigOpsCost, LockPoints lp)
|
||||
@ -894,7 +895,7 @@ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
|
||||
{
|
||||
auto it = mapTx.find(txid);
|
||||
if (it != mapTx.end()) return it;
|
||||
return std::optional<txiter>{};
|
||||
return {};
|
||||
}
|
||||
|
||||
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -16,7 +17,6 @@
|
||||
#include <amount.h>
|
||||
#include <coins.h>
|
||||
#include <indirectmap.h>
|
||||
#include <optional>
|
||||
#include <policy/feerate.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <random.h>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <compat/assumptions.h>
|
||||
#include <fs.h>
|
||||
#include <logging.h>
|
||||
#include <optional>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/settings.h>
|
||||
@ -28,6 +27,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <optional>
|
||||
#include <unistd.h>
|
||||
|
||||
TokenPipeEnd TokenPipe::TakeReadEnd()
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <logging/timer.h>
|
||||
#include <node/coinstats.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <optional>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/settings.h>
|
||||
#include <pow.h>
|
||||
@ -50,6 +49,7 @@
|
||||
#include <validationinterface.h>
|
||||
#include <warnings.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <crypto/common.h> // for ReadLE64
|
||||
#include <fs.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <optional>
|
||||
#include <policy/feerate.h>
|
||||
#include <protocol.h> // For CMessageHeader::MessageStartChars
|
||||
#include <script/script_error.h>
|
||||
@ -32,6 +31,7 @@
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@ -205,8 +205,7 @@ struct MempoolAcceptResult {
|
||||
|
||||
/** Constructor for failure case */
|
||||
explicit MempoolAcceptResult(TxValidationState state)
|
||||
: m_result_type(ResultType::INVALID),
|
||||
m_state(state), m_replaced_transactions(std::nullopt), m_base_fees(std::nullopt) {
|
||||
: m_result_type(ResultType::INVALID), m_state(state) {
|
||||
Assume(!state.IsValid()); // Can be invalid or error
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,14 @@
|
||||
#ifndef BITCOIN_WALLET_COINCONTROL_H
|
||||
#define BITCOIN_WALLET_COINCONTROL_H
|
||||
|
||||
#include <optional>
|
||||
#include <outputtype.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/fees.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <script/standard.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
const int DEFAULT_MIN_DEPTH = 0;
|
||||
const int DEFAULT_MAX_DEPTH = 9999999;
|
||||
|
||||
|
@ -4,11 +4,12 @@
|
||||
|
||||
#include <wallet/coinselection.h>
|
||||
|
||||
#include <optional>
|
||||
#include <policy/feerate.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
// Descending order comparator
|
||||
struct {
|
||||
bool operator()(const OutputGroup& a, const OutputGroup& b) const
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <fs.h>
|
||||
#include <optional>
|
||||
#include <streams.h>
|
||||
#include <support/allocators/secure.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
struct bilingual_str;
|
||||
|
@ -1788,7 +1788,7 @@ RPCHelpMan listdescriptors()
|
||||
const bool active = active_spk_mans.count(desc_spk_man) != 0;
|
||||
spk.pushKV("active", active);
|
||||
const auto& type = wallet_descriptor.descriptor->GetOutputType();
|
||||
if (active && type != std::nullopt) {
|
||||
if (active && type) {
|
||||
spk.pushKV("internal", wallet->GetScriptPubKeyMan(*type, true) == desc_spk_man);
|
||||
}
|
||||
if (wallet_descriptor.descriptor->IsRange()) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <interfaces/chain.h>
|
||||
#include <key_io.h>
|
||||
#include <node/context.h>
|
||||
#include <optional>
|
||||
#include <outputtype.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/fees.h>
|
||||
@ -38,6 +37,7 @@
|
||||
#include <wallet/walletdb.h>
|
||||
#include <wallet/walletutil.h>
|
||||
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <univalue.h>
|
||||
@ -219,7 +219,7 @@ static void SetFeeEstimateMode(const CWallet& wallet, CCoinControl& cc, const Un
|
||||
cc.m_feerate = CFeeRate(AmountFromValue(fee_rate), COIN);
|
||||
if (override_min_fee) cc.fOverrideFeeRate = true;
|
||||
// Default RBF to true for explicit fee_rate, if unset.
|
||||
if (cc.m_signal_bip125_rbf == std::nullopt) cc.m_signal_bip125_rbf = true;
|
||||
if (!cc.m_signal_bip125_rbf) cc.m_signal_bip125_rbf = true;
|
||||
return;
|
||||
}
|
||||
if (!estimate_mode.isNull() && !FeeModeFromString(estimate_mode.get_str(), cc.m_fee_mode)) {
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <wallet/external_signer.h>
|
||||
#include <wallet/scriptpubkeyman.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
//! Value for the first BIP 32 hardened derivation. Can be used as a bit mask and as a value. See BIP 32 for more details.
|
||||
const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000;
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <interfaces/wallet.h>
|
||||
#include <key.h>
|
||||
#include <key_io.h>
|
||||
#include <optional>
|
||||
#include <outputtype.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
@ -40,6 +39,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <optional>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
@ -87,7 +87,7 @@ static void UpdateWalletSetting(interfaces::Chain& chain,
|
||||
std::optional<bool> load_on_startup,
|
||||
std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
if (load_on_startup == std::nullopt) return;
|
||||
if (!load_on_startup) return;
|
||||
if (load_on_startup.value() && !AddWalletSetting(chain, wallet_name)) {
|
||||
warnings.emplace_back(Untranslated("Wallet load on startup setting could not be updated, so wallet may not be loaded next node startup."));
|
||||
} else if (!load_on_startup.value() && !RemoveWalletSetting(chain, wallet_name)) {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace DBKeys {
|
||||
|
Loading…
Reference in New Issue
Block a user