Skip to content

Commit 08e2947

Browse files
committed
Merge #17316: refactor: Replace all uses of boost::optional with our own Optional type
d314e8a refactor: Replace all uses of boost::optional with our own Optional type (Wladimir J. van der Laan) Pull request description: Replace all uses of boost::optional with our own Optional type. Luckily, there aren't so many. After this: - `boost::optional` is no longer used directly (only through `Optional` which is an alias for it) - `boost/optional.hpp` is only included in one place ACKs for top commit: MarcoFalke: ACK d314e8a practicalswift: ACK d314e8a -- diff looks correct + satisfying to see incremental progress towards the goal of a Boost free future :) jtimon: ACK d314e8a fanquake: ACK d314e8a Tree-SHA512: b43e0017af81b07b5851377cd09624f114510ac5b9018d037664b58ad0fc8e893e30946b61f8f5e21e39125925bf9998a81f2226b468aab2df653ee57ed3213d
2 parents a6abc94 + d314e8a commit 08e2947

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/psbt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ struct PSBTOutput
387387
/** A version of CTransaction with the PSBT format*/
388388
struct PartiallySignedTransaction
389389
{
390-
boost::optional<CMutableTransaction> tx;
390+
Optional<CMutableTransaction> tx;
391391
std::vector<PSBTInput> inputs;
392392
std::vector<PSBTOutput> outputs;
393393
std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;

src/txmempool.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <consensus/consensus.h>
99
#include <consensus/tx_verify.h>
1010
#include <consensus/validation.h>
11+
#include <optional.h>
1112
#include <validation.h>
1213
#include <policy/policy.h>
1314
#include <policy/fees.h>
@@ -155,7 +156,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr
155156
// GetMemPoolParents() is only valid for entries in the mempool, so we
156157
// iterate mapTx to find parents.
157158
for (unsigned int i = 0; i < tx.vin.size(); i++) {
158-
boost::optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
159+
Optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
159160
if (piter) {
160161
parentHashes.insert(*piter);
161162
if (parentHashes.size() + 1 > limitAncestorCount) {
@@ -860,11 +861,11 @@ const CTransaction* CTxMemPool::GetConflictTx(const COutPoint& prevout) const
860861
return it == mapNextTx.end() ? nullptr : it->second;
861862
}
862863

863-
boost::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
864+
Optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
864865
{
865866
auto it = mapTx.find(txid);
866867
if (it != mapTx.end()) return it;
867-
return boost::optional<txiter>{};
868+
return Optional<txiter>{};
868869
}
869870

870871
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const

src/txmempool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <coins.h>
1818
#include <crypto/siphash.h>
1919
#include <indirectmap.h>
20+
#include <optional.h>
2021
#include <policy/feerate.h>
2122
#include <primitives/transaction.h>
2223
#include <sync.h>
@@ -602,7 +603,7 @@ class CTxMemPool
602603
const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
603604

604605
/** Returns an iterator to the given hash, if found */
605-
boost::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
606+
Optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
606607

607608
/** Translate a set of hashes into a set of pool iterators to avoid repeated lookups */
608609
setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);

src/wallet/coincontrol.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
#ifndef BITCOIN_WALLET_COINCONTROL_H
66
#define BITCOIN_WALLET_COINCONTROL_H
77

8+
#include <optional.h>
89
#include <policy/feerate.h>
910
#include <policy/fees.h>
1011
#include <primitives/transaction.h>
1112
#include <wallet/wallet.h>
1213

13-
#include <boost/optional.hpp>
14-
1514
const int DEFAULT_MIN_DEPTH = 0;
1615
const int DEFAULT_MAX_DEPTH = 9999999;
1716

@@ -22,19 +21,19 @@ class CCoinControl
2221
//! Custom change destination, if not set an address is generated
2322
CTxDestination destChange;
2423
//! Override the default change type if set, ignored if destChange is set
25-
boost::optional<OutputType> m_change_type;
24+
Optional<OutputType> m_change_type;
2625
//! If false, allows unselected inputs, but requires all selected inputs be used
2726
bool fAllowOtherInputs;
2827
//! Includes watch only addresses which are solvable
2928
bool fAllowWatchOnly;
3029
//! Override automatic min/max checks on fee, m_feerate must be set if true
3130
bool fOverrideFeeRate;
3231
//! Override the wallet's m_pay_tx_fee if set
33-
boost::optional<CFeeRate> m_feerate;
32+
Optional<CFeeRate> m_feerate;
3433
//! Override the default confirmation target if set
35-
boost::optional<unsigned int> m_confirm_target;
34+
Optional<unsigned int> m_confirm_target;
3635
//! Override the wallet's m_signal_rbf if set
37-
boost::optional<bool> m_signal_bip125_rbf;
36+
Optional<bool> m_signal_bip125_rbf;
3837
//! Avoid partial use of funds sent to a given address
3938
bool m_avoid_partial_spends;
4039
//! Forbids inclusion of dirty (previously used) addresses

src/wallet/coinselection.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
#include <wallet/coinselection.h>
66

7+
#include <optional.h>
78
#include <util/system.h>
89
#include <util/moneystr.h>
910

10-
#include <boost/optional.hpp>
11-
1211
// Descending order comparator
1312
struct {
1413
bool operator()(const OutputGroup& a, const OutputGroup& b) const
@@ -219,7 +218,7 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
219218
nValueRet = 0;
220219

221220
// List of values less than target
222-
boost::optional<OutputGroup> lowest_larger;
221+
Optional<OutputGroup> lowest_larger;
223222
std::vector<OutputGroup> applicable_groups;
224223
CAmount nTotalLower = 0;
225224

0 commit comments

Comments
 (0)