Files
rippled/include/xrpl/core/ServiceRegistry.h
Peng Wang 5ae09518b8 Merge branch 'ripple/se/fees' into ripple/smart-escrow
Conflict resolution:

- sfields.macro: both sides claimed INT32 code 2. sfRemainingOwnerCountDelta
  is already in develop, so it keeps code 2 and sfVMReturnCode moves to 3.
  This changes the Smart Escrow serialization, which is safe while the
  amendment is unactivated, but is a deliberate renumber rather than a
  mechanical merge.
- EscrowFinish.cpp: took the SeqProxy form of the keylet::escrow call and
  kept this branch's comment.

Follow-on fixes the merge required:

- Adapted two keylet::escrow calls in EscrowSmart_test.cpp to SeqProxy; they
  are only on this branch, so the earlier pass over the wasm code did not
  cover them.
- Updated two gas expectations that the trace host function refactor and the
  regenerated fixtures invalidated: the codecov allowance in Wasm_test.cpp is
  now 264'467 and sfGasUsed in EscrowSmart_test.cpp is now 48'433. Both are
  measured, not estimated.
- Disabled testKeyletHostFunctions. kAllKeyletsWasmHex was built against the
  old trace ABI and is rejected with temINVALID_BYTECODE. Regenerating it
  needs the all_keylets source ported to the current stdlib first, along with
  float_tests and float_0, which are stale for the same reason. See the TODO
  on the test.
2026-08-09 18:17:53 -04:00

260 lines
5.3 KiB
C++

#pragma once
#include <xrpl/basics/Blob.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/SHAMapHash.h>
#include <xrpl/basics/TaggedCache.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/protocol/Fees.h>
#include <boost/asio.hpp>
#include <optional>
#include <string>
namespace xrpl {
// Forward declarations
namespace node_store {
class Database;
} // namespace node_store
namespace resource {
class Manager;
} // namespace resource
namespace perf {
class PerfLog;
} // namespace perf
// This is temporary until we migrate all code to use ServiceRegistry.
class Application;
template <
class Key,
class T,
bool IsKeyCache,
class SharedWeakUnionPointer,
class SharedPointerType,
class Hash,
class KeyEqual,
class Mutex>
class TaggedCache;
class STLedgerEntry;
using SLE = STLedgerEntry;
using CachedSLEs = TaggedCache<uint256, SLE const>;
// Forward declarations
class AcceptedLedger;
class AmendmentTable;
class Cluster;
class CollectorManager;
class DatabaseCon;
class Family;
class HashRouter;
class InboundLedgers;
class InboundTransactions;
class JobQueue;
class LedgerCleaner;
class LedgerMaster;
class LedgerReplayer;
class LoadFeeTrack;
class LoadManager;
class ManifestCache;
class NetworkOPs;
class NetworkIDService;
class OpenLedger;
class OrderBookDB;
class Overlay;
class PathRequestManager;
class PeerReservationTable;
class PendingSaves;
class RelationalDatabase;
class ServerHandler;
class SHAMapStore;
class TimeKeeper;
class TransactionMaster;
class TxQ;
class ValidatorList;
class ValidatorSite;
template <class Adaptor>
class Validations;
class RCLValidationsAdaptor;
using RCLValidations = Validations<RCLValidationsAdaptor>;
using NodeCache = TaggedCache<SHAMapHash, Blob>;
/**
* Service registry for dependency injection.
*
* This abstract interface provides access to various services and components
* used throughout the application. It separates the service locator pattern
* from the Application lifecycle management.
*
* Components that need access to services can hold a reference to
* ServiceRegistry rather than Application when they only need service
* access and not lifecycle management.
*/
class ServiceRegistry
{
public:
ServiceRegistry() = default;
virtual ~ServiceRegistry() = default;
// Core infrastructure services
virtual CollectorManager&
getCollectorManager() = 0;
virtual Family&
getNodeFamily() = 0;
virtual TimeKeeper&
getTimeKeeper() = 0;
virtual JobQueue&
getJobQueue() = 0;
virtual NodeCache&
getTempNodeCache() = 0;
virtual CachedSLEs&
getCachedSLEs() = 0;
virtual NetworkIDService&
getNetworkIDService() = 0;
// Protocol and validation services
virtual AmendmentTable&
getAmendmentTable() = 0;
virtual HashRouter&
getHashRouter() = 0;
virtual LoadFeeTrack&
getFeeTrack() = 0;
virtual LoadManager&
getLoadManager() = 0;
virtual RCLValidations&
getValidations() = 0;
virtual ValidatorList&
getValidators() = 0;
virtual ValidatorSite&
getValidatorSites() = 0;
virtual ManifestCache&
getValidatorManifests() = 0;
virtual ManifestCache&
getPublisherManifests() = 0;
// Network services
virtual Overlay&
getOverlay() = 0;
virtual Cluster&
getCluster() = 0;
virtual PeerReservationTable&
getPeerReservations() = 0;
virtual resource::Manager&
getResourceManager() = 0;
// Storage services
virtual node_store::Database&
getNodeStore() = 0;
virtual SHAMapStore&
getSHAMapStore() = 0;
virtual RelationalDatabase&
getRelationalDatabase() = 0;
// Ledger services
virtual InboundLedgers&
getInboundLedgers() = 0;
virtual InboundTransactions&
getInboundTransactions() = 0;
virtual TaggedCache<uint256, AcceptedLedger>&
getAcceptedLedgerCache() = 0;
virtual LedgerMaster&
getLedgerMaster() = 0;
virtual LedgerCleaner&
getLedgerCleaner() = 0;
virtual LedgerReplayer&
getLedgerReplayer() = 0;
virtual PendingSaves&
getPendingSaves() = 0;
virtual OpenLedger&
getOpenLedger() = 0;
[[nodiscard]] virtual OpenLedger const&
getOpenLedger() const = 0;
// Transaction and operation services
virtual NetworkOPs&
getOPs() = 0;
virtual OrderBookDB&
getOrderBookDB() = 0;
virtual TransactionMaster&
getMasterTransaction() = 0;
virtual TxQ&
getTxQ() = 0;
virtual PathRequestManager&
getPathRequestManager() = 0;
// Server services
virtual ServerHandler&
getServerHandler() = 0;
virtual perf::PerfLog&
getPerfLog() = 0;
// Configuration and state
[[nodiscard]] virtual bool
isStopping() const = 0;
virtual beast::Journal
getJournal(std::string const& name) = 0;
virtual boost::asio::io_context&
getIOContext() = 0;
virtual Logs&
getLogs() = 0;
[[nodiscard]] virtual std::optional<uint256> const&
getTrapTxID() const = 0;
/**
* Retrieve the "wallet database"
*/
virtual DatabaseCon&
getWalletDB() = 0;
[[nodiscard]] virtual Fees
getFees() const = 0;
// Temporary: Get the underlying Application for functions that haven't
// been migrated yet. This should be removed once all code is migrated.
virtual Application&
getApp() = 0;
};
} // namespace xrpl