From 3b33318dc8d401aec23b62fe16297e6425dda8f5 Mon Sep 17 00:00:00 2001 From: Scott Schurr Date: Fri, 13 Nov 2020 15:09:18 -0800 Subject: [PATCH] Prefer std::optional over boost:optional: Some of the boost::optionals must remain for now. Both boost::beast and SOCI have interfaces that require boost::optional. --- src/ripple/app/consensus/RCLConsensus.cpp | 12 +- src/ripple/app/consensus/RCLConsensus.h | 6 +- src/ripple/app/consensus/RCLValidations.cpp | 4 +- src/ripple/app/consensus/RCLValidations.h | 4 +- .../app/ledger/AbstractFetchPackContainer.h | 6 +- src/ripple/app/ledger/AccountStateSF.cpp | 2 +- src/ripple/app/ledger/AccountStateSF.h | 2 +- src/ripple/app/ledger/ConsensusTransSetSF.cpp | 4 +- src/ripple/app/ledger/ConsensusTransSetSF.h | 2 +- src/ripple/app/ledger/Ledger.cpp | 25 ++- src/ripple/app/ledger/Ledger.h | 11 +- src/ripple/app/ledger/LedgerHistory.cpp | 26 +-- src/ripple/app/ledger/LedgerHistory.h | 18 +- src/ripple/app/ledger/LedgerMaster.h | 16 +- src/ripple/app/ledger/TransactionStateSF.cpp | 2 +- src/ripple/app/ledger/TransactionStateSF.h | 2 +- src/ripple/app/ledger/impl/LedgerCleaner.cpp | 4 +- src/ripple/app/ledger/impl/LedgerMaster.cpp | 44 ++-- src/ripple/app/main/Application.cpp | 8 +- src/ripple/app/main/BasicApp.cpp | 2 +- src/ripple/app/main/BasicApp.h | 4 +- src/ripple/app/main/GRPCServer.cpp | 2 +- src/ripple/app/main/NodeIdentity.cpp | 5 +- src/ripple/app/misc/AmendmentTable.h | 4 +- src/ripple/app/misc/HashRouter.h | 3 +- src/ripple/app/misc/Manifest.h | 26 +-- src/ripple/app/misc/NetworkOPs.cpp | 14 +- src/ripple/app/misc/NetworkOPs.h | 7 +- src/ripple/app/misc/SHAMapStore.h | 4 +- src/ripple/app/misc/SHAMapStoreImp.cpp | 10 +- src/ripple/app/misc/SHAMapStoreImp.h | 4 +- src/ripple/app/misc/Transaction.h | 12 +- src/ripple/app/misc/TxQ.h | 33 +-- src/ripple/app/misc/ValidatorList.h | 44 ++-- src/ripple/app/misc/impl/AccountTxPaging.cpp | 1 + src/ripple/app/misc/impl/AmendmentTable.cpp | 8 +- src/ripple/app/misc/impl/Manifest.cpp | 46 ++--- src/ripple/app/misc/impl/Transaction.cpp | 8 +- src/ripple/app/misc/impl/TxQ.cpp | 24 +-- src/ripple/app/misc/impl/ValidatorList.cpp | 36 ++-- src/ripple/app/paths/Flow.cpp | 6 +- src/ripple/app/paths/Flow.h | 4 +- src/ripple/app/paths/PathRequest.cpp | 4 +- src/ripple/app/paths/PathRequest.h | 8 +- src/ripple/app/paths/Pathfinder.cpp | 6 +- src/ripple/app/paths/Pathfinder.h | 6 +- src/ripple/app/paths/RippleCalc.cpp | 8 +- src/ripple/app/paths/impl/AmountSpec.h | 8 +- src/ripple/app/paths/impl/BookStep.cpp | 32 +-- src/ripple/app/paths/impl/DirectStep.cpp | 19 +- src/ripple/app/paths/impl/FlowDebugInfo.h | 4 +- src/ripple/app/paths/impl/PaySteps.cpp | 20 +- src/ripple/app/paths/impl/Steps.h | 44 ++-- src/ripple/app/paths/impl/StrandFlow.h | 40 ++-- src/ripple/app/paths/impl/XRPEndpointStep.cpp | 16 +- src/ripple/app/tx/impl/ApplyContext.h | 4 +- src/ripple/app/tx/impl/CashCheck.cpp | 2 +- src/ripple/app/tx/impl/CreateOffer.cpp | 2 +- src/ripple/app/tx/impl/OfferStream.cpp | 2 +- src/ripple/app/tx/impl/OfferStream.h | 2 +- src/ripple/app/tx/impl/PayChan.cpp | 2 +- src/ripple/app/tx/impl/Transactor.h | 1 - src/ripple/app/tx/impl/applySteps.cpp | 2 +- src/ripple/basics/BasicConfig.h | 12 +- src/ripple/basics/FileUtilities.h | 5 +- src/ripple/basics/RangeSet.h | 10 +- src/ripple/basics/StringUtilities.h | 12 +- src/ripple/basics/XRPAmount.h | 6 +- src/ripple/basics/impl/FileUtilities.cpp | 2 +- src/ripple/basics/impl/PerfLogImp.cpp | 2 +- src/ripple/basics/impl/StringUtilities.cpp | 4 +- .../beast/insight/impl/StatsDCollector.cpp | 6 +- src/ripple/beast/net/IPEndpoint.h | 7 +- src/ripple/beast/net/impl/IPEndpoint.cpp | 4 +- src/ripple/conditions/Fulfillment.h | 1 - src/ripple/conditions/impl/Condition.cpp | 1 - src/ripple/conditions/impl/Fulfillment.cpp | 1 - src/ripple/consensus/Consensus.h | 17 +- src/ripple/consensus/LedgerTrie.h | 22 +- src/ripple/consensus/Validations.h | 31 ++- src/ripple/core/ClosureCounter.h | 10 +- src/ripple/core/Config.h | 8 +- src/ripple/core/DatabaseCon.h | 4 +- src/ripple/core/impl/Config.cpp | 2 +- src/ripple/core/impl/DatabaseCon.cpp | 2 +- src/ripple/core/impl/SNTPClock.cpp | 6 +- src/ripple/ledger/ApplyView.h | 15 +- src/ripple/ledger/ApplyViewImpl.h | 3 +- src/ripple/ledger/BookDirs.h | 2 +- src/ripple/ledger/CachedView.h | 6 +- src/ripple/ledger/Directory.h | 2 +- src/ripple/ledger/OpenView.h | 4 +- src/ripple/ledger/PaymentSandbox.h | 4 +- src/ripple/ledger/RawView.h | 1 - src/ripple/ledger/ReadView.h | 14 +- src/ripple/ledger/TxMeta.h | 6 +- src/ripple/ledger/View.h | 9 +- src/ripple/ledger/detail/ApplyStateTable.h | 6 +- src/ripple/ledger/detail/ApplyViewBase.h | 4 +- src/ripple/ledger/detail/RawStateTable.h | 4 +- src/ripple/ledger/detail/ReadViewFwdRange.h | 2 +- src/ripple/ledger/impl/ApplyStateTable.cpp | 8 +- src/ripple/ledger/impl/ApplyView.cpp | 4 +- src/ripple/ledger/impl/ApplyViewBase.cpp | 4 +- src/ripple/ledger/impl/BookDirs.cpp | 2 +- src/ripple/ledger/impl/CashDiff.cpp | 5 +- src/ripple/ledger/impl/Directory.cpp | 2 +- src/ripple/ledger/impl/OpenView.cpp | 4 +- src/ripple/ledger/impl/PaymentSandbox.cpp | 9 +- src/ripple/ledger/impl/RawStateTable.cpp | 6 +- src/ripple/ledger/impl/ReadView.cpp | 3 +- src/ripple/ledger/impl/View.cpp | 15 +- src/ripple/net/DatabaseBody.h | 3 + src/ripple/net/HTTPStream.h | 6 +- src/ripple/net/impl/DatabaseBody.ipp | 2 + src/ripple/net/impl/HTTPClient.cpp | 4 +- src/ripple/net/impl/RPCCall.cpp | 1 - src/ripple/nodestore/DatabaseShard.h | 10 +- src/ripple/nodestore/README.md | 4 +- .../nodestore/impl/DatabaseShardImp.cpp | 58 +++--- src/ripple/nodestore/impl/DatabaseShardImp.h | 16 +- src/ripple/nodestore/impl/Shard.cpp | 19 +- src/ripple/nodestore/impl/Shard.h | 4 +- src/ripple/overlay/Cluster.h | 4 +- src/ripple/overlay/Message.h | 6 +- src/ripple/overlay/Overlay.h | 4 +- src/ripple/overlay/Peer.h | 2 +- src/ripple/overlay/PeerReservationTable.h | 11 +- src/ripple/overlay/impl/Cluster.cpp | 4 +- src/ripple/overlay/impl/ConnectAttempt.cpp | 2 +- src/ripple/overlay/impl/Message.cpp | 2 +- src/ripple/overlay/impl/OverlayImpl.cpp | 4 +- src/ripple/overlay/impl/OverlayImpl.h | 8 +- src/ripple/overlay/impl/PeerImp.cpp | 20 +- src/ripple/overlay/impl/PeerImp.h | 12 +- .../overlay/impl/PeerReservationTable.cpp | 12 +- src/ripple/overlay/impl/ProtocolVersion.cpp | 6 +- src/ripple/overlay/impl/ProtocolVersion.h | 6 +- src/ripple/peerfinder/Slot.h | 8 +- src/ripple/peerfinder/impl/Logic.h | 4 +- .../peerfinder/impl/PeerfinderManager.cpp | 8 +- src/ripple/peerfinder/impl/SlotImp.h | 14 +- src/ripple/peerfinder/impl/StoreSqdb.h | 1 + src/ripple/protocol/AccountID.h | 6 +- src/ripple/protocol/Feature.h | 6 +- src/ripple/protocol/KeyType.h | 4 +- src/ripple/protocol/PublicKey.h | 20 +- src/ripple/protocol/SField.h | 2 +- src/ripple/protocol/STExchange.h | 14 +- src/ripple/protocol/STObject.h | 64 +++--- src/ripple/protocol/STParsedJSON.h | 6 +- src/ripple/protocol/STPathSet.h | 8 +- src/ripple/protocol/SecretKey.h | 2 +- src/ripple/protocol/Seed.h | 6 +- src/ripple/protocol/TER.h | 4 +- src/ripple/protocol/impl/AccountID.cpp | 4 +- src/ripple/protocol/impl/Feature.cpp | 6 +- src/ripple/protocol/impl/PublicKey.cpp | 34 ++-- src/ripple/protocol/impl/STParsedJSON.cpp | 50 ++--- src/ripple/protocol/impl/STPathSet.cpp | 1 - src/ripple/protocol/impl/STTx.cpp | 3 +- src/ripple/protocol/impl/SecretKey.cpp | 6 +- src/ripple/protocol/impl/Seed.cpp | 12 +- src/ripple/protocol/impl/TER.cpp | 4 +- src/ripple/protocol/tokens.h | 6 +- src/ripple/rpc/handlers/AccountInfo.cpp | 8 +- src/ripple/rpc/handlers/AccountObjects.cpp | 2 +- src/ripple/rpc/handlers/BookOffers.cpp | 2 +- src/ripple/rpc/handlers/PayChanClaim.cpp | 14 +- src/ripple/rpc/handlers/Reservations.cpp | 7 +- src/ripple/rpc/handlers/Subscribe.cpp | 2 +- src/ripple/rpc/handlers/TxHistory.cpp | 1 + src/ripple/rpc/handlers/ValidationCreate.cpp | 2 +- src/ripple/rpc/handlers/WalletPropose.cpp | 5 +- src/ripple/rpc/impl/DeliveredAmount.cpp | 6 +- src/ripple/rpc/impl/GRPCHelpers.cpp | 8 +- src/ripple/rpc/impl/RPCHelpers.cpp | 28 +-- src/ripple/rpc/impl/RPCHelpers.h | 12 +- src/ripple/rpc/impl/ServerHandlerImp.cpp | 1 - src/ripple/rpc/impl/ShardArchiveHandler.cpp | 4 +- src/ripple/rpc/impl/TransactionSign.cpp | 8 +- src/ripple/rpc/json_body.h | 4 + src/ripple/server/Port.h | 9 +- src/ripple/server/impl/Port.cpp | 4 +- src/ripple/server/impl/ServerImpl.h | 8 +- src/ripple/shamap/SHAMapSyncFilter.h | 4 +- src/test/app/Flow_test.cpp | 2 +- src/test/app/LedgerReplay_test.cpp | 2 +- src/test/app/Manifest_test.cpp | 16 +- src/test/app/Path_test.cpp | 54 ++--- src/test/app/PayChan_test.cpp | 34 ++-- src/test/app/PayStrand_test.cpp | 86 ++++---- src/test/app/TheoreticalQuality_test.cpp | 30 +-- src/test/app/Ticket_test.cpp | 2 +- src/test/app/TxQ_test.cpp | 191 +++++++++--------- src/test/app/ValidatorList_test.cpp | 18 +- src/test/basics/RangeSet_test.cpp | 2 +- .../beast/beast_io_latency_probe_test.cpp | 11 +- src/test/consensus/LedgerTrie_test.cpp | 6 +- src/test/consensus/NegativeUNL_test.cpp | 4 +- src/test/consensus/Validations_test.cpp | 12 +- src/test/core/ClosureCounter_test.cpp | 12 +- src/test/core/Config_test.cpp | 6 +- src/test/core/SociDB_test.cpp | 2 + src/test/csf/Digraph.h | 11 +- src/test/csf/Peer.h | 4 +- src/test/csf/TrustGraph.h | 4 +- src/test/csf/Validation.h | 11 +- src/test/csf/collectors.h | 13 +- src/test/csf/impl/ledgers.cpp | 4 +- src/test/csf/ledgers.h | 4 +- src/test/jtx/Env.h | 3 +- src/test/jtx/Env_test.cpp | 9 +- src/test/jtx/JTx.h | 7 +- src/test/jtx/TrustedPublisherServer.h | 2 +- src/test/jtx/WSClient.h | 9 +- src/test/jtx/fee.h | 5 +- src/test/jtx/impl/Env.cpp | 4 +- src/test/jtx/impl/WSClient.cpp | 12 +- src/test/jtx/impl/multisign.cpp | 2 +- src/test/jtx/impl/paths.cpp | 2 +- src/test/jtx/memo.h | 1 - src/test/jtx/seq.h | 5 +- src/test/jtx/sig.h | 5 +- src/test/jtx/ter.h | 2 +- src/test/jtx/ticket.h | 4 +- src/test/ledger/SkipList_test.cpp | 12 +- src/test/ledger/View_test.cpp | 20 +- src/test/nodestore/DatabaseShard_test.cpp | 8 +- src/test/overlay/ProtocolVersion_test.cpp | 4 +- src/test/overlay/reduce_relay_test.cpp | 3 +- src/test/overlay/short_read_test.cpp | 10 +- src/test/protocol/InnerObjectFormats_test.cpp | 2 +- src/test/protocol/PublicKey_test.cpp | 44 ++-- src/test/protocol/STObject_test.cpp | 44 ++-- src/test/rpc/AccountCurrencies_test.cpp | 4 +- src/test/rpc/Book_test.cpp | 2 +- src/test/rpc/KeyGeneration_test.cpp | 18 +- src/test/rpc/Subscribe_test.cpp | 2 +- src/test/server/Server_test.cpp | 23 ++- src/test/shamap/FetchPack_test.cpp | 4 +- 241 files changed, 1293 insertions(+), 1248 deletions(-) diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 805cc8867..11c5ff6c3 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -115,7 +115,7 @@ RCLConsensus::Adaptor::Adaptor( } } -boost::optional +std::optional RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) { // we need to switch the ledger we're working from @@ -138,7 +138,7 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) id, 0, InboundLedger::Reason::CONSENSUS); }); } - return boost::none; + return std::nullopt; } assert(!built->open() && built->isImmutable()); @@ -244,14 +244,14 @@ RCLConsensus::Adaptor::share(RCLTxSet const& txns) inboundTransactions_.giveSet(txns.id(), txns.map_, false); } -boost::optional +std::optional RCLConsensus::Adaptor::acquireTxSet(RCLTxSet::ID const& setId) { if (auto txns = inboundTransactions_.getSet(setId, true)) { return RCLTxSet{std::move(txns)}; } - return boost::none; + return std::nullopt; } bool @@ -634,7 +634,7 @@ RCLConsensus::Adaptor::doAccept( std::lock(lock, sl); auto const lastVal = ledgerMaster_.getValidatedLedger(); - boost::optional rules; + std::optional rules; if (lastVal) rules.emplace(*lastVal, app_.config().features); else @@ -939,7 +939,7 @@ RCLConsensus::gotTxSet(NetClock::time_point const& now, RCLTxSet const& txSet) void RCLConsensus::simulate( NetClock::time_point const& now, - boost::optional consensusDelay) + std::optional consensusDelay) { std::lock_guard _{mutex_}; consensus_.simulate(now, consensusDelay); diff --git a/src/ripple/app/consensus/RCLConsensus.h b/src/ripple/app/consensus/RCLConsensus.h index 384a747fa..f8c01e93c 100644 --- a/src/ripple/app/consensus/RCLConsensus.h +++ b/src/ripple/app/consensus/RCLConsensus.h @@ -199,7 +199,7 @@ class RCLConsensus @param hash The ID/hash of the ledger acquire @return Optional ledger, will be seated if we locally had the ledger */ - boost::optional + std::optional acquireLedger(LedgerHash const& hash); /** Share the given proposal with all peers @@ -226,7 +226,7 @@ class RCLConsensus @param setId The transaction set ID associated with the proposal @return Optional set of transactions, seated if available. */ - boost::optional + std::optional acquireTxSet(RCLTxSet::ID const& setId); /** Whether the open ledger has any transactions @@ -506,7 +506,7 @@ public: void simulate( NetClock::time_point const& now, - boost::optional consensusDelay); + std::optional consensusDelay); //! @see Consensus::proposal bool diff --git a/src/ripple/app/consensus/RCLValidations.cpp b/src/ripple/app/consensus/RCLValidations.cpp index 7372cceb3..482fe175d 100644 --- a/src/ripple/app/consensus/RCLValidations.cpp +++ b/src/ripple/app/consensus/RCLValidations.cpp @@ -123,7 +123,7 @@ RCLValidationsAdaptor::now() const return app_.timeKeeper().closeTime(); } -boost::optional +std::optional RCLValidationsAdaptor::acquire(LedgerHash const& hash) { auto ledger = app_.getLedgerMaster().getLedgerByHash(hash); @@ -139,7 +139,7 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) pApp->getInboundLedgers().acquire( hash, 0, InboundLedger::Reason::CONSENSUS); }); - return boost::none; + return std::nullopt; } assert(!ledger->open() && ledger->isImmutable()); diff --git a/src/ripple/app/consensus/RCLValidations.h b/src/ripple/app/consensus/RCLValidations.h index 9324e0c83..93628fe16 100644 --- a/src/ripple/app/consensus/RCLValidations.h +++ b/src/ripple/app/consensus/RCLValidations.h @@ -120,7 +120,7 @@ public: } /// Get the load fee of the validation if it exists - boost::optional + std::optional loadFee() const { return ~(*val_)[~sfLoadFee]; @@ -218,7 +218,7 @@ public: now() const; /** Attempt to acquire the ledger with given id from the network */ - boost::optional + std::optional acquire(LedgerHash const& id); beast::Journal diff --git a/src/ripple/app/ledger/AbstractFetchPackContainer.h b/src/ripple/app/ledger/AbstractFetchPackContainer.h index 75ae08447..43552a757 100644 --- a/src/ripple/app/ledger/AbstractFetchPackContainer.h +++ b/src/ripple/app/ledger/AbstractFetchPackContainer.h @@ -22,7 +22,7 @@ #include #include -#include +#include namespace ripple { @@ -37,10 +37,10 @@ public: /** Retrieves partial ledger data of the coresponding hash from peers.` @param nodeHash The 256-bit hash of the data to fetch. - @return `boost::none` if the hash isn't cached, + @return `std::nullopt` if the hash isn't cached, otherwise, the hash associated data. */ - virtual boost::optional + virtual std::optional getFetchPack(uint256 const& nodeHash) = 0; }; diff --git a/src/ripple/app/ledger/AccountStateSF.cpp b/src/ripple/app/ledger/AccountStateSF.cpp index 1137fae13..5c66469d5 100644 --- a/src/ripple/app/ledger/AccountStateSF.cpp +++ b/src/ripple/app/ledger/AccountStateSF.cpp @@ -33,7 +33,7 @@ AccountStateSF::gotNode( hotACCOUNT_NODE, std::move(nodeData), nodeHash.as_uint256(), ledgerSeq); } -boost::optional +std::optional AccountStateSF::getNode(SHAMapHash const& nodeHash) const { return fp_.getFetchPack(nodeHash.as_uint256()); diff --git a/src/ripple/app/ledger/AccountStateSF.h b/src/ripple/app/ledger/AccountStateSF.h index 5829880d5..43822add5 100644 --- a/src/ripple/app/ledger/AccountStateSF.h +++ b/src/ripple/app/ledger/AccountStateSF.h @@ -44,7 +44,7 @@ public: Blob&& nodeData, SHAMapNodeType type) const override; - boost::optional + std::optional getNode(SHAMapHash const& nodeHash) const override; private: diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.cpp b/src/ripple/app/ledger/ConsensusTransSetSF.cpp index 5ae864438..881424ff1 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.cpp +++ b/src/ripple/app/ledger/ConsensusTransSetSF.cpp @@ -74,7 +74,7 @@ ConsensusTransSetSF::gotNode( } } -boost::optional +std::optional ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const { Blob nodeData; @@ -96,7 +96,7 @@ ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const return nodeData; } - return boost::none; + return std::nullopt; } } // namespace ripple diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.h b/src/ripple/app/ledger/ConsensusTransSetSF.h index a010a1ba3..ad5b2a23a 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.h +++ b/src/ripple/app/ledger/ConsensusTransSetSF.h @@ -47,7 +47,7 @@ public: Blob&& nodeData, SHAMapNodeType type) const override; - boost::optional + std::optional getNode(SHAMapHash const& nodeHash) const override; private: diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index e5b0bf3f6..40e2b7abe 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -417,14 +417,14 @@ Ledger::exists(uint256 const& key) const return stateMap_->hasItem(key); } -boost::optional -Ledger::succ(uint256 const& key, boost::optional const& last) const +std::optional +Ledger::succ(uint256 const& key, std::optional const& last) const { auto item = stateMap_->upper_bound(key); if (item == stateMap_->end()) - return boost::none; + return std::nullopt; if (last && item->key() >= last) - return boost::none; + return std::nullopt; return item->key(); } @@ -500,13 +500,13 @@ Ledger::txRead(key_type const& key) const -> tx_type } auto -Ledger::digest(key_type const& key) const -> boost::optional +Ledger::digest(key_type const& key) const -> std::optional { SHAMapHash digest; // VFALCO Unfortunately this loads the item // from the NodeStore needlessly. if (!stateMap_->peekItem(key, digest)) - return boost::none; + return std::nullopt; return digest.as_uint256(); } @@ -678,7 +678,7 @@ Ledger::negativeUNL() const return negUnl; } -boost::optional +std::optional Ledger::validatorToDisable() const { if (auto sle = read(keylet::negativeUNL()); @@ -690,10 +690,10 @@ Ledger::validatorToDisable() const return PublicKey(s); } - return boost::none; + return std::nullopt; } -boost::optional +std::optional Ledger::validatorToReEnable() const { if (auto sle = read(keylet::negativeUNL()); @@ -705,7 +705,7 @@ Ledger::validatorToReEnable() const return PublicKey(s); } - return boost::none; + return std::nullopt; } void @@ -1203,6 +1203,7 @@ loadLedgerHelper(std::string const& sqlSuffix, Application& app, bool acquire) auto db = app.getLedgerDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional sLedgerHash, sPrevHash, sAccountHash, sTransHash; boost::optional totDrops, closingTime, prevClosingTime, @@ -1615,6 +1616,7 @@ getHashByIndex(std::uint32_t ledgerIndex, Application& app) { auto db = app.getLedgerDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional lh; *db << sql, soci::into(lh); @@ -1642,6 +1644,7 @@ getHashesByIndex( ledgerIndex, ledgerHash, parentHash, app); auto db = app.getLedgerDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional lhO, phO; *db << "SELECT LedgerHash,PrevHash FROM Ledgers " @@ -1676,6 +1679,8 @@ getHashesByIndex(std::uint32_t minSeq, std::uint32_t maxSeq, Application& app) std::uint64_t ls; std::string lh; + + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional ph; soci::statement st = (db->prepare << sql, soci::into(ls), soci::into(lh), soci::into(ph)); diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index ca77002fc..0467beac5 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -31,7 +31,6 @@ #include #include #include -#include #include namespace ripple { @@ -175,8 +174,8 @@ public: bool exists(uint256 const& key) const; - boost::optional - succ(uint256 const& key, boost::optional const& last = boost::none) + std::optional + succ(uint256 const& key, std::optional const& last = std::nullopt) const override; std::shared_ptr @@ -207,7 +206,7 @@ public: // DigestAwareReadView // - boost::optional + std::optional digest(key_type const& key) const override; // @@ -361,7 +360,7 @@ public: * * @return the public key if any */ - boost::optional + std::optional validatorToDisable() const; /** @@ -369,7 +368,7 @@ public: * * @return the public key if any */ - boost::optional + std::optional validatorToReEnable() const; /** diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index bfb8d0b5a..f407b2064 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -323,8 +323,8 @@ void LedgerHistory::handleMismatch( LedgerHash const& built, LedgerHash const& valid, - boost::optional const& builtConsensusHash, - boost::optional const& validatedConsensusHash, + std::optional const& builtConsensusHash, + std::optional const& validatedConsensusHash, Json::Value const& consensus) { assert(built != valid); @@ -444,14 +444,14 @@ LedgerHistory::builtLedger( if (entry->validated && !entry->built) { - if (entry->validated.get() != hash) + if (entry->validated.value() != hash) { - JLOG(j_.error()) - << "MISMATCH: seq=" << index - << " validated:" << entry->validated.get() << " then:" << hash; + JLOG(j_.error()) << "MISMATCH: seq=" << index + << " validated:" << entry->validated.value() + << " then:" << hash; handleMismatch( hash, - entry->validated.get(), + entry->validated.value(), consensusHash, entry->validatedConsensusHash, consensus); @@ -471,7 +471,7 @@ LedgerHistory::builtLedger( void LedgerHistory::validatedLedger( std::shared_ptr const& ledger, - boost::optional const& consensusHash) + std::optional const& consensusHash) { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; @@ -484,17 +484,17 @@ LedgerHistory::validatedLedger( if (entry->built && !entry->validated) { - if (entry->built.get() != hash) + if (entry->built.value() != hash) { JLOG(j_.error()) - << "MISMATCH: seq=" << index << " built:" << entry->built.get() - << " then:" << hash; + << "MISMATCH: seq=" << index + << " built:" << entry->built.value() << " then:" << hash; handleMismatch( - entry->built.get(), + entry->built.value(), hash, entry->builtConsensusHash, consensusHash, - entry->consensus.get()); + entry->consensus.value()); } else { diff --git a/src/ripple/app/ledger/LedgerHistory.h b/src/ripple/app/ledger/LedgerHistory.h index 56a50e9ea..f8d4318db 100644 --- a/src/ripple/app/ledger/LedgerHistory.h +++ b/src/ripple/app/ledger/LedgerHistory.h @@ -26,6 +26,8 @@ #include #include +#include + namespace ripple { // VFALCO TODO Rename to OldLedgers ? @@ -95,7 +97,7 @@ public: void validatedLedger( std::shared_ptr const&, - boost::optional const& consensusHash); + std::optional const& consensusHash); /** Repair a hash to index mapping @param ledgerIndex The index whose mapping is to be repaired @@ -123,8 +125,8 @@ private: handleMismatch( LedgerHash const& built, LedgerHash const& valid, - boost::optional const& builtConsensusHash, - boost::optional const& validatedConsensusHash, + std::optional const& builtConsensusHash, + std::optional const& validatedConsensusHash, Json::Value const& consensus); Application& app_; @@ -140,15 +142,15 @@ private: struct cv_entry { // Hash of locally built ledger - boost::optional built; + std::optional built; // Hash of the validated ledger - boost::optional validated; + std::optional validated; // Hash of locally accepted consensus transaction set - boost::optional builtConsensusHash; + std::optional builtConsensusHash; // Hash of validated consensus transaction set - boost::optional validatedConsensusHash; + std::optional validatedConsensusHash; // Consensus metadata of built ledger - boost::optional consensus; + std::optional consensus; }; using ConsensusValidated = TaggedCache; ConsensusValidated m_consensus_validated; diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index 564870d1e..1a6cafa42 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include @@ -181,7 +181,7 @@ public: getHashBySeq(std::uint32_t index); /** Walk to a ledger's hash using the skip list */ - boost::optional + std::optional walkHashBySeq(std::uint32_t index, InboundLedger::Reason reason); /** Walk the chain of ledger hashes to determine the hash of the @@ -191,7 +191,7 @@ public: from the reference ledger or any prior ledger are not present in the node store. */ - boost::optional + std::optional walkHashBySeq( std::uint32_t index, std::shared_ptr const& referenceLedger, @@ -206,10 +206,10 @@ public: void setLedgerRangePresent(std::uint32_t minV, std::uint32_t maxV); - boost::optional + std::optional getCloseTimeBySeq(LedgerIndex ledgerIndex); - boost::optional + std::optional getCloseTimeByHash(LedgerHash const& ledgerHash, LedgerIndex ledgerIndex); void @@ -284,7 +284,7 @@ public: void addFetchPack(uint256 const& hash, std::shared_ptr data); - boost::optional + std::optional getFetchPack(uint256 const& hash) override; void @@ -305,7 +305,7 @@ public: } // Returns the minimum ledger sequence in SQL database, if any. - boost::optional + std::optional minSqlSeq(); private: @@ -320,7 +320,7 @@ private: void getFetchPack(LedgerIndex missing, InboundLedger::Reason reason); - boost::optional + std::optional getLedgerHashForHistory(LedgerIndex index, InboundLedger::Reason reason); std::size_t diff --git a/src/ripple/app/ledger/TransactionStateSF.cpp b/src/ripple/app/ledger/TransactionStateSF.cpp index e717eef9b..f65de5f99 100644 --- a/src/ripple/app/ledger/TransactionStateSF.cpp +++ b/src/ripple/app/ledger/TransactionStateSF.cpp @@ -38,7 +38,7 @@ TransactionStateSF::gotNode( ledgerSeq); } -boost::optional +std::optional TransactionStateSF::getNode(SHAMapHash const& nodeHash) const { return fp_.getFetchPack(nodeHash.as_uint256()); diff --git a/src/ripple/app/ledger/TransactionStateSF.h b/src/ripple/app/ledger/TransactionStateSF.h index c9cae3dc8..6a5fa69eb 100644 --- a/src/ripple/app/ledger/TransactionStateSF.h +++ b/src/ripple/app/ledger/TransactionStateSF.h @@ -44,7 +44,7 @@ public: Blob&& nodeData, SHAMapNodeType type) const override; - boost::optional + std::optional getNode(SHAMapHash const& nodeHash) const override; private: diff --git a/src/ripple/app/ledger/impl/LedgerCleaner.cpp b/src/ripple/app/ledger/impl/LedgerCleaner.cpp index d80913ad7..b9138b698 100644 --- a/src/ripple/app/ledger/impl/LedgerCleaner.cpp +++ b/src/ripple/app/ledger/impl/LedgerCleaner.cpp @@ -260,11 +260,11 @@ private: stopped(); } - // VFALCO TODO This should return boost::optional + // VFALCO TODO This should return std::optional LedgerHash getLedgerHash(std::shared_ptr& ledger, LedgerIndex index) { - boost::optional hash; + std::optional hash; try { hash = hashOfSeq(*ledger, index, j_); diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 586023737..864f5b1b7 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -156,7 +156,7 @@ static bool shouldAcquire( std::uint32_t const currentLedger, std::uint32_t const ledgerHistory, - boost::optional const minimumOnline, + std::optional const minimumOnline, std::uint32_t const candidateLedger, beast::Journal j) { @@ -328,7 +328,7 @@ void LedgerMaster::setValidLedger(std::shared_ptr const& l) { std::vector times; - boost::optional consensusHash; + std::optional consensusHash; if (!standalone_) { @@ -609,13 +609,13 @@ LedgerMaster::getFullValidatedRange( if (!maxVal) return false; - boost::optional maybeMin; + std::optional maybeMin; { std::lock_guard sl(mCompleteLock); maybeMin = prevMissing(mCompleteLedgers, maxVal); } - if (maybeMin == boost::none) + if (maybeMin == std::nullopt) minVal = maxVal; else minVal = 1 + *maybeMin; @@ -854,7 +854,7 @@ void LedgerMaster::fixMismatch(ReadView const& ledger) { int invalidate = 0; - boost::optional hash; + std::optional hash; for (std::uint32_t lSeq = ledger.info().seq - 1; lSeq > 0; --lSeq) { @@ -1293,13 +1293,13 @@ LedgerMaster::advanceThread() JLOG(m_journal.trace()) << "advanceThread>"; } -boost::optional +std::optional LedgerMaster::getLedgerHashForHistory( LedgerIndex index, InboundLedger::Reason reason) { // Try to get the hash of a ledger we need to fetch for history - boost::optional ret; + std::optional ret; auto const& l{ reason == InboundLedger::Reason::SHARD ? mShardLedger : mHistLedger}; @@ -1672,15 +1672,15 @@ LedgerMaster::getCompleteLedgers() return to_string(mCompleteLedgers); } -boost::optional +std::optional LedgerMaster::getCloseTimeBySeq(LedgerIndex ledgerIndex) { uint256 hash = getHashBySeq(ledgerIndex); return hash.isNonZero() ? getCloseTimeByHash(hash, ledgerIndex) - : boost::none; + : std::nullopt; } -boost::optional +std::optional LedgerMaster::getCloseTimeByHash( LedgerHash const& ledgerHash, std::uint32_t index) @@ -1699,7 +1699,7 @@ LedgerMaster::getCloseTimeByHash( } } - return boost::none; + return std::nullopt; } uint256 @@ -1713,10 +1713,10 @@ LedgerMaster::getHashBySeq(std::uint32_t index) return getHashByIndex(index, app_); } -boost::optional +std::optional LedgerMaster::walkHashBySeq(std::uint32_t index, InboundLedger::Reason reason) { - boost::optional ledgerHash; + std::optional ledgerHash; if (auto referenceLedger = mValidLedger.get()) ledgerHash = walkHashBySeq(index, referenceLedger, reason); @@ -1724,7 +1724,7 @@ LedgerMaster::walkHashBySeq(std::uint32_t index, InboundLedger::Reason reason) return ledgerHash; } -boost::optional +std::optional LedgerMaster::walkHashBySeq( std::uint32_t index, std::shared_ptr const& referenceLedger, @@ -1733,7 +1733,7 @@ LedgerMaster::walkHashBySeq( if (!referenceLedger || (referenceLedger->info().seq < index)) { // Nothing we can do. No validated ledger. - return boost::none; + return std::nullopt; } // See if the hash for the ledger we need is in the reference ledger @@ -2033,7 +2033,7 @@ LedgerMaster::doAdvance(std::unique_lock& sl) { // We are in sync, so can acquire InboundLedger::Reason reason = InboundLedger::Reason::HISTORY; - boost::optional missing; + std::optional missing; { std::lock_guard sll(mCompleteLock); missing = prevMissing( @@ -2057,7 +2057,7 @@ LedgerMaster::doAdvance(std::unique_lock& sl) << "advanceThread should acquire"; } else - missing = boost::none; + missing = std::nullopt; } if (!missing && mFillInProgress == 0) { @@ -2121,7 +2121,7 @@ LedgerMaster::addFetchPack(uint256 const& hash, std::shared_ptr data) fetch_packs_.canonicalize_replace_client(hash, data); } -boost::optional +std::optional LedgerMaster::getFetchPack(uint256 const& hash) { Blob data; @@ -2131,7 +2131,7 @@ LedgerMaster::getFetchPack(uint256 const& hash) if (hash == sha512Half(makeSlice(data))) return data; } - return boost::none; + return std::nullopt; } void @@ -2341,15 +2341,17 @@ LedgerMaster::getFetchPackCacheSize() const } // Returns the minimum ledger sequence in SQL database, if any. -boost::optional +std::optional LedgerMaster::minSqlSeq() { if (!app_.config().reporting()) { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional seq; auto db = app_.getLedgerDB().checkoutDb(); *db << "SELECT MIN(LedgerSeq) FROM Ledgers", soci::into(seq); - return seq; + if (seq) + return *seq; } #ifdef RIPPLED_REPORTING { diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 80765e22b..0baaae14f 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -81,6 +81,7 @@ #include #include #include +#include #include #include @@ -173,7 +174,7 @@ public: std::unique_ptr m_shaMapStore; PendingSaves pendingSaves_; AccountIDCache accountIDCache_; - boost::optional openLedger_; + std::optional openLedger_; // These are not Stoppable-derived NodeCache m_tempNodeCache; @@ -1006,7 +1007,7 @@ public: NodeStore::Manager::instance().make_Database( "NodeStore.import", megabytes(config_->getValueFor( - SizedItem::burstSize, boost::none)), + SizedItem::burstSize, std::nullopt)), dummyScheduler, 0, dummyRoot, @@ -1220,7 +1221,7 @@ public: DatabaseCon::Setup dbSetup = setup_DatabaseCon(*config_); boost::filesystem::path dbPath = dbSetup.dataDir / TxDBName; boost::system::error_code ec; - boost::optional dbSize = + std::optional dbSize = boost::filesystem::file_size(dbPath, ec); if (ec) { @@ -2278,6 +2279,7 @@ ApplicationImp::setMaxDisallowedLedger() } else { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional seq; { auto db = getLedgerDB().checkoutDb(); diff --git a/src/ripple/app/main/BasicApp.cpp b/src/ripple/app/main/BasicApp.cpp index 77a792065..5993df62f 100644 --- a/src/ripple/app/main/BasicApp.cpp +++ b/src/ripple/app/main/BasicApp.cpp @@ -37,7 +37,7 @@ BasicApp::BasicApp(std::size_t numberOfThreads) BasicApp::~BasicApp() { - work_ = boost::none; + work_.reset(); for (auto& t : threads_) t.join(); diff --git a/src/ripple/app/main/BasicApp.h b/src/ripple/app/main/BasicApp.h index e1038d71f..1c42a3d33 100644 --- a/src/ripple/app/main/BasicApp.h +++ b/src/ripple/app/main/BasicApp.h @@ -21,7 +21,7 @@ #define RIPPLE_APP_BASICAPP_H_INCLUDED #include -#include +#include #include #include @@ -29,7 +29,7 @@ class BasicApp { private: - boost::optional work_; + std::optional work_; std::vector threads_; boost::asio::io_service io_service_; diff --git a/src/ripple/app/main/GRPCServer.cpp b/src/ripple/app/main/GRPCServer.cpp index 6c2983ebe..14792cd90 100644 --- a/src/ripple/app/main/GRPCServer.cpp +++ b/src/ripple/app/main/GRPCServer.cpp @@ -43,7 +43,7 @@ getEndpoint(std::string const& peer) peerClean = peer.substr(first + 1); } - boost::optional endpoint = + std::optional endpoint = beast::IP::Endpoint::from_string_checked(peerClean); if (endpoint) return beast::IP::to_asio_endpoint(endpoint.value()); diff --git a/src/ripple/app/main/NodeIdentity.cpp b/src/ripple/app/main/NodeIdentity.cpp index 4ed6fb6f7..5e1d12c0d 100644 --- a/src/ripple/app/main/NodeIdentity.cpp +++ b/src/ripple/app/main/NodeIdentity.cpp @@ -48,12 +48,13 @@ loadNodeIdentity(Application& app) } // Try to load a node identity from the database: - boost::optional publicKey; - boost::optional secretKey; + std::optional publicKey; + std::optional secretKey; auto db = app.getWalletDB().checkoutDb(); { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional pubKO, priKO; soci::statement st = (db->prepare << "SELECT PublicKey, PrivateKey FROM NodeIdentity;", diff --git a/src/ripple/app/misc/AmendmentTable.h b/src/ripple/app/misc/AmendmentTable.h index e30c25e33..654efaf65 100644 --- a/src/ripple/app/misc/AmendmentTable.h +++ b/src/ripple/app/misc/AmendmentTable.h @@ -25,6 +25,8 @@ #include #include +#include + namespace ripple { /** The amendment table stores the list of enabled and potential amendments. @@ -61,7 +63,7 @@ public: virtual bool hasUnsupportedEnabled() const = 0; - virtual boost::optional + virtual std::optional firstUnsupportedExpected() const = 0; virtual Json::Value diff --git a/src/ripple/app/misc/HashRouter.h b/src/ripple/app/misc/HashRouter.h index ba2f9436d..a43bc1278 100644 --- a/src/ripple/app/misc/HashRouter.h +++ b/src/ripple/app/misc/HashRouter.h @@ -25,7 +25,8 @@ #include #include #include -#include + +#include namespace ripple { diff --git a/src/ripple/app/misc/Manifest.h b/src/ripple/app/misc/Manifest.h index fd9c4d949..254d1758a 100644 --- a/src/ripple/app/misc/Manifest.h +++ b/src/ripple/app/misc/Manifest.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -113,7 +113,7 @@ struct Manifest revoked() const; /// Returns manifest signature - boost::optional + std::optional getSignature() const; /// Returns manifest master key signature @@ -129,16 +129,16 @@ to_string(Manifest const& m); @param s Serialized manifest string - @return `boost::none` if string is invalid + @return `std::nullopt` if string is invalid @note This does not verify manifest signatures. `Manifest::verify` should be called after constructing manifest. */ /** @{ */ -boost::optional +std::optional deserializeManifest(Slice s); -inline boost::optional +inline std::optional deserializeManifest(std::string const& s) { return deserializeManifest(makeSlice(s)); @@ -148,7 +148,7 @@ template < class T, class = std::enable_if_t< std::is_same::value || std::is_same::value>> -boost::optional +std::optional deserializeManifest(std::vector const& v) { return deserializeManifest(makeSlice(v)); @@ -177,7 +177,7 @@ struct ValidatorToken SecretKey validationSecret; }; -boost::optional +std::optional loadValidatorToken(std::vector const& blob); enum class ManifestDisposition { @@ -278,25 +278,25 @@ public: /** Returns master key's current manifest sequence. @return sequence corresponding to Master public key - if configured or boost::none otherwise + if configured or std::nullopt otherwise */ - boost::optional + std::optional getSequence(PublicKey const& pk) const; /** Returns domain claimed by a given public key @return domain corresponding to Master public key - if present, otherwise boost::none + if present, otherwise std::nullopt */ - boost::optional + std::optional getDomain(PublicKey const& pk) const; /** Returns mainfest corresponding to a given public key @return manifest corresponding to Master public key - if present, otherwise boost::none + if present, otherwise std::nullopt */ - boost::optional + std::optional getManifest(PublicKey const& pk) const; /** Returns `true` if master key has been revoked in a manifest. diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 208ecb329..261abe025 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -211,7 +211,7 @@ class NetworkOPsImp final : public NetworkOPs std::uint32_t loadFactorServer = 256; std::uint32_t loadBaseServer = 256; XRPAmount baseFee{10}; - boost::optional em = boost::none; + std::optional em = std::nullopt; }; public: @@ -440,7 +440,7 @@ public: getLedgerFetchInfo() override; std::uint32_t acceptLedger( - boost::optional consensusDelay) override; + std::optional consensusDelay) override; uint256 getConsensusLCL() override; void @@ -1302,7 +1302,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) if (changed) reportFeeChange(); - boost::optional validatedLedgerIndex; + std::optional validatedLedgerIndex; if (auto const l = m_ledgerMaster.getValidatedLedger()) validatedLedgerIndex = l->info().seq; @@ -1714,7 +1714,7 @@ NetworkOPsImp::switchLastClosedLedger( auto retries = m_localTX->getTxSet(); auto const lastVal = app_.getLedgerMaster().getValidatedLedger(); - boost::optional rules; + std::optional rules; if (lastVal) rules.emplace(*lastVal, app_.config().features); else @@ -1959,7 +1959,7 @@ NetworkOPsImp::ServerFeeSummary::operator!=( { if (loadFactorServer != b.loadFactorServer || loadBaseServer != b.loadBaseServer || baseFee != b.baseFee || - em.is_initialized() != b.em.is_initialized()) + em.has_value() != b.em.has_value()) return true; if (em && b.em) @@ -2312,6 +2312,7 @@ NetworkOPsImp::getAccountTxs( { auto db = app_.getTxnDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional ledgerSeq; boost::optional status; soci::blob sociTxnBlob(*db), sociTxnMetaBlob(*db); @@ -2392,6 +2393,7 @@ NetworkOPsImp::getAccountTxsB( { auto db = app_.getTxnDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional ledgerSeq; boost::optional status; soci::blob sociTxnBlob(*db), sociTxnMetaBlob(*db); @@ -3456,7 +3458,7 @@ NetworkOPsImp::unsubBook(std::uint64_t uSeq, Book const& book) std::uint32_t NetworkOPsImp::acceptLedger( - boost::optional consensusDelay) + std::optional consensusDelay) { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` diff --git a/src/ripple/app/misc/NetworkOPs.h b/src/ripple/app/misc/NetworkOPs.h index 04ebe08af..e9643de4f 100644 --- a/src/ripple/app/misc/NetworkOPs.h +++ b/src/ripple/app/misc/NetworkOPs.h @@ -27,13 +27,12 @@ #include #include #include +#include #include #include #include #include -#include - namespace ripple { // Operations that clients may wish to perform against the network @@ -238,8 +237,8 @@ public: */ virtual std::uint32_t acceptLedger( - boost::optional consensusDelay = - boost::none) = 0; + std::optional consensusDelay = + std::nullopt) = 0; virtual uint256 getConsensusLCL() = 0; diff --git a/src/ripple/app/misc/SHAMapStore.h b/src/ripple/app/misc/SHAMapStore.h index e45cb30b2..eec3763ae 100644 --- a/src/ripple/app/misc/SHAMapStore.h +++ b/src/ripple/app/misc/SHAMapStore.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace ripple { @@ -90,7 +90,7 @@ public: @return The minimum ledger sequence to keep online based on the description above. If not set, then an unseated optional. */ - virtual boost::optional + virtual std::optional minimumOnline() const = 0; }; diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/ripple/app/misc/SHAMapStoreImp.cpp index 2c09db862..c5a97b547 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/ripple/app/misc/SHAMapStoreImp.cpp @@ -53,6 +53,7 @@ SHAMapStoreImp::SavedStateDB::init( std::int64_t count = 0; { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional countO; session_ << "SELECT COUNT(Key) FROM DbState WHERE Key = 1;", soci::into(countO); @@ -68,6 +69,7 @@ SHAMapStoreImp::SavedStateDB::init( } { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional countO; session_ << "SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;", soci::into(countO); @@ -275,7 +277,7 @@ SHAMapStoreImp::makeNodeStore(std::string const& name, std::int32_t readThreads) db = NodeStore::Manager::instance().make_Database( name, megabytes( - app_.config().getValueFor(SizedItem::burstSize, boost::none)), + app_.config().getValueFor(SizedItem::burstSize, std::nullopt)), scheduler_, readThreads, app_.getJobQueue(), @@ -584,7 +586,8 @@ SHAMapStoreImp::makeBackendRotating(std::string path) auto backend{NodeStore::Manager::instance().make_Backend( section, - megabytes(app_.config().getValueFor(SizedItem::burstSize, boost::none)), + megabytes( + app_.config().getValueFor(SizedItem::burstSize, std::nullopt)), scheduler_, app_.logs().journal(nodeStoreName_))}; backend->open(); @@ -602,6 +605,7 @@ SHAMapStoreImp::clearSql( LedgerIndex min = std::numeric_limits::max(); { + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional m; JLOG(journal_.trace()) << "Begin: Look up lowest value of: " << minQuery; @@ -781,7 +785,7 @@ SHAMapStoreImp::onStop() } } -boost::optional +std::optional SHAMapStoreImp::minimumOnline() const { // minimumOnline_ with 0 value is equivalent to unknown/not set. diff --git a/src/ripple/app/misc/SHAMapStoreImp.h b/src/ripple/app/misc/SHAMapStoreImp.h index 062b90dde..188788bb6 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.h +++ b/src/ripple/app/misc/SHAMapStoreImp.h @@ -115,7 +115,7 @@ private: /// for this time and check again so the node can /// recover. /// See also: "recovery_wait_seconds" in rippled-example.cfg - boost::optional recoveryWaitTime_; + std::optional recoveryWaitTime_; // these do not exist upon SHAMapStore creation, but do exist // as of run() or before @@ -189,7 +189,7 @@ public: int fdRequired() const override; - boost::optional + std::optional minimumOnline() const override; private: diff --git a/src/ripple/app/misc/Transaction.h b/src/ripple/app/misc/Transaction.h index 1d64e8172..68a65ca50 100644 --- a/src/ripple/app/misc/Transaction.h +++ b/src/ripple/app/misc/Transaction.h @@ -30,6 +30,8 @@ #include #include +#include + namespace ripple { // @@ -69,6 +71,8 @@ public: std::string&, Application&) noexcept; + // The two boost::optional parameters are because SOCI requires + // boost::optional (not std::optional) parameters. static Transaction::pointer transactionFromSQL( boost::optional const& ledgerSeq, @@ -76,6 +80,8 @@ public: Blob const& rawTxn, Application& app); + // The boost::optional parameter is because SOCI requires + // boost::optional (not std::optional) parameters. static TransStatus sqlTransactionStatus(boost::optional const& status); @@ -276,7 +282,7 @@ public: * @brief getCurrentLedgerState Get current ledger state of transaction * @return Current ledger state */ - boost::optional + std::optional getCurrentLedgerState() const { return currentLedgerState_; @@ -376,7 +382,7 @@ private: load( uint256 const& id, Application& app, - boost::optional> const& range, + std::optional> const& range, error_code_i& ec); uint256 mTransactionID; @@ -389,7 +395,7 @@ private: /** different ways for transaction to be accepted */ SubmitResult submitResult_; - boost::optional currentLedgerState_; + std::optional currentLedgerState_; std::shared_ptr mTransaction; Application& mApp; diff --git a/src/ripple/app/misc/TxQ.h b/src/ripple/app/misc/TxQ.h index 748032cfc..5f1d41c01 100644 --- a/src/ripple/app/misc/TxQ.h +++ b/src/ripple/app/misc/TxQ.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace ripple { @@ -112,7 +113,7 @@ public: @todo eahennis. This setting seems to go against our goals and values. Can it be removed? */ - boost::optional maximumTxnInLedger; + std::optional maximumTxnInLedger; /** When the ledger has more transactions than "expected", and performance is humming along nicely, the expected ledger size is updated to the previous ledger size plus this percentage. @@ -164,7 +165,7 @@ public: /// Number of transactions in the queue std::size_t txCount; /// Max transactions currently allowed in queue - boost::optional txQMaxSize; + std::optional txQMaxSize; /// Number of transactions currently in the open ledger std::size_t txInLedger; /// Number of transactions expected per ledger @@ -191,14 +192,14 @@ public: /// Full initialization TxDetails( FeeLevel64 feeLevel_, - boost::optional const& lastValid_, + std::optional const& lastValid_, TxConsequences const& consequences_, AccountID const& account_, SeqProxy seqProxy_, std::shared_ptr const& txn_, int retriesRemaining_, TER preflightResult_, - boost::optional lastResult_) + std::optional lastResult_) : feeLevel(feeLevel_) , lastValid(lastValid_) , consequences(consequences_) @@ -214,7 +215,7 @@ public: /// Fee level of the queued transaction FeeLevel64 feeLevel; /// LastValidLedger field of the queued transaction, if any - boost::optional lastValid; + std::optional lastValid; /** Potential @ref TxConsequences of applying the queued transaction to the open ledger. */ @@ -247,7 +248,7 @@ public: `tem`, or `tesSUCCESS`, because those results cause the transaction to be removed from the queue. */ - boost::optional lastResult; + std::optional lastResult; }; /// Constructor @@ -378,7 +379,7 @@ private: /// towards". std::size_t const targetTxnCount_; /// Maximum value of txnsExpected - boost::optional const maximumTxnCount_; + std::optional const maximumTxnCount_; /// Number of transactions expected per ledger. /// One more than this value will be accepted /// before escalation kicks in. @@ -407,7 +408,7 @@ private: ? *setup.maximumTxnInLedger < targetTxnCount_ ? targetTxnCount_ : *setup.maximumTxnInLedger - : boost::optional(boost::none)) + : std::optional(std::nullopt)) , txnsExpected_(minimumTxnCount_) , recentTxnCounts_(setup.ledgersInQueue) , escalationMultiplier_(setup.minimumEscalationMultiplier) @@ -524,7 +525,7 @@ private: AccountID const account; /// Expiration ledger for the transaction /// (`sfLastLedgerSequence` field). - boost::optional const lastValid; + std::optional const lastValid; /// Transaction SeqProxy number /// (`sfSequence` or `sfTicketSequence` field). SeqProxy const seqProxy; @@ -547,16 +548,16 @@ private: `tem`, or `tesSUCCESS`, because those results cause the transaction to be removed from the queue. */ - boost::optional lastResult; + std::optional lastResult; /** Cached result of the `preflight` operation. Because `preflight` is expensive, minimize the number of times it needs to be done. @invariant `pfresult` is never allowed to be empty. The - `boost::optional` is leveraged to allow `emplace`d + `std::optional` is leveraged to allow `emplace`d construction and replacement without a copy assignment operation. */ - boost::optional pfresult; + std::optional pfresult; /** Starting retry count for newly queued transactions. @@ -710,9 +711,9 @@ private: beast::Journal j); // Helper function that removes a replaced entry in _byFee. - boost::optional + std::optional removeFromByFee( - boost::optional const& replacedTxIter, + std::optional const& replacedTxIter, std::shared_ptr const& tx); using FeeHook = boost::intrusive::member_hook< @@ -754,7 +755,7 @@ private: @note This member must always and only be accessed under locked mutex_ */ - boost::optional maxSize_; + std::optional maxSize_; /** Most queue operations are done under the master lock, but use this mutex for the RPC "fee" command, which isn't. @@ -777,7 +778,7 @@ private: OpenView const&, std::shared_ptr const& sleAccount, AccountMap::iterator const&, - boost::optional const&, + std::optional const&, std::lock_guard const& lock); /// Erase and return the next entry in byFee_ (lower fee level) diff --git a/src/ripple/app/misc/ValidatorList.h b/src/ripple/app/misc/ValidatorList.h index 0365ca88f..0d7605fc0 100644 --- a/src/ripple/app/misc/ValidatorList.h +++ b/src/ripple/app/misc/ValidatorList.h @@ -121,7 +121,7 @@ struct ValidatorBlobInfo std::string signature; // base-64 or hex-encoded manifest containing the publisher's master and // signing public keys - boost::optional manifest; + std::optional manifest; }; /** @@ -187,7 +187,7 @@ class ValidatorList std::string rawSignature; // base-64 or hex-encoded manifest containing the publisher's master and // signing public keys - boost::optional rawManifest; + std::optional rawManifest; uint256 hash; }; @@ -214,7 +214,7 @@ class ValidatorList date. */ std::map remaining; - boost::optional maxSequence; + std::optional maxSequence; // The hash of the full set if sent in a single message uint256 fullHash; std::string rawManifest; @@ -231,7 +231,7 @@ class ValidatorList using shared_lock = std::shared_lock; std::atomic quorum_; - boost::optional minimumQuorum_; + std::optional minimumQuorum_; // Published lists stored by publisher master public key hash_map publisherLists_; @@ -267,7 +267,7 @@ public: TimeKeeper& timeKeeper, std::string const& databasePath, beast::Journal j, - boost::optional minimumQuorum = boost::none); + std::optional minimumQuorum = std::nullopt); ~ValidatorList() = default; /** Describes the result of processing a Validator List (UNL), @@ -295,7 +295,7 @@ public: // Tracks the dispositions of each processed list and how many times it // occurred std::map dispositions; - boost::optional publisherKey; + std::optional publisherKey; PublisherStatus status = PublisherStatus::unavailable; std::size_t sequence = 0; }; @@ -438,7 +438,7 @@ public: std::uint32_t version, std::vector const& blobs, std::string siteUri, - boost::optional const& hash = {}); + std::optional const& hash = {}); /* Attempt to read previously stored list files. Expected to only be called when loading from URL fails. @@ -520,26 +520,26 @@ public: @param identity Validation public key - @return `boost::none` if key is not trusted + @return `std::nullopt` if key is not trusted @par Thread Safety May be called concurrently */ - boost::optional + std::optional getTrustedKey(PublicKey const& identity) const; /** Returns listed master public if public key is included on any lists @param identity Validation public key - @return `boost::none` if key is not listed + @return `std::nullopt` if key is not listed @par Thread Safety May be called concurrently */ - boost::optional + std::optional getListedKey(PublicKey const& identity) const; /** Returns `true` if public key is a trusted publisher @@ -620,10 +620,10 @@ public: /** Returns the current valid list for the given publisher key, if available, as a Json object. */ - boost::optional + std::optional getAvailable( boost::beast::string_view const& pubKey, - boost::optional forceVersion = {}); + std::optional forceVersion = {}); /** Return the number of configured validator list sites. */ std::size_t @@ -632,13 +632,13 @@ public: /** Return the time when the validator list will expire @note This may be a time in the past if a published list has not - been updated since its validUntil. It will be boost::none if any + been updated since its validUntil. It will be std::nullopt if any configured published list has not been fetched. @par Thread Safety May be called concurrently */ - boost::optional + std::optional expires() const; /** Return a JSON representation of the state of the validator list @@ -712,25 +712,25 @@ private: @param identity Validation public key - @return `boost::none` if key is not trusted + @return `std::nullopt` if key is not trusted @par Thread Safety May be called concurrently */ - boost::optional + std::optional getTrustedKey(shared_lock const&, PublicKey const& identity) const; /** Return the time when the validator list will expire @note This may be a time in the past if a published list has not - been updated since its expiration. It will be boost::none if any + been updated since its expiration. It will be std::nullopt if any configured published list has not been fetched. @par Thread Safety May be called concurrently */ - boost::optional + std::optional expires(shared_lock const&) const; /** Apply published list of public keys @@ -758,12 +758,12 @@ private: PublisherListStats applyList( std::string const& globalManifest, - boost::optional const& localManifest, + std::optional const& localManifest, std::string const& blob, std::string const& signature, std::uint32_t version, std::string siteUri, - boost::optional const& hash, + std::optional const& hash, lock_guard const&); void @@ -825,7 +825,7 @@ private: buildFileData( std::string const& pubKey, PublisherListCollection const& pubCollection, - boost::optional forceVersion, + std::optional forceVersion, beast::Journal j); template diff --git a/src/ripple/app/misc/impl/AccountTxPaging.cpp b/src/ripple/app/misc/impl/AccountTxPaging.cpp index 7acf37c8a..fd274c342 100644 --- a/src/ripple/app/misc/impl/AccountTxPaging.cpp +++ b/src/ripple/app/misc/impl/AccountTxPaging.cpp @@ -194,6 +194,7 @@ accountTxPage( Blob rawData; Blob rawMeta; + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional ledgerSeq; boost::optional txnSeq; boost::optional status; diff --git a/src/ripple/app/misc/impl/AmendmentTable.cpp b/src/ripple/app/misc/impl/AmendmentTable.cpp index ffb259729..633a8ece3 100644 --- a/src/ripple/app/misc/impl/AmendmentTable.cpp +++ b/src/ripple/app/misc/impl/AmendmentTable.cpp @@ -216,7 +216,7 @@ private: // Unset if no unsupported amendments reach majority, // else set to the earliest time an unsupported amendment // will be enabled. - boost::optional firstUnsupportedExpected_; + std::optional firstUnsupportedExpected_; beast::Journal const j_; @@ -276,7 +276,7 @@ public: bool hasUnsupportedEnabled() const override; - boost::optional + std::optional firstUnsupportedExpected() const override; Json::Value @@ -332,6 +332,7 @@ AmendmentTableImpl::AmendmentTableImpl( std::string sql = "SELECT count(*) FROM sqlite_master " "WHERE type='table' AND name='FeatureVotes'"; + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional featureVotesCount; *db << sql, soci::into(featureVotesCount); bool exists = static_cast(*featureVotesCount); @@ -410,6 +411,7 @@ AmendmentTableImpl::AmendmentTableImpl( soci::transaction tr(*db); std::string sql = "SELECT AmendmentHash, AmendmentName, Veto FROM FeatureVotes"; + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional amendment_hash; boost::optional amendment_name; boost::optional vote_to_veto; @@ -588,7 +590,7 @@ AmendmentTableImpl::hasUnsupportedEnabled() const return unsupportedEnabled_; } -boost::optional +std::optional AmendmentTableImpl::firstUnsupportedExpected() const { std::lock_guard sl(mutex_); diff --git a/src/ripple/app/misc/impl/Manifest.cpp b/src/ripple/app/misc/impl/Manifest.cpp index f0f70d0b1..e889fcbd3 100644 --- a/src/ripple/app/misc/impl/Manifest.cpp +++ b/src/ripple/app/misc/impl/Manifest.cpp @@ -46,11 +46,11 @@ to_string(Manifest const& m) toBase58(TokenType::NodePublic, m.signingKey) + ")"; } -boost::optional +std::optional deserializeManifest(Slice s) { if (s.empty()) - return boost::none; + return std::nullopt; static SOTemplate const manifestFormat{ // A manifest must include: @@ -86,12 +86,12 @@ deserializeManifest(Slice s) // We only understand "version 0" manifests at this time: if (st.isFieldPresent(sfVersion) && st.getFieldU16(sfVersion) != 0) - return boost::none; + return std::nullopt; auto const pk = st.getFieldVL(sfPublicKey); if (!publicKeyType(makeSlice(pk))) - return boost::none; + return std::nullopt; Manifest m; m.serialized.assign(reinterpret_cast(s.data()), s.size()); @@ -105,7 +105,7 @@ deserializeManifest(Slice s) m.domain.assign(reinterpret_cast(d.data()), d.size()); if (!isProperlyFormedTomlDomain(m.domain)) - return boost::none; + return std::nullopt; } bool const hasEphemeralKey = st.isFieldPresent(sfSigningPubKey); @@ -116,38 +116,38 @@ deserializeManifest(Slice s) // Revocation manifests should not specify a new signing key // or a signing key signature. if (hasEphemeralKey) - return boost::none; + return std::nullopt; if (hasEphemeralSig) - return boost::none; + return std::nullopt; } else { // Regular manifests should contain a signing key and an // associated signature. if (!hasEphemeralKey) - return boost::none; + return std::nullopt; if (!hasEphemeralSig) - return boost::none; + return std::nullopt; auto const spk = st.getFieldVL(sfSigningPubKey); if (!publicKeyType(makeSlice(spk))) - return boost::none; + return std::nullopt; m.signingKey = PublicKey(makeSlice(spk)); // The signing and master keys can't be the same if (m.signingKey == m.masterKey) - return boost::none; + return std::nullopt; } return m; } catch (std::exception const&) { - return boost::none; + return std::nullopt; } } @@ -215,14 +215,14 @@ Manifest::revoked() const return sequence == std::numeric_limits::max(); } -boost::optional +std::optional Manifest::getSignature() const { STObject st(sfGeneric); SerialIter sit(serialized.data(), serialized.size()); st.set(sit); if (!get(st, sfSignature)) - return boost::none; + return std::nullopt; return st.getFieldVL(sfSignature); } @@ -235,7 +235,7 @@ Manifest::getMasterSignature() const return st.getFieldVL(sfMasterSignature); } -boost::optional +std::optional loadValidatorToken(std::vector const& blob) { try @@ -272,11 +272,11 @@ loadValidatorToken(std::vector const& blob) } } - return boost::none; + return std::nullopt; } catch (std::exception const&) { - return boost::none; + return std::nullopt; } } @@ -304,7 +304,7 @@ ManifestCache::getMasterKey(PublicKey const& pk) const return pk; } -boost::optional +std::optional ManifestCache::getSequence(PublicKey const& pk) const { std::lock_guard lock{read_mutex_}; @@ -313,10 +313,10 @@ ManifestCache::getSequence(PublicKey const& pk) const if (iter != map_.end() && !iter->second.revoked()) return iter->second.sequence; - return boost::none; + return std::nullopt; } -boost::optional +std::optional ManifestCache::getDomain(PublicKey const& pk) const { std::lock_guard lock{read_mutex_}; @@ -325,10 +325,10 @@ ManifestCache::getDomain(PublicKey const& pk) const if (iter != map_.end() && !iter->second.revoked()) return iter->second.domain; - return boost::none; + return std::nullopt; } -boost::optional +std::optional ManifestCache::getManifest(PublicKey const& pk) const { std::lock_guard lock{read_mutex_}; @@ -337,7 +337,7 @@ ManifestCache::getManifest(PublicKey const& pk) const if (iter != map_.end() && !iter->second.revoked()) return iter->second.serialized; - return boost::none; + return std::nullopt; } bool diff --git a/src/ripple/app/misc/impl/Transaction.cpp b/src/ripple/app/misc/impl/Transaction.cpp index cba97ace8..007150d8d 100644 --- a/src/ripple/app/misc/impl/Transaction.cpp +++ b/src/ripple/app/misc/impl/Transaction.cpp @@ -30,7 +30,6 @@ #include #include #include -#include namespace ripple { @@ -112,7 +111,7 @@ std::variant< TxSearched> Transaction::load(uint256 const& id, Application& app, error_code_i& ec) { - return load(id, app, boost::none, ec); + return load(id, app, std::nullopt, ec); } std::variant< @@ -124,7 +123,7 @@ Transaction::load( ClosedInterval const& range, error_code_i& ec) { - using op = boost::optional>; + using op = std::optional>; return load(id, app, op{range}, ec); } @@ -211,7 +210,7 @@ std::variant< Transaction::load( uint256 const& id, Application& app, - boost::optional> const& range, + std::optional> const& range, error_code_i& ec) { std::string sql = @@ -221,6 +220,7 @@ Transaction::load( sql.append(to_string(id)); sql.append("';"); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional ledgerSeq; boost::optional status; Blob rawTxn, rawMeta; diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index 2d6768552..bf6ef060e 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -63,11 +63,11 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return FeeLevel64(std::numeric_limits::max()); } -static boost::optional +static std::optional getLastLedgerSequence(STTx const& tx) { if (!tx.isFieldPresent(sfLastLedgerSequence)) - return boost::none; + return std::nullopt; return tx.getFieldU32(sfLastLedgerSequence); } @@ -348,7 +348,7 @@ TxQ::TxQAccount::remove(SeqProxy seqProx) ////////////////////////////////////////////////////////////////////////// TxQ::TxQ(Setup const& setup, beast::Journal j) - : setup_(setup), j_(j), feeMetrics_(setup, j), maxSize_(boost::none) + : setup_(setup), j_(j), feeMetrics_(setup, j), maxSize_(std::nullopt) { } @@ -373,7 +373,7 @@ TxQ::canBeHeld( OpenView const& view, std::shared_ptr const& sleAccount, AccountMap::iterator const& accountIter, - boost::optional const& replacementIter, + std::optional const& replacementIter, std::lock_guard const& lock) { // PreviousTxnID is deprecated and should never be used. @@ -801,10 +801,10 @@ TxQ::apply( TxQAccount::TxMap::iterator end; }; - boost::optional const txIter = + std::optional const txIter = [accountIter, accountIsInQueue, - acctSeqProx]() -> boost::optional { + acctSeqProx]() -> std::optional { if (!accountIsInQueue) return {}; @@ -853,7 +853,7 @@ TxQ::apply( // If the transaction is intending to replace a transaction in the queue // identify the one that might be replaced. auto replacedTxIter = [accountIsInQueue, &accountIter, txSeqProx]() - -> boost::optional { + -> std::optional { if (accountIsInQueue) { TxQAccount& txQAcct = accountIter->second; @@ -936,7 +936,7 @@ TxQ::apply( } }; - boost::optional multiTxn; + std::optional multiTxn; if (acctTxCount == 0) { @@ -1178,7 +1178,7 @@ TxQ::apply( conditions change, but don't waste the effort to clear). */ if (!(flags & tapPREFER_QUEUE) && txSeqProx.isSeq() && txIter && - multiTxn.is_initialized() && + multiTxn.has_value() && txIter->first->second.retriesRemaining == MaybeTx::retriesAllowed && feeLevelPaid > requiredFeeLevel && requiredFeeLevel > baseLevel) { @@ -1693,9 +1693,9 @@ TxQ::tryDirectApply( return {}; } -boost::optional +std::optional TxQ::removeFromByFee( - boost::optional const& replacedTxIter, + std::optional const& replacedTxIter, std::shared_ptr const& tx) { if (replacedTxIter && tx) @@ -1710,7 +1710,7 @@ TxQ::removeFromByFee( erase(deleteIter); } - return boost::none; + return std::nullopt; } TxQ::Metrics diff --git a/src/ripple/app/misc/impl/ValidatorList.cpp b/src/ripple/app/misc/impl/ValidatorList.cpp index 8105acbad..bda38fe05 100644 --- a/src/ripple/app/misc/impl/ValidatorList.cpp +++ b/src/ripple/app/misc/impl/ValidatorList.cpp @@ -123,7 +123,7 @@ ValidatorList::ValidatorList( TimeKeeper& timeKeeper, std::string const& databasePath, beast::Journal j, - boost::optional minimumQuorum) + std::optional minimumQuorum) : validatorManifests_(validatorManifests) , publisherManifests_(publisherManifests) , timeKeeper_(timeKeeper) @@ -271,7 +271,7 @@ Json::Value ValidatorList::buildFileData( std::string const& pubKey, ValidatorList::PublisherListCollection const& pubCollection, - boost::optional forceVersion, + std::optional forceVersion, beast::Journal j) { Json::Value value(Json::objectValue); @@ -508,7 +508,7 @@ splitMessageParts( } else { - boost::optional smallMsg; + std::optional smallMsg; smallMsg.emplace(); smallMsg->set_version(largeMsg.version()); smallMsg->set_manifest(largeMsg.manifest()); @@ -926,7 +926,7 @@ ValidatorList::applyLists( std::uint32_t version, std::vector const& blobs, std::string siteUri, - boost::optional const& hash /* = {} */) + std::optional const& hash /* = {} */) { if (std::count( std::begin(supportedListVersions), @@ -1061,12 +1061,12 @@ ValidatorList::updatePublisherList( ValidatorList::PublisherListStats ValidatorList::applyList( std::string const& globalManifest, - boost::optional const& localManifest, + std::optional const& localManifest, std::string const& blob, std::string const& signature, std::uint32_t version, std::string siteUri, - boost::optional const& hash, + std::optional const& hash, ValidatorList::lock_guard const& lock) { using namespace std::string_literals; @@ -1159,7 +1159,7 @@ ValidatorList::applyList( if (val.isObject() && val.isMember(jss::validation_public_key) && val[jss::validation_public_key].isString()) { - boost::optional const ret = + std::optional const ret = strUnHex(val[jss::validation_public_key].asString()); if (!ret || !publicKeyType(makeSlice(*ret))) @@ -1372,7 +1372,7 @@ ValidatorList::trusted(PublicKey const& identity) const return trusted(read_lock, identity); } -boost::optional +std::optional ValidatorList::getListedKey(PublicKey const& identity) const { std::shared_lock read_lock{mutex_}; @@ -1380,10 +1380,10 @@ ValidatorList::getListedKey(PublicKey const& identity) const auto const pubKey = validatorManifests_.getMasterKey(identity); if (keyListings_.find(pubKey) != keyListings_.end()) return pubKey; - return boost::none; + return std::nullopt; } -boost::optional +std::optional ValidatorList::getTrustedKey( ValidatorList::shared_lock const&, PublicKey const& identity) const @@ -1391,10 +1391,10 @@ ValidatorList::getTrustedKey( auto const pubKey = validatorManifests_.getMasterKey(identity); if (trustedMasterKeys_.find(pubKey) != trustedMasterKeys_.end()) return pubKey; - return boost::none; + return std::nullopt; } -boost::optional +std::optional ValidatorList::getTrustedKey(PublicKey const& identity) const { std::shared_lock read_lock{mutex_}; @@ -1464,17 +1464,17 @@ ValidatorList::count() const return count(read_lock); } -boost::optional +std::optional ValidatorList::expires(ValidatorList::shared_lock const&) const { - boost::optional res{boost::none}; + std::optional res{}; for (auto const& [pubKey, collection] : publisherLists_) { (void)pubKey; // Unfetched auto const& current = collection.current; if (current.validUntil == TimeKeeper::time_point{}) - return boost::none; + return std::nullopt; // Find the latest validUntil in a chain where the next validFrom // overlaps with the previous validUntil. applyLists has already cleaned @@ -1498,7 +1498,7 @@ ValidatorList::expires(ValidatorList::shared_lock const&) const return res; } -boost::optional +std::optional ValidatorList::expires() const { std::shared_lock read_lock{mutex_}; @@ -1676,10 +1676,10 @@ ValidatorList::for_each_available( } } -boost::optional +std::optional ValidatorList::getAvailable( boost::beast::string_view const& pubKey, - boost::optional forceVersion /* = {} */) + std::optional forceVersion /* = {} */) { std::shared_lock read_lock{mutex_}; diff --git a/src/ripple/app/paths/Flow.cpp b/src/ripple/app/paths/Flow.cpp index c939af9f0..f177cfc11 100644 --- a/src/ripple/app/paths/Flow.cpp +++ b/src/ripple/app/paths/Flow.cpp @@ -65,8 +65,8 @@ flow( bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, - boost::optional const& limitQuality, - boost::optional const& sendMax, + std::optional const& limitQuality, + std::optional const& sendMax, beast::Journal j, path::detail::FlowDebugInfo* flowDebugInfo) { @@ -80,7 +80,7 @@ flow( Issue const dstIssue = deliver.issue(); - boost::optional sendMaxIssue; + std::optional sendMaxIssue; if (sendMax) sendMaxIssue = sendMax->issue(); diff --git a/src/ripple/app/paths/Flow.h b/src/ripple/app/paths/Flow.h index 70128b095..b692c3bdf 100644 --- a/src/ripple/app/paths/Flow.h +++ b/src/ripple/app/paths/Flow.h @@ -63,8 +63,8 @@ flow( bool partialPayment, bool ownerPaysTransferFee, bool offerCrossing, - boost::optional const& limitQuality, - boost::optional const& sendMax, + std::optional const& limitQuality, + std::optional const& sendMax, beast::Journal j, path::detail::FlowDebugInfo* flowDebugInfo = nullptr); diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index c0276dec9..489f271cc 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include @@ -474,7 +474,7 @@ PathRequest::getPathFinder( *raSrcAccount, *raDstAccount, currency, - boost::none, + std::nullopt, dst_amount, saSendMax, app_); diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index 4cba34fba..704414d03 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -26,9 +26,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -139,10 +139,10 @@ private: Json::Value jvStatus; // Last result // Client request parameters - boost::optional raSrcAccount; - boost::optional raDstAccount; + std::optional raSrcAccount; + std::optional raDstAccount; STAmount saDstAmount; - boost::optional saSendMax; + std::optional saSendMax; std::set sciSourceCurrencies; std::map mContext; diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/ripple/app/paths/Pathfinder.cpp index 1e698f3b5..f6908e29a 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/ripple/app/paths/Pathfinder.cpp @@ -159,9 +159,9 @@ Pathfinder::Pathfinder( AccountID const& uSrcAccount, AccountID const& uDstAccount, Currency const& uSrcCurrency, - boost::optional const& uSrcIssuer, + std::optional const& uSrcIssuer, STAmount const& saDstAmount, - boost::optional const& srcAmount, + std::optional const& srcAmount, Application& app) : mSrcAccount(uSrcAccount) , mDstAccount(uDstAccount) @@ -184,7 +184,7 @@ Pathfinder::Pathfinder( , app_(app) , j_(app.journal("Pathfinder")) { - assert(!uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.get())); + assert(!uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); } bool diff --git a/src/ripple/app/paths/Pathfinder.h b/src/ripple/app/paths/Pathfinder.h index d34a6fa38..aa40b1432 100644 --- a/src/ripple/app/paths/Pathfinder.h +++ b/src/ripple/app/paths/Pathfinder.h @@ -43,9 +43,9 @@ public: AccountID const& srcAccount, AccountID const& dstAccount, Currency const& uSrcCurrency, - boost::optional const& uSrcIssuer, + std::optional const& uSrcIssuer, STAmount const& dstAmount, - boost::optional const& srcAmount, + std::optional const& srcAmount, Application& app); Pathfinder(Pathfinder const&) = delete; Pathfinder& @@ -185,7 +185,7 @@ private: AccountID mEffectiveDst; // The account the paths need to end at STAmount mDstAmount; Currency mSrcCurrency; - boost::optional mSrcIssuer; + std::optional mSrcIssuer; STAmount mSrcAmount; /** The amount remaining from mSrcAccount after the default liquidity has been removed. */ diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/ripple/app/paths/RippleCalc.cpp index 6fc644bad..83da1398c 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/ripple/app/paths/RippleCalc.cpp @@ -76,21 +76,21 @@ RippleCalc::rippleCalculate( bool const partialPayment = !pInputs ? false : pInputs->partialPaymentAllowed; - auto const limitQuality = [&]() -> boost::optional { + auto const limitQuality = [&]() -> std::optional { if (pInputs && pInputs->limitQuality && saMaxAmountReq > beast::zero) return Quality{Amounts(saMaxAmountReq, saDstAmountReq)}; - return boost::none; + return std::nullopt; }(); - auto const sendMax = [&]() -> boost::optional { + auto const sendMax = [&]() -> std::optional { if (saMaxAmountReq >= beast::zero || saMaxAmountReq.getCurrency() != saDstAmountReq.getCurrency() || saMaxAmountReq.getIssuer() != uSrcAccountID) { return saMaxAmountReq; } - return boost::none; + return std::nullopt; }(); bool const ownerPaysTransferFee = diff --git a/src/ripple/app/paths/impl/AmountSpec.h b/src/ripple/app/paths/impl/AmountSpec.h index c1adfc15d..927c3d72f 100644 --- a/src/ripple/app/paths/impl/AmountSpec.h +++ b/src/ripple/app/paths/impl/AmountSpec.h @@ -24,6 +24,8 @@ #include #include +#include + namespace ripple { struct AmountSpec @@ -36,8 +38,8 @@ struct AmountSpec XRPAmount xrp; IOUAmount iou; }; - boost::optional issuer; - boost::optional currency; + std::optional issuer; + std::optional currency; friend std::ostream& operator<<(std::ostream& stream, AmountSpec const& amt) @@ -192,7 +194,7 @@ toEitherAmount(STAmount const& amt) } inline AmountSpec -toAmountSpec(EitherAmount const& ea, boost::optional const& c) +toAmountSpec(EitherAmount const& ea, std::optional const& c) { AmountSpec r; r.native = (!c || isXRP(*c)); diff --git a/src/ripple/app/paths/impl/BookStep.cpp b/src/ripple/app/paths/impl/BookStep.cpp index dfb404116..c0fd87458 100644 --- a/src/ripple/app/paths/impl/BookStep.cpp +++ b/src/ripple/app/paths/impl/BookStep.cpp @@ -72,7 +72,7 @@ protected: } }; - boost::optional cache_; + std::optional cache_; static uint32_t getMaxOffersToConsume(StrandContext const& ctx) @@ -100,19 +100,19 @@ public: return book_; } - boost::optional + std::optional cachedIn() const override { if (!cache_) - return boost::none; + return std::nullopt; return EitherAmount(cache_->in); } - boost::optional + std::optional cachedOut() const override { if (!cache_) - return boost::none; + return std::nullopt; return EitherAmount(cache_->out); } @@ -123,13 +123,13 @@ public: : DebtDirection::redeems; } - boost::optional + std::optional bookStepBook() const override { return book_; } - std::pair, DebtDirection> + std::pair, DebtDirection> qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const override; @@ -239,7 +239,7 @@ public: AccountID const&, AccountID const&, TOffer const& offer, - boost::optional&, + std::optional&, FlowOfferStream&, bool) const { @@ -319,7 +319,7 @@ private: // Helper function that throws if the optional passed to the constructor // is none. static Quality - getQuality(boost::optional const& limitQuality) + getQuality(std::optional const& limitQuality) { // It's really a programming error if the quality is missing. assert(limitQuality); @@ -344,7 +344,7 @@ public: AccountID const& strandSrc, AccountID const& strandDst, TOffer const& offer, - boost::optional& ofrQ, + std::optional& ofrQ, FlowOfferStream& offers, bool const offerAttempted) const { @@ -386,7 +386,7 @@ public: // If no offers have been attempted yet then it's okay to move to // a different quality. if (!offerAttempted) - ofrQ = boost::none; + ofrQ = std::nullopt; // Return true so the current offer will be deleted. return true; @@ -411,7 +411,7 @@ public: std::uint32_t trIn) const { auto const srcAcct = - prevStep ? prevStep->directStepSrcAcct() : boost::none; + prevStep ? prevStep->directStepSrcAcct() : std::nullopt; return // If offer crossing srcAcct && // && prevStep is DirectI @@ -473,7 +473,7 @@ BookStep::equal(Step const& rhs) const } template -std::pair, DebtDirection> +std::pair, DebtDirection> BookStep::qualityUpperBound( ReadView const& v, DebtDirection prevStepDir) const @@ -484,7 +484,7 @@ BookStep::qualityUpperBound( Sandbox sb(&v, tapNONE); BookTip bt(sb, book_); if (!bt.step(j_)) - return {boost::none, dir}; + return {std::nullopt, dir}; Quality const q = static_cast(this)->adjustQualityWithFees( v, bt.quality(), prevStepDir); @@ -579,7 +579,7 @@ BookStep::forEachOffer( bool const flowCross = afView.rules().enabled(featureFlowCross); bool offerAttempted = false; - boost::optional ofrQ; + std::optional ofrQ; while (offers.step()) { auto& offer = offers.tip(); @@ -619,7 +619,7 @@ BookStep::forEachOffer( offers.permRmOffer(offer.key()); if (!offerAttempted) // Change quality only if no previous offers were tried. - ofrQ = boost::none; + ofrQ = std::nullopt; // This continue causes offers.step() to delete the offer. continue; } diff --git a/src/ripple/app/paths/impl/DirectStep.cpp b/src/ripple/app/paths/impl/DirectStep.cpp index 0056f3bab..00647121b 100644 --- a/src/ripple/app/paths/impl/DirectStep.cpp +++ b/src/ripple/app/paths/impl/DirectStep.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -64,7 +63,7 @@ protected: } }; - boost::optional cache_; + std::optional cache_; // Compute the maximum value that can flow from src->dst at // the best available quality. @@ -120,29 +119,29 @@ public: return currency_; } - boost::optional + std::optional cachedIn() const override { if (!cache_) - return boost::none; + return std::nullopt; return EitherAmount(cache_->in); } - boost::optional + std::optional cachedOut() const override { if (!cache_) - return boost::none; + return std::nullopt; return EitherAmount(cache_->out); } - boost::optional + std::optional directStepSrcAcct() const override { return src_; } - boost::optional> + std::optional> directStepAccts() const override { return std::make_pair(src_, dst_); @@ -154,7 +153,7 @@ public: std::uint32_t lineQualityIn(ReadView const& v) const override; - std::pair, DebtDirection> + std::pair, DebtDirection> qualityUpperBound(ReadView const& v, DebtDirection dir) const override; std::pair @@ -831,7 +830,7 @@ DirectStepI::lineQualityIn(ReadView const& v) const } template -std::pair, DebtDirection> +std::pair, DebtDirection> DirectStepI::qualityUpperBound( ReadView const& v, DebtDirection prevStepDir) const diff --git a/src/ripple/app/paths/impl/FlowDebugInfo.h b/src/ripple/app/paths/impl/FlowDebugInfo.h index eeb5625d3..2d1728b5f 100644 --- a/src/ripple/app/paths/impl/FlowDebugInfo.h +++ b/src/ripple/app/paths/impl/FlowDebugInfo.h @@ -26,9 +26,9 @@ #include #include -#include #include +#include #include namespace ripple { @@ -357,7 +357,7 @@ balanceDiffs(PaymentSandbox const& sb, ReadView const& rv) } inline std::string -balanceDiffsToString(boost::optional const& bd) +balanceDiffsToString(std::optional const& bd) { if (!bd) return std::string{}; diff --git a/src/ripple/app/paths/impl/PaySteps.cpp b/src/ripple/app/paths/impl/PaySteps.cpp index 4a49f84b3..578d73fb7 100644 --- a/src/ripple/app/paths/impl/PaySteps.cpp +++ b/src/ripple/app/paths/impl/PaySteps.cpp @@ -137,8 +137,8 @@ toStrand( AccountID const& src, AccountID const& dst, Issue const& deliver, - boost::optional const& limitQuality, - boost::optional const& sendMaxIssue, + std::optional const& limitQuality, + std::optional const& sendMaxIssue, STPath const& path, bool ownerPaysTransferFee, bool offerCrossing, @@ -209,7 +209,7 @@ toStrand( path[0].getAccountID() != sendMaxIssue->account)) { normPath.emplace_back( - sendMaxIssue->account, boost::none, boost::none); + sendMaxIssue->account, std::nullopt, std::nullopt); } for (auto const& i : path) @@ -225,7 +225,7 @@ toStrand( lastCurrency.getIssuerID() != deliver.account)) { normPath.emplace_back( - boost::none, deliver.currency, deliver.account); + std::nullopt, deliver.currency, deliver.account); } } @@ -233,13 +233,13 @@ toStrand( normPath.back().getAccountID() == deliver.account) || (dst == deliver.account))) { - normPath.emplace_back(deliver.account, boost::none, boost::none); + normPath.emplace_back(deliver.account, std::nullopt, std::nullopt); } if (!normPath.back().isAccount() || normPath.back().getAccountID() != dst) { - normPath.emplace_back(dst, boost::none, boost::none); + normPath.emplace_back(dst, std::nullopt, std::nullopt); } } @@ -290,7 +290,7 @@ toStrand( account then no step is created, as a step has already been created for that offer. */ - boost::optional impliedPE; + std::optional impliedPE; auto cur = &normPath[i]; auto const next = &normPath[i + 1]; @@ -468,8 +468,8 @@ toStrands( AccountID const& src, AccountID const& dst, Issue const& deliver, - boost::optional const& limitQuality, - boost::optional const& sendMax, + std::optional const& limitQuality, + std::optional const& sendMax, STPathSet const& paths, bool addDefaultPath, bool ownerPaysTransferFee, @@ -580,7 +580,7 @@ StrandContext::StrandContext( AccountID const& strandSrc_, AccountID const& strandDst_, Issue const& strandDeliver_, - boost::optional const& limitQuality_, + std::optional const& limitQuality_, bool isLast_, bool ownerPaysTransferFee_, bool offerCrossing_, diff --git a/src/ripple/app/paths/impl/Steps.h b/src/ripple/app/paths/impl/Steps.h index 552161dc1..7bebd1899 100644 --- a/src/ripple/app/paths/impl/Steps.h +++ b/src/ripple/app/paths/impl/Steps.h @@ -27,7 +27,7 @@ #include #include -#include +#include namespace ripple { class PaymentSandbox; @@ -121,32 +121,32 @@ public: Amount of currency computed coming into the Step the last time the step ran in reverse. */ - virtual boost::optional + virtual std::optional cachedIn() const = 0; /** Amount of currency computed coming out of the Step the last time the step ran in reverse. */ - virtual boost::optional + virtual std::optional cachedOut() const = 0; /** If this step is DirectStepI (IOU->IOU direct step), return the src account. This is needed for checkNoRipple. */ - virtual boost::optional + virtual std::optional directStepSrcAcct() const { - return boost::none; + return std::nullopt; } // for debugging. Return the src and dst accounts for a direct step // For XRP endpoints, one of src or dst will be the root account - virtual boost::optional> + virtual std::optional> directStepAccts() const { - return boost::none; + return std::nullopt; } /** @@ -175,7 +175,7 @@ public: @param v view to query the ledger state from @param prevStepDir Set to DebtDirection::redeems if the previous step redeems. - @return A pair. The first element is the upper bound of quality for the step, or boost::none if the + @return A pair. The first element is the upper bound of quality for the step, or std::nullopt if the step is dry. The second element will be set to DebtDirection::redeems if this steps redeems, DebtDirection:issues if this step issues. @note it is an upper bound because offers on the books may be unfunded. @@ -185,7 +185,7 @@ public: it should be a good estimate for the actual quality. */ // clang-format on - virtual std::pair, DebtDirection> + virtual std::pair, DebtDirection> qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const = 0; /** Return the number of offers consumed or partially consumed the last time @@ -204,10 +204,10 @@ public: /** If this step is a BookStep, return the book. */ - virtual boost::optional + virtual std::optional bookStepBook() const { - return boost::none; + return std::nullopt; } /** @@ -339,7 +339,7 @@ normalizePath( AccountID const& src, AccountID const& dst, Issue const& deliver, - boost::optional const& sendMaxIssue, + std::optional const& sendMaxIssue, STPath const& path); /** @@ -370,8 +370,8 @@ toStrand( AccountID const& src, AccountID const& dst, Issue const& deliver, - boost::optional const& limitQuality, - boost::optional const& sendMaxIssue, + std::optional const& limitQuality, + std::optional const& sendMaxIssue, STPath const& path, bool ownerPaysTransferFee, bool offerCrossing, @@ -407,8 +407,8 @@ toStrands( AccountID const& src, AccountID const& dst, Issue const& deliver, - boost::optional const& limitQuality, - boost::optional const& sendMax, + std::optional const& limitQuality, + std::optional const& sendMax, STPathSet const& paths, bool addDefaultPath, bool ownerPaysTransferFee, @@ -496,11 +496,11 @@ checkNear(XRPAmount const& expected, XRPAmount const& actual); */ struct StrandContext { - ReadView const& view; ///< Current ReadView - AccountID const strandSrc; ///< Strand source account - AccountID const strandDst; ///< Strand destination account - Issue const strandDeliver; ///< Issue strand delivers - boost::optional const limitQuality; ///< Worst accepted quality + ReadView const& view; ///< Current ReadView + AccountID const strandSrc; ///< Strand source account + AccountID const strandDst; ///< Strand destination account + Issue const strandDeliver; ///< Issue strand delivers + std::optional const limitQuality; ///< Worst accepted quality bool const isFirst; ///< true if Step is first in Strand bool const isLast = false; ///< true if Step is last in Strand bool const ownerPaysTransferFee; ///< true if owner, not sender, pays fee @@ -532,7 +532,7 @@ struct StrandContext AccountID const& strandSrc_, AccountID const& strandDst_, Issue const& strandDeliver_, - boost::optional const& limitQuality_, + std::optional const& limitQuality_, bool isLast_, bool ownerPaysTransferFee_, bool offerCrossing_, diff --git a/src/ripple/app/paths/impl/StrandFlow.h b/src/ripple/app/paths/impl/StrandFlow.h index 8e2663231..487455f69 100644 --- a/src/ripple/app/paths/impl/StrandFlow.h +++ b/src/ripple/app/paths/impl/StrandFlow.h @@ -47,7 +47,7 @@ struct StrandResult bool success; ///< Strand succeeded TInAmt in = beast::zero; ///< Currency amount in TOutAmt out = beast::zero; ///< Currency amount out - boost::optional sandbox; ///< Resulting Sandbox state + std::optional sandbox; ///< Resulting Sandbox state boost::container::flat_set ofrsToRm; ///< Offers to remove // Num offers consumed or partially consumed (includes expired and unfunded // offers) @@ -103,7 +103,7 @@ StrandResult flow( PaymentSandbox const& baseView, Strand const& strand, - boost::optional const& maxIn, + std::optional const& maxIn, TOutAmt const& out, beast::Journal j) { @@ -126,11 +126,11 @@ flow( std::size_t const s = strand.size(); std::size_t limitingStep = strand.size(); - boost::optional sb(&baseView); + std::optional sb(&baseView); // The "all funds" view determines if an offer becomes unfunded or is // found unfunded // These are the account balances before the strand executes - boost::optional afView(&baseView); + std::optional afView(&baseView); EitherAmount limitStepOut; { EitherAmount stepOut(out); @@ -296,7 +296,7 @@ struct FlowResult { TInAmt in = beast::zero; TOutAmt out = beast::zero; - boost::optional sandbox; + std::optional sandbox; boost::container::flat_set removableOffers; TER ter = temUNKNOWN; @@ -332,18 +332,18 @@ struct FlowResult /// @endcond /// @cond INTERNAL -inline boost::optional +inline std::optional qualityUpperBound(ReadView const& v, Strand const& strand) { Quality q{STAmount::uRateOne}; - boost::optional stepQ; + std::optional stepQ; DebtDirection dir = DebtDirection::issues; for (auto const& step : strand) { if (std::tie(stepQ, dir) = step->qualityUpperBound(v, dir); stepQ) q = composed_quality(q, *stepQ); else - return boost::none; + return std::nullopt; } return q; }; @@ -377,9 +377,7 @@ public: // Start a new iteration in the search for liquidity // Set the current strands to the strands in `next_` void - activateNext( - ReadView const& v, - boost::optional const& limitQuality) + activateNext(ReadView const& v, std::optional const& limitQuality) { // add the strands in `next_` to `cur_`, sorted by theoretical quality. // Best quality first. @@ -501,8 +499,8 @@ flow( TOutAmt const& outReq, bool partialPayment, bool offerCrossing, - boost::optional const& limitQuality, - boost::optional const& sendMaxST, + std::optional const& limitQuality, + std::optional const& sendMaxST, beast::Journal j, path::detail::FlowDebugInfo* flowDebugInfo = nullptr) { @@ -542,11 +540,13 @@ flow( // natural way. Using `make_optional`, allows us to work around this bug. TInAmt const sendMaxInit = sendMaxST ? toAmount(*sendMaxST) : TInAmt{beast::zero}; - boost::optional const sendMax = boost::make_optional( - sendMaxST && sendMaxInit >= beast::zero, sendMaxInit); - boost::optional remainingIn = - boost::make_optional(!!sendMax, sendMaxInit); - // boost::optional remainingIn{sendMax}; + std::optional const sendMax = + (sendMaxST && sendMaxInit >= beast::zero) + ? std::make_optional(sendMaxInit) + : std::nullopt; + std::optional remainingIn = + !!sendMax ? std::make_optional(sendMaxInit) : std::nullopt; + // std::optional remainingIn{sendMax}; TOutAmt remainingOut(outReq); @@ -586,14 +586,14 @@ flow( activeStrands.activateNext(sb, limitQuality); boost::container::flat_set ofrsToRm; - boost::optional best; + std::optional best; if (flowDebugInfo) flowDebugInfo->newLiquidityPass(); // Index of strand to mark as inactive (remove from the active list) if // the liquidity is used. This is used for strands that consume too many // offers Constructed as `false,0` to workaround a gcc warning about // uninitialized variables - boost::optional markInactiveOnUse{false, 0}; + std::optional markInactiveOnUse; for (size_t strandIndex = 0, sie = activeStrands.size(); strandIndex != sie; ++strandIndex) diff --git a/src/ripple/app/paths/impl/XRPEndpointStep.cpp b/src/ripple/app/paths/impl/XRPEndpointStep.cpp index 05739788c..487846380 100644 --- a/src/ripple/app/paths/impl/XRPEndpointStep.cpp +++ b/src/ripple/app/paths/impl/XRPEndpointStep.cpp @@ -47,13 +47,13 @@ private: // Since this step will always be an endpoint in a strand // (either the first or last step) the same cache is used // for cachedIn and cachedOut and only one will ever be used - boost::optional cache_; + std::optional cache_; - boost::optional + std::optional cached() const { if (!cache_) - return boost::none; + return std::nullopt; return EitherAmount(*cache_); } @@ -69,7 +69,7 @@ public: return acc_; } - boost::optional> + std::optional> directStepAccts() const override { if (isLast_) @@ -77,13 +77,13 @@ public: return std::make_pair(acc_, xrpAccount()); } - boost::optional + std::optional cachedIn() const override { return cached(); } - boost::optional + std::optional cachedOut() const override { return cached(); @@ -95,7 +95,7 @@ public: return DebtDirection::issues; } - std::pair, DebtDirection> + std::pair, DebtDirection> qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const override; @@ -242,7 +242,7 @@ operator==( } template -std::pair, DebtDirection> +std::pair, DebtDirection> XRPEndpointStep::qualityUpperBound( ReadView const& v, DebtDirection prevStepDir) const diff --git a/src/ripple/app/tx/impl/ApplyContext.h b/src/ripple/app/tx/impl/ApplyContext.h index 97aca41cb..1a4782661 100644 --- a/src/ripple/app/tx/impl/ApplyContext.h +++ b/src/ripple/app/tx/impl/ApplyContext.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -123,7 +123,7 @@ private: OpenView& base_; ApplyFlags flags_; - boost::optional view_; + std::optional view_; }; } // namespace ripple diff --git a/src/ripple/app/tx/impl/CashCheck.cpp b/src/ripple/app/tx/impl/CashCheck.cpp index 9ab6e21e8..fc606be4f 100644 --- a/src/ripple/app/tx/impl/CashCheck.cpp +++ b/src/ripple/app/tx/impl/CashCheck.cpp @@ -357,7 +357,7 @@ CashCheck::doApply() static_cast(optDeliverMin), // partial payment true, // owner pays transfer fee false, // offer crossing - boost::none, + std::nullopt, sleCheck->getFieldAmount(sfSendMax), viewJ); diff --git a/src/ripple/app/tx/impl/CreateOffer.cpp b/src/ripple/app/tx/impl/CreateOffer.cpp index e952ac963..6e5873188 100644 --- a/src/ripple/app/tx/impl/CreateOffer.cpp +++ b/src/ripple/app/tx/impl/CreateOffer.cpp @@ -740,7 +740,7 @@ CreateOffer::flowCross( if (!takerAmount.in.native() & !takerAmount.out.native()) { STPath path; - path.emplace_back(boost::none, xrpCurrency(), boost::none); + path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt); paths.emplace_back(std::move(path)); } // Special handling for the tfSell flag. diff --git a/src/ripple/app/tx/impl/OfferStream.cpp b/src/ripple/app/tx/impl/OfferStream.cpp index 9b2f3beed..370ea46c5 100644 --- a/src/ripple/app/tx/impl/OfferStream.cpp +++ b/src/ripple/app/tx/impl/OfferStream.cpp @@ -144,7 +144,7 @@ TOfferStreamBase::step() for (;;) { - ownerFunds_ = boost::none; + ownerFunds_ = std::nullopt; // BookTip::step deletes the current offer from the view before // advancing to the next (unless the ledger entry is missing). if (!tip_.step(j_)) diff --git a/src/ripple/app/tx/impl/OfferStream.h b/src/ripple/app/tx/impl/OfferStream.h index d8c739b36..69946790c 100644 --- a/src/ripple/app/tx/impl/OfferStream.h +++ b/src/ripple/app/tx/impl/OfferStream.h @@ -76,7 +76,7 @@ protected: NetClock::time_point const expire_; BookTip tip_; TOffer offer_; - boost::optional ownerFunds_; + std::optional ownerFunds_; StepCounter& counter_; void diff --git a/src/ripple/app/tx/impl/PayChan.cpp b/src/ripple/app/tx/impl/PayChan.cpp index 654cf90e1..ba52b6260 100644 --- a/src/ripple/app/tx/impl/PayChan.cpp +++ b/src/ripple/app/tx/impl/PayChan.cpp @@ -541,7 +541,7 @@ PayChanClaim::doApply() { if (src != txAccount) return tecNO_PERMISSION; - (*slep)[~sfExpiration] = boost::none; + (*slep)[~sfExpiration] = std::nullopt; ctx_.view().update(slep); } diff --git a/src/ripple/app/tx/impl/Transactor.h b/src/ripple/app/tx/impl/Transactor.h index c66e25551..c54f5a1a3 100644 --- a/src/ripple/app/tx/impl/Transactor.h +++ b/src/ripple/app/tx/impl/Transactor.h @@ -24,7 +24,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/app/tx/impl/applySteps.cpp b/src/ripple/app/tx/impl/applySteps.cpp index c058b2967..c70ac96d7 100644 --- a/src/ripple/app/tx/impl/applySteps.cpp +++ b/src/ripple/app/tx/impl/applySteps.cpp @@ -440,7 +440,7 @@ preclaim( Application& app, OpenView const& view) { - boost::optional ctx; + std::optional ctx; if (preflightResult.rules != view.rules()) { auto secondFlight = preflight( diff --git a/src/ripple/basics/BasicConfig.h b/src/ripple/basics/BasicConfig.h index 1b85dee5b..704092cf3 100644 --- a/src/ripple/basics/BasicConfig.h +++ b/src/ripple/basics/BasicConfig.h @@ -23,10 +23,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -139,12 +139,12 @@ public: find(std::string const& name) const; template - boost::optional + std::optional get(std::string const& name) const { auto const iter = cont().find(name); if (iter == cont().end()) - return boost::none; + return std::nullopt; return boost::lexical_cast(iter->second); } @@ -154,7 +154,7 @@ public: value_or(std::string const& name, T const& other) const { auto const v = get(name); - return v.is_initialized() ? *v : other; + return v.has_value() ? *v : other; } // indicates if trailing comments were seen @@ -279,7 +279,7 @@ set(T& target, std::string const& name, Section const& section) try { auto const val = section.get(name); - if ((found_and_valid = val.is_initialized())) + if ((found_and_valid = val.has_value())) target = *val; } catch (boost::bad_lexical_cast&) @@ -333,7 +333,7 @@ get(Section const& section, std::string const& name, const char* defaultValue) try { auto const val = section.get(name); - if (val.is_initialized()) + if (val.has_value()) return *val; } catch (boost::bad_lexical_cast&) diff --git a/src/ripple/basics/FileUtilities.h b/src/ripple/basics/FileUtilities.h index 6970ba752..49138c83c 100644 --- a/src/ripple/basics/FileUtilities.h +++ b/src/ripple/basics/FileUtilities.h @@ -21,16 +21,17 @@ #define RIPPLE_BASICS_FILEUTILITIES_H_INCLUDED #include -#include #include +#include + namespace ripple { std::string getFileContents( boost::system::error_code& ec, boost::filesystem::path const& sourcePath, - boost::optional maxSize = boost::none); + std::optional maxSize = std::nullopt); void writeFileContents( diff --git a/src/ripple/basics/RangeSet.h b/src/ripple/basics/RangeSet.h index cbd25815f..994bbf4ab 100644 --- a/src/ripple/basics/RangeSet.h +++ b/src/ripple/basics/RangeSet.h @@ -25,8 +25,8 @@ #include #include #include -#include +#include #include namespace ripple { @@ -177,18 +177,18 @@ from_string(RangeSet& rs, std::string const& s) @param t The value that must be larger than the result @param minVal (Default is 0) The smallest allowed value @return The largest v such that minV <= v < t and !contains(rs, v) or - boost::none if no such v exists. + std::nullopt if no such v exists. */ template -boost::optional +std::optional prevMissing(RangeSet const& rs, T t, T minVal = 0) { if (rs.empty() || t == minVal) - return boost::none; + return std::nullopt; RangeSet tgt{ClosedInterval{minVal, t - 1}}; tgt -= rs; if (tgt.empty()) - return boost::none; + return std::nullopt; return boost::icl::last(tgt); } diff --git a/src/ripple/basics/StringUtilities.h b/src/ripple/basics/StringUtilities.h index 759d40736..81e9ae826 100644 --- a/src/ripple/basics/StringUtilities.h +++ b/src/ripple/basics/StringUtilities.h @@ -24,8 +24,8 @@ #include #include -#include #include +#include #include #include @@ -45,7 +45,7 @@ std::string sqlBlobLiteral(Blob const& blob); template -boost::optional +std::optional strUnHex(std::size_t strSize, Iterator begin, Iterator end) { Blob out; @@ -85,13 +85,13 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end) return {std::move(out)}; } -inline boost::optional +inline std::optional strUnHex(std::string const& strSrc) { return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend()); } -inline boost::optional +inline std::optional strViewUnHex(boost::string_view const& strSrc) { return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend()); @@ -105,7 +105,7 @@ struct parsedURL std::string username; std::string password; std::string domain; - boost::optional port; + std::optional port; std::string path; bool @@ -122,7 +122,7 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl); std::string trim_whitespace(std::string str); -boost::optional +std::optional to_uint64(std::string const& s); /** Determines if the given string looks like a TOML-file hosting domain. diff --git a/src/ripple/basics/XRPAmount.h b/src/ripple/basics/XRPAmount.h index e8f26266e..c9f0d08ea 100644 --- a/src/ripple/basics/XRPAmount.h +++ b/src/ripple/basics/XRPAmount.h @@ -27,9 +27,9 @@ #include #include -#include #include +#include #include #include @@ -178,7 +178,7 @@ public: decimalXRP() const; template - boost::optional + std::optional dropsAs() const { if ((drops_ > std::numeric_limits::max()) || @@ -186,7 +186,7 @@ public: (std::numeric_limits::is_signed && drops_ < std::numeric_limits::lowest())) { - return boost::none; + return std::nullopt; } return static_cast(drops_); } diff --git a/src/ripple/basics/impl/FileUtilities.cpp b/src/ripple/basics/impl/FileUtilities.cpp index 1a69abfde..be60a3e5c 100644 --- a/src/ripple/basics/impl/FileUtilities.cpp +++ b/src/ripple/basics/impl/FileUtilities.cpp @@ -25,7 +25,7 @@ std::string getFileContents( boost::system::error_code& ec, boost::filesystem::path const& sourcePath, - boost::optional maxSize) + std::optional maxSize) { using namespace boost::filesystem; using namespace boost::system::errc; diff --git a/src/ripple/basics/impl/PerfLogImp.cpp b/src/ripple/basics/impl/PerfLogImp.cpp index f553b3813..edf4651c9 100644 --- a/src/ripple/basics/impl/PerfLogImp.cpp +++ b/src/ripple/basics/impl/PerfLogImp.cpp @@ -24,13 +24,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include diff --git a/src/ripple/basics/impl/StringUtilities.cpp b/src/ripple/basics/impl/StringUtilities.cpp index 346e94c75..8036cc3bf 100644 --- a/src/ripple/basics/impl/StringUtilities.cpp +++ b/src/ripple/basics/impl/StringUtilities.cpp @@ -103,13 +103,13 @@ trim_whitespace(std::string str) return str; } -boost::optional +std::optional to_uint64(std::string const& s) { std::uint64_t result; if (beast::lexicalCastChecked(result, s)) return result; - return boost::none; + return std::nullopt; } bool diff --git a/src/ripple/beast/insight/impl/StatsDCollector.cpp b/src/ripple/beast/insight/impl/StatsDCollector.cpp index 288ebfbe4..6949a7f86 100644 --- a/src/ripple/beast/insight/impl/StatsDCollector.cpp +++ b/src/ripple/beast/insight/impl/StatsDCollector.cpp @@ -26,12 +26,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -224,7 +224,7 @@ private: IP::Endpoint m_address; std::string m_prefix; boost::asio::io_service m_io_service; - boost::optional m_work; + std::optional m_work; boost::asio::io_service::strand m_strand; boost::asio::basic_waitable_timer m_timer; boost::asio::ip::udp::socket m_socket; @@ -262,7 +262,7 @@ public: boost::system::error_code ec; m_timer.cancel(ec); - m_work = boost::none; + m_work.reset(); m_thread.join(); } diff --git a/src/ripple/beast/net/IPEndpoint.h b/src/ripple/beast/net/IPEndpoint.h index 7fa2fc86e..19ce36dcc 100644 --- a/src/ripple/beast/net/IPEndpoint.h +++ b/src/ripple/beast/net/IPEndpoint.h @@ -24,10 +24,9 @@ #include #include -#include - #include #include +#include #include namespace beast { @@ -47,9 +46,9 @@ public: /** Create an Endpoint from a string. If the port is omitted, the endpoint will have a zero port. - @return An optional endpoint; will be `boost::none` on failure + @return An optional endpoint; will be `std::nullopt` on failure */ - static boost::optional + static std::optional from_string_checked(std::string const& s); static Endpoint from_string(std::string const& s); diff --git a/src/ripple/beast/net/impl/IPEndpoint.cpp b/src/ripple/beast/net/impl/IPEndpoint.cpp index 5f2160f53..05a94152f 100644 --- a/src/ripple/beast/net/impl/IPEndpoint.cpp +++ b/src/ripple/beast/net/impl/IPEndpoint.cpp @@ -31,7 +31,7 @@ Endpoint::Endpoint(Address const& addr, Port port) : m_addr(addr), m_port(port) { } -boost::optional +std::optional Endpoint::from_string_checked(std::string const& s) { std::stringstream is(boost::trim_copy(s)); @@ -45,7 +45,7 @@ Endpoint::from_string_checked(std::string const& s) Endpoint Endpoint::from_string(std::string const& s) { - if (boost::optional const result = from_string_checked(s)) + if (std::optional const result = from_string_checked(s)) return *result; return Endpoint{}; } diff --git a/src/ripple/conditions/Fulfillment.h b/src/ripple/conditions/Fulfillment.h index 17869c0e3..075c00510 100644 --- a/src/ripple/conditions/Fulfillment.h +++ b/src/ripple/conditions/Fulfillment.h @@ -24,7 +24,6 @@ #include #include #include -#include namespace ripple { namespace cryptoconditions { diff --git a/src/ripple/conditions/impl/Condition.cpp b/src/ripple/conditions/impl/Condition.cpp index 5e7e18a49..af8c9eadb 100644 --- a/src/ripple/conditions/impl/Condition.cpp +++ b/src/ripple/conditions/impl/Condition.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/conditions/impl/Fulfillment.cpp b/src/ripple/conditions/impl/Fulfillment.cpp index 001a0569e..eaeabe26e 100644 --- a/src/ripple/conditions/impl/Fulfillment.cpp +++ b/src/ripple/conditions/impl/Fulfillment.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/consensus/Consensus.h b/src/ripple/consensus/Consensus.h index d22a4224c..7a5c49c85 100644 --- a/src/ripple/consensus/Consensus.h +++ b/src/ripple/consensus/Consensus.h @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace ripple { @@ -214,10 +215,10 @@ checkConsensus( //----------------------------------------------------------------------- // // Attempt to acquire a specific ledger. - boost::optional acquireLedger(Ledger::ID const & ledgerID); + std::optional acquireLedger(Ledger::ID const & ledgerID); // Acquire the transaction set associated with a proposed position. - boost::optional acquireTxSet(TxSet::ID const & setID); + std::optional acquireTxSet(TxSet::ID const & setID); // Whether any transactions are in the open ledger bool hasOpenTransactions() const; @@ -398,7 +399,7 @@ public: void simulate( NetClock::time_point const& now, - boost::optional consensusDelay); + std::optional consensusDelay); /** Get the previous ledger ID. @@ -577,7 +578,7 @@ private: // Transaction Sets, indexed by hash of transaction tree hash_map acquired_; - boost::optional result_; + std::optional result_; ConsensusCloseTimes rawCloseTimes_; //------------------------------------------------------------------------- @@ -792,7 +793,7 @@ Consensus::peerProposalInternal( if (ait == acquired_.end()) { // acquireTxSet will return the set if it is available, or - // spawn a request for it and return none/nullptr. It will call + // spawn a request for it and return nullopt/nullptr. It will call // gotTxSet once it arrives if (auto set = adaptor_.acquireTxSet(newPeerProp.position())) gotTxSet(now_, *set); @@ -881,7 +882,7 @@ template void Consensus::simulate( NetClock::time_point const& now, - boost::optional consensusDelay) + std::optional consensusDelay) { using namespace std::chrono_literals; JLOG(j_.info()) << "Simulating consensus"; @@ -1388,11 +1389,11 @@ Consensus::updateOurPositions() } // This will stay unseated unless there are any changes - boost::optional ourNewSet; + std::optional ourNewSet; // Update votes on disputed transactions { - boost::optional mutableSet; + std::optional mutableSet; for (auto& [txId, dispute] : result_->disputes) { // Because the threshold for inclusion increases, diff --git a/src/ripple/consensus/LedgerTrie.h b/src/ripple/consensus/LedgerTrie.h index 641bcfdf6..108da0a30 100644 --- a/src/ripple/consensus/LedgerTrie.h +++ b/src/ripple/consensus/LedgerTrie.h @@ -23,9 +23,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -116,14 +116,14 @@ public: } // Return the Span from [spot,end_) or none if no such valid span - boost::optional + std::optional from(Seq spot) const { return sub(spot, end_); } // Return the Span from [start_,spot) or none if no such valid span - boost::optional + std::optional before(Seq spot) const { return sub(start_, spot); @@ -167,14 +167,14 @@ private: } // Return a span of this over the half-open interval [from,to) - boost::optional + std::optional sub(Seq from, Seq to) const { Seq newFrom = clamp(from); Seq newTo = clamp(to); if (newFrom < newTo) return Span(newFrom, newTo, ledger_); - return boost::none; + return std::nullopt; } friend std::ostream& @@ -469,9 +469,9 @@ public: // a b c | g h i // prefix | newSuffix - boost::optional prefix = loc->span.before(diffSeq); - boost::optional oldSuffix = loc->span.from(diffSeq); - boost::optional newSuffix = Span{ledger}.from(diffSeq); + std::optional prefix = loc->span.before(diffSeq); + std::optional oldSuffix = loc->span.from(diffSeq); + std::optional newSuffix = Span{ledger}.from(diffSeq); if (oldSuffix) { @@ -672,13 +672,13 @@ public: @param largestIssued The sequence number of the largest validation issued by this node. @return Pair with the sequence number and ID of the preferred ledger or - boost::none if no preferred ledger exists + std::nullopt if no preferred ledger exists */ - boost::optional> + std::optional> getPreferred(Seq const largestIssued) const { if (empty()) - return boost::none; + return std::nullopt; Node* curr = root.get(); diff --git a/src/ripple/consensus/Validations.h b/src/ripple/consensus/Validations.h index a9c84a2e6..fce13cebf 100644 --- a/src/ripple/consensus/Validations.h +++ b/src/ripple/consensus/Validations.h @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include #include #include @@ -272,7 +272,7 @@ to_string(ValStatus m) NetClock::time_point now() const; // Attempt to acquire a specific ledger. - boost::optional acquire(Ledger::ID const & ledgerID); + std::optional acquire(Ledger::ID const & ledgerID); // ... implementation specific }; @@ -323,7 +323,7 @@ class Validations bySequence_; // Sequence of the earliest validation to keep from expire - boost::optional toKeep_; + std::optional toKeep_; // Represents the ancestry of validated ledgers LedgerTrie trie_; @@ -376,7 +376,7 @@ private: { for (auto it = acquiring_.begin(); it != acquiring_.end();) { - if (boost::optional ledger = + if (std::optional ledger = adaptor_.acquire(it->first.second)) { for (NodeID const& nodeID : it->second) @@ -423,7 +423,7 @@ private: std::lock_guard const& lock, NodeID const& nodeID, Validation const& val, - boost::optional> prior) + std::optional> prior) { assert(val.trusted()); @@ -449,8 +449,7 @@ private: } else { - if (boost::optional ledger = - adaptor_.acquire(val.ledgerID())) + if (std::optional ledger = adaptor_.acquire(val.ledgerID())) updateTrie(lock, nodeID, *ledger); else acquiring_[valPair].insert(nodeID); @@ -689,7 +688,7 @@ public: } else if (val.trusted()) { - updateTrie(lock, nodeID, val, boost::none); + updateTrie(lock, nodeID, val, std::nullopt); } } @@ -760,7 +759,7 @@ public: if (added.find(nodeId) != added.end()) { validation.setTrusted(); - updateTrie(lock, nodeId, validation, boost::none); + updateTrie(lock, nodeId, validation, std::nullopt); } else if (removed.find(nodeId) != removed.end()) { @@ -802,14 +801,14 @@ public: @param curr The local node's current working ledger @return The sequence and id of the preferred working ledger, - or boost::none if no trusted validations are available to + or std::nullopt if no trusted validations are available to determine the preferred ledger. */ - boost::optional> + std::optional> getPreferred(Ledger const& curr) { std::lock_guard lock{mutex_}; - boost::optional> preferred = + std::optional> preferred = withTrie(lock, [this](LedgerTrie& trie) { return trie.getPreferred(localSeqEnforcer_.largest()); }); @@ -834,7 +833,7 @@ public: }); if (it != acquiring_.end()) return it->first; - return boost::none; + return std::nullopt; } // If we are the parent of the preferred ledger, stick with our @@ -869,7 +868,7 @@ public: ID getPreferred(Ledger const& curr, Seq minValidSeq) { - boost::optional> preferred = getPreferred(curr); + std::optional> preferred = getPreferred(curr); if (preferred && preferred->first >= minValidSeq) return preferred->second; return curr.id(); @@ -897,7 +896,7 @@ public: Seq minSeq, hash_map const& peerCounts) { - boost::optional> preferred = getPreferred(lcl); + std::optional> preferred = getPreferred(lcl); // Trusted validations exist, but stick with local preferred ledger if // preferred is in the past @@ -1048,7 +1047,7 @@ public: [&](NodeID const&, Validation const& v) { if (v.trusted() && v.full()) { - boost::optional loadFee = v.loadFee(); + std::optional loadFee = v.loadFee(); if (loadFee) res.push_back(*loadFee); else diff --git a/src/ripple/core/ClosureCounter.h b/src/ripple/core/ClosureCounter.h index d71c5bcb5..79627bc70 100644 --- a/src/ripple/core/ClosureCounter.h +++ b/src/ripple/core/ClosureCounter.h @@ -21,10 +21,10 @@ #define RIPPLE_CORE_CLOSURE_COUNTER_H_INCLUDED #include -#include #include #include #include +#include #include namespace ripple { @@ -169,15 +169,15 @@ public: /** Wrap the passed closure with a reference counter. @param closure Closure that accepts Args_t parameters and returns Ret_t. - @return If join() has been called returns boost::none. Otherwise - returns a boost::optional that wraps closure with a + @return If join() has been called returns std::nullopt. Otherwise + returns a std::optional that wraps closure with a reference counter. */ template - boost::optional> + std::optional> wrap(Closure&& closure) { - boost::optional> ret; + std::optional> ret; std::lock_guard lock{mutex_}; if (!waitForClosures_) diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index f8097a07e..850b4f813 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -29,11 +29,11 @@ #include #include // VFALCO FIX: This include should not be here #include -#include #include #include #include #include +#include #include #include #include @@ -165,7 +165,7 @@ public: int PATH_SEARCH_MAX = 10; // Validation - boost::optional + std::optional VALIDATION_QUORUM; // validations to consider ledger authoritative XRPAmount FEE_DEFAULT{10}; @@ -214,7 +214,7 @@ public: bool VP_REDUCE_RELAY_SQUELCH = false; // These override the command line client settings - boost::optional rpc_ip; + std::optional rpc_ip; std::unordered_set> features; @@ -314,7 +314,7 @@ public: defaults in the code for every case. */ int - getValueFor(SizedItem item, boost::optional node = boost::none) + getValueFor(SizedItem item, std::optional node = std::nullopt) const; }; diff --git a/src/ripple/core/DatabaseCon.h b/src/ripple/core/DatabaseCon.h index 0355db0ce..59eec3a32 100644 --- a/src/ripple/core/DatabaseCon.h +++ b/src/ripple/core/DatabaseCon.h @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include #include namespace soci { @@ -234,7 +234,7 @@ checkpointerFromId(std::uintptr_t id); DatabaseCon::Setup setup_DatabaseCon( Config const& c, - boost::optional j = boost::none); + std::optional j = std::nullopt); } // namespace ripple diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index 5dcb2948f..fef5c2a5a 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -821,7 +821,7 @@ Config::getDebugLogFile() const } int -Config::getValueFor(SizedItem item, boost::optional node) const +Config::getValueFor(SizedItem item, std::optional node) const { auto const index = static_cast>(item); assert(index < sizedItems.size()); diff --git a/src/ripple/core/impl/DatabaseCon.cpp b/src/ripple/core/impl/DatabaseCon.cpp index c8f72236c..4f65f7003 100644 --- a/src/ripple/core/impl/DatabaseCon.cpp +++ b/src/ripple/core/impl/DatabaseCon.cpp @@ -103,7 +103,7 @@ DatabaseCon::~DatabaseCon() } DatabaseCon::Setup -setup_DatabaseCon(Config const& c, boost::optional j) +setup_DatabaseCon(Config const& c, std::optional j) { DatabaseCon::Setup setup; diff --git a/src/ripple/core/impl/SNTPClock.cpp b/src/ripple/core/impl/SNTPClock.cpp index e2b17b14a..8651dcbe5 100644 --- a/src/ripple/core/impl/SNTPClock.cpp +++ b/src/ripple/core/impl/SNTPClock.cpp @@ -22,12 +22,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include namespace ripple { @@ -90,7 +90,7 @@ private: std::mutex mutable mutex_; std::thread thread_; boost::asio::io_service io_service_; - boost::optional work_; + std::optional work_; std::map queries_; boost::asio::ip::udp::socket socket_; @@ -125,7 +125,7 @@ public: error_code ec; timer_.cancel(ec); socket_.cancel(ec); - work_ = boost::none; + work_ = std::nullopt; thread_.join(); } } diff --git a/src/ripple/ledger/ApplyView.h b/src/ripple/ledger/ApplyView.h index b6020c322..25d01fa27 100644 --- a/src/ripple/ledger/ApplyView.h +++ b/src/ripple/ledger/ApplyView.h @@ -23,7 +23,6 @@ #include #include #include -#include namespace ripple { @@ -141,7 +140,7 @@ class ApplyView : public ReadView { private: /** Add an entry to a directory using the specified insert strategy */ - boost::optional + std::optional dirAdd( bool preserveOrder, Keylet const& directory, @@ -265,7 +264,7 @@ public: @param key the entry to insert @param describe callback to add required entries to a new page - @return a \c boost::optional which, if insertion was successful, + @return a \c std::optional which, if insertion was successful, will contain the page number in which the item was stored. @note this function may create a page (including a root page), if no @@ -274,7 +273,7 @@ public: allowable pages. */ /** @{ */ - boost::optional + std::optional dirAppend( Keylet const& directory, uint256 const& key, @@ -283,7 +282,7 @@ public: return dirAdd(true, directory, key, describe); } - boost::optional + std::optional dirAppend( Keylet const& directory, Keylet const& key, @@ -302,7 +301,7 @@ public: @param key the entry to insert @param describe callback to add required entries to a new page - @return a \c boost::optional which, if insertion was successful, + @return a \c std::optional which, if insertion was successful, will contain the page number in which the item was stored. @note this function may create a page (including a root page), if no @@ -311,7 +310,7 @@ public: allowable pages. */ /** @{ */ - boost::optional + std::optional dirInsert( Keylet const& directory, uint256 const& key, @@ -320,7 +319,7 @@ public: return dirAdd(false, directory, key, describe); } - boost::optional + std::optional dirInsert( Keylet const& directory, Keylet const& key, diff --git a/src/ripple/ledger/ApplyViewImpl.h b/src/ripple/ledger/ApplyViewImpl.h index fe26ca25f..a7fb1bd42 100644 --- a/src/ripple/ledger/ApplyViewImpl.h +++ b/src/ripple/ledger/ApplyViewImpl.h @@ -24,7 +24,6 @@ #include #include #include -#include namespace ripple { @@ -86,7 +85,7 @@ public: std::shared_ptr const& after)> const& func); private: - boost::optional deliver_; + std::optional deliver_; }; } // namespace ripple diff --git a/src/ripple/ledger/BookDirs.h b/src/ripple/ledger/BookDirs.h index 7b384dc0c..86ea67d91 100644 --- a/src/ripple/ledger/BookDirs.h +++ b/src/ripple/ledger/BookDirs.h @@ -102,7 +102,7 @@ private: std::shared_ptr sle_; unsigned int entry_ = 0; uint256 index_; - boost::optional mutable cache_; + std::optional mutable cache_; static beast::Journal j_; }; diff --git a/src/ripple/ledger/CachedView.h b/src/ripple/ledger/CachedView.h index 57221c02f..e827d23c8 100644 --- a/src/ripple/ledger/CachedView.h +++ b/src/ripple/ledger/CachedView.h @@ -88,10 +88,10 @@ public: return base_.rules(); } - boost::optional + std::optional succ( key_type const& key, - boost::optional const& last = boost::none) const override + std::optional const& last = std::nullopt) const override { return base_.succ(key, last); } @@ -142,7 +142,7 @@ public: // DigestAwareReadView // - boost::optional + std::optional digest(key_type const& key) const override { return base_.digest(key); diff --git a/src/ripple/ledger/Directory.h b/src/ripple/ledger/Directory.h index 5946931fc..c24d348e7 100644 --- a/src/ripple/ledger/Directory.h +++ b/src/ripple/ledger/Directory.h @@ -103,7 +103,7 @@ private: Keylet root_; Keylet page_; uint256 index_; - boost::optional mutable cache_; + std::optional mutable cache_; std::shared_ptr sle_; STVector256 const* indexes_ = nullptr; std::vector::const_iterator it_; diff --git a/src/ripple/ledger/OpenView.h b/src/ripple/ledger/OpenView.h index cba9e2084..8467e4abc 100644 --- a/src/ripple/ledger/OpenView.h +++ b/src/ripple/ledger/OpenView.h @@ -203,10 +203,10 @@ public: bool exists(Keylet const& k) const override; - boost::optional + std::optional succ( key_type const& key, - boost::optional const& last = boost::none) const override; + std::optional const& last = std::nullopt) const override; std::shared_ptr read(Keylet const& k) const override; diff --git a/src/ripple/ledger/PaymentSandbox.h b/src/ripple/ledger/PaymentSandbox.h index 30f1f5f61..60e42af11 100644 --- a/src/ripple/ledger/PaymentSandbox.h +++ b/src/ripple/ledger/PaymentSandbox.h @@ -49,7 +49,7 @@ public: // Get the adjustments for the balance between main and other. // Returns the debits, credits and the original balance - boost::optional + std::optional adjustments( AccountID const& main, AccountID const& other, @@ -68,7 +68,7 @@ public: // Get the adjusted owner count. Since DeferredCredits is meant to be used // in payments, and payments only decrease owner counts, return the max // remembered owner count. - boost::optional + std::optional ownerCount(AccountID const& id) const; void diff --git a/src/ripple/ledger/RawView.h b/src/ripple/ledger/RawView.h index 1d71772aa..29c9ab9ab 100644 --- a/src/ripple/ledger/RawView.h +++ b/src/ripple/ledger/RawView.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/ledger/ReadView.h b/src/ripple/ledger/ReadView.h index f240ee6e2..bc9c0906a 100644 --- a/src/ripple/ledger/ReadView.h +++ b/src/ripple/ledger/ReadView.h @@ -32,10 +32,10 @@ #include #include #include -#include #include #include #include +#include #include namespace ripple { @@ -284,16 +284,16 @@ public: This returns the key of the first state item whose key is greater than the specified key. If - no such key is present, boost::none is returned. + no such key is present, std::nullopt is returned. - If `last` is engaged, returns boost::none when + If `last` is engaged, returns std::nullopt when the key returned would be outside the open interval (key, last). */ - virtual boost::optional + virtual std::optional succ( key_type const& key, - boost::optional const& last = boost::none) const = 0; + std::optional const& last = std::nullopt) const = 0; /** Return the state item associated with a key. @@ -403,9 +403,9 @@ public: /** Return the digest associated with the key. - @return boost::none if the item does not exist. + @return std::nullopt if the item does not exist. */ - virtual boost::optional + virtual std::optional digest(key_type const& key) const = 0; }; diff --git a/src/ripple/ledger/TxMeta.h b/src/ripple/ledger/TxMeta.h index b6c08040c..3b35abf55 100644 --- a/src/ripple/ledger/TxMeta.h +++ b/src/ripple/ledger/TxMeta.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace ripple { @@ -105,7 +105,7 @@ public: void setDeliveredAmount(STAmount const& delivered) { - mDelivered.reset(delivered); + mDelivered = delivered; } STAmount @@ -127,7 +127,7 @@ private: std::uint32_t mIndex; int mResult; - boost::optional mDelivered; + std::optional mDelivered; STArray mNodes; }; diff --git a/src/ripple/ledger/View.h b/src/ripple/ledger/View.h index d6a23d1e4..32df1f63a 100644 --- a/src/ripple/ledger/View.h +++ b/src/ripple/ledger/View.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -164,11 +163,11 @@ getMajorityAmendments(ReadView const& view); in the passed ledger. As the skip list is limited in size, if the requested ledger sequence number is out of the range of ledgers represented in the skip - list, then boost::none is returned. + list, then std::nullopt is returned. @return The hash of the ledger with the - given sequence number or boost::none. + given sequence number or std::nullopt. */ -[[nodiscard]] boost::optional +[[nodiscard]] std::optional hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal); /** Find a ledger index from which we could easily get the requested ledger @@ -251,7 +250,7 @@ dirNext( describeOwnerDir(AccountID const& account); // deprecated -boost::optional +std::optional dirAdd( ApplyView& view, Keylet const& uRootIndex, diff --git a/src/ripple/ledger/detail/ApplyStateTable.h b/src/ripple/ledger/detail/ApplyStateTable.h index c63fd4c2d..c090997a4 100644 --- a/src/ripple/ledger/detail/ApplyStateTable.h +++ b/src/ripple/ledger/detail/ApplyStateTable.h @@ -69,17 +69,17 @@ public: OpenView& to, STTx const& tx, TER ter, - boost::optional const& deliver, + std::optional const& deliver, beast::Journal j); bool exists(ReadView const& base, Keylet const& k) const; - boost::optional + std::optional succ( ReadView const& base, key_type const& key, - boost::optional const& last) const; + std::optional const& last) const; std::shared_ptr read(ReadView const& base, Keylet const& k) const; diff --git a/src/ripple/ledger/detail/ApplyViewBase.h b/src/ripple/ledger/detail/ApplyViewBase.h index 6b7c310e9..7fa34b5fb 100644 --- a/src/ripple/ledger/detail/ApplyViewBase.h +++ b/src/ripple/ledger/detail/ApplyViewBase.h @@ -60,10 +60,10 @@ public: bool exists(Keylet const& k) const override; - boost::optional + std::optional succ( key_type const& key, - boost::optional const& last = boost::none) const override; + std::optional const& last = std::nullopt) const override; std::shared_ptr read(Keylet const& k) const override; diff --git a/src/ripple/ledger/detail/RawStateTable.h b/src/ripple/ledger/detail/RawStateTable.h index c7052cd48..2bee9e2a9 100644 --- a/src/ripple/ledger/detail/RawStateTable.h +++ b/src/ripple/ledger/detail/RawStateTable.h @@ -68,11 +68,11 @@ public: bool exists(ReadView const& base, Keylet const& k) const; - boost::optional + std::optional succ( ReadView const& base, key_type const& key, - boost::optional const& last) const; + std::optional const& last) const; void erase(std::shared_ptr const& sle); diff --git a/src/ripple/ledger/detail/ReadViewFwdRange.h b/src/ripple/ledger/detail/ReadViewFwdRange.h index 5b743678f..626a5f474 100644 --- a/src/ripple/ledger/detail/ReadViewFwdRange.h +++ b/src/ripple/ledger/detail/ReadViewFwdRange.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_LEDGER_READVIEWFWDRANGE_H_INCLUDED #define RIPPLE_LEDGER_READVIEWFWDRANGE_H_INCLUDED -#include #include #include #include +#include namespace ripple { diff --git a/src/ripple/ledger/impl/ApplyStateTable.cpp b/src/ripple/ledger/impl/ApplyStateTable.cpp index 2bda195b1..ae70c7191 100644 --- a/src/ripple/ledger/impl/ApplyStateTable.cpp +++ b/src/ripple/ledger/impl/ApplyStateTable.cpp @@ -114,7 +114,7 @@ ApplyStateTable::apply( OpenView& to, STTx const& tx, TER ter, - boost::optional const& deliver, + std::optional const& deliver, beast::Journal j) { // Build metadata and insert @@ -290,9 +290,9 @@ auto ApplyStateTable::succ( ReadView const& base, key_type const& key, - boost::optional const& last) const -> boost::optional + std::optional const& last) const -> std::optional { - boost::optional next = key; + std::optional next = key; items_t::const_iterator iter; // Find base successor that is // not also deleted in our list @@ -317,7 +317,7 @@ ApplyStateTable::succ( // Nothing in our list, return // what we got from the parent. if (last && next >= last) - return boost::none; + return std::nullopt; return next; } diff --git a/src/ripple/ledger/impl/ApplyView.cpp b/src/ripple/ledger/impl/ApplyView.cpp index cccec9421..5c550b67b 100644 --- a/src/ripple/ledger/impl/ApplyView.cpp +++ b/src/ripple/ledger/impl/ApplyView.cpp @@ -24,7 +24,7 @@ namespace ripple { -boost::optional +std::optional ApplyView::dirAdd( bool preserveOrder, Keylet const& directory, @@ -93,7 +93,7 @@ ApplyView::dirAdd( // Check whether we're out of pages. if (++page >= dirNodeMaxPages) - return boost::none; + return std::nullopt; // We are about to create a new node; we'll link it to // the chain first: diff --git a/src/ripple/ledger/impl/ApplyViewBase.cpp b/src/ripple/ledger/impl/ApplyViewBase.cpp index 139a8c90a..4f92b9721 100644 --- a/src/ripple/ledger/impl/ApplyViewBase.cpp +++ b/src/ripple/ledger/impl/ApplyViewBase.cpp @@ -62,8 +62,8 @@ ApplyViewBase::exists(Keylet const& k) const } auto -ApplyViewBase::succ(key_type const& key, boost::optional const& last) - const -> boost::optional +ApplyViewBase::succ(key_type const& key, std::optional const& last) + const -> std::optional { return items_.succ(*base_, key, last); } diff --git a/src/ripple/ledger/impl/BookDirs.cpp b/src/ripple/ledger/impl/BookDirs.cpp index ddda64dd1..5f3171875 100644 --- a/src/ripple/ledger/impl/BookDirs.cpp +++ b/src/ripple/ledger/impl/BookDirs.cpp @@ -112,7 +112,7 @@ BookDirs::const_iterator::operator++() } } - cache_ = boost::none; + cache_ = std::nullopt; return *this; } diff --git a/src/ripple/ledger/impl/CashDiff.cpp b/src/ripple/ledger/impl/CashDiff.cpp index ed0fed00d..d2c915b32 100644 --- a/src/ripple/ledger/impl/CashDiff.cpp +++ b/src/ripple/ledger/impl/CashDiff.cpp @@ -23,6 +23,7 @@ #include #include #include // std::abs() +#include namespace ripple { namespace detail { @@ -299,7 +300,7 @@ private: std::size_t commonKeys_ = 0; // Number of keys common to both rhs and lhs. std::size_t lhsKeys_ = 0; // Number of keys in lhs but not rhs. std::size_t rhsKeys_ = 0; // Number of keys in rhs but not lhs. - boost::optional dropsGone_; + std::optional dropsGone_; detail::CashSummary lhsDiffs_; detail::CashSummary rhsDiffs_; @@ -337,7 +338,7 @@ public: bool hasDiff() const { - return dropsGone_ != boost::none || lhsDiffs_.hasDiff() || + return dropsGone_ != std::nullopt || lhsDiffs_.hasDiff() || rhsDiffs_.hasDiff(); } diff --git a/src/ripple/ledger/impl/Directory.cpp b/src/ripple/ledger/impl/Directory.cpp index 6faf41874..de7ea0d2d 100644 --- a/src/ripple/ledger/impl/Directory.cpp +++ b/src/ripple/ledger/impl/Directory.cpp @@ -108,7 +108,7 @@ const_iterator::operator++() } } - cache_ = boost::none; + cache_ = std::nullopt; return *this; } diff --git a/src/ripple/ledger/impl/OpenView.cpp b/src/ripple/ledger/impl/OpenView.cpp index f352f9352..67858ad56 100644 --- a/src/ripple/ledger/impl/OpenView.cpp +++ b/src/ripple/ledger/impl/OpenView.cpp @@ -161,8 +161,8 @@ OpenView::exists(Keylet const& k) const } auto -OpenView::succ(key_type const& key, boost::optional const& last) const - -> boost::optional +OpenView::succ(key_type const& key, std::optional const& last) const + -> std::optional { return items_.succ(*base_, key, last); } diff --git a/src/ripple/ledger/impl/PaymentSandbox.cpp b/src/ripple/ledger/impl/PaymentSandbox.cpp index 1cf071d6c..bbe2c3134 100644 --- a/src/ripple/ledger/impl/PaymentSandbox.cpp +++ b/src/ripple/ledger/impl/PaymentSandbox.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include @@ -100,13 +99,13 @@ DeferredCredits::ownerCount( } } -boost::optional +std::optional DeferredCredits::ownerCount(AccountID const& id) const { auto i = ownerCounts_.find(id); if (i != ownerCounts_.end()) return i->second; - return boost::none; + return std::nullopt; } // Get the adjustments for the balance between main and other. @@ -114,9 +113,9 @@ auto DeferredCredits::adjustments( AccountID const& main, AccountID const& other, - Currency const& currency) const -> boost::optional + Currency const& currency) const -> std::optional { - boost::optional result; + std::optional result; Key const k = makeKey(main, other, currency); auto i = credits_.find(k); diff --git a/src/ripple/ledger/impl/RawStateTable.cpp b/src/ripple/ledger/impl/RawStateTable.cpp index ff01b68eb..019ef6156 100644 --- a/src/ripple/ledger/impl/RawStateTable.cpp +++ b/src/ripple/ledger/impl/RawStateTable.cpp @@ -199,9 +199,9 @@ auto RawStateTable::succ( ReadView const& base, key_type const& key, - boost::optional const& last) const -> boost::optional + std::optional const& last) const -> std::optional { - boost::optional next = key; + std::optional next = key; items_t::const_iterator iter; // Find base successor that is // not also deleted in our list @@ -226,7 +226,7 @@ RawStateTable::succ( // Nothing in our list, return // what we got from the parent. if (last && next >= last) - return boost::none; + return std::nullopt; return next; } diff --git a/src/ripple/ledger/impl/ReadView.cpp b/src/ripple/ledger/impl/ReadView.cpp index 96192e792..77db253aa 100644 --- a/src/ripple/ledger/impl/ReadView.cpp +++ b/src/ripple/ledger/impl/ReadView.cpp @@ -18,7 +18,6 @@ //============================================================================== #include -#include namespace ripple { @@ -26,7 +25,7 @@ class Rules::Impl { private: std::unordered_set> set_; - boost::optional digest_; + std::optional digest_; std::unordered_set> const& presets_; public: diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index ebc45bded..d6a4dec63 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace ripple { @@ -173,14 +174,14 @@ accountFunds( // Prevent ownerCount from wrapping under error conditions. // // adjustment allows the ownerCount to be adjusted up or down in multiple steps. -// If id != boost.none, then do error reporting. +// If id != std::nullopt, then do error reporting. // // Returns adjusted owner count. static std::uint32_t confineOwnerCount( std::uint32_t current, std::int32_t adjustment, - boost::optional const& id = boost::none, + std::optional const& id = std::nullopt, beast::Journal j = beast::Journal{beast::Journal::getNullSink()}) { std::uint32_t adjusted{current + adjustment}; @@ -572,7 +573,7 @@ getMajorityAmendments(ReadView const& view) return ret; } -boost::optional +std::optional hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) { // Easy cases... @@ -580,7 +581,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) { JLOG(journal.warn()) << "Can't get seq " << seq << " from " << ledger.seq() << " future"; - return boost::none; + return std::nullopt; } if (seq == ledger.seq()) return ledger.info().hash; @@ -615,7 +616,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) { JLOG(journal.debug()) << "Can't get seq " << seq << " from " << ledger.seq() << " past"; - return boost::none; + return std::nullopt; } // in skiplist @@ -632,7 +633,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) } JLOG(journal.warn()) << "Can't get seq " << seq << " from " << ledger.seq() << " error"; - return boost::none; + return std::nullopt; } //------------------------------------------------------------------------------ @@ -720,7 +721,7 @@ describeOwnerDir(AccountID const& account) }; } -boost::optional +std::optional dirAdd( ApplyView& view, Keylet const& dir, diff --git a/src/ripple/net/DatabaseBody.h b/src/ripple/net/DatabaseBody.h index c12d8de90..c884dddd8 100644 --- a/src/ripple/net/DatabaseBody.h +++ b/src/ripple/net/DatabaseBody.h @@ -145,6 +145,9 @@ public: // the payload size (`content_length`) which we can // optionally use for optimization. // + // Note: boost::Beast calls init() and requires a + // boost::optional (not a std::optional) as the + // parameter. void init(boost::optional const&, boost::system::error_code& ec); diff --git a/src/ripple/net/HTTPStream.h b/src/ripple/net/HTTPStream.h index 767d33948..f5aaaa48a 100644 --- a/src/ripple/net/HTTPStream.h +++ b/src/ripple/net/HTTPStream.h @@ -28,6 +28,8 @@ #include #include +#include + namespace ripple { class HTTPStream @@ -111,7 +113,7 @@ public: private: HTTPClientSSLContext ssl_ctx_; - boost::optional> + std::optional> stream_; boost::asio::io_service::strand& strand_; }; @@ -154,7 +156,7 @@ public: boost::system::error_code& ec) override; private: - boost::optional stream_; + std::optional stream_; boost::asio::io_service::strand& strand_; }; diff --git a/src/ripple/net/impl/DatabaseBody.ipp b/src/ripple/net/impl/DatabaseBody.ipp index 5a1bd7e61..fda3b6bda 100644 --- a/src/ripple/net/impl/DatabaseBody.ipp +++ b/src/ripple/net/impl/DatabaseBody.ipp @@ -60,6 +60,7 @@ DatabaseBody::value_type::open( auto db = conn_->checkoutDb(); + // SOCI requires boost::optional (not std::optional) as the parameter. boost::optional pathFromDb; *db << "SELECT Path FROM Download WHERE Part=0;", soci::into(pathFromDb); @@ -78,6 +79,7 @@ DatabaseBody::value_type::open( // Continuing a file download. else { + // SOCI requires boost::optional (not std::optional) parameter. boost::optional size; *db << "SELECT SUM(LENGTH(Data)) FROM Download;", soci::into(size); diff --git a/src/ripple/net/impl/HTTPClient.cpp b/src/ripple/net/impl/HTTPClient.cpp index c9f136cb0..6ab013175 100644 --- a/src/ripple/net/impl/HTTPClient.cpp +++ b/src/ripple/net/impl/HTTPClient.cpp @@ -27,12 +27,12 @@ #include #include #include -#include #include +#include namespace ripple { -boost::optional httpClientSSLContext; +static std::optional httpClientSSLContext; void HTTPClient::initializeSSLContext(Config const& config, beast::Journal j) diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index b3d8f4e47..24fbda876 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/src/ripple/nodestore/DatabaseShard.h b/src/ripple/nodestore/DatabaseShard.h index 4a4f013fa..826b09afd 100644 --- a/src/ripple/nodestore/DatabaseShard.h +++ b/src/ripple/nodestore/DatabaseShard.h @@ -25,9 +25,8 @@ #include #include -#include - #include +#include namespace ripple { namespace NodeStore { @@ -68,14 +67,15 @@ public: @param validLedgerSeq The sequence of the maximum valid ledgers @return If a ledger should be fetched and stored, then returns the - ledger sequence of the ledger to request. Otherwise returns boost::none. - Some reasons this may return boost::none are: all shards are + ledger sequence of the ledger to request. Otherwise returns + std::nullopt. + Some reasons this may return std::nullopt are: all shards are stored and full, max allowed disk space would be exceeded, or a ledger was recently requested and not enough time has passed between requests. @implNote adds a new writable shard if necessary */ - virtual boost::optional + virtual std::optional prepareLedger(std::uint32_t validLedgerSeq) = 0; /** Prepare one or more shard indexes to be imported into the database diff --git a/src/ripple/nodestore/README.md b/src/ripple/nodestore/README.md index 1b1b5ecfd..6e8b5e004 100644 --- a/src/ripple/nodestore/README.md +++ b/src/ripple/nodestore/README.md @@ -48,7 +48,7 @@ contains. The fields are as follows: |0...7 |unused | | |8 |type |NodeObjectType enumeration| |9...end|data |body of the object data | ---- +--- The `NodeStore` provides an interface that stores, in a persistent database, a collection of NodeObjects that rippled uses as its primary representation of ledger entries. All ledger entries are stored as NodeObjects and as such, need @@ -200,7 +200,7 @@ skip list by calling `LedgerMaster::walkHashBySeq` and providing the sequence of a shard's last ledger: ```C++ -boost::optional expectedHash; +std::optional expectedHash; expectedHash = app_.getLedgerMaster().walkHashBySeq(lastLedgerSeq(shardIndex)); ``` diff --git a/src/ripple/nodestore/impl/DatabaseShardImp.cpp b/src/ripple/nodestore/impl/DatabaseShardImp.cpp index 211248aab..a56d9e1ce 100644 --- a/src/ripple/nodestore/impl/DatabaseShardImp.cpp +++ b/src/ripple/nodestore/impl/DatabaseShardImp.cpp @@ -59,7 +59,7 @@ DatabaseShardImp::DatabaseShardImp( , earliestShardIndex_(seqToShardIndex(earliestLedgerSeq())) , avgShardFileSz_(ledgersPerShard_ * kilobytes(192ull)) , openFinalLimit_( - app.config().getValueFor(SizedItem::openFinalLimit, boost::none)) + app.config().getValueFor(SizedItem::openFinalLimit, std::nullopt)) { if (app.config().reporting()) { @@ -191,7 +191,7 @@ DatabaseShardImp::init() shards_.emplace(shardIndex, std::move(shard)) .first->second, true, - boost::none); + std::nullopt); break; case Shard::acquire: @@ -230,10 +230,10 @@ DatabaseShardImp::init() return true; } -boost::optional +std::optional DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) { - boost::optional shardIndex; + std::optional shardIndex; { std::lock_guard lock(mutex_); @@ -246,11 +246,11 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) // Should never get here assert(false); - return boost::none; + return std::nullopt; } if (!canAdd_) - return boost::none; + return std::nullopt; shardIndex = findAcquireIndex(validLedgerSeq, lock); } @@ -262,7 +262,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) std::lock_guard lock(mutex_); canAdd_ = false; } - return boost::none; + return std::nullopt; } auto const pathDesignation = [this, shardIndex = *shardIndex]() { @@ -271,7 +271,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) }(); if (!pathDesignation) - return boost::none; + return std::nullopt; auto const needsHistoricalPath = *pathDesignation == PathDesignation::historical; @@ -287,7 +287,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) }(); if (!shard->init(scheduler_, *ctx_)) - return boost::none; + return std::nullopt; auto const ledgerSeq{shard->prepare()}; { @@ -303,7 +303,7 @@ DatabaseShardImp::prepareShards(std::vector const& shardIndexes) { auto fail = [j = j_, &shardIndexes]( std::string const& msg, - boost::optional shardIndex = boost::none) { + std::optional shardIndex = std::nullopt) { auto multipleIndexPrequel = [&shardIndexes] { std::vector indexesAsString(shardIndexes.size()); std::transform( @@ -750,7 +750,7 @@ DatabaseShardImp::import(Database& source) std::uint32_t latestIndex; { auto loadLedger = [&](bool ascendSort = - true) -> boost::optional { + true) -> std::optional { std::shared_ptr ledger; std::uint32_t ledgerSeq; std::tie(ledger, ledgerSeq, std::ignore) = loadLedgerHelper( @@ -764,7 +764,7 @@ DatabaseShardImp::import(Database& source) { JLOG(j_.error()) << "no suitable ledgers were found in" " the SQLite database to import"; - return boost::none; + return std::nullopt; } return ledgerSeq; }; @@ -889,7 +889,7 @@ DatabaseShardImp::import(Database& source) // Copy the ledgers from node store std::shared_ptr recentStored; - boost::optional lastLedgerHash; + std::optional lastLedgerHash; while (auto const ledgerSeq = shard->prepare()) { @@ -938,7 +938,7 @@ DatabaseShardImp::import(Database& source) shards_.emplace(shardIndex, std::move(shard)) .first->second, true, - boost::none); + std::nullopt); success = true; if (shardIndex < shardBoundaryIndex()) @@ -1214,13 +1214,13 @@ DatabaseShardImp::fetchNodeObject( return shard->fetchNodeObject(hash, fetchReport); } -boost::optional +std::optional DatabaseShardImp::findAcquireIndex( std::uint32_t validLedgerSeq, std::lock_guard const&) { if (validLedgerSeq < earliestLedgerSeq()) - return boost::none; + return std::nullopt; auto const maxShardIndex{[this, validLedgerSeq]() { auto shardIndex{seqToShardIndex(validLedgerSeq)}; @@ -1232,7 +1232,7 @@ DatabaseShardImp::findAcquireIndex( // Check if the shard store has all shards if (shards_.size() >= maxNumShards) - return boost::none; + return std::nullopt; if (maxShardIndex < 1024 || static_cast(shards_.size()) / maxNumShards > 0.5f) @@ -1254,7 +1254,7 @@ DatabaseShardImp::findAcquireIndex( } if (available.empty()) - return boost::none; + return std::nullopt; if (available.size() == 1) return available.front(); @@ -1277,14 +1277,14 @@ DatabaseShardImp::findAcquireIndex( } assert(false); - return boost::none; + return std::nullopt; } void DatabaseShardImp::finalizeShard( std::shared_ptr& shard, bool writeSQLite, - boost::optional const& expectedHash) + std::optional const& expectedHash) { taskQueue_->addTask([this, wptr = std::weak_ptr(shard), @@ -1519,7 +1519,7 @@ DatabaseShardImp::setStoredInShard( if (shard->index() == acquireIndex_) acquireIndex_ = 0; - finalizeShard(it->second, false, boost::none); + finalizeShard(it->second, false, std::nullopt); } else { @@ -1542,10 +1542,10 @@ DatabaseShardImp::removeFailedShard(std::shared_ptr& shard) acquireIndex_ = 0; if (shard->index() == latestShardIndex_) - latestShardIndex_ = boost::none; + latestShardIndex_ = std::nullopt; if (shard->index() == secondLatestShardIndex_) - secondLatestShardIndex_ = boost::none; + secondLatestShardIndex_ = std::nullopt; if ((shards_.erase(shard->index()) > 0) && shard->getState() == Shard::final) @@ -1715,7 +1715,7 @@ DatabaseShardImp::relocateOutdatedShards( moveShard(*prev); } - prev = boost::none; + prev = std::nullopt; } if (cur) @@ -1736,17 +1736,17 @@ DatabaseShardImp::relocateOutdatedShards( } } - cur = boost::none; + cur = std::nullopt; } } } } -auto +std::optional DatabaseShardImp::prepareForNewShard( std::uint32_t shardIndex, std::uint32_t numHistoricalShards, - std::lock_guard const& lock) -> boost::optional + std::lock_guard const& lock) { // Any shard earlier than the two most recent shards is a historical shard auto const boundaryIndex{shardBoundaryIndex()}; @@ -1761,13 +1761,13 @@ DatabaseShardImp::prepareForNewShard( { JLOG(j_.error()) << "maximum number of historical shards reached"; canAdd_ = false; - return boost::none; + return std::nullopt; } if (!sufficientStorage(1, designation, lock)) { JLOG(j_.error()) << "insufficient storage space available"; canAdd_ = false; - return boost::none; + return std::nullopt; } return designation; diff --git a/src/ripple/nodestore/impl/DatabaseShardImp.h b/src/ripple/nodestore/impl/DatabaseShardImp.h index a3fa60948..888fcfbe4 100644 --- a/src/ripple/nodestore/impl/DatabaseShardImp.h +++ b/src/ripple/nodestore/impl/DatabaseShardImp.h @@ -51,7 +51,7 @@ public: [[nodiscard]] bool init() override; - [[nodiscard]] boost::optional + [[nodiscard]] std::optional prepareLedger(std::uint32_t validLedgerSeq) override; bool @@ -230,10 +230,10 @@ private: // values are not updated in real time and are modified only // when adding shards to the database, in order to determine where // pending shards will be stored on the filesystem. A value of - // boost::none indicates that the corresponding shard is not held + // std::nullopt indicates that the corresponding shard is not held // by the database. - boost::optional latestShardIndex_; - boost::optional secondLatestShardIndex_; + std::optional latestShardIndex_; + std::optional secondLatestShardIndex_; // Initialize settings from the configuration file // Lock must be held @@ -254,7 +254,7 @@ private: // Randomly select a shard index not stored // Lock must be held - boost::optional + std::optional findAcquireIndex( std::uint32_t validLedgerSeq, std::lock_guard const&); @@ -265,7 +265,7 @@ private: finalizeShard( std::shared_ptr& shard, bool writeSQLite, - boost::optional const& expectedHash); + std::optional const& expectedHash); // Set storage and file descriptor usage stats void @@ -312,11 +312,11 @@ private: // Checks whether the shard can be stored. If // the new shard can't be stored, returns - // boost::none. Otherwise returns an enum + // std::nullopt. Otherwise returns an enum // indicating whether the new shard should be // placed in a separate directory for historical // shards. - boost::optional + std::optional prepareForNewShard( std::uint32_t shardIndex, std::uint32_t numHistoricalShards, diff --git a/src/ripple/nodestore/impl/Shard.cpp b/src/ripple/nodestore/impl/Shard.cpp index 8bddd9708..e9bce3a7c 100644 --- a/src/ripple/nodestore/impl/Shard.cpp +++ b/src/ripple/nodestore/impl/Shard.cpp @@ -118,7 +118,8 @@ Shard::init(Scheduler& scheduler, nudb::context& context) backend_ = factory->createInstance( NodeObject::keyBytes, section, - megabytes(app_.config().getValueFor(SizedItem::burstSize, boost::none)), + megabytes( + app_.config().getValueFor(SizedItem::burstSize, std::nullopt)), scheduler, context, j_); @@ -183,14 +184,14 @@ Shard::tryClose() return true; } -boost::optional +std::optional Shard::prepare() { if (state_ != acquire) { JLOG(j_.warn()) << "shard " << index_ << " prepare called when not acquiring"; - return boost::none; + return std::nullopt; } std::lock_guard lock(mutex_); @@ -198,7 +199,7 @@ Shard::prepare() { JLOG(j_.error()) << "shard " << index_ << " missing acquire SQLite database"; - return boost::none; + return std::nullopt; } if (acquireInfo_->storedSeqs.empty()) @@ -559,7 +560,7 @@ Shard::isLegacy() const } bool -Shard::finalize(bool writeSQLite, boost::optional const& referenceHash) +Shard::finalize(bool writeSQLite, std::optional const& referenceHash) { auto const scopedCount{makeBackendCount()}; if (!scopedCount) @@ -616,6 +617,8 @@ Shard::finalize(bool writeSQLite, boost::optional const& referenceHash) if (!acquireInfo_) return fail("missing acquire SQLite database"); + // index and sHash must be boost::optional (not std) because that's + // what SOCI expects in its interface. auto session{acquireInfo_->SQLiteDB->checkoutDb()}; boost::optional index; boost::optional sHash; @@ -897,6 +900,8 @@ Shard::open(std::lock_guard const& lock) // A shard being acquired, backend is likely incomplete createAcquireInfo(); + // index and must be boost::optional (not std) because that's + // what SOCI expects in its interface. auto& session{acquireInfo_->SQLiteDB->getSession()}; boost::optional index; soci::blob sociBlob(session); @@ -1003,14 +1008,14 @@ Shard::initSQLite(std::lock_guard const&) lgrSQLiteDB_->getSession() << boost::str( boost::format("PRAGMA cache_size=-%d;") % kilobytes( - config.getValueFor(SizedItem::lgrDBCache, boost::none))); + config.getValueFor(SizedItem::lgrDBCache, std::nullopt))); txSQLiteDB_ = std::make_unique( setup, TxDBName, FinalShardDBPragma, TxDBInit); txSQLiteDB_->getSession() << boost::str( boost::format("PRAGMA cache_size=-%d;") % kilobytes( - config.getValueFor(SizedItem::txnDBCache, boost::none))); + config.getValueFor(SizedItem::txnDBCache, std::nullopt))); } else { diff --git a/src/ripple/nodestore/impl/Shard.h b/src/ripple/nodestore/impl/Shard.h index a946de39a..574e912b4 100644 --- a/src/ripple/nodestore/impl/Shard.h +++ b/src/ripple/nodestore/impl/Shard.h @@ -106,7 +106,7 @@ public: stop_ = true; } - [[nodiscard]] boost::optional + [[nodiscard]] std::optional prepare(); [[nodiscard]] bool @@ -186,7 +186,7 @@ public: of the last ledger in the shard. */ [[nodiscard]] bool - finalize(bool writeSQLite, boost::optional const& referenceHash); + finalize(bool writeSQLite, std::optional const& referenceHash); /** Enables removal of the shard directory on destruction. */ diff --git a/src/ripple/overlay/Cluster.h b/src/ripple/overlay/Cluster.h index 687409f80..46d5a6ddb 100644 --- a/src/ripple/overlay/Cluster.h +++ b/src/ripple/overlay/Cluster.h @@ -71,11 +71,11 @@ public: Cluster(beast::Journal j); /** Determines whether a node belongs in the cluster - @return boost::none if the node isn't a member, + @return std::nullopt if the node isn't a member, otherwise, the comment associated with the node (which may be an empty string). */ - boost::optional + std::optional member(PublicKey const& node) const; /** The number of nodes in the cluster list. */ diff --git a/src/ripple/overlay/Message.h b/src/ripple/overlay/Message.h index 533001dca..0d6479366 100644 --- a/src/ripple/overlay/Message.h +++ b/src/ripple/overlay/Message.h @@ -65,7 +65,7 @@ public: Message( ::google::protobuf::Message const& message, int type, - boost::optional const& validator = {}); + std::optional const& validator = {}); /** Retrieve the size of the packed but uncompressed message data. */ std::size_t @@ -94,7 +94,7 @@ public: } /** Get the validator's key */ - boost::optional const& + std::optional const& getValidatorKey() const { return validatorKey_; @@ -105,7 +105,7 @@ private: std::vector bufferCompressed_; std::size_t category_; std::once_flag once_flag_; - boost::optional validatorKey_; + std::optional validatorKey_; /** Set the payload header * @param in Pointer to the payload diff --git a/src/ripple/overlay/Overlay.h b/src/ripple/overlay/Overlay.h index a9c52dd77..b8675f02a 100644 --- a/src/ripple/overlay/Overlay.h +++ b/src/ripple/overlay/Overlay.h @@ -33,9 +33,9 @@ #include #include #include -#include #include #include +#include #include namespace boost { @@ -215,7 +215,7 @@ public: @return The numerical identifier configured by the administrator of the server. An unseated optional, otherwise. */ - virtual boost::optional + virtual std::optional networkID() const = 0; }; diff --git a/src/ripple/overlay/Peer.h b/src/ripple/overlay/Peer.h index 076617d55..6b2da5a48 100644 --- a/src/ripple/overlay/Peer.h +++ b/src/ripple/overlay/Peer.h @@ -96,7 +96,7 @@ public: virtual bool supportsFeature(ProtocolFeature f) const = 0; - virtual boost::optional + virtual std::optional publisherListSequence(PublicKey const&) const = 0; virtual void diff --git a/src/ripple/overlay/PeerReservationTable.h b/src/ripple/overlay/PeerReservationTable.h index 72d22b9a8..3242ee68a 100644 --- a/src/ripple/overlay/PeerReservationTable.h +++ b/src/ripple/overlay/PeerReservationTable.h @@ -27,10 +27,10 @@ #include #define SOCI_USE_BOOST -#include #include #include +#include #include #include #include @@ -104,15 +104,14 @@ public: * @return the replaced reservation if it existed * @throw soci::soci_error */ - auto - insert_or_assign(PeerReservation const& reservation) - -> boost::optional; + std::optional + insert_or_assign(PeerReservation const& reservation); /** * @return the erased reservation if it existed */ - auto - erase(PublicKey const& nodeId) -> boost::optional; + std::optional + erase(PublicKey const& nodeId); private: beast::Journal mutable journal_; diff --git a/src/ripple/overlay/impl/Cluster.cpp b/src/ripple/overlay/impl/Cluster.cpp index 6707cfc4f..53ec13b74 100644 --- a/src/ripple/overlay/impl/Cluster.cpp +++ b/src/ripple/overlay/impl/Cluster.cpp @@ -35,14 +35,14 @@ Cluster::Cluster(beast::Journal j) : j_(j) { } -boost::optional +std::optional Cluster::member(PublicKey const& identity) const { std::lock_guard lock(mutex_); auto iter = nodes_.find(identity); if (iter == nodes_.end()) - return boost::none; + return std::nullopt; return iter->name(); } diff --git a/src/ripple/overlay/impl/ConnectAttempt.cpp b/src/ripple/overlay/impl/ConnectAttempt.cpp index 80b920831..c723b950b 100644 --- a/src/ripple/overlay/impl/ConnectAttempt.cpp +++ b/src/ripple/overlay/impl/ConnectAttempt.cpp @@ -333,7 +333,7 @@ ConnectAttempt::processResponse() // Just because our peer selected a particular protocol version doesn't // mean that it's acceptable to us. Check that it is: - boost::optional negotiatedProtocol; + std::optional negotiatedProtocol; { auto const pvs = parseProtocolVersions(response_["Upgrade"]); diff --git a/src/ripple/overlay/impl/Message.cpp b/src/ripple/overlay/impl/Message.cpp index 706069dde..86196fcea 100644 --- a/src/ripple/overlay/impl/Message.cpp +++ b/src/ripple/overlay/impl/Message.cpp @@ -26,7 +26,7 @@ namespace ripple { Message::Message( ::google::protobuf::Message const& message, int type, - boost::optional const& validator) + std::optional const& validator) : category_(TrafficCount::categorize(message, type, false)) , validatorKey_(validator) { diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 13721b62c..451bccf18 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -123,7 +123,7 @@ OverlayImpl::OverlayImpl( : Overlay(parent) , app_(app) , io_service_(io_service) - , work_(boost::in_place(std::ref(io_service_))) + , work_(std::in_place, std::ref(io_service_)) , strand_(io_service_) , setup_(setup) , journal_(app_.journal("Overlay")) @@ -1325,7 +1325,7 @@ OverlayImpl::stop() std::lock_guard lock(mutex_); if (!work_) return; - work_ = boost::none; + work_ = std::nullopt; children.reserve(list_.size()); for (auto const& element : list_) diff --git a/src/ripple/overlay/impl/OverlayImpl.h b/src/ripple/overlay/impl/OverlayImpl.h index ae04b388d..d670a2731 100644 --- a/src/ripple/overlay/impl/OverlayImpl.h +++ b/src/ripple/overlay/impl/OverlayImpl.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -47,6 +46,7 @@ #include #include #include +#include #include namespace ripple { @@ -96,7 +96,7 @@ private: Application& app_; boost::asio::io_service& io_service_; - boost::optional work_; + std::optional work_; boost::asio::io_service::strand strand_; mutable std::recursive_mutex mutex_; // VFALCO use std::mutex std::condition_variable_any cond_; @@ -124,7 +124,7 @@ private: // Peer IDs expecting to receive a last link notification std::set csIDs_; - boost::optional networkID_; + std::optional networkID_; reduce_relay::Slots slots_; @@ -365,7 +365,7 @@ public: return peerDisconnectsCharges_; } - boost::optional + std::optional networkID() const override { return networkID_; diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index bd9af1207..946ab0042 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -154,18 +154,18 @@ PeerImp::run() return post(strand_, std::bind(&PeerImp::run, shared_from_this())); auto parseLedgerHash = - [](std::string const& value) -> boost::optional { + [](std::string const& value) -> std::optional { if (uint256 ret; ret.parseHex(value)) return ret; if (auto const s = base64_decode(value); s.size() == uint256::size()) return uint256{s}; - return boost::none; + return std::nullopt; }; - boost::optional closed; - boost::optional previous; + std::optional closed; + std::optional previous; if (auto const iter = headers_.find("Closed-Ledger"); iter != headers_.end()) @@ -575,23 +575,23 @@ PeerImp::fail(std::string const& name, error_code ec) close(); } -boost::optional> +std::optional> PeerImp::getShardIndexes() const { std::lock_guard l{shardInfoMutex_}; auto it{shardInfo_.find(publicKey_)}; if (it != shardInfo_.end()) return it->second.shardIndexes; - return boost::none; + return std::nullopt; } -boost::optional> +std::optional> PeerImp::getPeerShardInfo() const { std::lock_guard l{shardInfoMutex_}; if (!shardInfo_.empty()) return shardInfo_; - return boost::none; + return std::nullopt; } void @@ -1262,7 +1262,7 @@ PeerImp::onMessage(std::shared_ptr const& m) return badData("Invalid shard indexes"); std::uint32_t earliestShard; - boost::optional latestShard; + std::optional latestShard; { auto const curLedgerSeq{ app_.getLedgerMaster().getCurrentLedgerIndex()}; @@ -3127,7 +3127,7 @@ PeerImp::getScore(bool haveItem) const if (haveItem) score += spHaveItem; - boost::optional latency; + std::optional latency; { std::lock_guard sl(recentLock_); latency = latency_; diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index 88aefedc1..ccfaa3176 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -37,9 +37,9 @@ #include #include -#include #include #include +#include #include namespace ripple { @@ -114,8 +114,8 @@ private: boost::circular_buffer recentLedgers_{128}; boost::circular_buffer recentTxSets_{128}; - boost::optional latency_; - boost::optional lastPingSeq_; + std::optional latency_; + std::optional lastPingSeq_; clock_type::time_point lastPingTime_; clock_type::time_point const creationTime_; @@ -339,7 +339,7 @@ public: bool supportsFeature(ProtocolFeature f) const override; - boost::optional + std::optional publisherListSequence(PublicKey const& pubKey) const override { std::lock_guard sl(recentLock_); @@ -398,11 +398,11 @@ public: fail(std::string const& reason); /** Return a range set of known shard indexes from this peer. */ - boost::optional> + std::optional> getShardIndexes() const; /** Return any known shard info from this peer and its sub peers. */ - boost::optional> + std::optional> getPeerShardInfo() const; bool diff --git a/src/ripple/overlay/impl/PeerReservationTable.cpp b/src/ripple/overlay/impl/PeerReservationTable.cpp index 32d0875fe..c391fe863 100644 --- a/src/ripple/overlay/impl/PeerReservationTable.cpp +++ b/src/ripple/overlay/impl/PeerReservationTable.cpp @@ -74,6 +74,8 @@ PeerReservationTable::load(DatabaseCon& connection) connection_ = &connection; auto db = connection_->checkoutDb(); + // These values must be boost::optionals (not std) because SOCI expects + // boost::optionals. boost::optional valPubKey, valDesc; // We should really abstract the table and column names into constants, // but no one else does. Because it is too tedious? It would be easy if we @@ -104,11 +106,10 @@ PeerReservationTable::load(DatabaseCon& connection) return true; } -auto +std::optional PeerReservationTable::insert_or_assign(PeerReservation const& reservation) - -> boost::optional { - boost::optional previous; + std::optional previous; std::lock_guard lock(mutex_); @@ -144,11 +145,10 @@ PeerReservationTable::insert_or_assign(PeerReservation const& reservation) return previous; } -auto +std::optional PeerReservationTable::erase(PublicKey const& nodeId) - -> boost::optional { - boost::optional previous; + std::optional previous; std::lock_guard lock(mutex_); diff --git a/src/ripple/overlay/impl/ProtocolVersion.cpp b/src/ripple/overlay/impl/ProtocolVersion.cpp index fade6c355..0565b8e39 100644 --- a/src/ripple/overlay/impl/ProtocolVersion.cpp +++ b/src/ripple/overlay/impl/ProtocolVersion.cpp @@ -134,10 +134,10 @@ parseProtocolVersions(boost::beast::string_view const& value) return result; } -boost::optional +std::optional negotiateProtocolVersion(std::vector const& versions) { - boost::optional result; + std::optional result; // The protocol version we want to negotiate is the largest item in the // intersection of the versions supported by us and the peer. Since the @@ -157,7 +157,7 @@ negotiateProtocolVersion(std::vector const& versions) return result; } -boost::optional +std::optional negotiateProtocolVersion(boost::beast::string_view const& versions) { auto const them = parseProtocolVersions(versions); diff --git a/src/ripple/overlay/impl/ProtocolVersion.h b/src/ripple/overlay/impl/ProtocolVersion.h index d06f60782..165321547 100644 --- a/src/ripple/overlay/impl/ProtocolVersion.h +++ b/src/ripple/overlay/impl/ProtocolVersion.h @@ -21,8 +21,8 @@ #define RIPPLE_OVERLAY_PROTOCOLVERSION_H_INCLUDED #include -#include #include +#include #include #include #include @@ -62,11 +62,11 @@ std::vector parseProtocolVersions(boost::beast::string_view const& s); /** Given a list of supported protocol versions, choose the one we prefer. */ -boost::optional +std::optional negotiateProtocolVersion(std::vector const& versions); /** Given a list of supported protocol versions, choose the one we prefer. */ -boost::optional +std::optional negotiateProtocolVersion(boost::beast::string_view const& versions); /** The list of all the protocol versions we support. */ diff --git a/src/ripple/peerfinder/Slot.h b/src/ripple/peerfinder/Slot.h index dd1b7467f..b43b8075d 100644 --- a/src/ripple/peerfinder/Slot.h +++ b/src/ripple/peerfinder/Slot.h @@ -22,8 +22,8 @@ #include #include -#include #include +#include namespace ripple { namespace PeerFinder { @@ -65,16 +65,16 @@ public: remote_endpoint() const = 0; /** The local endpoint of the socket, when known. */ - virtual boost::optional const& + virtual std::optional const& local_endpoint() const = 0; - virtual boost::optional + virtual std::optional listening_port() const = 0; /** The peer's public key, when known. The public key is established when the handshake is complete. */ - virtual boost::optional const& + virtual std::optional const& public_key() const = 0; }; diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index f3c91cec4..fa6b60042 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -852,7 +852,7 @@ public: slots_.erase(iter); } // Remove the key if present - if (slot->public_key() != boost::none) + if (slot->public_key() != std::nullopt) { auto const iter = keys_.find(*slot->public_key()); // Key must exist @@ -1109,7 +1109,7 @@ public: { beast::PropertyStream::Map item(set); SlotImp const& slot(*entry.second); - if (slot.local_endpoint() != boost::none) + if (slot.local_endpoint() != std::nullopt) item["local_address"] = to_string(*slot.local_endpoint()); item["remote_address"] = to_string(slot.remote_endpoint()); if (slot.inbound()) diff --git a/src/ripple/peerfinder/impl/PeerfinderManager.cpp b/src/ripple/peerfinder/impl/PeerfinderManager.cpp index 73383befd..7da7e1714 100644 --- a/src/ripple/peerfinder/impl/PeerfinderManager.cpp +++ b/src/ripple/peerfinder/impl/PeerfinderManager.cpp @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include #include namespace ripple { @@ -36,7 +36,7 @@ class ManagerImp : public Manager { public: boost::asio::io_service& io_service_; - boost::optional work_; + std::optional work_; clock_type& m_clock; beast::Journal m_journal; StoreSqdb m_store; @@ -55,7 +55,7 @@ public: beast::insight::Collector::ptr const& collector) : Manager(stoppable) , io_service_(io_service) - , work_(boost::in_place(std::ref(io_service_))) + , work_(std::in_place, std::ref(io_service_)) , m_clock(clock) , m_journal(journal) , m_store(journal) @@ -76,7 +76,7 @@ public: { if (work_) { - work_ = boost::none; + work_.reset(); checker_.stop(); m_logic.stop(); } diff --git a/src/ripple/peerfinder/impl/SlotImp.h b/src/ripple/peerfinder/impl/SlotImp.h index 91e1b83c3..2abd5c7c7 100644 --- a/src/ripple/peerfinder/impl/SlotImp.h +++ b/src/ripple/peerfinder/impl/SlotImp.h @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include namespace ripple { namespace PeerFinder { @@ -81,24 +81,24 @@ public: return m_remote_endpoint; } - boost::optional const& + std::optional const& local_endpoint() const override { return m_local_endpoint; } - boost::optional const& + std::optional const& public_key() const override { return m_public_key; } - boost::optional + std::optional listening_port() const override { std::uint32_t const value = m_listening_port; if (value == unknownPort) - return boost::none; + return std::nullopt; return value; } @@ -181,8 +181,8 @@ private: bool m_reserved; State m_state; beast::IP::Endpoint m_remote_endpoint; - boost::optional m_local_endpoint; - boost::optional m_public_key; + std::optional m_local_endpoint; + std::optional m_public_key; static std::int32_t constexpr unknownPort = -1; std::atomic m_listening_port; diff --git a/src/ripple/peerfinder/impl/StoreSqdb.h b/src/ripple/peerfinder/impl/StoreSqdb.h index 7b687a151..9319b95aa 100644 --- a/src/ripple/peerfinder/impl/StoreSqdb.h +++ b/src/ripple/peerfinder/impl/StoreSqdb.h @@ -140,6 +140,7 @@ public: // get version int version(0); { + // SOCI requires a boost::optional (not std::optional) parameter. boost::optional vO; m_session << "SELECT " " version " diff --git a/src/ripple/protocol/AccountID.h b/src/ripple/protocol/AccountID.h index e105084c8..e514cfb74 100644 --- a/src/ripple/protocol/AccountID.h +++ b/src/ripple/protocol/AccountID.h @@ -26,9 +26,9 @@ #include #include #include -#include #include #include +#include #include namespace ripple { @@ -51,10 +51,10 @@ std::string toBase58(AccountID const& v); /** Parse AccountID from checked, base58 string. - @return boost::none if a parse error occurs + @return std::nullopt if a parse error occurs */ template <> -boost::optional +std::optional parseBase58(std::string const& s); /** Compute AccountID from public key. diff --git a/src/ripple/protocol/Feature.h b/src/ripple/protocol/Feature.h index 05506614f..6864ff49a 100644 --- a/src/ripple/protocol/Feature.h +++ b/src/ripple/protocol/Feature.h @@ -22,9 +22,9 @@ #include #include -#include #include #include +#include #include /** @@ -131,7 +131,7 @@ public: return sizeof(featureNames) / sizeof(featureNames[0]); } - boost::optional + std::optional getRegisteredFeature(std::string const& name) const; std::size_t @@ -147,7 +147,7 @@ supportedAmendments(); } // namespace detail -boost::optional +std::optional getRegisteredFeature(std::string const& name); size_t diff --git a/src/ripple/protocol/KeyType.h b/src/ripple/protocol/KeyType.h index 5a3c6b5d0..810e3e6fd 100644 --- a/src/ripple/protocol/KeyType.h +++ b/src/ripple/protocol/KeyType.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_KEYTYPE_H_INCLUDED #define RIPPLE_PROTOCOL_KEYTYPE_H_INCLUDED -#include +#include #include namespace ripple { @@ -30,7 +30,7 @@ enum class KeyType { ed25519 = 1, }; -inline boost::optional +inline std::optional keyTypeFromString(std::string const& s) { if (s == "secp256k1") diff --git a/src/ripple/protocol/PublicKey.h b/src/ripple/protocol/PublicKey.h index dea6745cc..406c6c58f 100644 --- a/src/ripple/protocol/PublicKey.h +++ b/src/ripple/protocol/PublicKey.h @@ -25,10 +25,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -73,7 +73,7 @@ public: /** Create a public key. Preconditions: - publicKeyType(slice) != boost::none + publicKeyType(slice) != std::nullopt */ explicit PublicKey(Slice const& slice); @@ -168,7 +168,7 @@ struct STExchange using value_type = PublicKey; static void - get(boost::optional& t, STBlob const& u) + get(std::optional& t, STBlob const& u) { t.emplace(Slice(u.data(), u.size())); } @@ -189,7 +189,7 @@ toBase58(TokenType type, PublicKey const& pk) } template <> -boost::optional +std::optional parseBase58(TokenType type, std::string const& s); enum class ECDSACanonicality { canonical, fullyCanonical }; @@ -209,29 +209,29 @@ enum class ECDSACanonicality { canonical, fullyCanonical }; where G is the curve order. - This routine returns boost::none if the format + This routine returns std::nullopt if the format of the signature is invalid (for example, the points are encoded incorrectly). - @return boost::none if the signature fails + @return std::nullopt if the signature fails validity checks. @note Only the format of the signature is checked, no verification cryptography is performed. */ -boost::optional +std::optional ecdsaCanonicality(Slice const& sig); /** Returns the type of public key. - @return boost::none If the public key does not + @return std::nullopt If the public key does not represent a known type. */ /** @{ */ -[[nodiscard]] boost::optional +[[nodiscard]] std::optional publicKeyType(Slice const& slice); -[[nodiscard]] inline boost::optional +[[nodiscard]] inline std::optional publicKeyType(PublicKey const& publicKey) { return publicKeyType(publicKey.slice()); diff --git a/src/ripple/protocol/SField.h b/src/ripple/protocol/SField.h index d6c510146..f9278ea73 100644 --- a/src/ripple/protocol/SField.h +++ b/src/ripple/protocol/SField.h @@ -292,7 +292,7 @@ struct TypedField : SField } }; -/** Indicate boost::optional field semantics. */ +/** Indicate std::optional field semantics. */ template struct OptionaledField { diff --git a/src/ripple/protocol/STExchange.h b/src/ripple/protocol/STExchange.h index 64392bc04..e22d75b08 100644 --- a/src/ripple/protocol/STExchange.h +++ b/src/ripple/protocol/STExchange.h @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -48,7 +48,7 @@ struct STExchange, T> using value_type = U; static void - get(boost::optional& t, STInteger const& u) + get(std::optional& t, STInteger const& u) { t = u.value(); } @@ -68,7 +68,7 @@ struct STExchange using value_type = Slice; static void - get(boost::optional& t, STBlob const& u) + get(std::optional& t, STBlob const& u) { t.emplace(u.data(), u.size()); } @@ -88,7 +88,7 @@ struct STExchange using value_type = Buffer; static void - get(boost::optional& t, STBlob const& u) + get(std::optional& t, STBlob const& u) { t.emplace(u.data(), u.size()); } @@ -111,10 +111,10 @@ struct STExchange /** Return the value of a field in an STObject as a given type. */ /** @{ */ template -boost::optional +std::optional get(STObject const& st, TypedField const& f) { - boost::optional t; + std::optional t; STBase const* const b = st.peekAtPField(f); if (!b) return t; @@ -130,7 +130,7 @@ get(STObject const& st, TypedField const& f) } template -boost::optional::value_type> +std::optional::value_type> get(STObject const& st, TypedField const& f) { return get(st, f); diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index df50826bb..3d2a72b02 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -104,7 +104,7 @@ private: using value_type = typename T::value_type; using optional_type = - boost::optional::type>; + std::optional::type>; public: OptionalProxy(OptionalProxy const&) = default; @@ -129,20 +129,20 @@ private: operator optional_type() const; - /** Explicit conversion to boost::optional */ + /** Explicit conversion to std::optional */ optional_type operator~() const; friend bool - operator==(OptionalProxy const& lhs, boost::none_t) noexcept + operator==(OptionalProxy const& lhs, std::nullopt_t) noexcept { return !lhs.engaged(); } friend bool - operator==(boost::none_t, OptionalProxy const& rhs) noexcept + operator==(std::nullopt_t, OptionalProxy const& rhs) noexcept { - return rhs == boost::none; + return rhs == std::nullopt; } friend bool @@ -170,15 +170,15 @@ private: } friend bool - operator!=(OptionalProxy const& lhs, boost::none_t) noexcept + operator!=(OptionalProxy const& lhs, std::nullopt_t) noexcept { - return !(lhs == boost::none); + return !(lhs == std::nullopt); } friend bool - operator!=(boost::none_t, OptionalProxy const& rhs) noexcept + operator!=(std::nullopt_t, OptionalProxy const& rhs) noexcept { - return !(rhs == boost::none); + return !(rhs == std::nullopt); } friend bool @@ -199,7 +199,7 @@ private: return !(lhs == rhs); } - // Emulate boost::optional::value_or + // Emulate std::optional::value_or value_type value_or(value_type val) const { @@ -207,7 +207,7 @@ private: } OptionalProxy& - operator=(boost::none_t const&); + operator=(std::nullopt_t const&); OptionalProxy& operator=(optional_type&& v); OptionalProxy& @@ -482,16 +482,16 @@ public: typename T::value_type operator[](TypedField const& f) const; - /** Get the value of a field as boost::optional + /** Get the value of a field as a std::optional @param An OptionaledField built from an SField value representing the desired object field. In typical use, the OptionaledField will be constructed by using the ~ operator on an SField. - @return boost::none if the field is not present, else the value of the - specified field. + @return std::nullopt if the field is not present, else the value of + the specified field. */ template - boost::optional> + std::optional> operator[](OptionaledField const& of) const; /** Get a modifiable field value. @@ -505,14 +505,14 @@ public: ValueProxy operator[](TypedField const& f); - /** Return a modifiable field value as boost::optional + /** Return a modifiable field value as std::optional @param An OptionaledField built from an SField value representing the desired object field. In typical use, the OptionaledField will be constructed by using the ~ operator on an SField. @return Transparent proxy object to an `optional` holding a modifiable - reference to the value of the specified field. Returns boost::none - if the field is not present. + reference to the value of the specified field. Returns + std::nullopt if the field is not present. */ template OptionalProxy @@ -529,16 +529,16 @@ public: typename T::value_type at(TypedField const& f) const; - /** Get the value of a field as boost::optional + /** Get the value of a field as std::optional @param An OptionaledField built from an SField value representing the desired object field. In typical use, the OptionaledField will be constructed by using the ~ operator on an SField. - @return boost::none if the field is not present, else the value of the - specified field. + @return std::nullopt if the field is not present, else the value of + the specified field. */ template - boost::optional> + std::optional> at(OptionaledField const& of) const; /** Get a modifiable field value. @@ -552,14 +552,14 @@ public: ValueProxy at(TypedField const& f); - /** Return a modifiable field value as boost::optional + /** Return a modifiable field value as std::optional @param An OptionaledField built from an SField value representing the desired object field. In typical use, the OptionaledField will be constructed by using the ~ operator on an SField. @return Transparent proxy object to an `optional` holding a modifiable - reference to the value of the specified field. Returns boost::none - if the field is not present. + reference to the value of the specified field. Returns + std::nullopt if the field is not present. */ template OptionalProxy @@ -901,7 +901,7 @@ STObject::OptionalProxy::operator~() const template auto -STObject::OptionalProxy::operator=(boost::none_t const&) -> OptionalProxy& +STObject::OptionalProxy::operator=(std::nullopt_t const&) -> OptionalProxy& { disengage(); return *this; @@ -969,7 +969,7 @@ auto STObject::OptionalProxy::optional_value() const -> optional_type { if (!engaged()) - return boost::none; + return std::nullopt; return this->value(); } @@ -983,7 +983,7 @@ STObject::operator[](TypedField const& f) const } template -boost::optional> +std::optional> STObject::operator[](OptionaledField const& of) const { return at(of); @@ -1030,19 +1030,19 @@ STObject::at(TypedField const& f) const } template -boost::optional> +std::optional> STObject::at(OptionaledField const& of) const { auto const b = peekAtPField(*of.f); if (!b) - return boost::none; + return std::nullopt; auto const u = dynamic_cast(b); if (!u) { assert(mType); assert(b->getSType() == STI_NOTPRESENT); if (mType->style(*of.f) == soeOPTIONAL) - return boost::none; + return std::nullopt; assert(mType->style(*of.f) == soeDEFAULT); return typename T::value_type{}; } diff --git a/src/ripple/protocol/STParsedJSON.h b/src/ripple/protocol/STParsedJSON.h index 0d38618cb..11cba5740 100644 --- a/src/ripple/protocol/STParsedJSON.h +++ b/src/ripple/protocol/STParsedJSON.h @@ -21,7 +21,7 @@ #define RIPPLE_PROTOCOL_STPARSEDJSON_H_INCLUDED #include -#include +#include namespace ripple { @@ -47,7 +47,7 @@ public: ~STParsedJSONObject() = default; /** The STObject if the parse was successful. */ - boost::optional object; + std::optional object; /** On failure, an appropriate set of error values. */ Json::Value error; @@ -75,7 +75,7 @@ public: ~STParsedJSONArray() = default; /** The STArray if the parse was successful. */ - boost::optional array; + std::optional array; /** On failure, an appropriate set of error values. */ Json::Value error; diff --git a/src/ripple/protocol/STPathSet.h b/src/ripple/protocol/STPathSet.h index dce226a01..804cf818d 100644 --- a/src/ripple/protocol/STPathSet.h +++ b/src/ripple/protocol/STPathSet.h @@ -24,9 +24,9 @@ #include #include #include -#include #include #include +#include namespace ripple { @@ -50,9 +50,9 @@ private: public: STPathElement( - boost::optional const& account, - boost::optional const& currency, - boost::optional const& issuer) + std::optional const& account, + std::optional const& currency, + std::optional const& issuer) : mType(typeNone) { if (!account) diff --git a/src/ripple/protocol/SecretKey.h b/src/ripple/protocol/SecretKey.h index 69c390a16..3026fb9d7 100644 --- a/src/ripple/protocol/SecretKey.h +++ b/src/ripple/protocol/SecretKey.h @@ -113,7 +113,7 @@ operator!=(SecretKey const& lhs, SecretKey const& rhs) /** Parse a secret key */ template <> -boost::optional +std::optional parseBase58(TokenType type, std::string const& s); inline std::string diff --git a/src/ripple/protocol/Seed.h b/src/ripple/protocol/Seed.h index b31ad1d6c..c1768d205 100644 --- a/src/ripple/protocol/Seed.h +++ b/src/ripple/protocol/Seed.h @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include namespace ripple { @@ -113,11 +113,11 @@ generateSeed(std::string const& passPhrase); /** Parse a Base58 encoded string into a seed */ template <> -boost::optional +std::optional parseBase58(std::string const& s); /** Attempt to parse a string as a seed */ -boost::optional +std::optional parseGenericSeed(std::string const& str); /** Encode a Seed in RFC1751 format */ diff --git a/src/ripple/protocol/TER.h b/src/ripple/protocol/TER.h index 7077a1ac0..eff280b4f 100644 --- a/src/ripple/protocol/TER.h +++ b/src/ripple/protocol/TER.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -598,7 +598,7 @@ transToken(TER code); std::string transHuman(TER code); -boost::optional +std::optional transCode(std::string const& token); } // namespace ripple diff --git a/src/ripple/protocol/impl/AccountID.cpp b/src/ripple/protocol/impl/AccountID.cpp index 5f9b7a1b7..8ca8d1d15 100644 --- a/src/ripple/protocol/impl/AccountID.cpp +++ b/src/ripple/protocol/impl/AccountID.cpp @@ -32,12 +32,12 @@ toBase58(AccountID const& v) } template <> -boost::optional +std::optional parseBase58(std::string const& s) { auto const result = decodeBase58Token(s, TokenType::AccountID); if (result.size() != AccountID::bytes) - return boost::none; + return std::nullopt; return AccountID{result}; } diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/ripple/protocol/impl/Feature.cpp index eaf1cbf71..87e739e2e 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/ripple/protocol/impl/Feature.cpp @@ -48,12 +48,12 @@ detail::FeatureCollections::FeatureCollections() } } -boost::optional +std::optional detail::FeatureCollections::getRegisteredFeature(std::string const& name) const { auto const i = nameToFeature.find(name); if (i == nameToFeature.end()) - return boost::none; + return std::nullopt; return i->second; } @@ -141,7 +141,7 @@ detail::supportedAmendments() //------------------------------------------------------------------------------ -boost::optional +std::optional getRegisteredFeature(std::string const& name) { return featureCollections.getRegisteredFeature(name); diff --git a/src/ripple/protocol/impl/PublicKey.cpp b/src/ripple/protocol/impl/PublicKey.cpp index 2feb9fef2..e1c6c5fd3 100644 --- a/src/ripple/protocol/impl/PublicKey.cpp +++ b/src/ripple/protocol/impl/PublicKey.cpp @@ -36,13 +36,13 @@ operator<<(std::ostream& os, PublicKey const& pk) } template <> -boost::optional +std::optional parseBase58(TokenType type, std::string const& s) { auto const result = decodeBase58Token(s, type); auto const pks = makeSlice(result); if (!publicKeyType(pks)) - return boost::none; + return std::nullopt; return PublicKey(pks); } @@ -50,28 +50,28 @@ parseBase58(TokenType type, std::string const& s) // Parse a length-prefixed number // Format: 0x02 -static boost::optional +static std::optional sigPart(Slice& buf) { if (buf.size() < 3 || buf[0] != 0x02) - return boost::none; + return std::nullopt; auto const len = buf[1]; buf += 2; if (len > buf.size() || len < 1 || len > 33) - return boost::none; + return std::nullopt; // Can't be negative if ((buf[0] & 0x80) != 0) - return boost::none; + return std::nullopt; if (buf[0] == 0) { // Can't be zero if (len == 1) - return boost::none; + return std::nullopt; // Can't be padded if ((buf[1] & 0x80) == 0) - return boost::none; + return std::nullopt; } - boost::optional number = Slice(buf.data(), len); + std::optional number = Slice(buf.data(), len); buf += len; return number; } @@ -110,7 +110,7 @@ sliceToHex(Slice const& slice) https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 https://github.com/sipa/bitcoin/commit/58bc86e37fda1aec270bccb3df6c20fbd2a6591c */ -boost::optional +std::optional ecdsaCanonicality(Slice const& sig) { using uint264 = @@ -127,22 +127,22 @@ ecdsaCanonicality(Slice const& sig) // The format of a signature should be: // <30> [ <02> ] [ <02> ] if ((sig.size() < 8) || (sig.size() > 72)) - return boost::none; + return std::nullopt; if ((sig[0] != 0x30) || (sig[1] != (sig.size() - 2))) - return boost::none; + return std::nullopt; Slice p = sig + 2; auto r = sigPart(p); auto s = sigPart(p); if (!r || !s || !p.empty()) - return boost::none; + return std::nullopt; uint264 R(sliceToHex(*r)); if (R >= G) - return boost::none; + return std::nullopt; uint264 S(sliceToHex(*s)); if (S >= G) - return boost::none; + return std::nullopt; // (R,S) and (R,G-S) are canonical, // but is fully canonical when S <= G-S @@ -199,7 +199,7 @@ PublicKey::operator=(PublicKey const& other) //------------------------------------------------------------------------------ -boost::optional +std::optional publicKeyType(Slice const& slice) { if (slice.size() == 33) @@ -211,7 +211,7 @@ publicKeyType(Slice const& slice) return KeyType::secp256k1; } - return boost::none; + return std::nullopt; } bool diff --git a/src/ripple/protocol/impl/STParsedJSON.cpp b/src/ripple/protocol/impl/STParsedJSON.cpp index da5e53b33..890715424 100644 --- a/src/ripple/protocol/impl/STParsedJSON.cpp +++ b/src/ripple/protocol/impl/STParsedJSON.cpp @@ -184,7 +184,7 @@ non_object_in_array(std::string const& item, Json::UInt index) // This function is used by parseObject to parse any JSON type that doesn't // recurse. Everything represented here is a leaf-type. -static boost::optional +static std::optional parseLeaf( std::string const& json_name, std::string const& fieldName, @@ -192,7 +192,7 @@ parseLeaf( Json::Value const& value, Json::Value& error) { - boost::optional ret; + std::optional ret; auto const& field = SField::getField(fieldName); @@ -756,7 +756,7 @@ parseLeaf( static const int maxDepth = 64; // Forward declaration since parseObject() and parseArray() call each other. -static boost::optional +static std::optional parseArray( std::string const& json_name, Json::Value const& json, @@ -764,7 +764,7 @@ parseArray( int depth, Json::Value& error); -static boost::optional +static std::optional parseObject( std::string const& json_name, Json::Value const& json, @@ -775,13 +775,13 @@ parseObject( if (!json.isObjectOrNull()) { error = not_an_object(json_name); - return boost::none; + return std::nullopt; } if (depth > maxDepth) { error = too_deep(json_name); - return boost::none; + return std::nullopt; } try @@ -797,7 +797,7 @@ parseObject( if (field == sfInvalid) { error = unknown_field(json_name, fieldName); - return boost::none; + return std::nullopt; } switch (field.fieldType) @@ -810,7 +810,7 @@ parseObject( if (!value.isObject()) { error = not_an_object(json_name, fieldName); - return boost::none; + return std::nullopt; } try @@ -822,13 +822,13 @@ parseObject( depth + 1, error); if (!ret) - return boost::none; + return std::nullopt; data.emplace_back(std::move(*ret)); } catch (std::exception const&) { error = invalid_data(json_name, fieldName); - return boost::none; + return std::nullopt; } break; @@ -843,14 +843,14 @@ parseObject( field, depth + 1, error); - if (array == boost::none) - return boost::none; + if (!array.has_value()) + return std::nullopt; data.emplace_back(std::move(*array)); } catch (std::exception const&) { error = invalid_data(json_name, fieldName); - return boost::none; + return std::nullopt; } break; @@ -861,7 +861,7 @@ parseObject( parseLeaf(json_name, fieldName, &inName, value, error); if (!leaf) - return boost::none; + return std::nullopt; data.emplace_back(std::move(*leaf)); } @@ -883,10 +883,10 @@ parseObject( { error = invalid_data(json_name); } - return boost::none; + return std::nullopt; } -static boost::optional +static std::optional parseArray( std::string const& json_name, Json::Value const& json, @@ -897,13 +897,13 @@ parseArray( if (!json.isArrayOrNull()) { error = not_an_array(json_name); - return boost::none; + return std::nullopt; } if (depth > maxDepth) { error = too_deep(json_name); - return boost::none; + return std::nullopt; } try @@ -919,7 +919,7 @@ parseArray( { // null values are !singleKey error = singleton_expected(json_name, i); - return boost::none; + return std::nullopt; } // TODO: There doesn't seem to be a nice way to get just the @@ -932,7 +932,7 @@ parseArray( if (nameField == sfInvalid) { error = unknown_field(json_name, objectName); - return boost::none; + return std::nullopt; } Json::Value const objectFields(json[i][objectName]); @@ -948,13 +948,13 @@ parseArray( std::string errMsg = error["error_message"].asString(); error["error_message"] = "Error at '" + ss.str() + "'. " + errMsg; - return boost::none; + return std::nullopt; } if (ret->getFName().fieldType != STI_OBJECT) { error = non_object_in_array(ss.str(), i); - return boost::none; + return std::nullopt; } tail.push_back(std::move(*ret)); @@ -965,7 +965,7 @@ parseArray( catch (std::exception const&) { error = invalid_data(json_name); - return boost::none; + return std::nullopt; } } @@ -990,12 +990,12 @@ STParsedJSONArray::STParsedJSONArray( using namespace STParsedJSONDetail; auto arr = parseArray(name, json, sfGeneric, 0, error); if (!arr) - array = boost::none; + array.reset(); else { auto p = dynamic_cast(&arr->get()); if (p == nullptr) - array = boost::none; + array.reset(); else array = std::move(*p); } diff --git a/src/ripple/protocol/impl/STPathSet.cpp b/src/ripple/protocol/impl/STPathSet.cpp index 141fad329..620cbaab0 100644 --- a/src/ripple/protocol/impl/STPathSet.cpp +++ b/src/ripple/protocol/impl/STPathSet.cpp @@ -23,7 +23,6 @@ #include #include #include -#include namespace ripple { diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/ripple/protocol/impl/STTx.cpp index 6e1b86f1f..898738d7b 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -167,8 +167,7 @@ STTx::getSeqProxy() const if (seq != 0) return SeqProxy::sequence(seq); - boost::optional const ticketSeq{operator[]( - ~sfTicketSequence)}; + std::optional const ticketSeq{operator[](~sfTicketSequence)}; if (!ticketSeq) // No TicketSequence specified. Return the Sequence, whatever it is. return SeqProxy::sequence(seq); diff --git a/src/ripple/protocol/impl/SecretKey.cpp b/src/ripple/protocol/impl/SecretKey.cpp index 741e864e4..13aafdb1f 100644 --- a/src/ripple/protocol/impl/SecretKey.cpp +++ b/src/ripple/protocol/impl/SecretKey.cpp @@ -372,14 +372,14 @@ randomKeyPair(KeyType type) } template <> -boost::optional +std::optional parseBase58(TokenType type, std::string const& s) { auto const result = decodeBase58Token(s, type); if (result.empty()) - return boost::none; + return std::nullopt; if (result.size() != 32) - return boost::none; + return std::nullopt; return SecretKey(makeSlice(result)); } diff --git a/src/ripple/protocol/impl/Seed.cpp b/src/ripple/protocol/impl/Seed.cpp index f38556c2e..f4c6ee52b 100644 --- a/src/ripple/protocol/impl/Seed.cpp +++ b/src/ripple/protocol/impl/Seed.cpp @@ -75,22 +75,22 @@ generateSeed(std::string const& passPhrase) } template <> -boost::optional +std::optional parseBase58(std::string const& s) { auto const result = decodeBase58Token(s, TokenType::FamilySeed); if (result.empty()) - return boost::none; + return std::nullopt; if (result.size() != 16) - return boost::none; + return std::nullopt; return Seed(makeSlice(result)); } -boost::optional +std::optional parseGenericSeed(std::string const& str) { if (str.empty()) - return boost::none; + return std::nullopt; if (parseBase58(str) || parseBase58(TokenType::NodePublic, str) || @@ -98,7 +98,7 @@ parseGenericSeed(std::string const& str) parseBase58(TokenType::NodePrivate, str) || parseBase58(TokenType::AccountSecret, str)) { - return boost::none; + return std::nullopt; } { diff --git a/src/ripple/protocol/impl/TER.cpp b/src/ripple/protocol/impl/TER.cpp index b0592d248..cb8cd7e89 100644 --- a/src/ripple/protocol/impl/TER.cpp +++ b/src/ripple/protocol/impl/TER.cpp @@ -210,7 +210,7 @@ transHuman(TER code) return transResultInfo(code, token, text) ? text : "-"; } -boost::optional +std::optional transCode(std::string const& token) { static auto const results = [] { @@ -227,7 +227,7 @@ transCode(std::string const& token) auto const r = results.find(token); if (r == results.end()) - return boost::none; + return std::nullopt; return TER::fromInt(r->second); } diff --git a/src/ripple/protocol/tokens.h b/src/ripple/protocol/tokens.h index d507c2542..0afb4509f 100644 --- a/src/ripple/protocol/tokens.h +++ b/src/ripple/protocol/tokens.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_TOKENS_H_INCLUDED #define RIPPLE_PROTOCOL_TOKENS_H_INCLUDED -#include #include +#include #include namespace ripple { @@ -38,11 +38,11 @@ enum class TokenType : std::uint8_t { }; template -boost::optional +std::optional parseBase58(std::string const& s); template -boost::optional +std::optional parseBase58(TokenType type, std::string const& s); /** Encode data in Base58Check format using XRPL alphabet diff --git a/src/ripple/rpc/handlers/AccountInfo.cpp b/src/ripple/rpc/handlers/AccountInfo.cpp index d8d638b0a..e20e828a9 100644 --- a/src/ripple/rpc/handlers/AccountInfo.cpp +++ b/src/ripple/rpc/handlers/AccountInfo.cpp @@ -129,10 +129,10 @@ doAccountInfo(RPC::JsonContext& context) std::uint32_t seqCount = 0; std::uint32_t ticketCount = 0; - boost::optional lowestSeq; - boost::optional highestSeq; - boost::optional lowestTicket; - boost::optional highestTicket; + std::optional lowestSeq; + std::optional highestSeq; + std::optional lowestTicket; + std::optional highestTicket; bool anyAuthChanged = false; XRPAmount totalSpend(0); diff --git a/src/ripple/rpc/handlers/AccountObjects.cpp b/src/ripple/rpc/handlers/AccountObjects.cpp index 1783c89da..e9205424e 100644 --- a/src/ripple/rpc/handlers/AccountObjects.cpp +++ b/src/ripple/rpc/handlers/AccountObjects.cpp @@ -73,7 +73,7 @@ doAccountObjects(RPC::JsonContext& context) if (!ledger->exists(keylet::account(accountID))) return rpcError(rpcACT_NOT_FOUND); - boost::optional> typeFilter; + std::optional> typeFilter; if (params.isMember(jss::deletion_blockers_only) && params[jss::deletion_blockers_only].asBool()) diff --git a/src/ripple/rpc/handlers/BookOffers.cpp b/src/ripple/rpc/handlers/BookOffers.cpp index a802dd5cc..a42a0de99 100644 --- a/src/ripple/rpc/handlers/BookOffers.cpp +++ b/src/ripple/rpc/handlers/BookOffers.cpp @@ -159,7 +159,7 @@ doBookOffers(RPC::JsonContext& context) rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', expected non-XRP issuer."); - boost::optional takerID; + std::optional takerID; if (context.params.isMember(jss::taker)) { if (!context.params[jss::taker].isString()) diff --git a/src/ripple/rpc/handlers/PayChanClaim.cpp b/src/ripple/rpc/handlers/PayChanClaim.cpp index 9c46893dd..c5b1202fa 100644 --- a/src/ripple/rpc/handlers/PayChanClaim.cpp +++ b/src/ripple/rpc/handlers/PayChanClaim.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include namespace ripple { @@ -63,10 +63,9 @@ doChannelAuthorize(RPC::JsonContext& context) if (!channelId.parseHex(params[jss::channel_id].asString())) return rpcError(rpcCHANNEL_MALFORMED); - boost::optional const optDrops = - params[jss::amount].isString() + std::optional const optDrops = params[jss::amount].isString() ? to_uint64(params[jss::amount].asString()) - : boost::none; + : std::nullopt; if (!optDrops) return rpcError(rpcCHANNEL_AMT_MALFORMED); @@ -104,7 +103,7 @@ doChannelVerify(RPC::JsonContext& context) if (!params.isMember(p)) return RPC::missing_field_error(p); - boost::optional pk; + std::optional pk; { std::string const strPk = params[jss::public_key].asString(); pk = parseBase58(TokenType::AccountPublic, strPk); @@ -125,10 +124,9 @@ doChannelVerify(RPC::JsonContext& context) if (!channelId.parseHex(params[jss::channel_id].asString())) return rpcError(rpcCHANNEL_MALFORMED); - boost::optional const optDrops = - params[jss::amount].isString() + std::optional const optDrops = params[jss::amount].isString() ? to_uint64(params[jss::amount].asString()) - : boost::none; + : std::nullopt; if (!optDrops) return rpcError(rpcCHANNEL_AMT_MALFORMED); diff --git a/src/ripple/rpc/handlers/Reservations.cpp b/src/ripple/rpc/handlers/Reservations.cpp index ec180a591..0d4ad65eb 100644 --- a/src/ripple/rpc/handlers/Reservations.cpp +++ b/src/ripple/rpc/handlers/Reservations.cpp @@ -25,8 +25,7 @@ #include #include -#include - +#include #include #include @@ -71,7 +70,7 @@ doPeerReservationsAdd(RPC::JsonContext& context) // channel_verify takes a key in both base58 and hex. // @nikb prefers that we take only base58. - boost::optional optPk = parseBase58( + std::optional optPk = parseBase58( TokenType::NodePublic, params[jss::public_key].asString()); if (!optPk) return rpcError(rpcPUBLIC_MALFORMED); @@ -102,7 +101,7 @@ doPeerReservationsDel(RPC::JsonContext& context) if (!params[jss::public_key].isString()) return RPC::expected_field_error(jss::public_key, "a string"); - boost::optional optPk = parseBase58( + std::optional optPk = parseBase58( TokenType::NodePublic, params[jss::public_key].asString()); if (!optPk) return rpcError(rpcPUBLIC_MALFORMED); diff --git a/src/ripple/rpc/handlers/Subscribe.cpp b/src/ripple/rpc/handlers/Subscribe.cpp index 6a5848468..c11fa7e4d 100644 --- a/src/ripple/rpc/handlers/Subscribe.cpp +++ b/src/ripple/rpc/handlers/Subscribe.cpp @@ -273,7 +273,7 @@ doSubscribe(RPC::JsonContext& context) return rpcError(rpcBAD_MARKET); } - boost::optional takerID; + std::optional takerID; if (j.isMember(jss::taker)) { diff --git a/src/ripple/rpc/handlers/TxHistory.cpp b/src/ripple/rpc/handlers/TxHistory.cpp index 9e7bf2315..6b972bae2 100644 --- a/src/ripple/rpc/handlers/TxHistory.cpp +++ b/src/ripple/rpc/handlers/TxHistory.cpp @@ -176,6 +176,7 @@ doTxHistory(RPC::JsonContext& context) { auto db = context.app.getTxnDB().checkoutDb(); + // SOCI requires boost::optional (not std::optional) as parameters. boost::optional ledgerSeq; boost::optional status; soci::blob sociRawTxnBlob(*db); diff --git a/src/ripple/rpc/handlers/ValidationCreate.cpp b/src/ripple/rpc/handlers/ValidationCreate.cpp index d41a01db8..ae1ee33d4 100644 --- a/src/ripple/rpc/handlers/ValidationCreate.cpp +++ b/src/ripple/rpc/handlers/ValidationCreate.cpp @@ -26,7 +26,7 @@ namespace ripple { -static boost::optional +static std::optional validationSeed(Json::Value const& params) { if (!params.isMember(jss::secret)) diff --git a/src/ripple/rpc/handlers/WalletPropose.cpp b/src/ripple/rpc/handlers/WalletPropose.cpp index e8fb9541f..012ed5c16 100644 --- a/src/ripple/rpc/handlers/WalletPropose.cpp +++ b/src/ripple/rpc/handlers/WalletPropose.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -73,8 +72,8 @@ doWalletPropose(RPC::JsonContext& context) Json::Value walletPropose(Json::Value const& params) { - boost::optional keyType; - boost::optional seed; + std::optional keyType; + std::optional seed; bool rippleLibSeed = false; if (params.isMember(jss::key_type)) diff --git a/src/ripple/rpc/impl/DeliveredAmount.cpp b/src/ripple/rpc/impl/DeliveredAmount.cpp index 3f71e926a..03a36b9a1 100644 --- a/src/ripple/rpc/impl/DeliveredAmount.cpp +++ b/src/ripple/rpc/impl/DeliveredAmount.cpp @@ -41,7 +41,7 @@ namespace RPC { GetLedgerIndex is a callable that returns a LedgerIndex GetCloseTime is a callable that returns a - boost::optional + std::optional */ template std::optional @@ -174,7 +174,7 @@ insertDeliveredAmount( } template -std::optional +static std::optional getDeliveredAmount( RPC::Context const& context, std::shared_ptr const& serializedTx, @@ -185,7 +185,7 @@ getDeliveredAmount( { auto const getCloseTime = [&context, - &getLedgerIndex]() -> boost::optional { + &getLedgerIndex]() -> std::optional { return context.ledgerMaster.getCloseTimeBySeq(getLedgerIndex()); }; return getDeliveredAmount( diff --git a/src/ripple/rpc/impl/GRPCHelpers.cpp b/src/ripple/rpc/impl/GRPCHelpers.cpp index ed50fd2d4..e6a0100e9 100644 --- a/src/ripple/rpc/impl/GRPCHelpers.cpp +++ b/src/ripple/rpc/impl/GRPCHelpers.cpp @@ -1756,10 +1756,10 @@ convert( std::uint32_t seqCount = 0; std::uint32_t ticketCount = 0; - boost::optional lowestSeq; - boost::optional highestSeq; - boost::optional lowestTicket; - boost::optional highestTicket; + std::optional lowestSeq; + std::optional highestSeq; + std::optional lowestTicket; + std::optional highestTicket; bool anyAuthChanged = false; XRPAmount totalSpend(0); diff --git a/src/ripple/rpc/impl/RPCHelpers.cpp b/src/ripple/rpc/impl/RPCHelpers.cpp index d937b2f38..fc17b5ee3 100644 --- a/src/ripple/rpc/impl/RPCHelpers.cpp +++ b/src/ripple/rpc/impl/RPCHelpers.cpp @@ -34,10 +34,10 @@ namespace ripple { namespace RPC { -boost::optional +std::optional accountFromStringStrict(std::string const& account) { - boost::optional result; + std::optional result; auto const publicKey = parseBase58(TokenType::AccountPublic, account); @@ -92,7 +92,7 @@ bool getAccountObjects( ReadView const& ledger, AccountID const& account, - boost::optional> const& typeFilter, + std::optional> const& typeFilter, uint256 dirIndex, uint256 const& entryIndex, std::uint32_t const limit, @@ -608,7 +608,7 @@ injectSLE(Json::Value& jv, SLE const& sle) } } -boost::optional +std::optional readLimitField( unsigned int& limit, Tuning::LimitRange const& range, @@ -624,17 +624,17 @@ readLimitField( if (!isUnlimited(context.role)) limit = std::max(range.rmin, std::min(range.rmax, limit)); } - return boost::none; + return std::nullopt; } -boost::optional +std::optional parseRippleLibSeed(Json::Value const& value) { // ripple-lib encodes seed used to generate an Ed25519 wallet in a // non-standard way. While rippled never encode seeds that way, we // try to detect such keys to avoid user confusion. if (!value.isString()) - return boost::none; + return std::nullopt; auto const result = decodeBase58Token(value.asString(), TokenType::None); @@ -643,10 +643,10 @@ parseRippleLibSeed(Json::Value const& value) static_cast(result[1]) == std::uint8_t(0x4B)) return Seed(makeSlice(result.substr(2))); - return boost::none; + return std::nullopt; } -boost::optional +std::optional getSeedFromRPC(Json::Value const& params, Json::Value& error) { // The array should be constexpr, but that makes Visual Studio unhappy. @@ -671,20 +671,20 @@ getSeedFromRPC(Json::Value const& params, Json::Value& error) "Exactly one of the following must be specified: " + std::string(jss::passphrase) + ", " + std::string(jss::seed) + " or " + std::string(jss::seed_hex)); - return boost::none; + return std::nullopt; } // Make sure a string is present if (!params[seedType].isString()) { error = RPC::expected_field_error(seedType, "string"); - return boost::none; + return std::nullopt; } auto const fieldContents = params[seedType].asString(); // Convert string to seed. - boost::optional seed; + std::optional seed; if (seedType == jss::seed.c_str()) seed = parseBase58(fieldContents); @@ -745,8 +745,8 @@ keypairForSignature(Json::Value const& params, Json::Value& error) return {}; } - boost::optional keyType; - boost::optional seed; + std::optional keyType; + std::optional seed; if (has_key_type) { diff --git a/src/ripple/rpc/impl/RPCHelpers.h b/src/ripple/rpc/impl/RPCHelpers.h index 33ead9cee..11331d30c 100644 --- a/src/ripple/rpc/impl/RPCHelpers.h +++ b/src/ripple/rpc/impl/RPCHelpers.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include namespace Json { @@ -46,7 +46,7 @@ namespace RPC { struct JsonContext; /** Get an AccountID from an account ID or public key. */ -boost::optional +std::optional accountFromStringStrict(std::string const&); // --> strIdent: public key, account ID, or regular seed. @@ -84,7 +84,7 @@ bool getAccountObjects( ReadView const& ledger, AccountID const& account, - boost::optional> const& typeFilter, + std::optional> const& typeFilter, uint256 dirIndex, uint256 const& entryIndex, std::uint32_t const limit, @@ -174,16 +174,16 @@ injectSLE(Json::Value& jv, SLE const& sle); If there is an error, return it as JSON. */ -boost::optional +std::optional readLimitField( unsigned int& limit, Tuning::LimitRange const&, JsonContext const&); -boost::optional +std::optional getSeedFromRPC(Json::Value const& params, Json::Value& error); -boost::optional +std::optional parseRippleLibSeed(Json::Value const& params); std::pair diff --git a/src/ripple/rpc/impl/ServerHandlerImp.cpp b/src/ripple/rpc/impl/ServerHandlerImp.cpp index fd709507d..e3ea56d30 100644 --- a/src/ripple/rpc/impl/ServerHandlerImp.cpp +++ b/src/ripple/rpc/impl/ServerHandlerImp.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/rpc/impl/ShardArchiveHandler.cpp b/src/ripple/rpc/impl/ShardArchiveHandler.cpp index 18e49c6a8..c0b0676dd 100644 --- a/src/ripple/rpc/impl/ShardArchiveHandler.cpp +++ b/src/ripple/rpc/impl/ShardArchiveHandler.cpp @@ -330,7 +330,7 @@ ShardArchiveHandler::next(std::lock_guard const& l) // that comes after the last ledger in this shard. A // later ledger must be present in order to reliably // retrieve the hash of the shard's last ledger. - boost::optional expectedHash; + std::optional expectedHash; bool shouldHaveHash = false; if (auto const seq = app_.getShardStore()->lastLedgerSeq(shardIndex); (shouldHaveHash = app_.getLedgerMaster().getValidLedgerIndex() > seq)) @@ -387,7 +387,7 @@ ShardArchiveHandler::next(std::lock_guard const& l) if (!downloader_->download( url.domain, - std::to_string(url.port.get_value_or(defaultPort)), + std::to_string(url.port.value_or(defaultPort)), url.path, 11, dstDir / "archive.tar.lz4", diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index df443d816..0c7871cfc 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -229,7 +229,7 @@ checkPayment( sendMax.issue().currency, sendMax.issue().account, amount, - boost::none, + std::nullopt, app); if (pf.findPaths(app.config().PATH_SEARCH_OLD)) { @@ -496,7 +496,7 @@ transactionPreProcessImpl( } STParsedJSONObject parsed(std::string(jss::tx_json), tx_json); - if (parsed.object == boost::none) + if (!parsed.object.has_value()) { Json::Value err; err[jss::error] = parsed.error[jss::error]; @@ -514,7 +514,7 @@ transactionPreProcessImpl( sfSigningPubKey, signingArgs.isMultiSigning() ? Slice(nullptr, 0) : pk.slice()); - stpTrans = std::make_shared(std::move(parsed.object.get())); + stpTrans = std::make_shared(std::move(parsed.object.value())); } catch (STObject::FieldErr& err) { @@ -1118,7 +1118,7 @@ transactionSubmitMultiSigned( try { stpTrans = - std::make_shared(std::move(parsedTx_json.object.get())); + std::make_shared(std::move(parsedTx_json.object.value())); } catch (STObject::FieldErr& err) { diff --git a/src/ripple/rpc/json_body.h b/src/ripple/rpc/json_body.h index b4d35abaa..fb5289981 100644 --- a/src/ripple/rpc/json_body.h +++ b/src/ripple/rpc/json_body.h @@ -62,6 +62,8 @@ struct json_body { } + // get() must return a boost::optional (not a std::optional) to meet + // requirements of a boost::beast::BodyReader. boost::optional> get(boost::beast::error_code& ec) { @@ -95,6 +97,8 @@ struct json_body ec.assign(0, ec.category()); } + // get() must return a boost::optional (not a std::optional) to meet + // requirements of a boost::beast::BodyWriter. boost::optional> get(boost::beast::error_code& ec) { diff --git a/src/ripple/server/Port.h b/src/ripple/server/Port.h index 2c2b37566..ae260f679 100644 --- a/src/ripple/server/Port.h +++ b/src/ripple/server/Port.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -105,10 +106,10 @@ struct ParsedPort int limit = 0; std::uint16_t ws_queue_limit; - boost::optional ip; - boost::optional port; - boost::optional> admin_ip; - boost::optional> secure_gateway_ip; + std::optional ip; + std::optional port; + std::optional> admin_ip; + std::optional> secure_gateway_ip; }; void diff --git a/src/ripple/server/impl/Port.cpp b/src/ripple/server/impl/Port.cpp index 7639a62af..27e162c70 100644 --- a/src/ripple/server/impl/Port.cpp +++ b/src/ripple/server/impl/Port.cpp @@ -72,7 +72,7 @@ populate( Section const& section, std::string const& field, std::ostream& log, - boost::optional>& ips, + std::optional>& ips, bool allowAllIps, std::vector const& admin_ip) { @@ -240,7 +240,7 @@ parse_Port(ParsedPort& port, Section const& section, std::ostream& log) log, port.secure_gateway_ip, false, - port.admin_ip.get_value_or({})); + port.admin_ip.value_or(std::vector{})); set(port.user, "user", section); set(port.password, "password", section); diff --git a/src/ripple/server/impl/ServerImpl.h b/src/ripple/server/impl/ServerImpl.h index 2c2d63789..a3abf7891 100644 --- a/src/ripple/server/impl/ServerImpl.h +++ b/src/ripple/server/impl/ServerImpl.h @@ -26,10 +26,10 @@ #include #include #include -#include #include #include #include +#include namespace ripple { @@ -84,7 +84,7 @@ private: beast::Journal const j_; boost::asio::io_service& io_service_; boost::asio::io_service::strand strand_; - boost::optional work_; + std::optional work_; std::mutex m_; std::vector ports_; @@ -151,7 +151,7 @@ template ServerImpl::~ServerImpl() { // Handler::onStopped will not be called - work_ = boost::none; + work_ = std::nullopt; ios_.close(); ios_.join(); } @@ -184,7 +184,7 @@ void ServerImpl::close() { ios_.close([&] { - work_ = boost::none; + work_ = std::nullopt; handler_.onStopped(*this); }); } diff --git a/src/ripple/shamap/SHAMapSyncFilter.h b/src/ripple/shamap/SHAMapSyncFilter.h index 7ab649f8a..37eda4fdb 100644 --- a/src/ripple/shamap/SHAMapSyncFilter.h +++ b/src/ripple/shamap/SHAMapSyncFilter.h @@ -22,7 +22,7 @@ #include #include -#include +#include /** Callback for filtering SHAMap during sync. */ namespace ripple { @@ -45,7 +45,7 @@ public: Blob&& nodeData, SHAMapNodeType type) const = 0; - virtual boost::optional + virtual std::optional getNode(SHAMapHash const& nodeHash) const = 0; }; diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 5023a1cab..3a0138884 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -482,7 +482,7 @@ struct Flow_test : public beast::unit_test::suite false, true, false, - boost::none, + std::nullopt, smax, flowJournal); }(); diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 848451974..a1a59d3f0 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -246,7 +246,7 @@ public: return true; return false; } - boost::optional + std::optional publisherListSequence(PublicKey const&) const override { return {}; diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index d9d51cf8d..82457802a 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -485,8 +485,8 @@ public: BEAST_EXPECT(cache.getMasterKey(kp1.first) == pk); BEAST_EXPECT(cache.getMasterKey(kp0.first) == kp0.first); - // getSigningKey should return boost::none for a revoked master public - // key getMasterKey should return boost::none for an ephemeral public + // getSigningKey should return std::nullopt for a revoked master public + // key getMasterKey should return std::nullopt for an ephemeral public // key from a revoked master public key BEAST_EXPECT( ManifestDisposition::accepted == @@ -644,7 +644,7 @@ public: auto buildManifestObject = [&](std::uint32_t seq, - boost::optional domain, + std::optional domain, bool noSigningPublic = false, bool noSignature = false) { STObject st(sfGeneric); @@ -677,7 +677,7 @@ public: { // valid manifest without domain auto const st = - buildManifestObject(++sequence, boost::none); + buildManifestObject(++sequence, std::nullopt); auto const m = toString(st); auto const manifest = deserializeManifest(m); @@ -831,7 +831,7 @@ public: { auto const st = buildManifestObject( std::numeric_limits::max(), - boost::none, + std::nullopt, true, true); @@ -850,7 +850,7 @@ public: { // can't specify an ephemeral signing key auto const st = buildManifestObject( std::numeric_limits::max(), - boost::none, + std::nullopt, true, false); @@ -859,7 +859,7 @@ public: { // can't specify an ephemeral signature auto const st = buildManifestObject( std::numeric_limits::max(), - boost::none, + std::nullopt, false, true); @@ -868,7 +868,7 @@ public: { // can't specify an ephemeral key & signature auto const st = buildManifestObject( std::numeric_limits::max(), - boost::none, + std::nullopt, false, false); diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index 8bb870e99..70b17e136 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -47,7 +47,7 @@ namespace detail { void stpath_append_one(STPath& st, jtx::Account const& account) { - st.push_back(STPathElement({account.id(), boost::none, boost::none})); + st.push_back(STPathElement({account.id(), std::nullopt, std::nullopt})); } template @@ -60,7 +60,7 @@ stpath_append_one(STPath& st, T const& t) void stpath_append_one(STPath& st, jtx::IOU const& iou) { - st.push_back(STPathElement({iou.account.id(), iou.currency, boost::none})); + st.push_back(STPathElement({iou.account.id(), iou.currency, std::nullopt})); } void @@ -72,7 +72,7 @@ stpath_append_one(STPath& st, STPathElement const& pe) void stpath_append_one(STPath& st, jtx::BookSpec const& book) { - st.push_back(STPathElement({boost::none, book.currency, book.account})); + st.push_back(STPathElement({std::nullopt, book.currency, book.account})); } template @@ -207,8 +207,8 @@ public: jtx::Account const& src, jtx::Account const& dst, STAmount const& saDstAmount, - boost::optional const& saSendMax = boost::none, - boost::optional const& saSrcCurrency = boost::none) + std::optional const& saSendMax = std::nullopt, + std::optional const& saSrcCurrency = std::nullopt) { using namespace jtx; @@ -268,8 +268,8 @@ public: jtx::Account const& src, jtx::Account const& dst, STAmount const& saDstAmount, - boost::optional const& saSendMax = boost::none, - boost::optional const& saSrcCurrency = boost::none) + std::optional const& saSendMax = std::nullopt, + std::optional const& saSrcCurrency = std::nullopt) { Json::Value result = find_paths_request( env, src, dst, saDstAmount, saSendMax, saSrcCurrency); @@ -516,14 +516,14 @@ public: "alice", "bob", Account("bob")["AUD"](-1), - boost::optional(XRP(100000000))); + std::optional(XRP(100000000))); BEAST_EXPECT(st.empty()); std::tie(st, sa, da) = find_paths( env, "alice", "bob", Account("bob")["USD"](-1), - boost::optional(XRP(100000000))); + std::optional(XRP(100000000))); BEAST_EXPECT(sa == XRP(100)); BEAST_EXPECT(equal(da, Account("bob")["USD"](100))); } @@ -970,7 +970,7 @@ public: { auto const& send_amt = XRP(10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, boost::none, xrpCurrency()); + find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(st.empty()); } @@ -980,7 +980,7 @@ public: // does not exist. auto const& send_amt = XRP(200); std::tie(st, sa, da) = find_paths( - env, A1, Account{"A0"}, send_amt, boost::none, xrpCurrency()); + env, A1, Account{"A0"}, send_amt, std::nullopt, xrpCurrency()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(st.empty()); } @@ -988,7 +988,7 @@ public: { auto const& send_amt = G3["ABC"](10); std::tie(st, sa, da) = - find_paths(env, A2, G3, send_amt, boost::none, xrpCurrency()); + find_paths(env, A2, G3, send_amt, std::nullopt, xrpCurrency()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, XRP(100))); BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"])))); @@ -997,7 +997,7 @@ public: { auto const& send_amt = A2["ABC"](1); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, boost::none, xrpCurrency()); + find_paths(env, A1, A2, send_amt, std::nullopt, xrpCurrency()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, XRP(10))); BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3))); @@ -1006,7 +1006,7 @@ public: { auto const& send_amt = A3["ABC"](1); std::tie(st, sa, da) = - find_paths(env, A1, A3, send_amt, boost::none, xrpCurrency()); + find_paths(env, A1, A3, send_amt, std::nullopt, xrpCurrency()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, XRP(10))); BEAST_EXPECT(same(st, stpath(IPE(G3["ABC"]), G3, A2))); @@ -1044,7 +1044,7 @@ public: auto const& send_amt = XRP(10); std::tie(st, sa, da) = - find_paths(env, A1, A2, send_amt, boost::none, A2["ABC"].currency); + find_paths(env, A1, A2, send_amt, std::nullopt, A2["ABC"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["ABC"](1))); BEAST_EXPECT(same(st, stpath(G3, IPE(xrpIssue())))); @@ -1087,7 +1087,7 @@ public: { auto const& send_amt = A2["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, A2, send_amt, boost::none, A2["HKD"].currency); + env, A1, A2, send_amt, std::nullopt, A2["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); BEAST_EXPECT(same(st, stpath(G1BS, M1, G2SW))); @@ -1096,7 +1096,7 @@ public: { auto const& send_amt = A1["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A2, A1, send_amt, boost::none, A1["HKD"].currency); + env, A2, A1, send_amt, std::nullopt, A1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A2["HKD"](10))); BEAST_EXPECT(same(st, stpath(G2SW, M1, G1BS))); @@ -1105,7 +1105,7 @@ public: { auto const& send_amt = A2["HKD"](10); std::tie(st, sa, da) = find_paths( - env, G1BS, A2, send_amt, boost::none, A1["HKD"].currency); + env, G1BS, A2, send_amt, std::nullopt, A1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, G1BS["HKD"](10))); BEAST_EXPECT(same(st, stpath(M1, G2SW))); @@ -1114,7 +1114,7 @@ public: { auto const& send_amt = M1["HKD"](10); std::tie(st, sa, da) = find_paths( - env, M1, G1BS, send_amt, boost::none, A1["HKD"].currency); + env, M1, G1BS, send_amt, std::nullopt, A1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, M1["HKD"](10))); BEAST_EXPECT(st.empty()); @@ -1123,7 +1123,7 @@ public: { auto const& send_amt = A1["HKD"](10); std::tie(st, sa, da) = find_paths( - env, G2SW, A1, send_amt, boost::none, A1["HKD"].currency); + env, G2SW, A1, send_amt, std::nullopt, A1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, G2SW["HKD"](10))); BEAST_EXPECT(same(st, stpath(M1, G1BS))); @@ -1182,7 +1182,7 @@ public: // Source -> Destination (repay source issuer) auto const& send_amt = G1["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, G1, send_amt, boost::none, G1["HKD"].currency); + env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(st.empty()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); @@ -1193,7 +1193,7 @@ public: // Source -> Destination (repay destination issuer) auto const& send_amt = A1["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, G1, send_amt, boost::none, G1["HKD"].currency); + env, A1, G1, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(st.empty()); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); @@ -1204,7 +1204,7 @@ public: // Source -> AC -> Destination auto const& send_amt = A3["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, A3, send_amt, boost::none, G1["HKD"].currency); + env, A1, A3, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); BEAST_EXPECT(same(st, stpath(G1))); @@ -1215,7 +1215,7 @@ public: // Source -> OB -> Destination auto const& send_amt = G2["HKD"](10); std::tie(st, sa, da) = find_paths( - env, G1, G2, send_amt, boost::none, G1["HKD"].currency); + env, G1, G2, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, G1["HKD"](10))); BEAST_EXPECT(same( @@ -1231,7 +1231,7 @@ public: // Source -> AC -> OB -> Destination auto const& send_amt = G2["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, G2, send_amt, boost::none, G1["HKD"].currency); + env, A1, G2, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); BEAST_EXPECT(same( @@ -1247,7 +1247,7 @@ public: // Source -> AC -> OB to XRP -> OB from XRP -> AC -> Destination auto const& send_amt = A2["HKD"](10); std::tie(st, sa, da) = find_paths( - env, A1, A2, send_amt, boost::none, G1["HKD"].currency); + env, A1, A2, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, A1["HKD"](10))); BEAST_EXPECT(same( @@ -1297,7 +1297,7 @@ public: STPathSet st; STAmount sa, da; std::tie(st, sa, da) = - find_paths(env, G1, A2, send_amt, boost::none, G1["HKD"].currency); + find_paths(env, G1, A2, send_amt, std::nullopt, G1["HKD"].currency); BEAST_EXPECT(equal(da, send_amt)); BEAST_EXPECT(equal(sa, G1["HKD"](10))); BEAST_EXPECT(same(st, stpath(M1, G2), stpath(IPE(G2["HKD"]), G2))); diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index af501ad6b..0e38de517 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -92,15 +92,15 @@ struct PayChan_test : public beast::unit_test::suite return (*slep)[sfAmount]; } - static boost::optional + static std::optional channelExpiration(ReadView const& view, uint256 const& chan) { auto const slep = view.read({ltPAYCHAN, chan}); if (!slep) - return boost::none; + return std::nullopt; if (auto const r = (*slep)[~sfExpiration]) return r.value(); - return boost::none; + return std::nullopt; } static Json::Value @@ -110,8 +110,8 @@ struct PayChan_test : public beast::unit_test::suite STAmount const& amount, NetClock::duration const& settleDelay, PublicKey const& pk, - boost::optional const& cancelAfter = boost::none, - boost::optional const& dstTag = boost::none) + std::optional const& cancelAfter = std::nullopt, + std::optional const& dstTag = std::nullopt) { using namespace jtx; Json::Value jv; @@ -134,7 +134,7 @@ struct PayChan_test : public beast::unit_test::suite jtx::Account const& account, uint256 const& channel, STAmount const& amount, - boost::optional const& expiration = boost::none) + std::optional const& expiration = std::nullopt) { using namespace jtx; Json::Value jv; @@ -152,10 +152,10 @@ struct PayChan_test : public beast::unit_test::suite claim( jtx::Account const& account, uint256 const& channel, - boost::optional const& balance = boost::none, - boost::optional const& amount = boost::none, - boost::optional const& signature = boost::none, - boost::optional const& pk = boost::none) + std::optional const& balance = std::nullopt, + std::optional const& amount = std::nullopt, + std::optional const& signature = std::nullopt, + std::optional const& pk = std::nullopt) { using namespace jtx; Json::Value jv; @@ -604,7 +604,7 @@ struct PayChan_test : public beast::unit_test::suite assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); - env(claim(bob, chan, reqBal, boost::none, Slice(sig), alice.pk())); + env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); BEAST_EXPECT(channelBalance(*env.current(), chan) == reqBal); auto const feeDrops = env.current()->fees().base; BEAST_EXPECT(env.balance(bob) == preBob + delta - feeDrops); @@ -621,7 +621,7 @@ struct PayChan_test : public beast::unit_test::suite assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); - env(claim(bob, chan, reqBal, boost::none, Slice(sig), alice.pk())); + env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); BEAST_EXPECT(channelBalance(*env.current(), chan) == reqBal); auto const feeDrops = env.current()->fees().base; BEAST_EXPECT(env.balance(bob) == preBob + delta - feeDrops); @@ -714,7 +714,7 @@ struct PayChan_test : public beast::unit_test::suite { auto const chan = channel(alice, bob, env.seq(alice)); env(create( - alice, bob, channelFunds, settleDelay, pk, boost::none, 1)); + alice, bob, channelFunds, settleDelay, pk, std::nullopt, 1)); BEAST_EXPECT(channelExists(*env.current(), chan)); } } @@ -961,10 +961,10 @@ struct PayChan_test : public beast::unit_test::suite auto testLimit = [](test::jtx::Env& env, test::jtx::Account const& src, - boost::optional limit = boost::none, + std::optional limit = std::nullopt, Json::Value const& marker = Json::nullValue, - boost::optional const& dst = - boost::none) { + std::optional const& dst = + std::nullopt) { Json::Value jvc; jvc[jss::account] = src.human(); if (dst) @@ -1431,7 +1431,7 @@ struct PayChan_test : public beast::unit_test::suite auto const settleDelay = 3600s; auto const channelFunds = XRP(1000); - boost::optional cancelAfter; + std::optional cancelAfter; { auto const chan = to_string(channel(alice, bob, env.seq(alice))); diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 24ffa2f9f..09adf115e 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -286,24 +286,24 @@ public: AccFactory&& accF, IssFactory&& issF, CurrencyFactory&& currencyF, - boost::optional const& existingAcc, - boost::optional const& existingCur, - boost::optional const& existingIss) + std::optional const& existingAcc, + std::optional const& existingCur, + std::optional const& existingIss) { assert(!has(SB::last)); - auto const acc = [&]() -> boost::optional { + auto const acc = [&]() -> std::optional { if (!has(SB::acc)) - return boost::none; + return std::nullopt; if (has(SB::rootAcc)) return xrpAccount(); if (has(SB::existingAcc) && existingAcc) return existingAcc; return accF().id(); }(); - auto const iss = [&]() -> boost::optional { + auto const iss = [&]() -> std::optional { if (!has(SB::iss)) - return boost::none; + return std::nullopt; if (has(SB::rootIss)) return xrpAccount(); if (has(SB::sameAccIss)) @@ -312,9 +312,9 @@ public: return *existingIss; return issF().id(); }(); - auto const cur = [&]() -> boost::optional { + auto const cur = [&]() -> std::optional { if (!has(SB::cur)) - return boost::none; + return std::nullopt; if (has(SB::xrp)) return xrpCurrency(); if (has(SB::existingCur) && existingCur) @@ -395,7 +395,7 @@ struct ExistingElementPool jtx::Env& env, size_t numAct, size_t numCur, - boost::optional const& offererIndex) + std::optional const& offererIndex) { using namespace jtx; @@ -582,9 +582,9 @@ struct ExistingElementPool STAmount const& deliver, std::vector const& prefix, std::vector const& suffix, - boost::optional const& existingAcc, - boost::optional const& existingCur, - boost::optional const& existingIss, + std::optional const& existingAcc, + std::optional const& existingCur, + std::optional const& existingIss, F&& f) { auto accF = [&] { return this->getAvailAccount(); }; @@ -660,7 +660,7 @@ struct PayStrand_test : public beast::unit_test::suite auto test = [&, this]( jtx::Env& env, Issue const& deliver, - boost::optional const& sendMaxIssue, + std::optional const& sendMaxIssue, STPath const& path, TER expTer, auto&&... expSteps) { @@ -669,7 +669,7 @@ struct PayStrand_test : public beast::unit_test::suite alice, bob, deliver, - boost::none, + std::nullopt, sendMaxIssue, path, true, @@ -696,7 +696,7 @@ struct PayStrand_test : public beast::unit_test::suite alice, alice, /*deliver*/ xrpIssue(), - /*limitQuality*/ boost::none, + /*limitQuality*/ std::nullopt, /*sendMaxIssue*/ EUR.issue(), path, true, @@ -713,7 +713,7 @@ struct PayStrand_test : public beast::unit_test::suite alice, alice, /*deliver*/ xrpIssue(), - /*limitQuality*/ boost::none, + /*limitQuality*/ std::nullopt, /*sendMaxIssue*/ EUR.issue(), path, true, @@ -730,10 +730,10 @@ struct PayStrand_test : public beast::unit_test::suite Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); - test(env, USD, boost::none, STPath(), terNO_LINE); + test(env, USD, std::nullopt, STPath(), terNO_LINE); env.trust(USD(1000), alice, bob, carol); - test(env, USD, boost::none, STPath(), tecPATH_DRY); + test(env, USD, std::nullopt, STPath(), tecPATH_DRY); env(pay(gw, alice, USD(100))); env(pay(gw, carol, USD(100))); @@ -742,7 +742,7 @@ struct PayStrand_test : public beast::unit_test::suite test( env, USD, - boost::none, + std::nullopt, STPath(), tesSUCCESS, D{alice, gw, usdC}, @@ -818,7 +818,7 @@ struct PayStrand_test : public beast::unit_test::suite D{gw, bob, eurC}); // XRP -> XRP transaction can't include a path - test(env, XRP, boost::none, STPath({ape(carol)}), temBAD_PATH); + test(env, XRP, std::nullopt, STPath({ape(carol)}), temBAD_PATH); { // The root account can't be the src or dst @@ -830,7 +830,7 @@ struct PayStrand_test : public beast::unit_test::suite alice, xrpAccount(), XRP, - boost::none, + std::nullopt, USD.issue(), STPath(), true, @@ -845,8 +845,8 @@ struct PayStrand_test : public beast::unit_test::suite xrpAccount(), alice, XRP, - boost::none, - boost::none, + std::nullopt, + std::nullopt, STPath(), true, false, @@ -860,8 +860,8 @@ struct PayStrand_test : public beast::unit_test::suite noAccount(), bob, USD, - boost::none, - boost::none, + std::nullopt, + std::nullopt, STPath(), true, false, @@ -882,7 +882,7 @@ struct PayStrand_test : public beast::unit_test::suite test( env, USD, - boost::none, + std::nullopt, STPath({STPathElement( 0, xrpAccount(), xrpCurrency(), xrpAccount())}), temBAD_PATH); @@ -893,7 +893,7 @@ struct PayStrand_test : public beast::unit_test::suite test( env, USD, - boost::none, + std::nullopt, STPath({ape(gw), ape(carol)}), temBAD_PATH_LOOP); @@ -936,7 +936,7 @@ struct PayStrand_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, noripple(gw)); env.trust(USD(1000), alice, bob); env(pay(gw, alice, USD(100))); - test(env, USD, boost::none, STPath(), terNO_RIPPLE); + test(env, USD, std::nullopt, STPath(), terNO_RIPPLE); } { @@ -948,21 +948,21 @@ struct PayStrand_test : public beast::unit_test::suite // Account can still issue payments env(fset(alice, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), tesSUCCESS); + test(env, USD, std::nullopt, STPath(), tesSUCCESS); env(fclear(alice, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), tesSUCCESS); + test(env, USD, std::nullopt, STPath(), tesSUCCESS); // Account can not issue funds env(fset(gw, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), terNO_LINE); + test(env, USD, std::nullopt, STPath(), terNO_LINE); env(fclear(gw, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), tesSUCCESS); + test(env, USD, std::nullopt, STPath(), tesSUCCESS); // Account can not receive funds env(fset(bob, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), terNO_LINE); + test(env, USD, std::nullopt, STPath(), terNO_LINE); env(fclear(bob, asfGlobalFreeze)); - test(env, USD, boost::none, STPath(), tesSUCCESS); + test(env, USD, std::nullopt, STPath(), tesSUCCESS); } { // Freeze between gw and alice @@ -970,10 +970,10 @@ struct PayStrand_test : public beast::unit_test::suite env.fund(XRP(10000), alice, bob, gw); env.trust(USD(1000), alice, bob); env(pay(gw, alice, USD(100))); - test(env, USD, boost::none, STPath(), tesSUCCESS); + test(env, USD, std::nullopt, STPath(), tesSUCCESS); env(trust(gw, alice["USD"](0), tfSetFreeze)); BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::freeze)); - test(env, USD, boost::none, STPath(), terNO_LINE); + test(env, USD, std::nullopt, STPath(), terNO_LINE); } { // check no auth @@ -988,7 +988,7 @@ struct PayStrand_test : public beast::unit_test::suite BEAST_EXPECT(getTrustFlag(env, gw, alice, usdC, TrustFlag::auth)); env(pay(gw, alice, USD(100))); env.require(balance(alice, USD(100))); - test(env, USD, boost::none, STPath(), terNO_AUTH); + test(env, USD, std::nullopt, STPath(), terNO_AUTH); // Check pure issue redeem still works auto [ter, strand] = toStrand( @@ -996,8 +996,8 @@ struct PayStrand_test : public beast::unit_test::suite alice, gw, USD, - boost::none, - boost::none, + std::nullopt, + std::nullopt, STPath(), true, false, @@ -1029,15 +1029,15 @@ struct PayStrand_test : public beast::unit_test::suite // alice -> USD/XRP -> bob STPath path; - path.emplace_back(boost::none, USD.currency, USD.account.id()); - path.emplace_back(boost::none, xrpCurrency(), boost::none); + path.emplace_back(std::nullopt, USD.currency, USD.account.id()); + path.emplace_back(std::nullopt, xrpCurrency(), std::nullopt); auto [ter, strand] = toStrand( *env.current(), alice, bob, XRP, - boost::none, + std::nullopt, USD.issue(), path, false, diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index b0dbb2c41..70eaa2cd9 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -40,7 +40,7 @@ struct RippleCalcTestParams AccountID dstAccount; STAmount dstAmt; - boost::optional sendMax; + std::optional sendMax; STPathSet paths; @@ -69,22 +69,22 @@ struct RippleCalcTestParams p.emplace_back( *parseBase58( pe[jss::account].asString()), - boost::none, - boost::none); + std::nullopt, + std::nullopt); } else if ( pe.isMember(jss::currency) && pe.isMember(jss::issuer)) { auto const currency = to_currency(pe[jss::currency].asString()); - boost::optional issuer; + std::optional issuer; if (!isXRP(currency)) issuer = *parseBase58( pe[jss::issuer].asString()); else assert(isXRP(*parseBase58( pe[jss::issuer].asString()))); - p.emplace_back(boost::none, currency, issuer); + p.emplace_back(std::nullopt, currency, issuer); } else { @@ -242,14 +242,14 @@ class TheoreticalQuality_test : public beast::unit_test::suite testCase( RippleCalcTestParams const& rcp, std::shared_ptr closed, - boost::optional const& expectedQ = {}) + std::optional const& expectedQ = {}) { PaymentSandbox sb(closed.get(), tapNONE); - auto const sendMaxIssue = [&rcp]() -> boost::optional { + auto const sendMaxIssue = [&rcp]() -> std::optional { if (rcp.sendMax) return rcp.sendMax->issue(); - return boost::none; + return std::nullopt; }(); beast::Journal dummyJ{beast::Journal::getNullSink()}; @@ -259,7 +259,7 @@ class TheoreticalQuality_test : public beast::unit_test::suite rcp.srcAccount, rcp.dstAccount, rcp.dstAmt.issue(), - /*limitQuality*/ boost::none, + /*limitQuality*/ std::nullopt, sendMaxIssue, rcp.paths, /*defaultPaths*/ rcp.paths.empty(), @@ -312,7 +312,7 @@ class TheoreticalQuality_test : public beast::unit_test::suite public: void - testDirectStep(boost::optional const& reqNumIterations) + testDirectStep(std::optional const& reqNumIterations) { testcase("Direct Step"); @@ -404,7 +404,7 @@ public: } void - testBookStep(boost::optional const& reqNumIterations) + testBookStep(std::optional const& reqNumIterations) { testcase("Book Step"); using namespace jtx; @@ -527,20 +527,20 @@ public: { // Use the command line argument `--unittest-arg=500 ` to change the // number of iterations to 500 - auto const numIterations = [s = arg()]() -> boost::optional { + auto const numIterations = [s = arg()]() -> std::optional { if (s.empty()) - return boost::none; + return std::nullopt; try { std::size_t pos; auto const r = stoi(s, &pos); if (pos != s.size()) - return boost::none; + return std::nullopt; return r; } catch (...) { - return boost::none; + return std::nullopt; } }(); testRelativeQDistance(); diff --git a/src/test/app/Ticket_test.cpp b/src/test/app/Ticket_test.cpp index c6907fb3b..b50059711 100644 --- a/src/test/app/Ticket_test.cpp +++ b/src/test/app/Ticket_test.cpp @@ -792,7 +792,7 @@ class Ticket_test : public beast::unit_test::suite uint256 const& txID, std::uint32_t ledgerSeq, std::uint32_t txSeq, - boost::optional ticketSeq, + std::optional ticketSeq, TxType txType) { error_code_i txErrCode{rpcSUCCESS}; diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index db5cb5f78..81c84de72 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,7 @@ class TxQ1_test : public beast::unit_test::suite checkMetrics( jtx::Env& env, std::size_t expectedCount, - boost::optional expectedMaxCount, + std::optional expectedMaxCount, std::size_t expectedInLedger, std::size_t expectedPerLedger, std::uint64_t expectedMinFeeLevel, @@ -188,23 +187,23 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // Create several accounts while the fee is cheap so they all apply. env.fund(XRP(50000), noripple(alice, bob, charlie, daria)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Alice - price starts exploding: held env(noop(alice), queued); - checkMetrics(env, 1, boost::none, 4, 3, 256); + checkMetrics(env, 1, std::nullopt, 4, 3, 256); // Bob with really high fee - applies env(noop(bob), openLedgerFee(env)); - checkMetrics(env, 1, boost::none, 5, 3, 256); + checkMetrics(env, 1, std::nullopt, 5, 3, 256); // Daria with low fee: hold env(noop(daria), fee(1000), queued); - checkMetrics(env, 2, boost::none, 5, 3, 256); + checkMetrics(env, 2, std::nullopt, 5, 3, 256); env.close(); // Verify that the held transactions got applied @@ -390,14 +389,14 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // Fund alice and then fill the ledger. env.fund(XRP(50000), noripple(alice)); env(noop(alice)); env(noop(alice)); env(noop(alice)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); ////////////////////////////////////////////////////////////////// @@ -409,7 +408,7 @@ public: env(noop(alice), ticket::use(tkt1 - 2), ter(tefNO_TICKET)); env(noop(alice), ticket::use(tkt1 - 1), ter(terPRE_TICKET)); env.require(owners(alice, 0), tickets(alice, 0)); - checkMetrics(env, 1, boost::none, 4, 3, 256); + checkMetrics(env, 1, std::nullopt, 4, 3, 256); env.close(); env.require(owners(alice, 250), tickets(alice, 250)); @@ -645,11 +644,11 @@ public: auto gw = Account("gw"); auto USD = gw["USD"]; - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); // Create accounts env.fund(XRP(50000), noripple(alice, gw)); - checkMetrics(env, 0, boost::none, 2, 2, 256); + checkMetrics(env, 0, std::nullopt, 2, 2, 256); env.close(); checkMetrics(env, 0, 4, 0, 2, 256); @@ -686,38 +685,38 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); // Create several accounts while the fee is cheap so they all apply. env.fund(XRP(50000), noripple(alice, bob, charlie)); - checkMetrics(env, 0, boost::none, 3, 2, 256); + checkMetrics(env, 0, std::nullopt, 3, 2, 256); // Future transaction for Alice - fails env(noop(alice), openLedgerFee(env), seq(env.seq(alice) + 1), ter(terPRE_SEQ)); - checkMetrics(env, 0, boost::none, 3, 2, 256); + checkMetrics(env, 0, std::nullopt, 3, 2, 256); // Current transaction for Alice: held env(noop(alice), queued); - checkMetrics(env, 1, boost::none, 3, 2, 256); + checkMetrics(env, 1, std::nullopt, 3, 2, 256); // Alice - sequence is too far ahead, so won't queue. env(noop(alice), seq(env.seq(alice) + 2), ter(telCAN_NOT_QUEUE)); - checkMetrics(env, 1, boost::none, 3, 2, 256); + checkMetrics(env, 1, std::nullopt, 3, 2, 256); // Bob with really high fee - applies env(noop(bob), openLedgerFee(env)); - checkMetrics(env, 1, boost::none, 4, 2, 256); + checkMetrics(env, 1, std::nullopt, 4, 2, 256); // Daria with low fee: hold env(noop(charlie), fee(1000), queued); - checkMetrics(env, 2, boost::none, 4, 2, 256); + checkMetrics(env, 2, std::nullopt, 4, 2, 256); // Alice with normal fee: hold env(noop(alice), seq(env.seq(alice) + 1), queued); - checkMetrics(env, 3, boost::none, 4, 2, 256); + checkMetrics(env, 3, std::nullopt, 4, 2, 256); env.close(); // Verify that the held transactions got applied @@ -744,7 +743,7 @@ public: auto queued = ter(terQUEUED); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); // Fund across several ledgers so the TxQ metrics stay restricted. env.fund(XRP(1000), noripple(alice, bob)); @@ -754,11 +753,11 @@ public: env.fund(XRP(1000), noripple(edgar, felicia)); env.close(env.now() + 5s, 10000ms); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); env(noop(bob)); env(noop(charlie)); env(noop(daria)); - checkMetrics(env, 0, boost::none, 3, 2, 256); + checkMetrics(env, 0, std::nullopt, 3, 2, 256); BEAST_EXPECT(env.current()->info().seq == 6); // Fail to queue an item with a low LastLedgerSeq @@ -773,7 +772,7 @@ public: env(noop(charlie), fee(7000), queued); env(noop(daria), fee(7000), queued); env(noop(edgar), fee(7000), queued); - checkMetrics(env, 5, boost::none, 3, 2, 256); + checkMetrics(env, 5, std::nullopt, 3, 2, 256); { auto& txQ = env.app().getTxQ(); auto aliceStat = txQ.getAccountTxs(alice.id(), *env.current()); @@ -852,7 +851,7 @@ public: auto queued = ter(terQUEUED); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); // Fund across several ledgers so the TxQ metrics stay restricted. env.fund(XRP(1000), noripple(alice, bob)); @@ -864,14 +863,14 @@ public: env(noop(alice)); env(noop(alice)); env(noop(alice)); - checkMetrics(env, 0, boost::none, 3, 2, 256); + checkMetrics(env, 0, std::nullopt, 3, 2, 256); env(noop(bob), queued); - checkMetrics(env, 1, boost::none, 3, 2, 256); + checkMetrics(env, 1, std::nullopt, 3, 2, 256); // Since Alice's queue is empty this blocker can go into her queue. env(regkey(alice, bob), fee(0), queued); - checkMetrics(env, 2, boost::none, 3, 2, 256); + checkMetrics(env, 2, std::nullopt, 3, 2, 256); // Close out this ledger so we can get a maxsize env.close(); @@ -971,19 +970,19 @@ public: auto queued = ter(terQUEUED); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); env.fund(XRP(1000), noripple(alice, bob)); - checkMetrics(env, 0, boost::none, 2, 2, 256); + checkMetrics(env, 0, std::nullopt, 2, 2, 256); // Fill the ledger env(noop(alice)); - checkMetrics(env, 0, boost::none, 3, 2, 256); + checkMetrics(env, 0, std::nullopt, 3, 2, 256); // Put a transaction in the queue env(noop(alice), queued); - checkMetrics(env, 1, boost::none, 3, 2, 256); + checkMetrics(env, 1, std::nullopt, 3, 2, 256); // Now cheat, and bypass the queue. { @@ -1001,7 +1000,7 @@ public: }); env.postconditions(jt, ter, didApply); } - checkMetrics(env, 1, boost::none, 4, 2, 256); + checkMetrics(env, 1, std::nullopt, 4, 2, 256); env.close(); // Alice's queued transaction failed in TxQ::accept @@ -1030,7 +1029,7 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // ledgers in queue is 2 because of makeConfig auto const initQueueMax = initFee(env, 3, 2, 10, 10, 200, 50); @@ -1300,11 +1299,11 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 4, 256); + checkMetrics(env, 0, std::nullopt, 0, 4, 256); // Create several accounts while the fee is cheap so they all apply. env.fund(XRP(50000), noripple(alice, bob, charlie, daria)); - checkMetrics(env, 0, boost::none, 4, 4, 256); + checkMetrics(env, 0, std::nullopt, 4, 4, 256); env.close(); checkMetrics(env, 0, 8, 0, 4, 256); @@ -1429,13 +1428,13 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 1, 256); + checkMetrics(env, 0, std::nullopt, 0, 1, 256); env.fund(XRP(50000), noripple(alice)); - checkMetrics(env, 0, boost::none, 1, 1, 256); + checkMetrics(env, 0, std::nullopt, 1, 1, 256); env(fset(alice, asfAccountTxnID)); - checkMetrics(env, 0, boost::none, 2, 1, 256); + checkMetrics(env, 0, std::nullopt, 2, 1, 256); // Immediately after the fset, the sfAccountTxnID field // is still uninitialized, so preflight succeeds here, @@ -1444,7 +1443,7 @@ public: json(R"({"AccountTxnID": "0"})"), ter(telCAN_NOT_QUEUE)); - checkMetrics(env, 0, boost::none, 2, 1, 256); + checkMetrics(env, 0, std::nullopt, 2, 1, 256); env.close(); // The failed transaction is retried from LocalTx // and succeeds. @@ -1473,15 +1472,15 @@ public: auto alice = Account("alice"); - checkMetrics(env, 0, boost::none, 0, 2, 256); + checkMetrics(env, 0, std::nullopt, 0, 2, 256); env.fund(XRP(50000), noripple(alice)); - checkMetrics(env, 0, boost::none, 1, 2, 256); + checkMetrics(env, 0, std::nullopt, 1, 2, 256); for (int i = 0; i < 10; ++i) env(noop(alice), openLedgerFee(env)); - checkMetrics(env, 0, boost::none, 11, 2, 256); + checkMetrics(env, 0, std::nullopt, 11, 2, 256); env.close(); // If not for the maximum, the per ledger would be 11. @@ -1667,11 +1666,11 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); env.fund(XRP(50000), noripple(alice, bob)); env.memoize(charlie); - checkMetrics(env, 0, boost::none, 2, 3, 256); + checkMetrics(env, 0, std::nullopt, 2, 3, 256); { // Cannot put a blocker in an account's queue if that queue // already holds two or more (non-blocker) entries. @@ -1680,7 +1679,7 @@ public: env(noop(alice)); // Set a regular key just to clear the password spent flag env(regkey(alice, charlie)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Put two "normal" txs in the queue auto const aliceSeq = env.seq(alice); @@ -1706,7 +1705,7 @@ public: // Other accounts are not affected env(noop(bob), queued); - checkMetrics(env, 3, boost::none, 4, 3, 256); + checkMetrics(env, 3, std::nullopt, 4, 3, 256); // Drain the queue. env.close(); @@ -1797,12 +1796,12 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); env.fund(XRP(50000), noripple(alice, bob)); env.memoize(charlie); - checkMetrics(env, 0, boost::none, 2, 3, 256); + checkMetrics(env, 0, std::nullopt, 2, 3, 256); std::uint32_t tkt{env.seq(alice) + 1}; { @@ -1813,7 +1812,7 @@ public: env(ticket::create(alice, 250), seq(tkt - 1)); // Set a regular key just to clear the password spent flag env(regkey(alice, charlie)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Put two "normal" txs in the queue auto const aliceSeq = env.seq(alice); @@ -1843,7 +1842,7 @@ public: // Other accounts are not affected env(noop(bob), queued); - checkMetrics(env, 3, boost::none, 4, 3, 256); + checkMetrics(env, 3, std::nullopt, 4, 3, 256); // Drain the queue and local transactions. env.close(); @@ -2382,23 +2381,23 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // Fund accounts while the fee is cheap so they all apply. env.fund(XRP(50000), noripple(alice, bob, charlie)); - checkMetrics(env, 0, boost::none, 3, 3, 256); + checkMetrics(env, 0, std::nullopt, 3, 3, 256); // Alice - no fee change yet env(noop(alice)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Bob with really high fee - applies env(noop(bob), openLedgerFee(env)); - checkMetrics(env, 0, boost::none, 5, 3, 256); + checkMetrics(env, 0, std::nullopt, 5, 3, 256); // Charlie with low fee: queued env(noop(charlie), fee(1000), queued); - checkMetrics(env, 1, boost::none, 5, 3, 256); + checkMetrics(env, 1, std::nullopt, 5, 3, 256); env.close(); // Verify that the queued transaction was applied @@ -2556,7 +2555,7 @@ public: auto const bob = Account("bob"); env.fund(XRP(500000), noripple(alice, bob)); - checkMetrics(env, 0, boost::none, 2, 1, 256); + checkMetrics(env, 0, std::nullopt, 2, 1, 256); auto const aliceSeq = env.seq(alice); BEAST_EXPECT(env.current()->info().seq == 3); @@ -2576,7 +2575,7 @@ public: seq(aliceSeq + 3), json(R"({"LastLedgerSequence":11})"), ter(terQUEUED)); - checkMetrics(env, 4, boost::none, 2, 1, 256); + checkMetrics(env, 4, std::nullopt, 2, 1, 256); auto const bobSeq = env.seq(bob); // Ledger 4 gets 3, // Ledger 5 gets 4, @@ -2585,7 +2584,7 @@ public: { env(noop(bob), seq(bobSeq + i), fee(200), ter(terQUEUED)); } - checkMetrics(env, 4 + 3 + 4 + 5, boost::none, 2, 1, 256); + checkMetrics(env, 4 + 3 + 4 + 5, std::nullopt, 2, 1, 256); // Close ledger 3 env.close(); checkMetrics(env, 4 + 4 + 5, 20, 3, 2, 256); @@ -2650,7 +2649,7 @@ public: auto const bob = Account("bob"); env.fund(XRP(500000), noripple(alice, bob)); - checkMetrics(env, 0, boost::none, 2, 1, 256); + checkMetrics(env, 0, std::nullopt, 2, 1, 256); auto const aliceSeq = env.seq(alice); BEAST_EXPECT(env.current()->info().seq == 3); @@ -2697,7 +2696,7 @@ public: seq(aliceSeq + 19), json(R"({"LastLedgerSequence":11})"), ter(terQUEUED)); - checkMetrics(env, 10, boost::none, 2, 1, 256); + checkMetrics(env, 10, std::nullopt, 2, 1, 256); auto const bobSeq = env.seq(bob); // Ledger 4 gets 2 from bob and 1 from alice, @@ -2707,7 +2706,7 @@ public: { env(noop(bob), seq(bobSeq + i), fee(200), ter(terQUEUED)); } - checkMetrics(env, 10 + 2 + 4 + 5, boost::none, 2, 1, 256); + checkMetrics(env, 10 + 2 + 4 + 5, std::nullopt, 2, 1, 256); // Close ledger 3 env.close(); checkMetrics(env, 9 + 4 + 5, 20, 3, 2, 256); @@ -2801,7 +2800,7 @@ public: env.fund(XRP(100000), alice, bob); fillQueue(env, alice); - checkMetrics(env, 0, boost::none, 7, 6, 256); + checkMetrics(env, 0, std::nullopt, 7, 6, 256); // Queue up several transactions for alice sign-and-submit auto const aliceSeq = env.seq(alice); @@ -2821,7 +2820,7 @@ public: envs(noop(alice), fee(1000), seq(none), ter(terQUEUED))( submitParams); } - checkMetrics(env, 5, boost::none, 7, 6, 256); + checkMetrics(env, 5, std::nullopt, 7, 6, 256); { auto aliceStat = txQ.getAccountTxs(alice.id(), *env.current()); SeqProxy seq = SeqProxy::sequence(aliceSeq); @@ -2846,7 +2845,7 @@ public: // Give them a higher fee so they'll beat alice's. for (int i = 0; i < 8; ++i) envs(noop(bob), fee(2000), seq(none), ter(terQUEUED))(); - checkMetrics(env, 13, boost::none, 7, 6, 256); + checkMetrics(env, 13, std::nullopt, 7, 6, 256); env.close(); checkMetrics(env, 5, 14, 8, 7, 256); @@ -3479,7 +3478,7 @@ public: // Fund the first few accounts at non escalated fee env.fund(XRP(50000), noripple(a, b, c, d)); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // First transaction establishes the messaging using namespace std::chrono_literals; @@ -3612,14 +3611,14 @@ public: auto alice = Account("alice"); auto bob = Account("bob"); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); env.fund(XRP(50000000), alice, bob); fillQueue(env, alice); auto calcTotalFee = [&](std::int64_t alreadyPaid, - boost::optional numToClear = - boost::none) -> std::uint64_t { + std::optional numToClear = + std::nullopt) -> std::uint64_t { auto totalFactor = 0; auto const metrics = env.app().getTxQ().getMetrics(*env.current()); if (!numToClear) @@ -3658,7 +3657,7 @@ public: seq(aliceSeq++), ter(terQUEUED)); - checkMetrics(env, 3, boost::none, 4, 3, 256); + checkMetrics(env, 3, std::nullopt, 4, 3, 256); // Figure out how much it would cost to cover all the // queued txs + itself @@ -3671,7 +3670,7 @@ public: // the edge case test. env(noop(alice), fee(totalFee1), seq(aliceSeq++), ter(terQUEUED)); - checkMetrics(env, 4, boost::none, 4, 3, 256); + checkMetrics(env, 4, std::nullopt, 4, 3, 256); // Now repeat the process including the new tx // and avoiding the rounding error @@ -3681,7 +3680,7 @@ public: // Submit a transaction with that fee. It will succeed. env(noop(alice), fee(totalFee2), seq(aliceSeq++)); - checkMetrics(env, 0, boost::none, 9, 3, 256); + checkMetrics(env, 0, std::nullopt, 9, 3, 256); } testcase("replace last tx with enough to clear queue"); @@ -3701,7 +3700,7 @@ public: seq(aliceSeq++), ter(terQUEUED)); - checkMetrics(env, 3, boost::none, 9, 3, 256); + checkMetrics(env, 3, std::nullopt, 9, 3, 256); // Figure out how much it would cost to cover all the // queued txs + itself @@ -3714,7 +3713,7 @@ public: env(noop(alice), fee(totalFee), seq(aliceSeq++)); // The queue is clear - checkMetrics(env, 0, boost::none, 12, 3, 256); + checkMetrics(env, 0, std::nullopt, 12, 3, 256); env.close(); checkMetrics(env, 0, 24, 0, 12, 256); @@ -3826,16 +3825,16 @@ public: {"maximum_txn_per_account", "200"}})); auto alice = Account("alice"); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); env.fund(XRP(50000000), alice); fillQueue(env, alice); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); auto seqAlice = env.seq(alice); auto txCount = 140; for (int i = 0; i < txCount; ++i) env(noop(alice), seq(seqAlice++), ter(terQUEUED)); - checkMetrics(env, txCount, boost::none, 4, 3, 256); + checkMetrics(env, txCount, std::nullopt, 4, 3, 256); // Close a few ledgers successfully, so the limit grows @@ -3912,16 +3911,16 @@ public: {"maximum_txn_per_account", "200"}})); auto alice = Account("alice"); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); env.fund(XRP(50000000), alice); fillQueue(env, alice); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); auto seqAlice = env.seq(alice); auto txCount = 43; for (int i = 0; i < txCount; ++i) env(noop(alice), seq(seqAlice++), ter(terQUEUED)); - checkMetrics(env, txCount, boost::none, 4, 3, 256); + checkMetrics(env, txCount, std::nullopt, 4, 3, 256); // Close a few ledgers successfully, so the limit grows @@ -3970,19 +3969,19 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // Create account env.fund(XRP(50000), noripple(alice)); - checkMetrics(env, 0, boost::none, 1, 3, 256); + checkMetrics(env, 0, std::nullopt, 1, 3, 256); fillQueue(env, alice); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Queue a transaction auto const aliceSeq = env.seq(alice); env(noop(alice), queued); - checkMetrics(env, 1, boost::none, 4, 3, 256); + checkMetrics(env, 1, std::nullopt, 4, 3, 256); // Now, apply a (different) transaction directly // to the open ledger, bypassing the queue @@ -3998,18 +3997,18 @@ public: return result.second; }); // the queued transaction is still there - checkMetrics(env, 1, boost::none, 5, 3, 256); + checkMetrics(env, 1, std::nullopt, 5, 3, 256); // The next transaction should be able to go into the open // ledger, even though aliceSeq is queued. In earlier incarnations // of the TxQ this would cause an assert. env(noop(alice), seq(aliceSeq + 1), openLedgerFee(env)); - checkMetrics(env, 1, boost::none, 6, 3, 256); + checkMetrics(env, 1, std::nullopt, 6, 3, 256); // Now queue a couple more transactions to make sure // they succeed despite aliceSeq being queued env(noop(alice), seq(aliceSeq + 2), queued); env(noop(alice), seq(aliceSeq + 3), queued); - checkMetrics(env, 3, boost::none, 6, 3, 256); + checkMetrics(env, 3, std::nullopt, 6, 3, 256); // Now close the ledger. One of the queued transactions // (aliceSeq) should be dropped. @@ -4037,11 +4036,11 @@ public: BEAST_EXPECT(env.current()->fees().base == 10); - checkMetrics(env, 0, boost::none, 0, 3, 256); + checkMetrics(env, 0, std::nullopt, 0, 3, 256); // Create account env.fund(XRP(50000), noripple(alice)); - checkMetrics(env, 0, boost::none, 1, 3, 256); + checkMetrics(env, 0, std::nullopt, 1, 3, 256); // Create tickets std::uint32_t const tktSeq0{env.seq(alice) + 1}; @@ -4049,12 +4048,12 @@ public: // Fill the queue so the next transaction will be queued. fillQueue(env, alice); - checkMetrics(env, 0, boost::none, 4, 3, 256); + checkMetrics(env, 0, std::nullopt, 4, 3, 256); // Queue a transaction with a ticket. Leave an unused ticket // on either side. env(noop(alice), ticket::use(tktSeq0 + 1), queued); - checkMetrics(env, 1, boost::none, 4, 3, 256); + checkMetrics(env, 1, std::nullopt, 4, 3, 256); // Now, apply a (different) transaction directly // to the open ledger, bypassing the queue @@ -4070,25 +4069,25 @@ public: return result.second; }); // the queued transaction is still there - checkMetrics(env, 1, boost::none, 5, 3, 256); + checkMetrics(env, 1, std::nullopt, 5, 3, 256); // The next (sequence-based) transaction should be able to go into // the open ledger, even though tktSeq0 is queued. Note that this // sequence-based transaction goes in front of the queued // transaction, so the queued transaction is left in the queue. env(noop(alice), openLedgerFee(env)); - checkMetrics(env, 1, boost::none, 6, 3, 256); + checkMetrics(env, 1, std::nullopt, 6, 3, 256); // We should be able to do the same thing with a ticket that goes // if front of the queued transaction. This one too will leave // the queued transaction in place. env(noop(alice), ticket::use(tktSeq0 + 0), openLedgerFee(env)); - checkMetrics(env, 1, boost::none, 7, 3, 256); + checkMetrics(env, 1, std::nullopt, 7, 3, 256); // We have one ticketed transaction in the queue. We should able // to add another to the queue. env(noop(alice), ticket::use(tktSeq0 + 2), queued); - checkMetrics(env, 2, boost::none, 7, 3, 256); + checkMetrics(env, 2, std::nullopt, 7, 3, 256); // Here we try to force the queued transactions into the ledger by // adding one more queued (ticketed) transaction that pays enough @@ -4104,7 +4103,7 @@ public: // transaction is equally capable of going into the ledger independent // of all other ticket- or sequence-based transactions. env(noop(alice), ticket::use(tktSeq0 + 3), fee(XRP(1))); - checkMetrics(env, 2, boost::none, 8, 3, 256); + checkMetrics(env, 2, std::nullopt, 8, 3, 256); // Now close the ledger. One of the queued transactions // (the one with tktSeq0 + 1) should be dropped. diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index acb978fef..860b8fc17 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -130,7 +130,7 @@ private: std::vector const& validators, std::size_t sequence, std::size_t validUntil, - boost::optional validFrom = {}) + std::optional validFrom = {}) { std::string data = "{\"sequence\":" + std::to_string(sequence) + ",\"expiration\":" + std::to_string(validUntil); @@ -1635,7 +1635,7 @@ private: env.journal); // Empty list has no expiration - BEAST_EXPECT(trustedKeys->expires() == boost::none); + BEAST_EXPECT(trustedKeys->expires() == std::nullopt); // Config listed keys have maximum expiry PublicKey emptyLocalKey; @@ -1643,7 +1643,7 @@ private: trustedKeys->load(emptyLocalKey, {toStr(localCfgListed)}, {}); BEAST_EXPECT( trustedKeys->expires() && - trustedKeys->expires().get() == NetClock::time_point::max()); + trustedKeys->expires().value() == NetClock::time_point::max()); BEAST_EXPECT(trustedKeys->listed(localCfgListed)); } @@ -1726,7 +1726,7 @@ private: PreparedList prep2 = addPublishedList(); // Initially, no list has been published, so no known expiration - BEAST_EXPECT(trustedKeys->expires() == boost::none); + BEAST_EXPECT(trustedKeys->expires() == std::nullopt); // Apply first list checkResult( @@ -1738,7 +1738,7 @@ private: // One list still hasn't published, so expiration is still // unknown - BEAST_EXPECT(trustedKeys->expires() == boost::none); + BEAST_EXPECT(trustedKeys->expires() == std::nullopt); // Apply second list checkResult( @@ -1750,7 +1750,7 @@ private: // We now have loaded both lists, so expiration is known BEAST_EXPECT( trustedKeys->expires() && - trustedKeys->expires().get() == prep1.expirations.back()); + trustedKeys->expires().value() == prep1.expirations.back()); // Advance past the first list's LAST validFrom date. It remains // the earliest validUntil, while rotating in the second list @@ -1764,7 +1764,7 @@ private: env.app().getHashRouter()); BEAST_EXPECT( trustedKeys->expires() && - trustedKeys->expires().get() == prep1.expirations.back()); + trustedKeys->expires().value() == prep1.expirations.back()); BEAST_EXPECT(!changes.added.empty()); BEAST_EXPECT(changes.removed.empty()); } @@ -1781,7 +1781,7 @@ private: env.app().getHashRouter()); BEAST_EXPECT( trustedKeys->expires() && - trustedKeys->expires().get() == prep1.expirations.back()); + trustedKeys->expires().value() == prep1.expirations.back()); BEAST_EXPECT(changes.added.empty()); BEAST_EXPECT(changes.removed.empty()); } @@ -1798,7 +1798,7 @@ private: auto createValidatorList = [&](std::uint32_t vlSize, - boost::optional minimumQuorum = {}) + std::optional minimumQuorum = {}) -> std::shared_ptr { auto trustedKeys = std::make_shared( manifests, diff --git a/src/test/basics/RangeSet_test.cpp b/src/test/basics/RangeSet_test.cpp index 70e2a7d5a..30cca8fe6 100644 --- a/src/test/basics/RangeSet_test.cpp +++ b/src/test/basics/RangeSet_test.cpp @@ -41,7 +41,7 @@ public: for (std::uint32_t i = 1; i < 100; ++i) { - boost::optional expected; + std::optional expected; // no prev missing in domain for i <= 6 if (i > 6) { diff --git a/src/test/beast/beast_io_latency_probe_test.cpp b/src/test/beast/beast_io_latency_probe_test.cpp index a04d0ee19..6baf5b986 100644 --- a/src/test/beast/beast_io_latency_probe_test.cpp +++ b/src/test/beast/beast_io_latency_probe_test.cpp @@ -18,15 +18,18 @@ //============================================================================== #include #include + +#include + #include #include #include -#include + #include -#include #include #include #include +#include #include #include @@ -60,7 +63,7 @@ class io_latency_probe_test : public beast::unit_test::suite, { using namespace std::chrono; boost::asio::io_service ios; - boost::optional work{ios}; + std::optional work{ios}; std::thread worker{[&] { ios.run(); }}; boost::asio::basic_waitable_timer timer{ios}; elapsed_times_.reserve(num_samples); @@ -86,7 +89,7 @@ class io_latency_probe_test : public beast::unit_test::suite, }); cv.wait(mainlock, [&done] { return done; }); } - work = boost::none; + work.reset(); worker.join(); if (wait_err) boost::asio::detail::throw_error(wait_err, "wait"); diff --git a/src/test/consensus/LedgerTrie_test.cpp b/src/test/consensus/LedgerTrie_test.cpp index dcc11136b..3feb3b099 100644 --- a/src/test/consensus/LedgerTrie_test.cpp +++ b/src/test/consensus/LedgerTrie_test.cpp @@ -362,8 +362,8 @@ class LedgerTrie_test : public beast::unit_test::suite // Empty { LedgerTrie t; - BEAST_EXPECT(t.getPreferred(Seq{0}) == boost::none); - BEAST_EXPECT(t.getPreferred(Seq{2}) == boost::none); + BEAST_EXPECT(t.getPreferred(Seq{0}) == std::nullopt); + BEAST_EXPECT(t.getPreferred(Seq{2}) == std::nullopt); } // Genesis support is NOT empty { @@ -373,7 +373,7 @@ class LedgerTrie_test : public beast::unit_test::suite t.insert(genesis); BEAST_EXPECT(t.getPreferred(Seq{0})->id == genesis.id()); BEAST_EXPECT(t.remove(genesis)); - BEAST_EXPECT(t.getPreferred(Seq{0}) == boost::none); + BEAST_EXPECT(t.getPreferred(Seq{0}) == std::nullopt); BEAST_EXPECT(!t.remove(genesis)); } // Single node no children diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 6edbb5e24..59b0c5682 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -2020,9 +2020,9 @@ negUnlSizeTest( { bool sameSize = l->negativeUNL().size() == size; bool sameToDisable = - (l->validatorToDisable() != boost::none) == hasToDisable; + (l->validatorToDisable() != std::nullopt) == hasToDisable; bool sameToReEnable = - (l->validatorToReEnable() != boost::none) == hasToReEnable; + (l->validatorToReEnable() != std::nullopt) == hasToReEnable; return sameSize && sameToDisable && sameToReEnable; } diff --git a/src/test/consensus/Validations_test.cpp b/src/test/consensus/Validations_test.cpp index bdb96323a..4dc1df7de 100644 --- a/src/test/consensus/Validations_test.cpp +++ b/src/test/consensus/Validations_test.cpp @@ -55,7 +55,7 @@ class Validations_test : public beast::unit_test::suite PeerID nodeID_; bool trusted_ = true; std::size_t signIdx_{1}; - boost::optional loadFee_; + std::optional loadFee_; public: Node(PeerID nodeID, clock_type const& c) : c_(c), nodeID_(nodeID) @@ -200,7 +200,7 @@ class Validations_test : public beast::unit_test::suite return toNetClock(c_); } - boost::optional + std::optional acquire(Ledger::ID const& id) { return oracle_.lookup(id); @@ -444,7 +444,7 @@ class Validations_test : public beast::unit_test::suite BEAST_EXPECT( harness.vals().getNodesAfter(ledgerA, ledgerA.id()) == 0); BEAST_EXPECT( - harness.vals().getPreferred(genesisLedger) == boost::none); + harness.vals().getPreferred(genesisLedger) == std::nullopt); } } @@ -781,7 +781,7 @@ class Validations_test : public beast::unit_test::suite }; // Empty (no ledgers) - BEAST_EXPECT(harness.vals().getPreferred(ledgerA) == boost::none); + BEAST_EXPECT(harness.vals().getPreferred(ledgerA) == std::nullopt); // Single ledger BEAST_EXPECT(ValStatus::current == harness.add(a.validate(ledgerB))); @@ -1015,7 +1015,7 @@ class Validations_test : public beast::unit_test::suite trustedVals.size()); if (trustedVals.empty()) BEAST_EXPECT( - vals.getPreferred(this->genesisLedger) == boost::none); + vals.getPreferred(this->genesisLedger) == std::nullopt); else BEAST_EXPECT( vals.getPreferred(this->genesisLedger)->second == testID); @@ -1084,7 +1084,7 @@ class Validations_test : public beast::unit_test::suite // make acquiring ledger available h["ab"]; BEAST_EXPECT(vals.currentTrusted() == trustedVals); - BEAST_EXPECT(vals.getPreferred(genesisLedger) == boost::none); + BEAST_EXPECT(vals.getPreferred(genesisLedger) == std::nullopt); BEAST_EXPECT( vals.getNodesAfter(genesisLedger, genesisLedger.id()) == 0); } diff --git a/src/test/core/ClosureCounter_test.cpp b/src/test/core/ClosureCounter_test.cpp index 980b6ed48..478816a89 100644 --- a/src/test/core/ClosureCounter_test.cpp +++ b/src/test/core/ClosureCounter_test.cpp @@ -58,7 +58,7 @@ class ClosureCounter_test : public beast::unit_test::suite BEAST_EXPECT(evidence == 2); // Destroying the contents of wrapped should decrement voidCounter. - wrapped = boost::none; + wrapped = std::nullopt; BEAST_EXPECT(voidCounter.count() == 0); } { @@ -82,7 +82,7 @@ class ClosureCounter_test : public beast::unit_test::suite BEAST_EXPECT(evidence == 11); // Destroying the contents of wrapped should decrement setCounter. - wrapped = boost::none; + wrapped = std::nullopt; BEAST_EXPECT(setCounter.count() == 0); } { @@ -102,7 +102,7 @@ class ClosureCounter_test : public beast::unit_test::suite BEAST_EXPECT((*wrapped)(2, -8) == -6); // Destroying the contents of wrapped should decrement sumCounter. - wrapped = boost::none; + wrapped = std::nullopt; BEAST_EXPECT(sumCounter.count() == 0); } } @@ -274,8 +274,8 @@ class ClosureCounter_test : public beast::unit_test::suite using namespace std::chrono_literals; voidCounter.join("testWrap", 1ms, j); - // Wrapping a closure after join() should return boost::none. - BEAST_EXPECT(voidCounter.wrap([]() {}) == boost::none); + // Wrapping a closure after join() should return std::nullopt. + BEAST_EXPECT(voidCounter.wrap([]() {}) == std::nullopt); } void @@ -310,7 +310,7 @@ class ClosureCounter_test : public beast::unit_test::suite // Destroy the contents of wrapped and expect the thread to exit // (asynchronously). - wrapped = boost::none; + wrapped = std::nullopt; BEAST_EXPECT(voidCounter.count() == 0); // Wait for the thread to exit. diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index b7a8a1835..ca0d677be 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -810,11 +810,11 @@ trustthesevalidators.gov ParsedPort rpc; if (!unexcept([&]() { parse_Port(rpc, conf["port_rpc"], log); })) return; - BEAST_EXPECT(rpc.admin_ip && (rpc.admin_ip.get().size() == 2)); + BEAST_EXPECT(rpc.admin_ip && (rpc.admin_ip.value().size() == 2)); ParsedPort wss; if (!unexcept([&]() { parse_Port(wss, conf["port_wss_admin"], log); })) return; - BEAST_EXPECT(wss.admin_ip && (wss.admin_ip.get().size() == 1)); + BEAST_EXPECT(wss.admin_ip && (wss.admin_ip.value().size() == 1)); } void @@ -991,7 +991,7 @@ r.ripple.com 51235 BEAST_EXPECT(!get_if_exists(s, "a_string", val_10)); BEAST_EXPECT(val_10 == 10); - BEAST_EXPECT(s.get("not_a_key") == boost::none); + BEAST_EXPECT(s.get("not_a_key") == std::nullopt); try { s.get("a_string"); diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index 42c939ed0..b9e348b32 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -223,6 +223,8 @@ public: } try { + // SOCI requires boost::optional (not std::optional) as + // parameters. boost::optional ig; boost::optional uig; boost::optional big; diff --git a/src/test/csf/Digraph.h b/src/test/csf/Digraph.h index 99610b944..2c6b356bf 100644 --- a/src/test/csf/Digraph.h +++ b/src/test/csf/Digraph.h @@ -21,10 +21,11 @@ #define RIPPLE_TEST_CSF_DIGRAPH_H_INCLUDED #include -#include #include #include + #include +#include #include #include @@ -111,10 +112,10 @@ public: @param source The source vertex @param target The target vertex - @return optional which is boost::none if no edge exists + @return optional which is std::nullopt if no edge exists */ - boost::optional + std::optional edge(Vertex source, Vertex target) const { auto it = graph_.find(source); @@ -124,7 +125,7 @@ public: if (edgeIt != it->second.end()) return edgeIt->second; } - return boost::none; + return std::nullopt; } /** Check if two vertices are connected @@ -136,7 +137,7 @@ public: bool connected(Vertex source, Vertex target) const { - return edge(source, target) != boost::none; + return edge(source, target) != std::nullopt; } /** Range over vertices in the graph diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index fe99de7e5..3b972493a 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -144,12 +144,12 @@ struct Peer return p_.now(); } - boost::optional + std::optional acquire(Ledger::ID const& lId) { if (Ledger const* ledger = p_.acquireLedger(lId)) return *ledger; - return boost::none; + return std::nullopt; } }; diff --git a/src/test/csf/TrustGraph.h b/src/test/csf/TrustGraph.h index 2a0d676cc..c6c216053 100644 --- a/src/test/csf/TrustGraph.h +++ b/src/test/csf/TrustGraph.h @@ -21,11 +21,11 @@ #define RIPPLE_TEST_CSF_UNL_H_INCLUDED #include -#include +#include + #include #include #include -#include #include namespace ripple { diff --git a/src/test/csf/Validation.h b/src/test/csf/Validation.h index cf1d71e78..aacb155fb 100644 --- a/src/test/csf/Validation.h +++ b/src/test/csf/Validation.h @@ -20,9 +20,10 @@ #define RIPPLE_TEST_CSF_VALIDATION_H_INCLUDED #include -#include -#include #include + +#include +#include #include namespace ripple { @@ -54,7 +55,7 @@ class Validation PeerID nodeID_{0}; bool trusted_ = false; bool full_ = false; - boost::optional loadFee_; + std::optional loadFee_; std::uint64_t cookie_{0}; public: @@ -69,7 +70,7 @@ public: PeerKey key, PeerID nodeID, bool full, - boost::optional loadFee = boost::none, + std::optional loadFee = std::nullopt, std::uint64_t cookie = 0) : ledgerID_{id} , seq_{seq} @@ -137,7 +138,7 @@ public: return cookie_; } - boost::optional + std::optional loadFee() const { return loadFee_; diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 1f2a2fded..352aa4cb8 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -20,12 +20,13 @@ #define RIPPLE_TEST_CSF_COLLECTORS_H_INCLUDED #include -#include -#include -#include #include #include #include + +#include +#include +#include #include namespace ripple { @@ -180,8 +181,8 @@ struct TxCollector { Tx tx; SimTime submitted; - boost::optional accepted; - boost::optional validated; + std::optional accepted; + std::optional validated; Tracker(Tx tx_, SimTime submitted_) : tx{tx_}, submitted{submitted_} { @@ -453,7 +454,7 @@ struct LedgerCollector struct Tracker { SimTime accepted; - boost::optional fullyValidated; + std::optional fullyValidated; Tracker(SimTime accepted_) : accepted{accepted_} { diff --git a/src/test/csf/impl/ledgers.cpp b/src/test/csf/impl/ledgers.cpp index e4cd83051..ccc767008 100644 --- a/src/test/csf/impl/ledgers.cpp +++ b/src/test/csf/impl/ledgers.cpp @@ -125,7 +125,7 @@ LedgerOracle::accept( return Ledger(it->second, &(it->first)); } -boost::optional +std::optional LedgerOracle::lookup(Ledger::ID const& id) const { auto const it = instances_.right.find(id); @@ -133,7 +133,7 @@ LedgerOracle::lookup(Ledger::ID const& id) const { return Ledger(it->first, &(it->second)); } - return boost::none; + return std::nullopt; } std::size_t diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index 60aa34f74..e5bd479cd 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -256,7 +256,7 @@ public: LedgerOracle(); /** Find the ledger with the given ID */ - boost::optional + std::optional lookup(Ledger::ID const& id) const; /** Accept the given txs and generate a new ledger diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index 57b68b118..529a6b739 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -333,8 +333,7 @@ public: bool close( NetClock::time_point closeTime, - boost::optional consensusDelay = - boost::none); + std::optional consensusDelay = std::nullopt); /** Close and advance the ledger. diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index b36c1c821..d8ee49cdb 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -25,9 +25,10 @@ #include #include #include -#include -#include #include + +#include +#include #include namespace ripple { @@ -765,13 +766,13 @@ public: // the supported amendments list and tests that it can be // enabled explicitly - auto const neverSupportedFeat = [&]() -> boost::optional { + auto const neverSupportedFeat = [&]() -> std::optional { auto const n = supported.size(); for (size_t i = 0; i < n; ++i) if (!supported[i]) return bitsetIndexToFeature(i); - return boost::none; + return std::nullopt; }(); if (!neverSupportedFeat) diff --git a/src/test/jtx/JTx.h b/src/test/jtx/JTx.h index 13582747a..8a2557d55 100644 --- a/src/test/jtx/JTx.h +++ b/src/test/jtx/JTx.h @@ -23,10 +23,11 @@ #include #include #include -#include -#include #include #include + +#include +#include #include namespace ripple { @@ -42,7 +43,7 @@ struct JTx { Json::Value jv; requires_t requires; - boost::optional ter = TER{tesSUCCESS}; + std::optional ter = TER{tesSUCCESS}; bool fill_fee = true; bool fill_seq = true; bool fill_sig = true; diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index c02196206..8eab4368d 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -546,7 +546,7 @@ private: socket_type sock(std::move(s)); flat_buffer sb; error_code ec; - boost::optional> ssl_stream; + std::optional> ssl_stream; if (ssl) { diff --git a/src/test/jtx/WSClient.h b/src/test/jtx/WSClient.h index aa6793b21..8961522a0 100644 --- a/src/test/jtx/WSClient.h +++ b/src/test/jtx/WSClient.h @@ -21,10 +21,11 @@ #define RIPPLE_TEST_WSCLIENT_H_INCLUDED #include -#include +#include + #include #include -#include +#include namespace ripple { namespace test { @@ -33,13 +34,13 @@ class WSClient : public AbstractClient { public: /** Retrieve a message. */ - virtual boost::optional + virtual std::optional getMsg( std::chrono::milliseconds const& timeout = std::chrono::milliseconds{ 0}) = 0; /** Retrieve a message that meets the predicate criteria. */ - virtual boost::optional + virtual std::optional findMsg( std::chrono::milliseconds const& timeout, std::function pred) = 0; diff --git a/src/test/jtx/fee.h b/src/test/jtx/fee.h index 35b7dfc6f..58813409e 100644 --- a/src/test/jtx/fee.h +++ b/src/test/jtx/fee.h @@ -22,10 +22,11 @@ #include #include -#include #include #include +#include + namespace ripple { namespace test { namespace jtx { @@ -35,7 +36,7 @@ class fee { private: bool manual_ = true; - boost::optional amount_; + std::optional amount_; public: explicit fee(autofill_t) : manual_(false) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index a8c5aca49..d6ca9d82e 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -120,7 +120,7 @@ Env::closed() bool Env::close( NetClock::time_point closeTime, - boost::optional consensusDelay) + std::optional consensusDelay) { // Round up to next distinguishable value using namespace std::chrono_literals; @@ -422,7 +422,7 @@ Env::st(JTx const& jt) { // The parse must succeed, since we // generated the JSON ourselves. - boost::optional obj; + std::optional obj; try { obj = jtx::parse(jt.jv); diff --git a/src/test/jtx/impl/WSClient.cpp b/src/test/jtx/impl/WSClient.cpp index 8d8f6728e..e9b271681 100644 --- a/src/test/jtx/impl/WSClient.cpp +++ b/src/test/jtx/impl/WSClient.cpp @@ -88,7 +88,7 @@ class WSClientImpl : public WSClient } boost::asio::io_service ios_; - boost::optional work_; + std::optional work_; boost::asio::io_service::strand strand_; std::thread thread_; boost::asio::ip::tcp::socket stream_; @@ -120,7 +120,7 @@ class WSClientImpl : public WSClient })); } })); - work_ = boost::none; + work_ = std::nullopt; thread_.join(); } @@ -212,21 +212,21 @@ public: return {}; } - boost::optional + std::optional getMsg(std::chrono::milliseconds const& timeout) override { std::shared_ptr m; { std::unique_lock lock(m_); if (!cv_.wait_for(lock, timeout, [&] { return !msgs_.empty(); })) - return boost::none; + return std::nullopt; m = std::move(msgs_.back()); msgs_.pop_back(); } return std::move(m->jv); } - boost::optional + std::optional findMsg( std::chrono::milliseconds const& timeout, std::function pred) override @@ -247,7 +247,7 @@ public: return false; })) { - return boost::none; + return std::nullopt; } } return std::move(m->jv); diff --git a/src/test/jtx/impl/multisign.cpp b/src/test/jtx/impl/multisign.cpp index 50fc34e0b..129f30701 100644 --- a/src/test/jtx/impl/multisign.cpp +++ b/src/test/jtx/impl/multisign.cpp @@ -79,7 +79,7 @@ msig::operator()(Env& env, JTx& jt) const auto const mySigners = signers; jt.signer = [mySigners, &env](Env&, JTx& jtx) { jtx[sfSigningPubKey.getJsonName()] = ""; - boost::optional st; + std::optional st; try { st = parse(jtx.jv); diff --git a/src/test/jtx/impl/paths.cpp b/src/test/jtx/impl/paths.cpp index 31af97ff9..e27d2789b 100644 --- a/src/test/jtx/impl/paths.cpp +++ b/src/test/jtx/impl/paths.cpp @@ -39,7 +39,7 @@ paths::operator()(Env& env, JTx& jt) const in_.currency, in_.account, amount, - boost::none, + std::nullopt, env.app()); if (!pf.findPaths(depth_)) return; diff --git a/src/test/jtx/memo.h b/src/test/jtx/memo.h index 8dc760a5a..161dc70f3 100644 --- a/src/test/jtx/memo.h +++ b/src/test/jtx/memo.h @@ -20,7 +20,6 @@ #ifndef RIPPLE_TEST_JTX_MEMO_H_INCLUDED #define RIPPLE_TEST_JTX_MEMO_H_INCLUDED -#include #include namespace ripple { diff --git a/src/test/jtx/seq.h b/src/test/jtx/seq.h index 5439ed085..0227c573d 100644 --- a/src/test/jtx/seq.h +++ b/src/test/jtx/seq.h @@ -20,10 +20,11 @@ #ifndef RIPPLE_TEST_JTX_SEQ_H_INCLUDED #define RIPPLE_TEST_JTX_SEQ_H_INCLUDED -#include #include #include +#include + namespace ripple { namespace test { namespace jtx { @@ -33,7 +34,7 @@ struct seq { private: bool manual_ = true; - boost::optional num_; + std::optional num_; public: explicit seq(autofill_t) : manual_(false) diff --git a/src/test/jtx/sig.h b/src/test/jtx/sig.h index 25df8ed43..aa65a4f69 100644 --- a/src/test/jtx/sig.h +++ b/src/test/jtx/sig.h @@ -20,9 +20,10 @@ #ifndef RIPPLE_TEST_JTX_SIG_H_INCLUDED #define RIPPLE_TEST_JTX_SIG_H_INCLUDED -#include #include +#include + namespace ripple { namespace test { namespace jtx { @@ -34,7 +35,7 @@ class sig { private: bool manual_ = true; - boost::optional account_; + std::optional account_; public: explicit sig(autofill_t) : manual_(false) diff --git a/src/test/jtx/ter.h b/src/test/jtx/ter.h index b1d934cd3..d75d9f09d 100644 --- a/src/test/jtx/ter.h +++ b/src/test/jtx/ter.h @@ -33,7 +33,7 @@ namespace jtx { class ter { private: - boost::optional v_; + std::optional v_; public: explicit ter(decltype(std::ignore)) diff --git a/src/test/jtx/ticket.h b/src/test/jtx/ticket.h index 2ddf295f9..820aaee4a 100644 --- a/src/test/jtx/ticket.h +++ b/src/test/jtx/ticket.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_TEST_JTX_TICKET_H_INCLUDED #define RIPPLE_TEST_JTX_TICKET_H_INCLUDED -#include -#include #include #include #include +#include + namespace ripple { namespace test { namespace jtx { diff --git a/src/test/ledger/SkipList_test.cpp b/src/test/ledger/SkipList_test.cpp index 386a80277..4fd117a4c 100644 --- a/src/test/ledger/SkipList_test.cpp +++ b/src/test/ledger/SkipList_test.cpp @@ -55,15 +55,14 @@ class SkipList_test : public beast::unit_test::suite auto l = *(std::next(std::begin(history))); BEAST_EXPECT((*std::begin(history))->info().seq < l->info().seq); BEAST_EXPECT( - hashOfSeq(*l, l->info().seq + 1, env.journal) == boost::none); + !hashOfSeq(*l, l->info().seq + 1, env.journal).has_value()); BEAST_EXPECT( hashOfSeq(*l, l->info().seq, env.journal) == l->info().hash); BEAST_EXPECT( hashOfSeq(*l, l->info().seq - 1, env.journal) == l->info().parentHash); - BEAST_EXPECT( - hashOfSeq(*history.back(), l->info().seq, env.journal) == - boost::none); + BEAST_EXPECT(!hashOfSeq(*history.back(), l->info().seq, env.journal) + .has_value()); } // ledger skip lists store up to the previous 256 hashes @@ -79,9 +78,8 @@ class SkipList_test : public beast::unit_test::suite } // edge case accessing beyond 256 - BEAST_EXPECT( - hashOfSeq(**i, (*i)->info().seq - 258, env.journal) == - boost::none); + BEAST_EXPECT(!hashOfSeq(**i, (*i)->info().seq - 258, env.journal) + .has_value()); } // every 256th hash beyond the first 256 is stored diff --git a/src/test/ledger/View_test.cpp b/src/test/ledger/View_test.cpp index 6822eb015..3d86ad227 100644 --- a/src/test/ledger/View_test.cpp +++ b/src/test/ledger/View_test.cpp @@ -70,7 +70,7 @@ class View_test : public beast::unit_test::suite { openLedger.modify([](OpenView& view, beast::Journal) { // HACK! - boost::optional next; + std::optional next; next.emplace(0); for (;;) { @@ -88,7 +88,7 @@ class View_test : public beast::unit_test::suite wipe(Ledger& ledger) { // HACK! - boost::optional next; + std::optional next; next.emplace(0); for (;;) { @@ -105,7 +105,7 @@ class View_test : public beast::unit_test::suite succ( ReadView const& v, std::uint32_t id, - boost::optional answer) + std::optional answer) { auto const next = v.succ(k(id).key); if (answer) @@ -142,12 +142,12 @@ class View_test : public beast::unit_test::suite *genesis, env.app().timeKeeper().closeTime()); wipe(*ledger); ReadView& v = *ledger; - succ(v, 0, boost::none); + succ(v, 0, std::nullopt); ledger->rawInsert(sle(1, 1)); BEAST_EXPECT(v.exists(k(1))); BEAST_EXPECT(seq(v.read(k(1))) == 1); succ(v, 0, 1); - succ(v, 1, boost::none); + succ(v, 1, std::nullopt); ledger->rawInsert(sle(2, 2)); BEAST_EXPECT(seq(v.read(k(2))) == 2); ledger->rawInsert(sle(3, 3)); @@ -170,13 +170,13 @@ class View_test : public beast::unit_test::suite wipe(env.app().openLedger()); auto const open = env.current(); ApplyViewImpl v(&*open, tapNONE); - succ(v, 0, boost::none); + succ(v, 0, std::nullopt); v.insert(sle(1)); BEAST_EXPECT(v.exists(k(1))); BEAST_EXPECT(seq(v.read(k(1))) == 1); BEAST_EXPECT(seq(v.peek(k(1))) == 1); succ(v, 0, 1); - succ(v, 1, boost::none); + succ(v, 1, std::nullopt); v.insert(sle(2, 2)); BEAST_EXPECT(seq(v.read(k(2))) == 2); v.insert(sle(3, 3)); @@ -221,7 +221,7 @@ class View_test : public beast::unit_test::suite succ(v0, 4, 7); succ(v0, 5, 7); succ(v0, 6, 7); - succ(v0, 7, boost::none); + succ(v0, 7, std::nullopt); succ(v1, 0, 1); succ(v1, 1, 2); @@ -230,7 +230,7 @@ class View_test : public beast::unit_test::suite succ(v1, 4, 5); succ(v1, 5, 6); succ(v1, 6, 7); - succ(v1, 7, boost::none); + succ(v1, 7, std::nullopt); v1.erase(v1.peek(k(4))); succ(v1, 3, 5); @@ -254,7 +254,7 @@ class View_test : public beast::unit_test::suite succ(v0, 4, 5); succ(v0, 5, 7); succ(v0, 6, 7); - succ(v0, 7, boost::none); + succ(v0, 7, std::nullopt); } void diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index 91b8d3775..f8babe9f5 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -618,7 +618,7 @@ class DatabaseShard_test : public TestBase { auto const ledgerSeq{ db.prepareLedger((maxShardNumber + 1) * ledgersPerShard)}; - if (!BEAST_EXPECT(ledgerSeq != boost::none)) + if (!BEAST_EXPECT(ledgerSeq != std::nullopt)) return {}; shardIndex = db.seqToShardIndex(*ledgerSeq); @@ -830,7 +830,7 @@ class DatabaseShard_test : public TestBase // try to create another shard BEAST_EXPECT( db->prepareLedger((nTestShards + 1) * ledgersPerShard) == - boost::none); + std::nullopt); } void @@ -970,7 +970,7 @@ class DatabaseShard_test : public TestBase { auto const ledgerSeq{ db->prepareLedger(2 * ledgersPerShard)}; - if (!BEAST_EXPECT(ledgerSeq != boost::none)) + if (!BEAST_EXPECT(ledgerSeq != std::nullopt)) return; shardIndex = db->seqToShardIndex(*ledgerSeq); @@ -1487,7 +1487,7 @@ class DatabaseShard_test : public TestBase // Create one shard more than the open final limit auto const openFinalLimit{env.app().config().getValueFor( - SizedItem::openFinalLimit, boost::none)}; + SizedItem::openFinalLimit, std::nullopt)}; auto const numShards{openFinalLimit + 1}; TestData data(seedValue, 2, numShards); diff --git a/src/test/overlay/ProtocolVersion_test.cpp b/src/test/overlay/ProtocolVersion_test.cpp index c01354980..c10f54278 100644 --- a/src/test/overlay/ProtocolVersion_test.cpp +++ b/src/test/overlay/ProtocolVersion_test.cpp @@ -92,8 +92,8 @@ public: make_protocol(2, 0)); BEAST_EXPECT( negotiateProtocolVersion("XRPL/999.999, WebSocket/1.0") == - boost::none); - BEAST_EXPECT(negotiateProtocolVersion("") == boost::none); + std::nullopt); + BEAST_EXPECT(negotiateProtocolVersion("") == std::nullopt); } } }; diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 11d5d3e2a..c413e59e2 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -117,7 +116,7 @@ public: { return false; } - boost::optional + std::optional publisherListSequence(PublicKey const&) const override { return {}; diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index cecfa618a..dd649bfd1 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -20,15 +20,17 @@ #include #include #include +#include + #include #include -#include #include + #include #include #include #include -#include +#include #include #include @@ -60,7 +62,7 @@ private: using address_type = boost::asio::ip::address; io_context_type io_context_; - boost::optional> + std::optional> work_; std::thread thread_; std::shared_ptr context_; @@ -639,7 +641,7 @@ public: ~short_read_test() { - work_ = boost::none; + work_.reset(); thread_.join(); } diff --git a/src/test/protocol/InnerObjectFormats_test.cpp b/src/test/protocol/InnerObjectFormats_test.cpp index 2ed1d70cf..009ceef25 100644 --- a/src/test/protocol/InnerObjectFormats_test.cpp +++ b/src/test/protocol/InnerObjectFormats_test.cpp @@ -186,7 +186,7 @@ public: "Internal InnerObjectFormatsParsedJSON error. Bad JSON."); } STParsedJSONObject parsed("request", req); - bool const noObj = parsed.object == boost::none; + bool const noObj = !parsed.object.has_value(); if (noObj == test.expectFail) { pass(); diff --git a/src/test/protocol/PublicKey_test.cpp b/src/test/protocol/PublicKey_test.cpp index df09a35a2..c79740218 100644 --- a/src/test/protocol/PublicKey_test.cpp +++ b/src/test/protocol/PublicKey_test.cpp @@ -73,7 +73,7 @@ public: } bool - check(boost::optional answer, std::string const& s) + check(std::optional answer, std::string const& s) { return ecdsaCanonicality(makeSlice(sig(s))) == answer; } @@ -179,126 +179,126 @@ public: "b6ba")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3005" "0201FF" "0200")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020101" "020202")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020701" "020102")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020401" "020102")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020501" "020102")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020201" "020102")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020301" "020202")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3006" "020401" "020202")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3047" "0221005990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba" "6105" "022200002d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e56" "6695ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3144" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3045" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "301F" "01205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3045" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed00")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3044" "01205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3024" "0200" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3044" "02208990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3045" "0221005990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba" "6105" "02202d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3044" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05012" "02d5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695e" "d")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3024" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "0200")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3044" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" "0220fd5876262c288beb511d061691bf26777344b702b00f8fe28621fe4e566695" "ed")); BEAST_EXPECT(check( - boost::none, + std::nullopt, "3045" "02205990e0584b2b238e1dfaad8d6ed69ecc1a4a13ac85fc0b31d0df395eb1ba61" "05" diff --git a/src/test/protocol/STObject_test.cpp b/src/test/protocol/STObject_test.cpp index f2df54fb1..c165aafd1 100644 --- a/src/test/protocol/STObject_test.cpp +++ b/src/test/protocol/STObject_test.cpp @@ -415,7 +415,7 @@ public: except([&]() { st[sf3Outer]; }); BEAST_EXPECT(*st[~sf1Outer] == 1); BEAST_EXPECT(*st[~sf2Outer] == 2); - BEAST_EXPECT(st[~sf3Outer] == boost::none); + BEAST_EXPECT(st[~sf3Outer] == std::nullopt); BEAST_EXPECT(!!st[~sf1Outer]); BEAST_EXPECT(!!st[~sf2Outer]); BEAST_EXPECT(!st[~sf3Outer]); @@ -457,14 +457,14 @@ public: STObject st(sfGeneric); unexcept([&]() { st[sf1Outer]; }); except([&]() { return st[sf1Outer] == 0; }); - BEAST_EXPECT(st[~sf1Outer] == boost::none); - BEAST_EXPECT(st[~sf1Outer] == boost::optional{}); - BEAST_EXPECT(st[~sf1Outer] != boost::optional(1)); + BEAST_EXPECT(st[~sf1Outer] == std::nullopt); + BEAST_EXPECT(st[~sf1Outer] == std::optional{}); + BEAST_EXPECT(st[~sf1Outer] != std::optional(1)); BEAST_EXPECT(!st[~sf1Outer]); st[sf1Outer] = 2; BEAST_EXPECT(st[sf1Outer] == 2); - BEAST_EXPECT(st[~sf1Outer] != boost::none); - BEAST_EXPECT(st[~sf1Outer] == boost::optional(2)); + BEAST_EXPECT(st[~sf1Outer] != std::nullopt); + BEAST_EXPECT(st[~sf1Outer] == std::optional(2)); BEAST_EXPECT(!!st[~sf1Outer]); st[sf1Outer] = 1; BEAST_EXPECT(st[sf1Outer] == 1); @@ -473,11 +473,11 @@ public: st[sf1Outer] = 0; BEAST_EXPECT(!st[sf1Outer]); BEAST_EXPECT(!!st[~sf1Outer]); - st[~sf1Outer] = boost::none; + st[~sf1Outer] = std::nullopt; BEAST_EXPECT(!st[~sf1Outer]); - BEAST_EXPECT(st[~sf1Outer] == boost::none); - BEAST_EXPECT(st[~sf1Outer] == boost::optional{}); - st[~sf1Outer] = boost::none; + BEAST_EXPECT(st[~sf1Outer] == std::nullopt); + BEAST_EXPECT(st[~sf1Outer] == std::optional{}); + st[~sf1Outer] = std::nullopt; BEAST_EXPECT(!st[~sf1Outer]); except([&]() { return st[sf1Outer] == 0; }); except([&]() { return *st[~sf1Outer]; }); @@ -502,16 +502,16 @@ public: { STObject st(sotOuter, sfGeneric); BEAST_EXPECT(!!st[~sf1Outer]); - BEAST_EXPECT(st[~sf1Outer] != boost::none); + BEAST_EXPECT(st[~sf1Outer] != std::nullopt); BEAST_EXPECT(st[sf1Outer] == 0); BEAST_EXPECT(*st[~sf1Outer] == 0); BEAST_EXPECT(!st[~sf2Outer]); - BEAST_EXPECT(st[~sf2Outer] == boost::none); + BEAST_EXPECT(st[~sf2Outer] == std::nullopt); except([&]() { return st[sf2Outer] == 0; }); BEAST_EXPECT(!!st[~sf3Outer]); - BEAST_EXPECT(st[~sf3Outer] != boost::none); + BEAST_EXPECT(st[~sf3Outer] != std::nullopt); BEAST_EXPECT(st[sf3Outer] == 0); - except([&]() { st[~sf1Outer] = boost::none; }); + except([&]() { st[~sf1Outer] = std::nullopt; }); st[sf1Outer] = 1; BEAST_EXPECT(st[sf1Outer] == 1); BEAST_EXPECT(*st[~sf1Outer] == 1); @@ -524,7 +524,7 @@ public: BEAST_EXPECT(st[sf2Outer] == 2); BEAST_EXPECT(*st[~sf2Outer] == 2); BEAST_EXPECT(!!st[~sf2Outer]); - st[~sf2Outer] = boost::none; + st[~sf2Outer] = std::nullopt; except([&]() { return *st[~sf2Outer]; }); BEAST_EXPECT(!st[~sf2Outer]); st[sf3Outer] = 3; @@ -539,13 +539,13 @@ public: BEAST_EXPECT(st[sf3Outer] == 0); BEAST_EXPECT(*st[~sf3Outer] == 0); BEAST_EXPECT(!!st[~sf3Outer]); - except([&]() { st[~sf3Outer] = boost::none; }); + except([&]() { st[~sf3Outer] = std::nullopt; }); BEAST_EXPECT(st[sf3Outer] == 0); BEAST_EXPECT(*st[~sf3Outer] == 0); BEAST_EXPECT(!!st[~sf3Outer]); } - // coercion operator to boost::optional + // coercion operator to std::optional { STObject st(sfGeneric); @@ -553,7 +553,7 @@ public: static_assert( std::is_same< std::decay_t, - boost::optional>::value, + std::optional>::value, ""); } @@ -577,7 +577,7 @@ public: st[sf4] = std::move(b); BEAST_EXPECT(b.empty()); BEAST_EXPECT(Slice(st[sf4]).size() == 1); - st[~sf4] = boost::none; + st[~sf4] = std::nullopt; BEAST_EXPECT(!~st[~sf4]); b = Buffer{2}; st[sf4] = Slice(b); @@ -596,7 +596,7 @@ public: st[sf5] = std::move(b); BEAST_EXPECT(b.empty()); BEAST_EXPECT(Slice(st[sf5]).size() == 1); - st[~sf4] = boost::none; + st[~sf4] = std::nullopt; BEAST_EXPECT(!~st[~sf4]); } } @@ -610,7 +610,7 @@ public: generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")); st[sf5] = kp.first; BEAST_EXPECT(st[sf5] != PublicKey{}); - st[~sf5] = boost::none; + st[~sf5] = std::nullopt; #if 0 pk = st[sf5]; BEAST_EXPECT(pk.size() == 0); @@ -663,7 +663,7 @@ public: st[sf2] = v; BEAST_EXPECT(cst[sf2].size() == 1); BEAST_EXPECT(cst[sf2][0] == uint256{1}); - st[~sf2] = boost::none; + st[~sf2] = std::nullopt; BEAST_EXPECT(!st[~sf2]); st[sf3] = v; BEAST_EXPECT(cst[sf3].size() == 1); diff --git a/src/test/rpc/AccountCurrencies_test.cpp b/src/test/rpc/AccountCurrencies_test.cpp index b865aeb8e..ac4adcf51 100644 --- a/src/test/rpc/AccountCurrencies_test.cpp +++ b/src/test/rpc/AccountCurrencies_test.cpp @@ -93,7 +93,7 @@ class AccountCurrencies_test : public beast::unit_test::suite auto const gw = Account{"gateway"}; env.fund(XRP(10000), alice, gw); char currencySuffix{'A'}; - std::vector> gwCurrencies(26); // A - Z + std::vector> gwCurrencies(26); // A - Z std::generate(gwCurrencies.begin(), gwCurrencies.end(), [&]() { auto gwc = gw[std::string("US") + currencySuffix++]; env(trust(alice, gwc(100))); @@ -111,7 +111,7 @@ class AccountCurrencies_test : public beast::unit_test::suite auto arrayCheck = [&result]( Json::StaticString const& fld, - std::vector> const& expected) -> bool { + std::vector> const& expected) -> bool { bool stat = result.isMember(fld) && result[fld].isArray() && result[fld].size() == expected.size(); for (size_t i = 0; stat && i < expected.size(); ++i) diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index a2ebc21cb..81a9cfc72 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -1157,7 +1157,7 @@ public: t[jss::TakerPays] != takerPays.value().getJson(JsonOptions::none)) return false; // Make sure no other message is waiting - return wsc->getMsg(timeout) == boost::none; + return wsc->getMsg(timeout) == std::nullopt; } void diff --git a/src/test/rpc/KeyGeneration_test.cpp b/src/test/rpc/KeyGeneration_test.cpp index 0b39dce2a..735bae40b 100644 --- a/src/test/rpc/KeyGeneration_test.cpp +++ b/src/test/rpc/KeyGeneration_test.cpp @@ -97,7 +97,7 @@ class WalletPropose_test : public ripple::TestSuite { public: void - testRandomWallet(boost::optional const& keyType) + testRandomWallet(std::optional const& keyType) { Json::Value params; if (keyType) @@ -146,7 +146,7 @@ public: void testSeed( - boost::optional const& keyType, + std::optional const& keyType, key_strings const& strings) { testcase("seed"); @@ -162,7 +162,7 @@ public: void testSeedHex( - boost::optional const& keyType, + std::optional const& keyType, key_strings const& strings) { testcase("seed_hex"); @@ -179,7 +179,7 @@ public: void testLegacyPassphrase( char const* value, - boost::optional const& keyType, + std::optional const& keyType, key_strings const& strings) { Json::Value params; @@ -196,7 +196,7 @@ public: void testLegacyPassphrase( - boost::optional const& keyType, + std::optional const& keyType, key_strings const& strings) { testcase("passphrase"); @@ -209,7 +209,7 @@ public: void testKeyType( - boost::optional const& keyType, + std::optional const& keyType, key_strings const& strings) { testcase(keyType ? *keyType : "no key_type"); @@ -318,7 +318,7 @@ public: void testKeypairForSignature( - boost::optional keyType, + std::optional keyType, key_strings const& strings) { testcase( @@ -852,13 +852,13 @@ public: void run() override { - testKeyType(boost::none, secp256k1_strings); + testKeyType(std::nullopt, secp256k1_strings); testKeyType(std::string("secp256k1"), secp256k1_strings); testKeyType(std::string("ed25519"), ed25519_strings); testKeyType(std::string("secp256k1"), strong_brain_strings); testBadInput(); - testKeypairForSignature(boost::none, secp256k1_strings); + testKeypairForSignature(std::nullopt, secp256k1_strings); testKeypairForSignature(std::string("secp256k1"), secp256k1_strings); testKeypairForSignature(std::string("ed25519"), ed25519_strings); testKeypairForSignature(std::string("secp256k1"), strong_brain_strings); diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 22a4afb29..d1d5e6e61 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -98,7 +98,7 @@ public: // Check stream update auto jvo = wsc->getMsg(10ms); - BEAST_EXPECTS(!jvo, "getMsg: " + to_string(jvo.get())); + BEAST_EXPECTS(!jvo, "getMsg: " + to_string(jvo.value())); } } diff --git a/src/test/server/Server_test.cpp b/src/test/server/Server_test.cpp index 521661c58..35f9149ca 100644 --- a/src/test/server/Server_test.cpp +++ b/src/test/server/Server_test.cpp @@ -23,17 +23,20 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include + #include #include #include #include + +#include +#include +#include +#include + +#include +#include +#include #include namespace ripple { @@ -49,19 +52,19 @@ public: { private: boost::asio::io_service io_service_; - boost::optional work_; + std::optional work_; std::thread thread_; public: TestThread() - : work_(boost::in_place(std::ref(io_service_))) + : work_(std::in_place, std::ref(io_service_)) , thread_([&]() { this->io_service_.run(); }) { } ~TestThread() { - work_ = boost::none; + work_.reset(); thread_.join(); } diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index 3b6bf0d4f..ae1174b4d 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -69,14 +69,14 @@ public: { } - boost::optional + std::optional getNode(SHAMapHash const& nodeHash) const override { Map::iterator it = mMap.find(nodeHash); if (it == mMap.end()) { JLOG(mJournal.fatal()) << "Test filter missing node"; - return boost::none; + return std::nullopt; } return it->second; }