Skip to content

Commit ebc4ab7

Browse files
committed
refactor: post Optional<> removal cleanups
1 parent 57e980d commit ebc4ab7

37 files changed

+53
-39
lines changed

src/bench/wallet_balance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
#include <bench/bench.h>
66
#include <interfaces/chain.h>
77
#include <node/context.h>
8-
#include <optional>
98
#include <test/util/mining.h>
109
#include <test/util/setup_common.h>
1110
#include <test/util/wallet.h>
1211
#include <validationinterface.h>
1312
#include <wallet/wallet.h>
1413

14+
#include <optional>
15+
1516
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_watchonly, const bool add_mine)
1617
{
1718
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <chainparamsbase.h>
1111
#include <clientversion.h>
12-
#include <optional>
1312
#include <rpc/client.h>
1413
#include <rpc/mining.h>
1514
#include <rpc/protocol.h>
@@ -24,6 +23,7 @@
2423
#include <cmath>
2524
#include <functional>
2625
#include <memory>
26+
#include <optional>
2727
#include <stdio.h>
2828
#include <string>
2929
#include <tuple>

src/bitcoind.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <util/url.h>
2626

2727
#include <functional>
28+
#include <optional>
2829

2930
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
3031
UrlDecodeFn* const URL_DECODE = urlDecode;

src/interfaces/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#ifndef BITCOIN_INTERFACES_CHAIN_H
66
#define BITCOIN_INTERFACES_CHAIN_H
77

8-
#include <optional> // For Optional and nullopt
98
#include <primitives/transaction.h> // For CTransactionRef
109
#include <util/settings.h> // For util::SettingsValue
1110

1211
#include <functional>
1312
#include <memory>
13+
#include <optional>
1414
#include <stddef.h>
1515
#include <stdint.h>
1616
#include <string>

src/miner.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ void BlockAssembler::resetBlock()
9696
nFees = 0;
9797
}
9898

99-
std::optional<int64_t> BlockAssembler::m_last_block_num_txs{std::nullopt};
100-
std::optional<int64_t> BlockAssembler::m_last_block_weight{std::nullopt};
101-
10299
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn)
103100
{
104101
int64_t nTimeStart = GetTimeMicros();

src/miner.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#ifndef BITCOIN_MINER_H
77
#define BITCOIN_MINER_H
88

9-
#include <optional>
109
#include <primitives/block.h>
1110
#include <txmempool.h>
1211
#include <validation.h>
1312

1413
#include <memory>
14+
#include <optional>
1515
#include <stdint.h>
1616

1717
#include <boost/multi_index_container.hpp>
@@ -160,8 +160,8 @@ class BlockAssembler
160160
/** Construct a new block template with coinbase to scriptPubKeyIn */
161161
std::unique_ptr<CBlockTemplate> CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn);
162162

163-
static std::optional<int64_t> m_last_block_num_txs;
164-
static std::optional<int64_t> m_last_block_weight;
163+
inline static std::optional<int64_t> m_last_block_num_txs{};
164+
inline static std::optional<int64_t> m_last_block_weight{};
165165

166166
private:
167167
// utility functions

src/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <net_permissions.h>
1919
#include <netbase.h>
2020
#include <node/ui_interface.h>
21-
#include <optional>
2221
#include <protocol.h>
2322
#include <random.h>
2423
#include <scheduler.h>
@@ -39,6 +38,7 @@
3938
#include <algorithm>
4039
#include <cstdint>
4140
#include <functional>
41+
#include <optional>
4242
#include <unordered_map>
4343

4444
#include <math.h>
@@ -752,7 +752,7 @@ std::optional<CNetMessage> V1TransportDeserializer::GetMessage(const std::chrono
752752
LogPrint(BCLog::NET, "HEADER ERROR - COMMAND (%s, %u bytes), peer=%d\n",
753753
hdr.GetCommand(), msg->m_message_size, m_node_id);
754754
out_err_raw_size = msg->m_raw_message_size;
755-
msg = std::nullopt;
755+
msg.reset();
756756
}
757757

758758
// Always reset the network deserializer (prepare for the next message)

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <net_permissions.h>
1919
#include <netaddress.h>
2020
#include <netbase.h>
21-
#include <optional>
2221
#include <policy/feerate.h>
2322
#include <protocol.h>
2423
#include <random.h>
@@ -35,6 +34,7 @@
3534
#include <deque>
3635
#include <map>
3736
#include <memory>
37+
#include <optional>
3838
#include <thread>
3939
#include <vector>
4040

src/net_processing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <validation.h>
3535

3636
#include <memory>
37+
#include <optional>
3738
#include <typeinfo>
3839

3940
/** How long to cache transactions in mapRelay for normal relay */

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#endif
5151

5252
#include <memory>
53+
#include <optional>
5354
#include <utility>
5455

5556
using interfaces::BlockTip;

0 commit comments

Comments
 (0)