From 11ab8ec33a6302d6c53a4e43ff63d23ef2c05742 Mon Sep 17 00:00:00 2001 From: JCW Date: Wed, 11 Mar 2026 18:39:42 +0000 Subject: [PATCH] Modularise Ledger.cpp Signed-off-by: JCW --- include/xrpl/core/ServiceRegistry.h | 6 +- .../app => include/xrpl}/ledger/Ledger.h | 48 +++-- .../xrpl/ledger}/LedgerTiming.h | 0 .../xrpl}/ledger/PendingSaves.h | 0 include/xrpl/protocol/Fees.h | 9 + .../xrpl/tx}/paths/AMMLiquidity.h | 0 .../app => include/xrpl/tx}/paths/AMMOffer.h | 0 .../xrpl/tx}/paths/detail/StepChecks.h | 0 src/{xrpld/app => libxrpl}/ledger/Ledger.cpp | 169 ++++++++---------- .../detail => libxrpl/server}/Manifest.cpp | 0 .../tx/paths}/AMMLiquidity.cpp | 4 +- .../detail => libxrpl/tx/paths}/AMMOffer.cpp | 5 +- .../detail => libxrpl/tx/paths}/BookStep.cpp | 5 +- .../tx/paths}/DirectStep.cpp | 3 +- .../detail => libxrpl/tx/paths}/PaySteps.cpp | 0 .../tx/paths}/XRPEndpointStep.cpp | 3 +- src/test/app/AMMExtended_test.cpp | 3 +- src/test/app/FeeVote_test.cpp | 68 +++---- src/test/app/LedgerHistory_test.cpp | 7 +- src/test/app/RCLValidations_test.cpp | 12 +- src/test/app/Regression_test.cpp | 4 +- src/test/consensus/LedgerTiming_test.cpp | 3 +- src/test/consensus/NegativeUNL_test.cpp | 15 +- src/test/csf/ledgers.h | 3 +- src/test/jtx/Env.h | 4 +- src/test/jtx/impl/paths.cpp | 2 +- src/test/jtx/utility.h | 3 +- src/test/ledger/PendingSaves_test.cpp | 3 +- src/test/ledger/SkipList_test.cpp | 8 +- src/test/ledger/View_test.cpp | 22 ++- src/test/overlay/compression_test.cpp | 2 +- src/xrpld/app/consensus/RCLConsensus.cpp | 4 +- src/xrpld/app/consensus/RCLCxLedger.h | 2 +- src/xrpld/app/consensus/RCLValidations.h | 2 +- src/xrpld/app/ledger/InboundLedger.h | 2 +- src/xrpld/app/ledger/LedgerHistory.cpp | 9 +- src/xrpld/app/ledger/LedgerHistory.h | 2 +- src/xrpld/app/ledger/LedgerMaster.h | 3 +- src/xrpld/app/ledger/LedgerToJson.h | 2 +- src/xrpld/app/ledger/OpenLedger.h | 2 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 2 +- src/xrpld/app/ledger/detail/InboundLedger.cpp | 6 +- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 5 +- .../app/ledger/detail/LedgerDeltaAcquire.cpp | 3 +- .../app/ledger/detail/LedgerDeltaAcquire.h | 2 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 10 +- src/xrpld/app/ledger/detail/LedgerReplay.cpp | 3 +- src/xrpld/app/ledger/detail/LocalTxs.cpp | 2 +- src/xrpld/app/ledger/detail/SkipListAcquire.h | 2 +- src/xrpld/app/main/Application.cpp | 49 +++-- src/xrpld/app/main/Application.h | 2 +- src/xrpld/app/misc/FeeVoteImpl.cpp | 4 +- src/xrpld/app/misc/NegativeUNLVote.cpp | 2 +- src/xrpld/app/misc/NegativeUNLVote.h | 3 +- src/xrpld/app/misc/NetworkOPs.cpp | 4 +- src/xrpld/app/misc/SHAMapStore.h | 3 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 2 +- src/xrpld/app/rdb/backend/detail/Node.h | 2 +- src/xrpld/consensus/Consensus.h | 2 +- src/xrpld/core/Config.h | 12 +- .../detail}/AccountCurrencies.cpp | 2 +- .../paths => rpc/detail}/AccountCurrencies.h | 2 +- .../{app/paths => rpc/detail}/PathRequest.cpp | 12 +- .../{app/paths => rpc/detail}/PathRequest.h | 14 +- .../detail/PathRequestManager.cpp} | 16 +- .../detail/PathRequestManager.h} | 8 +- .../{app/paths => rpc/detail}/Pathfinder.cpp | 6 +- .../{app/paths => rpc/detail}/Pathfinder.h | 4 +- .../paths => rpc}/detail/PathfinderUtils.h | 0 src/xrpld/rpc/detail/RPCHelpers.cpp | 2 +- src/xrpld/rpc/detail/RPCLedgerHelpers.h | 2 +- .../paths => rpc/detail}/RippleLineCache.cpp | 4 +- .../paths => rpc/detail}/RippleLineCache.h | 4 +- src/xrpld/rpc/detail/TransactionSign.cpp | 2 +- .../{app/paths => rpc/detail}/TrustLine.cpp | 2 +- .../{app/paths => rpc/detail}/TrustLine.h | 0 .../rpc/handlers/AccountCurrenciesHandler.cpp | 2 +- src/xrpld/rpc/handlers/AccountLines.cpp | 2 +- src/xrpld/rpc/handlers/GatewayBalances.cpp | 2 +- src/xrpld/rpc/handlers/NoRippleCheck.cpp | 2 +- src/xrpld/rpc/handlers/PathFind.cpp | 4 +- src/xrpld/rpc/handlers/RipplePathFind.cpp | 6 +- 82 files changed, 354 insertions(+), 303 deletions(-) rename {src/xrpld/app => include/xrpl}/ledger/Ledger.h (91%) rename {src/xrpld/consensus => include/xrpl/ledger}/LedgerTiming.h (100%) rename {src/xrpld/app => include/xrpl}/ledger/PendingSaves.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/AMMLiquidity.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/AMMOffer.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/StepChecks.h (100%) rename src/{xrpld/app => libxrpl}/ledger/Ledger.cpp (86%) rename src/{xrpld/app/misc/detail => libxrpl/server}/Manifest.cpp (100%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/AMMLiquidity.cpp (99%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/AMMOffer.cpp (98%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/BookStep.cpp (99%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/DirectStep.cpp (99%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/PaySteps.cpp (100%) rename src/{xrpld/app/paths/detail => libxrpl/tx/paths}/XRPEndpointStep.cpp (99%) rename src/xrpld/{app/paths => rpc/detail}/AccountCurrencies.cpp (97%) rename src/xrpld/{app/paths => rpc/detail}/AccountCurrencies.h (89%) rename src/xrpld/{app/paths => rpc/detail}/PathRequest.cpp (98%) rename src/xrpld/{app/paths => rpc/detail}/PathRequest.h (94%) rename src/xrpld/{app/paths/PathRequests.cpp => rpc/detail/PathRequestManager.cpp} (95%) rename src/xrpld/{app/paths/PathRequests.h => rpc/detail/PathRequestManager.h} (94%) rename src/xrpld/{app/paths => rpc/detail}/Pathfinder.cpp (99%) rename src/xrpld/{app/paths => rpc/detail}/Pathfinder.h (98%) rename src/xrpld/{app/paths => rpc}/detail/PathfinderUtils.h (100%) rename src/xrpld/{app/paths => rpc/detail}/RippleLineCache.cpp (98%) rename src/xrpld/{app/paths => rpc/detail}/RippleLineCache.h (97%) rename src/xrpld/{app/paths => rpc/detail}/TrustLine.cpp (98%) rename src/xrpld/{app/paths => rpc/detail}/TrustLine.h (100%) diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index 1a2e33d5ee..bff475c461 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -45,7 +45,7 @@ class NetworkIDService; class OpenLedger; class OrderBookDB; class Overlay; -class PathRequests; +class PathRequestManager; class PeerReservationTable; class PendingSaves; class RelationalDatabase; @@ -195,8 +195,8 @@ public: virtual TxQ& getTxQ() = 0; - virtual PathRequests& - getPathRequests() = 0; + virtual PathRequestManager& + getPathRequestManager() = 0; // Server services virtual ServerHandler& diff --git a/src/xrpld/app/ledger/Ledger.h b/include/xrpl/ledger/Ledger.h similarity index 91% rename from src/xrpld/app/ledger/Ledger.h rename to include/xrpl/ledger/Ledger.h index f040e93369..30254ef091 100644 --- a/src/xrpld/app/ledger/Ledger.h +++ b/include/xrpl/ledger/Ledger.h @@ -1,13 +1,12 @@ #pragma once -#include -#include - #include #include #include #include +#include #include +#include #include #include #include @@ -15,7 +14,7 @@ namespace xrpl { -class Application; +class ServiceRegistry; class Job; class TransactionMaster; @@ -83,11 +82,12 @@ public: */ Ledger( create_genesis_t, - Config const& config, + Rules const& rules, + Fees const& fees, std::vector const& amendments, Family& family); - Ledger(LedgerHeader const& info, Config const& config, Family& family); + Ledger(LedgerHeader const& info, Rules const& rules, Family& family); /** Used for ledgers loaded from JSON files @@ -97,7 +97,8 @@ public: LedgerHeader const& info, bool& loaded, bool acquire, - Config const& config, + Rules const& rules, + Fees const& fees, Family& family, beast::Journal j); @@ -113,7 +114,8 @@ public: Ledger( std::uint32_t ledgerSeq, NetClock::time_point closeTime, - Config const& config, + Rules const& rules, + Fees const& fees, Family& family); ~Ledger() = default; @@ -322,7 +324,7 @@ public: walkLedger(beast::Journal j, bool parallel = false) const; bool - assertSensible(beast::Journal ledgerJ) const; + isSensible() const; void invariants() const; @@ -379,9 +381,6 @@ private: bool setup(); - void - defaultFees(Config const& config); - bool mImmutable; // A SHAMap containing the transactions associated with this ledger. @@ -410,23 +409,38 @@ using CachedLedger = CachedView; extern bool pendSaveValidated( - Application& app, + ServiceRegistry& registry, std::shared_ptr const& ledger, bool isSynchronous, bool isCurrent); std::shared_ptr -loadLedgerHelper(LedgerHeader const& sinfo, Application& app, bool acquire); +loadLedgerHelper( + LedgerHeader const& sinfo, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire); std::shared_ptr -loadByIndex(std::uint32_t ledgerIndex, Application& app, bool acquire = true); +loadByIndex( + std::uint32_t ledgerIndex, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire = true); std::shared_ptr -loadByHash(uint256 const& ledgerHash, Application& app, bool acquire = true); +loadByHash( + uint256 const& ledgerHash, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire = true); // Fetch the ledger with the highest sequence contained in the database extern std::tuple, std::uint32_t, uint256> -getLatestLedger(Application& app); +getLatestLedger(Rules const& rules, Fees const& fees, ServiceRegistry& registry); /** Deserialize a SHAMapItem containing a single STTx diff --git a/src/xrpld/consensus/LedgerTiming.h b/include/xrpl/ledger/LedgerTiming.h similarity index 100% rename from src/xrpld/consensus/LedgerTiming.h rename to include/xrpl/ledger/LedgerTiming.h diff --git a/src/xrpld/app/ledger/PendingSaves.h b/include/xrpl/ledger/PendingSaves.h similarity index 100% rename from src/xrpld/app/ledger/PendingSaves.h rename to include/xrpl/ledger/PendingSaves.h diff --git a/include/xrpl/protocol/Fees.h b/include/xrpl/protocol/Fees.h index 84c8ffe81f..6ddc734d9e 100644 --- a/include/xrpl/protocol/Fees.h +++ b/include/xrpl/protocol/Fees.h @@ -4,6 +4,10 @@ namespace xrpl { +// Deprecated constant for backwards compatibility with pre-XRPFees amendment. +// This was the reference fee units used in the old fee calculation. +inline constexpr std::uint32_t FEE_UNITS_DEPRECATED = 10; + /** Reflects the fee settings for a particular ledger. The fees are always the same for any transactions applied @@ -20,6 +24,11 @@ struct Fees Fees& operator=(Fees const&) = default; + Fees(XRPAmount base_, XRPAmount reserve_, XRPAmount increment_) + : base(base_), reserve(reserve_), increment(increment_) + { + } + /** Returns the account reserve given the owner count, in drops. The reserve is calculated as the reserve base plus diff --git a/src/xrpld/app/paths/AMMLiquidity.h b/include/xrpl/tx/paths/AMMLiquidity.h similarity index 100% rename from src/xrpld/app/paths/AMMLiquidity.h rename to include/xrpl/tx/paths/AMMLiquidity.h diff --git a/src/xrpld/app/paths/AMMOffer.h b/include/xrpl/tx/paths/AMMOffer.h similarity index 100% rename from src/xrpld/app/paths/AMMOffer.h rename to include/xrpl/tx/paths/AMMOffer.h diff --git a/src/xrpld/app/paths/detail/StepChecks.h b/include/xrpl/tx/paths/detail/StepChecks.h similarity index 100% rename from src/xrpld/app/paths/detail/StepChecks.h rename to include/xrpl/tx/paths/detail/StepChecks.h diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/libxrpl/ledger/Ledger.cpp similarity index 86% rename from src/xrpld/app/ledger/Ledger.cpp rename to src/libxrpl/ledger/Ledger.cpp index bde5ca010a..52afe7c477 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/libxrpl/ledger/Ledger.cpp @@ -1,17 +1,12 @@ -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include #include +#include +#include +#include #include #include #include @@ -147,13 +142,15 @@ public: Ledger::Ledger( create_genesis_t, - Config const& config, + Rules const& rules, + Fees const& fees, std::vector const& amendments, Family& family) : mImmutable(false) , txMap_(SHAMapType::TRANSACTION, family) , stateMap_(SHAMapType::STATE, family) - , rules_{config.features} + , fees_(fees) + , rules_(rules) , j_(beast::Journal(beast::Journal::getNullSink())) { header_.seq = 1; @@ -182,19 +179,19 @@ Ledger::Ledger( // Whether featureXRPFees is supported will depend on startup options. if (std::find(amendments.begin(), amendments.end(), featureXRPFees) != amendments.end()) { - sle->at(sfBaseFeeDrops) = config.FEES.reference_fee; - sle->at(sfReserveBaseDrops) = config.FEES.account_reserve; - sle->at(sfReserveIncrementDrops) = config.FEES.owner_reserve; + sle->at(sfBaseFeeDrops) = fees.base; + sle->at(sfReserveBaseDrops) = fees.reserve; + sle->at(sfReserveIncrementDrops) = fees.increment; } else { - if (auto const f = config.FEES.reference_fee.dropsAs()) + if (auto const f = fees.base.dropsAs()) sle->at(sfBaseFee) = *f; - if (auto const f = config.FEES.account_reserve.dropsAs()) + if (auto const f = fees.reserve.dropsAs()) sle->at(sfReserveBase) = *f; - if (auto const f = config.FEES.owner_reserve.dropsAs()) + if (auto const f = fees.increment.dropsAs()) sle->at(sfReserveIncrement) = *f; - sle->at(sfReferenceFeeUnits) = Config::FEE_UNITS_DEPRECATED; + sle->at(sfReferenceFeeUnits) = FEE_UNITS_DEPRECATED; } rawInsert(sle); } @@ -207,13 +204,15 @@ Ledger::Ledger( LedgerHeader const& info, bool& loaded, bool acquire, - Config const& config, + Rules const& rules, + Fees const& fees, Family& family, beast::Journal j) : mImmutable(true) , txMap_(SHAMapType::TRANSACTION, info.txHash, family) , stateMap_(SHAMapType::STATE, info.accountHash, family) - , rules_(config.features) + , fees_(fees) + , rules_(rules) , header_(info) , j_(j) { @@ -235,7 +234,7 @@ Ledger::Ledger( txMap_.setImmutable(); stateMap_.setImmutable(); - defaultFees(config); + // Note: fees_ is passed in, but setup() may override it from the ledger state if (!setup()) loaded = false; @@ -275,11 +274,11 @@ Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime) } } -Ledger::Ledger(LedgerHeader const& info, Config const& config, Family& family) +Ledger::Ledger(LedgerHeader const& info, Rules const& rules, Family& family) : mImmutable(true) , txMap_(SHAMapType::TRANSACTION, info.txHash, family) , stateMap_(SHAMapType::STATE, info.accountHash, family) - , rules_{config.features} + , rules_(rules) , header_(info) , j_(beast::Journal(beast::Journal::getNullSink())) { @@ -289,18 +288,19 @@ Ledger::Ledger(LedgerHeader const& info, Config const& config, Family& family) Ledger::Ledger( std::uint32_t ledgerSeq, NetClock::time_point closeTime, - Config const& config, + Rules const& rules, + Fees const& fees, Family& family) : mImmutable(false) , txMap_(SHAMapType::TRANSACTION, family) , stateMap_(SHAMapType::STATE, family) - , rules_{config.features} + , fees_(fees) + , rules_(rules) , j_(beast::Journal(beast::Journal::getNullSink())) { header_.seq = ledgerSeq; header_.closeTime = closeTime; header_.closeTimeResolution = ledgerDefaultTimeResolution; - defaultFees(config); setup(); } @@ -628,20 +628,6 @@ Ledger::setup() return ret; } -void -Ledger::defaultFees(Config const& config) -{ - XRPL_ASSERT( - fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0, - "xrpl::Ledger::defaultFees : zero fees"); - if (fees_.base == 0) - fees_.base = config.FEES.reference_fee; - if (fees_.reserve == 0) - fees_.reserve = config.FEES.account_reserve; - if (fees_.increment == 0) - fees_.increment = config.FEES.owner_reserve; -} - std::shared_ptr Ledger::peek(Keylet const& k) const { @@ -806,27 +792,11 @@ Ledger::walkLedger(beast::Journal j, bool parallel) const } bool -Ledger::assertSensible(beast::Journal ledgerJ) const +Ledger::isSensible() const { - if (header_.hash.isNonZero() && header_.accountHash.isNonZero() && + return header_.hash.isNonZero() && header_.accountHash.isNonZero() && (header_.accountHash == stateMap_.getHash().as_uint256()) && - (header_.txHash == txMap_.getHash().as_uint256())) - { - return true; - } - - // LCOV_EXCL_START - Json::Value j = getJson({*this, {}}); - - j[jss::accountTreeHash] = to_string(header_.accountHash); - j[jss::transTreeHash] = to_string(header_.txHash); - - JLOG(ledgerJ.fatal()) << "ledger is not sensible" << j; - - UNREACHABLE("xrpl::Ledger::assertSensible : ledger is not sensible"); - - return false; - // LCOV_EXCL_STOP + (header_.txHash == txMap_.getHash().as_uint256()); } // update the skip list with the information from our previous ledger @@ -908,24 +878,27 @@ Ledger::isVotingLedger() const } static bool -saveValidatedLedger(Application& app, std::shared_ptr const& ledger, bool current) +saveValidatedLedger( + ServiceRegistry& registry, + std::shared_ptr const& ledger, + bool current) { - auto j = app.journal("Ledger"); + auto j = registry.journal("Ledger"); auto seq = ledger->header().seq; - if (!app.pendingSaves().startWork(seq)) + if (!registry.pendingSaves().startWork(seq)) { // The save was completed synchronously JLOG(j.debug()) << "Save aborted"; return true; } - auto& db = app.getRelationalDatabase(); + auto& db = registry.getRelationalDatabase(); auto const res = db.saveValidatedLedger(ledger, current); // Clients can now trust the database for // information about this ledger sequence. - app.pendingSaves().finishWork(seq); + registry.pendingSaves().finishWork(seq); return res; } @@ -934,18 +907,18 @@ saveValidatedLedger(Application& app, std::shared_ptr const& ledge */ bool pendSaveValidated( - Application& app, + ServiceRegistry& registry, std::shared_ptr const& ledger, bool isSynchronous, bool isCurrent) { - if (!app.getHashRouter().setFlags(ledger->header().hash, HashRouterFlags::SAVED)) + if (!registry.getHashRouter().setFlags(ledger->header().hash, HashRouterFlags::SAVED)) { // We have tried to save this ledger recently - auto stream = app.journal("Ledger").debug(); + auto stream = registry.journal("Ledger").debug(); JLOG(stream) << "Double pend save for " << ledger->header().seq; - if (!isSynchronous || !app.pendingSaves().pending(ledger->header().seq)) + if (!isSynchronous || !registry.pendingSaves().pending(ledger->header().seq)) { // Either we don't need it to be finished // or it is finished @@ -955,9 +928,9 @@ pendSaveValidated( XRPL_ASSERT(ledger->isImmutable(), "xrpl::pendSaveValidated : immutable ledger"); - if (!app.pendingSaves().shouldWork(ledger->header().seq, isSynchronous)) + if (!registry.pendingSaves().shouldWork(ledger->header().seq, isSynchronous)) { - auto stream = app.journal("Ledger").debug(); + auto stream = registry.journal("Ledger").debug(); JLOG(stream) << "Pend save with seq in pending saves " << ledger->header().seq; return true; @@ -965,16 +938,16 @@ pendSaveValidated( // See if we can use the JobQueue. if (!isSynchronous && - app.getJobQueue().addJob( + registry.getJobQueue().addJob( isCurrent ? jtPUBLEDGER : jtPUBOLDLEDGER, std::to_string(ledger->seq()), - [&app, ledger, isCurrent]() { saveValidatedLedger(app, ledger, isCurrent); })) + [®istry, ledger, isCurrent]() { saveValidatedLedger(registry, ledger, isCurrent); })) { return true; } // The JobQueue won't do the Job. Do the save synchronously. - return saveValidatedLedger(app, ledger, isCurrent); + return saveValidatedLedger(registry, ledger, isCurrent); } void @@ -995,17 +968,24 @@ Ledger::invariants() const /* * Make ledger using info loaded from database. * - * @param LedgerHeader: Ledger information. - * @param app: Link to the Application. + * @param info: Ledger information. + * @param rules: Rules to use (may be overwritten by setup()). + * @param fees: Fees to use (may be overwritten by setup()). + * @param registry: Service registry for dependency injection. * @param acquire: Acquire the ledger if not found locally. * @return Shared pointer to the ledger. */ std::shared_ptr -loadLedgerHelper(LedgerHeader const& info, Application& app, bool acquire) +loadLedgerHelper( + LedgerHeader const& info, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire) { bool loaded; auto ledger = std::make_shared( - info, loaded, acquire, app.config(), app.getNodeFamily(), app.journal("Ledger")); + info, loaded, acquire, rules, fees, registry.getNodeFamily(), registry.journal("Ledger")); if (!loaded) ledger.reset(); @@ -1014,10 +994,7 @@ loadLedgerHelper(LedgerHeader const& info, Application& app, bool acquire) } static void -finishLoadByIndexOrHash( - std::shared_ptr const& ledger, - Config const& config, - beast::Journal j) +finishLoadByIndexOrHash(std::shared_ptr const& ledger, beast::Journal j) { if (!ledger) return; @@ -1033,35 +1010,45 @@ finishLoadByIndexOrHash( } std::tuple, std::uint32_t, uint256> -getLatestLedger(Application& app) +getLatestLedger(Rules const& rules, Fees const& fees, ServiceRegistry& registry) { - std::optional const info = app.getRelationalDatabase().getNewestLedgerInfo(); + std::optional const info = registry.getRelationalDatabase().getNewestLedgerInfo(); if (!info) return {std::shared_ptr(), {}, {}}; - return {loadLedgerHelper(*info, app, true), info->seq, info->hash}; + return {loadLedgerHelper(*info, rules, fees, registry, true), info->seq, info->hash}; } std::shared_ptr -loadByIndex(std::uint32_t ledgerIndex, Application& app, bool acquire) +loadByIndex( + std::uint32_t ledgerIndex, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire) { if (std::optional info = - app.getRelationalDatabase().getLedgerInfoByIndex(ledgerIndex)) + registry.getRelationalDatabase().getLedgerInfoByIndex(ledgerIndex)) { - std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); - finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); + std::shared_ptr ledger = loadLedgerHelper(*info, rules, fees, registry, acquire); + finishLoadByIndexOrHash(ledger, registry.journal("Ledger")); return ledger; } return {}; } std::shared_ptr -loadByHash(uint256 const& ledgerHash, Application& app, bool acquire) +loadByHash( + uint256 const& ledgerHash, + Rules const& rules, + Fees const& fees, + ServiceRegistry& registry, + bool acquire) { if (std::optional info = - app.getRelationalDatabase().getLedgerInfoByHash(ledgerHash)) + registry.getRelationalDatabase().getLedgerInfoByHash(ledgerHash)) { - std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); - finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); + std::shared_ptr ledger = loadLedgerHelper(*info, rules, fees, registry, acquire); + finishLoadByIndexOrHash(ledger, registry.journal("Ledger")); XRPL_ASSERT( !ledger || ledger->header().hash == ledgerHash, "xrpl::loadByHash : ledger hash match if loaded"); diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/libxrpl/server/Manifest.cpp similarity index 100% rename from src/xrpld/app/misc/detail/Manifest.cpp rename to src/libxrpl/server/Manifest.cpp diff --git a/src/xrpld/app/paths/detail/AMMLiquidity.cpp b/src/libxrpl/tx/paths/AMMLiquidity.cpp similarity index 99% rename from src/xrpld/app/paths/detail/AMMLiquidity.cpp rename to src/libxrpl/tx/paths/AMMLiquidity.cpp index 3ffc86d1ba..8be2c1d8de 100644 --- a/src/xrpld/app/paths/detail/AMMLiquidity.cpp +++ b/src/libxrpl/tx/paths/AMMLiquidity.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/detail/AMMOffer.cpp b/src/libxrpl/tx/paths/AMMOffer.cpp similarity index 98% rename from src/xrpld/app/paths/detail/AMMOffer.cpp rename to src/libxrpl/tx/paths/AMMOffer.cpp index 4871d2251a..2168d80094 100644 --- a/src/xrpld/app/paths/detail/AMMOffer.cpp +++ b/src/libxrpl/tx/paths/AMMOffer.cpp @@ -1,7 +1,6 @@ -#include -#include - #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/libxrpl/tx/paths/BookStep.cpp similarity index 99% rename from src/xrpld/app/paths/detail/BookStep.cpp rename to src/libxrpl/tx/paths/BookStep.cpp index dca38f8df5..5f2bff02f3 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/libxrpl/tx/paths/BookStep.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -10,6 +7,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/libxrpl/tx/paths/DirectStep.cpp similarity index 99% rename from src/xrpld/app/paths/detail/DirectStep.cpp rename to src/libxrpl/tx/paths/DirectStep.cpp index 09ad2fcd67..d74bc69423 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/libxrpl/tx/paths/DirectStep.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/paths/detail/PaySteps.cpp b/src/libxrpl/tx/paths/PaySteps.cpp similarity index 100% rename from src/xrpld/app/paths/detail/PaySteps.cpp rename to src/libxrpl/tx/paths/PaySteps.cpp diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/libxrpl/tx/paths/XRPEndpointStep.cpp similarity index 99% rename from src/xrpld/app/paths/detail/XRPEndpointStep.cpp rename to src/libxrpl/tx/paths/XRPEndpointStep.cpp index ceb166d6ec..0c959f1f2c 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/libxrpl/tx/paths/XRPEndpointStep.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -8,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 14be260822..6bcdb852de 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -5,11 +5,10 @@ #include #include -#include - #include #include #include +#include #include #include #include diff --git a/src/test/app/FeeVote_test.cpp b/src/test/app/FeeVote_test.cpp index 360def1abf..2c3e3b7d2a 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -1,9 +1,9 @@ #include -#include #include #include +#include #include #include #include @@ -249,11 +249,10 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees disabled (legacy format) { jtx::Env env(*this, jtx::testable_amendments() - featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Create the next ledger to apply transaction to ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -278,11 +277,10 @@ class FeeVote_test : public beast::unit_test::suite // Test with XRPFees enabled (new format) { jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Create the next ledger to apply transaction to ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -310,11 +308,10 @@ class FeeVote_test : public beast::unit_test::suite { jtx::Env env(*this, jtx::testable_amendments() - featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Create the next ledger to apply transaction to ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -331,11 +328,10 @@ class FeeVote_test : public beast::unit_test::suite { jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Create the next ledger to apply transaction to ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -357,8 +353,10 @@ class FeeVote_test : public beast::unit_test::suite testcase("Pseudo Transaction Properties"); jtx::Env env(*this, jtx::testable_amendments()); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Create the next ledger to apply transaction to ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -392,8 +390,10 @@ class FeeVote_test : public beast::unit_test::suite testcase("Multiple Fee Updates"); jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -436,8 +436,10 @@ class FeeVote_test : public beast::unit_test::suite testcase("Wrong Ledger Sequence"); jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -463,8 +465,10 @@ class FeeVote_test : public beast::unit_test::suite testcase("Partial Field Updates"); jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -505,8 +509,10 @@ class FeeVote_test : public beast::unit_test::suite testcase("Single Invalid Transaction"); jtx::Env env(*this, jtx::testable_amendments() | featureXRPFees); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); ledger = std::make_shared(*ledger, env.app().timeKeeper().closeTime()); @@ -542,11 +548,10 @@ class FeeVote_test : public beast::unit_test::suite Env env(*this, testable_amendments() | featureXRPFees); auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote")); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto sec = randomSecretKey(); auto pub = derivePublicKey(KeyType::secp256k1, sec); @@ -571,11 +576,10 @@ class FeeVote_test : public beast::unit_test::suite Env env(*this, testable_amendments() - featureXRPFees); auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote")); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto sec = randomSecretKey(); auto pub = derivePublicKey(KeyType::secp256k1, sec); @@ -615,8 +619,10 @@ class FeeVote_test : public beast::unit_test::suite BEAST_EXPECT(env.current()->fees().increment == XRPAmount{50'000'000}); auto feeVote = make_FeeVote(setup, env.app().journal("FeeVote")); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto ledger = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // doVoting requires a flag ledger (every 256th ledger) // We need to create a ledger at sequence 256 to make it a flag ledger diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index 93ab4a6210..d25896ae42 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -36,11 +36,10 @@ public: if (!prev) { assert(!stx); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); return std::make_shared( - create_genesis, - env.app().config(), - std::vector{}, - env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); } auto res = std::make_shared(*prev, prev->header().closeTime + closeOffset); diff --git a/src/test/app/RCLValidations_test.cpp b/src/test/app/RCLValidations_test.cpp index 140ba9f1d7..2aa63af381 100644 --- a/src/test/app/RCLValidations_test.cpp +++ b/src/test/app/RCLValidations_test.cpp @@ -1,10 +1,10 @@ #include #include -#include #include #include +#include namespace xrpl { namespace test { @@ -55,9 +55,10 @@ class RCLValidations_test : public beast::unit_test::suite std::vector> history; jtx::Env env(*this); - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; auto prev = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); history.push_back(prev); for (auto i = 0; i < (2 * maxAncestors + 1); ++i) { @@ -213,9 +214,10 @@ class RCLValidations_test : public beast::unit_test::suite // Generate a chain of 256 + 10 ledgers jtx::Env env(*this); auto& j = env.journal; - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; auto prev = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); history.push_back(prev); for (auto i = 0; i < (maxAncestors + 10); ++i) { diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index e323e61132..4f5884c22d 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -44,8 +44,10 @@ struct Regression_test : public beast::unit_test::suite // The low balance scenario can not deterministically // be reproduced against an open ledger. Make a local // closed ledger and work with it directly. + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto closed = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto expectedDrops = INITIAL_XRP; BEAST_EXPECT(closed->header().drops == expectedDrops); diff --git a/src/test/consensus/LedgerTiming_test.cpp b/src/test/consensus/LedgerTiming_test.cpp index 62902d6a28..b9aa3bdc1e 100644 --- a/src/test/consensus/LedgerTiming_test.cpp +++ b/src/test/consensus/LedgerTiming_test.cpp @@ -1,6 +1,5 @@ -#include - #include +#include namespace xrpl { namespace test { diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index d03ee3950d..70d52c7610 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include +#include #include #include @@ -210,8 +210,10 @@ class NegativeUNL_test : public beast::unit_test::suite jtx::Env env(*this, jtx::testable_amendments()); std::vector publicKeys = createPublicKeys(3); // genesis ledger + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto l = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); // Record the public keys and ledger sequences of expected negative UNL // validators when we build the ledger history @@ -541,9 +543,12 @@ struct NetworkHistory createLedgerHistory() { static uint256 fake_amendment; // So we have different genesis ledgers + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto l = std::make_shared( create_genesis, - env.app().config(), + rules, + fees, std::vector{fake_amendment++}, env.app().getNodeFamily()); history.push_back(l); @@ -1656,8 +1661,10 @@ class NegativeUNLVoteFilterValidations_test : public beast::unit_test::suite { testcase("Filter Validations"); jtx::Env env(*this); + Rules const rules{env.app().config().features}; + Fees const fees = env.app().config().FEES.toFees(); auto l = std::make_shared( - create_genesis, env.app().config(), std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto createSTVal = [&](std::pair const& keys) { return std::make_shared( diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index 9da1c2182a..f33314ad0f 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -2,13 +2,12 @@ #include -#include - #include #include #include #include #include +#include #include diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index 2ac0ca7435..b4f46e8fc8 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -11,17 +11,17 @@ #include #include -#include #include #include -#include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/src/test/jtx/impl/paths.cpp b/src/test/jtx/impl/paths.cpp index e26f214fe4..fe9ff916bd 100644 --- a/src/test/jtx/impl/paths.cpp +++ b/src/test/jtx/impl/paths.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include diff --git a/src/test/jtx/utility.h b/src/test/jtx/utility.h index 895d00f12b..15c323f047 100644 --- a/src/test/jtx/utility.h +++ b/src/test/jtx/utility.h @@ -2,9 +2,8 @@ #include -#include - #include +#include #include #include diff --git a/src/test/ledger/PendingSaves_test.cpp b/src/test/ledger/PendingSaves_test.cpp index ddf371e913..5e08fc53e4 100644 --- a/src/test/ledger/PendingSaves_test.cpp +++ b/src/test/ledger/PendingSaves_test.cpp @@ -1,6 +1,5 @@ -#include - #include +#include namespace xrpl { namespace test { diff --git a/src/test/ledger/SkipList_test.cpp b/src/test/ledger/SkipList_test.cpp index 8430db3904..d05341eeb1 100644 --- a/src/test/ledger/SkipList_test.cpp +++ b/src/test/ledger/SkipList_test.cpp @@ -1,8 +1,7 @@ #include -#include - #include +#include #include namespace xrpl { @@ -16,9 +15,10 @@ class SkipList_test : public beast::unit_test::suite jtx::Env env(*this); std::vector> history; { - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; auto prev = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); history.push_back(prev); for (auto i = 0; i < 1023; ++i) { diff --git a/src/test/ledger/View_test.cpp b/src/test/ledger/View_test.cpp index 80ecdba2d5..1cfaae4322 100644 --- a/src/test/ledger/View_test.cpp +++ b/src/test/ledger/View_test.cpp @@ -1,9 +1,9 @@ #include -#include #include #include +#include #include #include #include @@ -112,9 +112,10 @@ class View_test : public beast::unit_test::suite using namespace jtx; Env env(*this); - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; std::shared_ptr const genesis = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto const ledger = std::make_shared(*genesis, env.app().timeKeeper().closeTime()); wipe(*ledger); ReadView& v = *ledger; @@ -375,9 +376,10 @@ class View_test : public beast::unit_test::suite using namespace jtx; Env env(*this); - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; std::shared_ptr const genesis = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto const ledger = std::make_shared(*genesis, env.app().timeKeeper().closeTime()); auto setup = [&ledger](std::vector const& vec) { @@ -579,9 +581,10 @@ class View_test : public beast::unit_test::suite using namespace jtx; Env env(*this); - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; std::shared_ptr const genesis = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto const ledger = std::make_shared(*genesis, env.app().timeKeeper().closeTime()); auto setup123 = [&ledger, this]() { // erase middle element @@ -925,9 +928,10 @@ class View_test : public beast::unit_test::suite // erase the item, apply. { Env env(*this); - Config config; + Rules const rules{{}}; + Fees const fees{XRPAmount{10}, XRPAmount{10000000}, XRPAmount{2000000}}; std::shared_ptr const genesis = std::make_shared( - create_genesis, config, std::vector{}, env.app().getNodeFamily()); + create_genesis, rules, fees, std::vector{}, env.app().getNodeFamily()); auto const ledger = std::make_shared(*genesis, env.app().timeKeeper().closeTime()); wipe(*ledger); diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index 3c787a4c72..7142ac500e 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 91f24a650c..46eae7265e 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -11,7 +10,6 @@ #include #include #include -#include #include #include @@ -20,6 +18,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/xrpld/app/consensus/RCLCxLedger.h b/src/xrpld/app/consensus/RCLCxLedger.h index 6b96fc8af3..09111ebdb6 100644 --- a/src/xrpld/app/consensus/RCLCxLedger.h +++ b/src/xrpld/app/consensus/RCLCxLedger.h @@ -1,8 +1,8 @@ #pragma once -#include #include +#include #include #include diff --git a/src/xrpld/app/consensus/RCLValidations.h b/src/xrpld/app/consensus/RCLValidations.h index 35c1686f9e..8da82e6425 100644 --- a/src/xrpld/app/consensus/RCLValidations.h +++ b/src/xrpld/app/consensus/RCLValidations.h @@ -1,8 +1,8 @@ #pragma once -#include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/InboundLedger.h b/src/xrpld/app/ledger/InboundLedger.h index ef1362365d..4795ea8f9f 100644 --- a/src/xrpld/app/ledger/InboundLedger.h +++ b/src/xrpld/app/ledger/InboundLedger.h @@ -1,11 +1,11 @@ #pragma once -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index f2e2afb3e6..7fd02bcdab 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -73,7 +74,9 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) } } - std::shared_ptr ret = loadByIndex(index, app_); + Rules const rules{app_.config().features}; + Fees const fees = app_.config().FEES.toFees(); + std::shared_ptr ret = loadByIndex(index, rules, fees, app_); if (!ret) return ret; @@ -111,7 +114,9 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) return ret; } - ret = loadByHash(hash, app_); + Rules const rules{app_.config().features}; + Fees const fees = app_.config().FEES.toFees(); + ret = loadByHash(hash, rules, fees, app_); if (!ret) return ret; diff --git a/src/xrpld/app/ledger/LedgerHistory.h b/src/xrpld/app/ledger/LedgerHistory.h index 6ec279b28a..b988d152ad 100644 --- a/src/xrpld/app/ledger/LedgerHistory.h +++ b/src/xrpld/app/ledger/LedgerHistory.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/LedgerMaster.h b/src/xrpld/app/ledger/LedgerMaster.h index ab71302b73..16e35c3dcd 100644 --- a/src/xrpld/app/ledger/LedgerMaster.h +++ b/src/xrpld/app/ledger/LedgerMaster.h @@ -2,17 +2,18 @@ #include #include -#include #include #include #include #include +#include #include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/LedgerToJson.h b/src/xrpld/app/ledger/LedgerToJson.h index 9def1c3826..3686311656 100644 --- a/src/xrpld/app/ledger/LedgerToJson.h +++ b/src/xrpld/app/ledger/LedgerToJson.h @@ -1,11 +1,11 @@ #pragma once -#include #include #include #include #include +#include #include namespace xrpl { diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index 2bbb7b5b8d..5b1d611b44 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 1575bbc960..249c0489c5 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -1,10 +1,10 @@ #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index b8158e507f..a05b996d78 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -218,8 +218,9 @@ InboundLedger::tryDB(NodeStore::Database& srcDB) { auto makeLedger = [&, this](Blob const& data) { JLOG(journal_.trace()) << "Ledger header found in fetch pack"; + Rules const rules{app_.config().features}; mLedger = std::make_shared( - deserializePrefixedHeader(makeSlice(data)), app_.config(), app_.getNodeFamily()); + deserializePrefixedHeader(makeSlice(data)), rules, app_.getNodeFamily()); if (mLedger->header().hash != hash_ || (mSeq != 0 && mSeq != mLedger->header().seq)) { // We know for a fact the ledger can never be acquired @@ -763,7 +764,8 @@ InboundLedger::takeHeader(std::string const& data) return true; auto* f = &app_.getNodeFamily(); - mLedger = std::make_shared(deserializeHeader(makeSlice(data)), app_.config(), *f); + Rules const rules{app_.config().features}; + mLedger = std::make_shared(deserializeHeader(makeSlice(data)), rules, *f); if (mLedger->header().hash != hash_ || (mSeq != 0 && mSeq != mLedger->header().seq)) { JLOG(journal_.warn()) << "Acquire hash mismatch: " << mLedger->header().hash diff --git a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp index ad9c6a277d..3f1121ce13 100644 --- a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -259,7 +260,9 @@ private: return false; } - auto dbLedger = loadByIndex(ledgerIndex, app_); + Rules const rules{app_.config().features}; + Fees const fees = app_.config().FEES.toFees(); + auto dbLedger = loadByIndex(ledgerIndex, rules, fees, app_); if (!dbLedger || (dbLedger->header().hash != ledgerHash) || (dbLedger->header().parentHash != nodeLedger->header().parentHash)) { diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index e22351fc77..c218c2a2f8 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -124,7 +124,8 @@ LedgerDeltaAcquire::processData( if (info.seq == ledgerSeq_) { // create a temporary ledger for building a LedgerReplay object later - replayTemp_ = std::make_shared(info, app_.config(), app_.getNodeFamily()); + Rules const rules{app_.config().features}; + replayTemp_ = std::make_shared(info, rules, app_.getNodeFamily()); if (replayTemp_) { complete_ = true; diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h index 2877d997e6..9ac58c2e7c 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h @@ -1,11 +1,11 @@ #pragma once #include -#include #include #include #include +#include #include diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 64bdf04df1..84b097482a 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -1,18 +1,16 @@ #include -#include #include #include #include -#include #include #include #include #include #include -#include #include #include #include +#include #include #include @@ -22,7 +20,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -1372,7 +1372,7 @@ LedgerMaster::updatePaths() try { - auto& pathRequests = app_.getPathRequests(); + auto& pathRequests = app_.getPathRequestManager(); { std::lock_guard ml(m_mutex); if (!pathRequests.requestsPending()) @@ -1454,7 +1454,7 @@ LedgerMaster::newOrderBookDB() bool LedgerMaster::newPFWork(char const* name, std::unique_lock&) { - if (!app_.isStopping() && mPathFindThread < 2 && app_.getPathRequests().requestsPending()) + if (!app_.isStopping() && mPathFindThread < 2 && app_.getPathRequestManager().requestsPending()) { JLOG(m_journal.debug()) << "newPFWork: Creating job. path find threads: " << mPathFindThread; diff --git a/src/xrpld/app/ledger/detail/LedgerReplay.cpp b/src/xrpld/app/ledger/detail/LedgerReplay.cpp index d115402115..a02267e4a1 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplay.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplay.cpp @@ -1,6 +1,7 @@ -#include #include +#include + namespace xrpl { LedgerReplay::LedgerReplay( diff --git a/src/xrpld/app/ledger/detail/LocalTxs.cpp b/src/xrpld/app/ledger/detail/LocalTxs.cpp index 48bd80fbf2..6131db317c 100644 --- a/src/xrpld/app/ledger/detail/LocalTxs.cpp +++ b/src/xrpld/app/ledger/detail/LocalTxs.cpp @@ -1,6 +1,6 @@ -#include #include +#include #include /* diff --git a/src/xrpld/app/ledger/detail/SkipListAcquire.h b/src/xrpld/app/ledger/detail/SkipListAcquire.h index 5a79e8ae5c..da62578d41 100644 --- a/src/xrpld/app/ledger/detail/SkipListAcquire.h +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.h @@ -1,10 +1,10 @@ #pragma once #include -#include #include #include +#include #include namespace xrpl { diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 3e3d87dcd5..e8abdfd765 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -21,13 +20,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -170,7 +170,7 @@ public: std::unique_ptr m_nodeStore; NodeFamily nodeFamily_; std::unique_ptr m_orderBookDB; - std::unique_ptr m_pathRequests; + std::unique_ptr m_pathRequestManager; std::unique_ptr m_ledgerMaster; std::unique_ptr ledgerCleaner_; std::unique_ptr m_inboundLedgers; @@ -324,8 +324,8 @@ public: , m_orderBookDB(make_OrderBookDB(*this, {config_->PATH_SEARCH_MAX, config_->standalone()})) - , m_pathRequests( - std::make_unique( + , m_pathRequestManager( + std::make_unique( *this, logs_->journal("PathRequest"), m_collectorManager->collector())) @@ -654,10 +654,10 @@ public: return *m_orderBookDB; } - PathRequests& - getPathRequests() override + PathRequestManager& + getPathRequestManager() override { - return *m_pathRequests; + return *m_pathRequestManager; } CachedSLEs& @@ -1630,8 +1630,12 @@ ApplicationImp::startGenesisLedger() ? m_amendmentTable->getDesired() : std::vector{}; - std::shared_ptr const genesis = - std::make_shared(create_genesis, *config_, initialAmendments, nodeFamily_); + std::shared_ptr const genesis = std::make_shared( + create_genesis, + Rules{config_->features}, + config_->FEES.toFees(), + initialAmendments, + nodeFamily_); m_ledgerMaster->storeLedger(genesis); auto const next = std::make_shared(*genesis, timeKeeper().closeTime()); @@ -1652,7 +1656,8 @@ ApplicationImp::getLastFullLedger() try { - auto const [ledger, seq, hash] = getLatestLedger(*this); + auto const [ledger, seq, hash] = + getLatestLedger(Rules{config_->features}, config_->FEES.toFees(), *this); if (!ledger) return ledger; @@ -1763,7 +1768,8 @@ ApplicationImp::loadLedgerFromFile(std::string const& name) return nullptr; } - auto loadLedger = std::make_shared(seq, closeTime, *config_, nodeFamily_); + auto loadLedger = std::make_shared( + seq, closeTime, Rules{config_->features}, config_->FEES.toFees(), nodeFamily_); loadLedger->setTotalDrops(totalDrops); for (Json::UInt index = 0; index < ledger.get().size(); ++index) @@ -1843,7 +1849,8 @@ ApplicationImp::loadOldLedger( if (hash.parseHex(ledgerID)) { - loadLedger = loadByHash(hash, *this); + loadLedger = + loadByHash(hash, Rules{config_->features}, config_->FEES.toFees(), *this); if (!loadLedger) { @@ -1870,7 +1877,8 @@ ApplicationImp::loadOldLedger( std::uint32_t index; if (beast::lexicalCastChecked(index, ledgerID)) - loadLedger = loadByIndex(index, *this); + loadLedger = + loadByIndex(index, Rules{config_->features}, config_->FEES.toFees(), *this); } if (!loadLedger) @@ -1885,7 +1893,11 @@ ApplicationImp::loadOldLedger( JLOG(m_journal.info()) << "Loading parent ledger"; - loadLedger = loadByHash(replayLedger->header().parentHash, *this); + loadLedger = loadByHash( + replayLedger->header().parentHash, + Rules{config_->features}, + config_->FEES.toFees(), + *this); if (!loadLedger) { JLOG(m_journal.info()) << "Loading parent ledger from node store"; @@ -1954,10 +1966,13 @@ ApplicationImp::loadOldLedger( // LCOV_EXCL_STOP } - if (!loadLedger->assertSensible(journal("Ledger"))) + if (!loadLedger->isSensible()) { // LCOV_EXCL_START - JLOG(m_journal.fatal()) << "Ledger is not sensible."; + Json::Value j = getJson({*loadLedger, {}}); + j[jss::accountTreeHash] = to_string(loadLedger->header().accountHash); + j[jss::transTreeHash] = to_string(loadLedger->header().txHash); + JLOG(m_journal.fatal()) << "Ledger is not sensible: " << j; UNREACHABLE( "xrpl::ApplicationImp::loadOldLedger : ledger is not " "sensible"); diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 0000ae010b..9c79aabb02 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -66,7 +66,7 @@ class NetworkOPs; class OpenLedger; class OrderBookDB; class Overlay; -class PathRequests; +class PathRequestManager; class PendingSaves; class PublicKey; class ServerHandler; diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index 5cb203115a..930fea25f7 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -1,7 +1,7 @@ -#include #include #include +#include #include #include @@ -264,7 +264,7 @@ FeeVoteImpl::doVoting( baseReserve.first.dropsAs(baseReserveVote.current()); obj[sfReserveIncrement] = incReserve.first.dropsAs(incReserveVote.current()); - obj[sfReferenceFeeUnits] = Config::FEE_UNITS_DEPRECATED; + obj[sfReferenceFeeUnits] = FEE_UNITS_DEPRECATED; } }); diff --git a/src/xrpld/app/misc/NegativeUNLVote.cpp b/src/xrpld/app/misc/NegativeUNLVote.cpp index 6673785b61..22970bfa14 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.cpp +++ b/src/xrpld/app/misc/NegativeUNLVote.cpp @@ -1,7 +1,7 @@ #include -#include #include +#include #include namespace xrpl { diff --git a/src/xrpld/app/misc/NegativeUNLVote.h b/src/xrpld/app/misc/NegativeUNLVote.h index 95646af034..e6f76a7db6 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.h +++ b/src/xrpld/app/misc/NegativeUNLVote.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include #include #include #include diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index b8663a76fb..a627274bf6 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -2935,7 +2935,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID(); if (!lpAccepted->rules().enabled(featureXRPFees)) - jvObj[jss::fee_ref] = Config::FEE_UNITS_DEPRECATED; + jvObj[jss::fee_ref] = FEE_UNITS_DEPRECATED; jvObj[jss::fee_base] = lpAccepted->fees().base.jsonClipped(); jvObj[jss::reserve_base] = lpAccepted->fees().reserve.jsonClipped(); jvObj[jss::reserve_inc] = lpAccepted->fees().increment.jsonClipped(); @@ -3942,7 +3942,7 @@ NetworkOPsImp::subLedger(InfoSub::ref isrListener, Json::Value& jvResult) jvResult[jss::ledger_time] = Json::Value::UInt(lpClosed->header().closeTime.time_since_epoch().count()); if (!lpClosed->rules().enabled(featureXRPFees)) - jvResult[jss::fee_ref] = Config::FEE_UNITS_DEPRECATED; + jvResult[jss::fee_ref] = FEE_UNITS_DEPRECATED; jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped(); jvResult[jss::reserve_base] = lpClosed->fees().reserve.jsonClipped(); jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped(); diff --git a/src/xrpld/app/misc/SHAMapStore.h b/src/xrpld/app/misc/SHAMapStore.h index 67477593cb..b377538f62 100644 --- a/src/xrpld/app/misc/SHAMapStore.h +++ b/src/xrpld/app/misc/SHAMapStore.h @@ -1,7 +1,6 @@ #pragma once -#include - +#include #include #include diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 9425cd9159..ecb7d73bde 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/rdb/backend/detail/Node.h b/src/xrpld/app/rdb/backend/detail/Node.h index cb49a373bd..14eff07b94 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.h +++ b/src/xrpld/app/rdb/backend/detail/Node.h @@ -1,8 +1,8 @@ #pragma once -#include #include +#include #include namespace xrpl { diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 3c1e4e7dbf..2ed40cd2eb 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -4,12 +4,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/core/Config.h b/src/xrpld/core/Config.h index c40d13c83a..44509d2145 100644 --- a/src/xrpld/core/Config.h +++ b/src/xrpld/core/Config.h @@ -5,6 +5,7 @@ #include #include #include +#include #include // VFALCO Breaks levelization #include @@ -57,6 +58,13 @@ struct FeeSetup /* (Remember to update the example cfg files when changing any of these * values.) */ + + /** Convert to a Fees object for use with Ledger construction. */ + Fees + toFees() const + { + return Fees{reference_fee, account_reserve, owner_reserve}; + } }; // This entire derived class is deprecated. @@ -137,10 +145,6 @@ public: // Network parameters uint32_t NETWORK_ID = 0; - // DEPRECATED - Fee units for a reference transaction. - // Only provided for backwards compatibility in a couple of places - static constexpr std::uint32_t FEE_UNITS_DEPRECATED = 10; - // Note: The following parameters do not relate to the UNL or trust at all // Minimum number of nodes to consider the network present std::size_t NETWORK_QUORUM = 1; diff --git a/src/xrpld/app/paths/AccountCurrencies.cpp b/src/xrpld/rpc/detail/AccountCurrencies.cpp similarity index 97% rename from src/xrpld/app/paths/AccountCurrencies.cpp rename to src/xrpld/rpc/detail/AccountCurrencies.cpp index 92ba61e00e..c839b1475c 100644 --- a/src/xrpld/app/paths/AccountCurrencies.cpp +++ b/src/xrpld/rpc/detail/AccountCurrencies.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/AccountCurrencies.h b/src/xrpld/rpc/detail/AccountCurrencies.h similarity index 89% rename from src/xrpld/app/paths/AccountCurrencies.h rename to src/xrpld/rpc/detail/AccountCurrencies.h index d8459de7f2..76c531cb9b 100644 --- a/src/xrpld/app/paths/AccountCurrencies.h +++ b/src/xrpld/rpc/detail/AccountCurrencies.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/rpc/detail/PathRequest.cpp similarity index 98% rename from src/xrpld/app/paths/PathRequest.cpp rename to src/xrpld/rpc/detail/PathRequest.cpp index c6d0f59ff0..3ec83ce3ce 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/rpc/detail/PathRequest.cpp @@ -1,9 +1,9 @@ #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include @@ -24,7 +24,7 @@ PathRequest::PathRequest( Application& app, std::shared_ptr const& subscriber, int id, - PathRequests& owner, + PathRequestManager& owner, beast::Journal journal) : app_(app) , m_journal(journal) @@ -47,7 +47,7 @@ PathRequest::PathRequest( std::function const& completion, Resource::Consumer& consumer, int id, - PathRequests& owner, + PathRequestManager& owner, beast::Journal journal) : app_(app) , m_journal(journal) diff --git a/src/xrpld/app/paths/PathRequest.h b/src/xrpld/rpc/detail/PathRequest.h similarity index 94% rename from src/xrpld/app/paths/PathRequest.h rename to src/xrpld/rpc/detail/PathRequest.h index fde499a312..21fbaf0443 100644 --- a/src/xrpld/app/paths/PathRequest.h +++ b/src/xrpld/rpc/detail/PathRequest.h @@ -1,11 +1,11 @@ #pragma once -#include -#include -#include +#include +#include #include #include +#include #include #include @@ -20,7 +20,7 @@ namespace xrpl { // The request issuer must maintain a strong pointer class RippleLineCache; -class PathRequests; +class PathRequestManager; // Return values from parseJson <0 = invalid, >0 = valid #define PFR_PJ_INVALID -1 @@ -43,7 +43,7 @@ public: Application& app, std::shared_ptr const& subscriber, int id, - PathRequests&, + PathRequestManager&, beast::Journal journal); // ripple_path_find semantics @@ -53,7 +53,7 @@ public: std::function const& completion, Resource::Consumer& consumer, int id, - PathRequests&, + PathRequestManager&, beast::Journal journal); ~PathRequest(); @@ -119,7 +119,7 @@ private: std::recursive_mutex mLock; - PathRequests& mOwner; + PathRequestManager& mOwner; std::weak_ptr wpSubscriber; // Who this request came from std::function fCompletion; diff --git a/src/xrpld/app/paths/PathRequests.cpp b/src/xrpld/rpc/detail/PathRequestManager.cpp similarity index 95% rename from src/xrpld/app/paths/PathRequests.cpp rename to src/xrpld/rpc/detail/PathRequestManager.cpp index 35a6c7aa48..7f8c8a7eb1 100644 --- a/src/xrpld/app/paths/PathRequests.cpp +++ b/src/xrpld/rpc/detail/PathRequestManager.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -16,7 +16,7 @@ namespace xrpl { Get the correct ledger to use. */ std::shared_ptr -PathRequests::getLineCache(std::shared_ptr const& ledger, bool authoritative) +PathRequestManager::getLineCache(std::shared_ptr const& ledger, bool authoritative) { std::lock_guard sl(mLock); @@ -43,7 +43,7 @@ PathRequests::getLineCache(std::shared_ptr const& ledger, bool a } void -PathRequests::updateAll(std::shared_ptr const& inLedger) +PathRequestManager::updateAll(std::shared_ptr const& inLedger) { auto event = app_.getJobQueue().makeLoadEvent(jtPATH_FIND, "PathRequest::updateAll"); @@ -189,14 +189,14 @@ PathRequests::updateAll(std::shared_ptr const& inLedger) } bool -PathRequests::requestsPending() const +PathRequestManager::requestsPending() const { std::lock_guard sl(mLock); return !requests_.empty(); } void -PathRequests::insertPathRequest(PathRequest::pointer const& req) +PathRequestManager::insertPathRequest(PathRequest::pointer const& req) { std::lock_guard sl(mLock); @@ -214,7 +214,7 @@ PathRequests::insertPathRequest(PathRequest::pointer const& req) // Make a new-style path_find request Json::Value -PathRequests::makePathRequest( +PathRequestManager::makePathRequest( std::shared_ptr const& subscriber, std::shared_ptr const& inLedger, Json::Value const& requestJson) @@ -234,7 +234,7 @@ PathRequests::makePathRequest( // Make an old-style ripple_path_find request Json::Value -PathRequests::makeLegacyPathRequest( +PathRequestManager::makeLegacyPathRequest( PathRequest::pointer& req, std::function completion, Resource::Consumer& consumer, @@ -267,7 +267,7 @@ PathRequests::makeLegacyPathRequest( } Json::Value -PathRequests::doLegacyPathRequest( +PathRequestManager::doLegacyPathRequest( Resource::Consumer& consumer, std::shared_ptr const& inLedger, Json::Value const& request) diff --git a/src/xrpld/app/paths/PathRequests.h b/src/xrpld/rpc/detail/PathRequestManager.h similarity index 94% rename from src/xrpld/app/paths/PathRequests.h rename to src/xrpld/rpc/detail/PathRequestManager.h index 98f4be9fd7..0f884de5f3 100644 --- a/src/xrpld/app/paths/PathRequests.h +++ b/src/xrpld/rpc/detail/PathRequestManager.h @@ -1,8 +1,8 @@ #pragma once #include -#include -#include +#include +#include #include #include @@ -10,11 +10,11 @@ namespace xrpl { -class PathRequests +class PathRequestManager { public: /** A collection of all PathRequest instances. */ - PathRequests( + PathRequestManager( Application& app, beast::Journal journal, beast::insight::Collector::ptr const& collector) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/rpc/detail/Pathfinder.cpp similarity index 99% rename from src/xrpld/app/paths/Pathfinder.cpp rename to src/xrpld/rpc/detail/Pathfinder.cpp index 254db35ea5..7f52c61aa1 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/rpc/detail/Pathfinder.cpp @@ -1,7 +1,7 @@ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/xrpld/app/paths/Pathfinder.h b/src/xrpld/rpc/detail/Pathfinder.h similarity index 98% rename from src/xrpld/app/paths/Pathfinder.h rename to src/xrpld/rpc/detail/Pathfinder.h index 03f2d6f038..5eaafd3370 100644 --- a/src/xrpld/app/paths/Pathfinder.h +++ b/src/xrpld/rpc/detail/Pathfinder.h @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include #include #include +#include #include #include diff --git a/src/xrpld/app/paths/detail/PathfinderUtils.h b/src/xrpld/rpc/detail/PathfinderUtils.h similarity index 100% rename from src/xrpld/app/paths/detail/PathfinderUtils.h rename to src/xrpld/rpc/detail/PathfinderUtils.h diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 385bc7f4af..d1e121d22d 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -1,8 +1,8 @@ #include -#include #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.h b/src/xrpld/rpc/detail/RPCLedgerHelpers.h index c60b7bc6b2..6a04ab41d6 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.h +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.h @@ -1,11 +1,11 @@ #pragma once -#include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/paths/RippleLineCache.cpp b/src/xrpld/rpc/detail/RippleLineCache.cpp similarity index 98% rename from src/xrpld/app/paths/RippleLineCache.cpp rename to src/xrpld/rpc/detail/RippleLineCache.cpp index 9916facdc2..71ca9c3cff 100644 --- a/src/xrpld/app/paths/RippleLineCache.cpp +++ b/src/xrpld/rpc/detail/RippleLineCache.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/RippleLineCache.h b/src/xrpld/rpc/detail/RippleLineCache.h similarity index 97% rename from src/xrpld/app/paths/RippleLineCache.h rename to src/xrpld/rpc/detail/RippleLineCache.h index c4ddad6c81..65607f2d25 100644 --- a/src/xrpld/app/paths/RippleLineCache.h +++ b/src/xrpld/rpc/detail/RippleLineCache.h @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include #include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 8afe3612fe..d008fe5892 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/src/xrpld/app/paths/TrustLine.cpp b/src/xrpld/rpc/detail/TrustLine.cpp similarity index 98% rename from src/xrpld/app/paths/TrustLine.cpp rename to src/xrpld/rpc/detail/TrustLine.cpp index 6c54aa52d7..b652e38b0d 100644 --- a/src/xrpld/app/paths/TrustLine.cpp +++ b/src/xrpld/rpc/detail/TrustLine.cpp @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/src/xrpld/app/paths/TrustLine.h b/src/xrpld/rpc/detail/TrustLine.h similarity index 100% rename from src/xrpld/app/paths/TrustLine.h rename to src/xrpld/rpc/detail/TrustLine.h diff --git a/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp b/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp index 2ec1e20875..fe74c915f5 100644 --- a/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp +++ b/src/xrpld/rpc/handlers/AccountCurrenciesHandler.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include #include #include diff --git a/src/xrpld/rpc/handlers/AccountLines.cpp b/src/xrpld/rpc/handlers/AccountLines.cpp index bb61e6f6c0..7888125695 100644 --- a/src/xrpld/rpc/handlers/AccountLines.cpp +++ b/src/xrpld/rpc/handlers/AccountLines.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/handlers/GatewayBalances.cpp b/src/xrpld/rpc/handlers/GatewayBalances.cpp index a2176ab388..b46add7d63 100644 --- a/src/xrpld/rpc/handlers/GatewayBalances.cpp +++ b/src/xrpld/rpc/handlers/GatewayBalances.cpp @@ -1,7 +1,7 @@ #include -#include #include #include +#include #include #include diff --git a/src/xrpld/rpc/handlers/NoRippleCheck.cpp b/src/xrpld/rpc/handlers/NoRippleCheck.cpp index e17a437efc..64580d9202 100644 --- a/src/xrpld/rpc/handlers/NoRippleCheck.cpp +++ b/src/xrpld/rpc/handlers/NoRippleCheck.cpp @@ -1,8 +1,8 @@ #include -#include #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/handlers/PathFind.cpp b/src/xrpld/rpc/handlers/PathFind.cpp index 357cd9b91e..1b180167ea 100644 --- a/src/xrpld/rpc/handlers/PathFind.cpp +++ b/src/xrpld/rpc/handlers/PathFind.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include @@ -34,7 +34,7 @@ doPathFind(RPC::JsonContext& context) { context.loadType = Resource::feeHeavyBurdenRPC; context.infoSub->clearRequest(); - return context.app.getPathRequests().makePathRequest( + return context.app.getPathRequestManager().makePathRequest( context.infoSub, lpLedger, context.params); } diff --git a/src/xrpld/rpc/handlers/RipplePathFind.cpp b/src/xrpld/rpc/handlers/RipplePathFind.cpp index 5f73165287..cc695908fb 100644 --- a/src/xrpld/rpc/handlers/RipplePathFind.cpp +++ b/src/xrpld/rpc/handlers/RipplePathFind.cpp @@ -1,7 +1,7 @@ #include -#include #include #include +#include #include #include @@ -105,7 +105,7 @@ doRipplePathFind(RPC::JsonContext& context) // JobQueue before letting the thread continue. // // May 2017 - jvResult = context.app.getPathRequests().makeLegacyPathRequest( + jvResult = context.app.getPathRequestManager().makeLegacyPathRequest( request, [&context]() { // Copying the shared_ptr keeps the coroutine alive up @@ -144,7 +144,7 @@ doRipplePathFind(RPC::JsonContext& context) if (!lpf.isOk()) return rpcError(rpcTOO_BUSY); - auto result = context.app.getPathRequests().doLegacyPathRequest( + auto result = context.app.getPathRequestManager().doLegacyPathRequest( context.consumer, lpLedger, context.params); for (auto& fieldName : jvResult.getMemberNames())