diff --git a/.clang-tidy b/.clang-tidy index 41df5470ff..02e90d9148 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -85,6 +85,8 @@ CheckOptions: readability-braces-around-statements.ShortStatementLines: 2 readability-identifier-naming.MacroDefinitionCase: UPPER_CASE + readability-identifier-naming.NamespaceCase: lower_case + readability-identifier-naming.InlineNamespaceCase: lower_case readability-identifier-naming.ClassCase: CamelCase readability-identifier-naming.StructCase: CamelCase readability-identifier-naming.UnionCase: CamelCase diff --git a/include/xrpl/basics/Resolver.h b/include/xrpl/basics/Resolver.h index 239eb9630e..a159619517 100644 --- a/include/xrpl/basics/Resolver.h +++ b/include/xrpl/basics/Resolver.h @@ -11,7 +11,7 @@ namespace xrpl { class Resolver { public: - using HandlerType = std::function)>; + using HandlerType = std::function)>; virtual ~Resolver() = 0; diff --git a/include/xrpl/beast/insight/StatsDCollector.h b/include/xrpl/beast/insight/StatsDCollector.h index e14d3a27ff..0b44f345ba 100644 --- a/include/xrpl/beast/insight/StatsDCollector.h +++ b/include/xrpl/beast/insight/StatsDCollector.h @@ -26,7 +26,7 @@ public: * @param journal Destination for logging output. */ static std::shared_ptr - make(IP::Endpoint const& address, std::string const& prefix, Journal journal); + make(ip::Endpoint const& address, std::string const& prefix, Journal journal); }; } // namespace beast::insight diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 4f4fb189a6..7422778ea2 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -15,7 +15,7 @@ //------------------------------------------------------------------------------ namespace beast { -namespace IP { +namespace ip { using Address = boost::asio::ip::address; @@ -73,13 +73,13 @@ isPublic(Address const& addr) return (addr.is_v4()) ? isPublic(addr.to_v4()) : isPublic(addr.to_v6()); } -} // namespace IP +} // namespace ip //------------------------------------------------------------------------------ template void -hash_append(Hasher& h, beast::IP::Address const& addr) noexcept +hash_append(Hasher& h, beast::ip::Address const& addr) noexcept { using beast::hash_append; if (addr.is_v4()) @@ -101,12 +101,12 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept namespace boost { template <> -struct hash<::beast::IP::Address> +struct hash<::beast::ip::Address> { explicit hash() = default; std::size_t - operator()(::beast::IP::Address const& addr) const + operator()(::beast::ip::Address const& addr) const { return ::beast::Uhash<>{}(addr); } diff --git a/include/xrpl/beast/net/IPAddressConversion.h b/include/xrpl/beast/net/IPAddressConversion.h index 73777cf841..e2d485642f 100644 --- a/include/xrpl/beast/net/IPAddressConversion.h +++ b/include/xrpl/beast/net/IPAddressConversion.h @@ -4,7 +4,7 @@ #include -namespace beast::IP { +namespace beast::ip { /** * Convert to Endpoint. @@ -32,7 +32,7 @@ toAsioAddress(Endpoint const& endpoint); boost::asio::ip::tcp::endpoint toAsioEndpoint(Endpoint const& endpoint); -} // namespace beast::IP +} // namespace beast::ip namespace beast { @@ -41,25 +41,25 @@ struct IPAddressConversion { explicit IPAddressConversion() = default; - static IP::Endpoint + static ip::Endpoint fromAsio(boost::asio::ip::address const& address) { - return IP::fromAsio(address); + return ip::fromAsio(address); } - static IP::Endpoint + static ip::Endpoint fromAsio(boost::asio::ip::tcp::endpoint const& endpoint) { - return IP::fromAsio(endpoint); + return ip::fromAsio(endpoint); } static boost::asio::ip::address - toAsioAddress(IP::Endpoint const& address) + toAsioAddress(ip::Endpoint const& address) { - return IP::toAsioAddress(address); + return ip::toAsioAddress(address); } static boost::asio::ip::tcp::endpoint - toAsioEndpoint(IP::Endpoint const& address) + toAsioEndpoint(ip::Endpoint const& address) { - return IP::toAsioEndpoint(address); + return ip::toAsioEndpoint(address); } }; diff --git a/include/xrpl/beast/net/IPAddressV4.h b/include/xrpl/beast/net/IPAddressV4.h index 94943af3ea..280c2c791c 100644 --- a/include/xrpl/beast/net/IPAddressV4.h +++ b/include/xrpl/beast/net/IPAddressV4.h @@ -2,7 +2,7 @@ #include -namespace beast::IP { +namespace beast::ip { using AddressV4 = boost::asio::ip::address_v4; @@ -25,4 +25,4 @@ isPublic(AddressV4 const& addr); char getClass(AddressV4 const& address); -} // namespace beast::IP +} // namespace beast::ip diff --git a/include/xrpl/beast/net/IPAddressV6.h b/include/xrpl/beast/net/IPAddressV6.h index b51cb62532..0659e7e405 100644 --- a/include/xrpl/beast/net/IPAddressV6.h +++ b/include/xrpl/beast/net/IPAddressV6.h @@ -2,7 +2,7 @@ #include -namespace beast::IP { +namespace beast::ip { using AddressV6 = boost::asio::ip::address_v6; @@ -18,4 +18,4 @@ isPrivate(AddressV6 const& addr); bool isPublic(AddressV6 const& addr); -} // namespace beast::IP +} // namespace beast::ip diff --git a/include/xrpl/beast/net/IPEndpoint.h b/include/xrpl/beast/net/IPEndpoint.h index c4b269e9c3..d4d3b2ab12 100644 --- a/include/xrpl/beast/net/IPEndpoint.h +++ b/include/xrpl/beast/net/IPEndpoint.h @@ -13,7 +13,7 @@ #include #include -namespace beast::IP { +namespace beast::ip { using Port = std::uint16_t; @@ -223,7 +223,7 @@ operator<<(OutputStream& os, Endpoint const& endpoint) std::istream& operator>>(std::istream& is, Endpoint& endpoint); -} // namespace beast::IP +} // namespace beast::ip //------------------------------------------------------------------------------ @@ -232,12 +232,12 @@ namespace std { * std::hash support. */ template <> -struct hash<::beast::IP::Endpoint> +struct hash<::beast::ip::Endpoint> { hash() = default; std::size_t - operator()(::beast::IP::Endpoint const& endpoint) const + operator()(::beast::ip::Endpoint const& endpoint) const { return ::beast::Uhash<>{}(endpoint); } @@ -249,12 +249,12 @@ namespace boost { * boost::hash support. */ template <> -struct hash<::beast::IP::Endpoint> +struct hash<::beast::ip::Endpoint> { hash() = default; std::size_t - operator()(::beast::IP::Endpoint const& endpoint) const + operator()(::beast::ip::Endpoint const& endpoint) const { return ::beast::Uhash<>{}(endpoint); } diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index 2747ecd9e8..000bdaa7fa 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -18,9 +18,9 @@ namespace xrpl { namespace node_store { class Database; } // namespace node_store -namespace Resource { +namespace resource { class Manager; -} // namespace Resource +} // namespace resource namespace perf { class PerfLog; } // namespace perf @@ -160,7 +160,7 @@ public: virtual PeerReservationTable& getPeerReservations() = 0; - virtual Resource::Manager& + virtual resource::Manager& getResourceManager() = 0; // Storage services diff --git a/include/xrpl/ledger/helpers/LendingHelpers.h b/include/xrpl/ledger/helpers/LendingHelpers.h index fef18e3e09..c69efff964 100644 --- a/include/xrpl/ledger/helpers/LendingHelpers.h +++ b/include/xrpl/ledger/helpers/LendingHelpers.h @@ -296,7 +296,7 @@ struct AccountingDeltas // Whole-life (pre-LendingProtocolV1_1) recognition model: interest is // recognized into AssetsTotal/DebtTotal up front, at origination. -namespace Accrual { +namespace accrual { // LoanSet origination: what's added to Vault.AssetsTotal and LoanBroker.DebtTotal AccountingDeltas @@ -318,11 +318,11 @@ loanVaultExposure(SLE::const_ref loanSle); AccountingDeltas loanPaymentDeltas(LoanPaymentParts const& parts); -} // namespace Accrual +} // namespace accrual // Cash-basis (LendingProtocolV1_1) recognition model: AssetsTotal/DebtTotal // are principal-only, interest is recognized only as it's actually paid. -namespace CashBasis { +namespace cash_basis { AccountingDeltas loanOriginationDeltas(Number const& principalRequested); @@ -333,11 +333,11 @@ loanVaultExposure(SLE::const_ref loanSle); AccountingDeltas loanPaymentDeltas(LoanPaymentParts const& parts); -} // namespace CashBasis +} // namespace cash_basis -// Public dispatchers: pick CashBasis:: if featureLendingProtocolV1_1 is +// Public dispatchers: pick cash_basis:: if featureLendingProtocolV1_1 is // enabled AND the Vault's LEVersion (VaultHelpers::getVaultVersion) is -// VaultVersion::CashBasis, else Accrual::. These are the only entry points +// VaultVersion::CashBasis, else accrual::. These are the only entry points // transactors call. AccountingDeltas loanOriginationDeltas( diff --git a/include/xrpl/net/AutoSocket.h b/include/xrpl/net/AutoSocket.h index b98885959d..d090247388 100644 --- a/include/xrpl/net/AutoSocket.h +++ b/include/xrpl/net/AutoSocket.h @@ -67,16 +67,16 @@ public: return socket_->next_layer(); } - beast::IP::Endpoint + beast::ip::Endpoint localEndpoint() { - return beast::IP::fromAsio(lowestLayer().local_endpoint()); + return beast::ip::fromAsio(lowestLayer().local_endpoint()); } - beast::IP::Endpoint + beast::ip::Endpoint remoteEndpoint() { - return beast::IP::fromAsio(lowestLayer().remote_endpoint()); + return beast::ip::fromAsio(lowestLayer().remote_endpoint()); } lowest_layer_type& diff --git a/include/xrpl/peerfinder/Config.h b/include/xrpl/peerfinder/Config.h index 9ff0d342c3..3326ae8a97 100644 --- a/include/xrpl/peerfinder/Config.h +++ b/include/xrpl/peerfinder/Config.h @@ -9,7 +9,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { struct PeerLimitConfig { @@ -28,7 +28,7 @@ struct Config * This includes both inbound and outbound, but does not include * fixed peers. */ - std::size_t maxPeers{Tuning::kDefaultMaxPeers}; + std::size_t maxPeers{tuning::kDefaultMaxPeers}; /** * The number of automatic outbound connections to maintain. @@ -100,7 +100,7 @@ struct Config onWrite(beast::PropertyStream::Map& map) const; /** - * Make PeerFinder::Config from peer limit and server mode parameters. + * Make peer_finder::Config from peer limit and server mode parameters. */ static Config makeConfig( @@ -160,4 +160,4 @@ to_string(Result result) noexcept return "unknown"; } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/PeerfinderManager.h b/include/xrpl/peerfinder/PeerfinderManager.h index ed683520c1..bb03d85537 100644 --- a/include/xrpl/peerfinder/PeerfinderManager.h +++ b/include/xrpl/peerfinder/PeerfinderManager.h @@ -15,7 +15,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Maintains a set of IP addresses used for getting into the network. @@ -68,17 +68,17 @@ public: * file, along with the set of corresponding IP addresses. */ virtual void - addFixedPeer(std::string_view name, std::vector const& addresses) = 0; + addFixedPeer(std::string_view name, std::vector const& addresses) = 0; /** - * Add a set of strings as fallback IP::Endpoint sources. + * Add a set of strings as fallback ip::Endpoint sources. * @param name A label used for diagnostics. */ virtual void addFallbackStrings(std::string const& name, std::vector const& strings) = 0; /** - * Add a URL as a fallback location to obtain IP::Endpoint sources. + * Add a URL as a fallback location to obtain ip::Endpoint sources. * @param name A label used for diagnostics. */ /* VFALCO NOTE Unimplemented @@ -95,8 +95,8 @@ public: */ virtual std::pair, Result> newInboundSlot( - beast::IP::Endpoint const& localEndpoint, - beast::IP::Endpoint const& remoteEndpoint) = 0; + beast::ip::Endpoint const& localEndpoint, + beast::ip::Endpoint const& remoteEndpoint) = 0; /** * Create a new outbound slot with the specified remote endpoint. @@ -104,7 +104,7 @@ public: * Usually this is because of a duplicate connection. */ virtual std::pair, Result> - newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint) = 0; + newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint) = 0; /** * Called when mtENDPOINTS is received. @@ -145,7 +145,7 @@ public: * @return `true` if the connection should be kept */ virtual bool - onConnected(std::shared_ptr const& slot, beast::IP::Endpoint const& localEndpoint) = 0; + onConnected(std::shared_ptr const& slot, beast::ip::Endpoint const& localEndpoint) = 0; /** * Request an active slot type. @@ -162,7 +162,7 @@ public: /** * Return a set of addresses we should connect to. */ - virtual std::vector + virtual std::vector autoconnect() = 0; virtual std::vector, std::vector>> @@ -176,4 +176,4 @@ public: oncePerSecond() = 0; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/Slot.h b/include/xrpl/peerfinder/Slot.h index 9db39ac94c..58e094afc4 100644 --- a/include/xrpl/peerfinder/Slot.h +++ b/include/xrpl/peerfinder/Slot.h @@ -7,7 +7,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Properties and state associated with a peer to peer overlay connection. @@ -52,13 +52,13 @@ public: /** * The remote endpoint of socket. */ - [[nodiscard]] virtual beast::IP::Endpoint const& + [[nodiscard]] virtual beast::ip::Endpoint const& remoteEndpoint() const = 0; /** * The local endpoint of the socket, when known. */ - [[nodiscard]] virtual std::optional const& + [[nodiscard]] virtual std::optional const& localEndpoint() const = 0; [[nodiscard]] virtual std::optional @@ -72,4 +72,4 @@ public: publicKey() const = 0; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/Types.h b/include/xrpl/peerfinder/Types.h index 9e82d9d65c..1327f2564f 100644 --- a/include/xrpl/peerfinder/Types.h +++ b/include/xrpl/peerfinder/Types.h @@ -8,14 +8,14 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { using clock_type = beast::AbstractClock; /** * Represents a set of addresses. */ -using IPAddresses = std::vector; +using IPAddresses = std::vector; //------------------------------------------------------------------------------ @@ -26,10 +26,10 @@ struct Endpoint { Endpoint() = default; - Endpoint(beast::IP::Endpoint ep, std::uint32_t hops); + Endpoint(beast::ip::Endpoint ep, std::uint32_t hops); std::uint32_t hops = 0; - beast::IP::Endpoint address; + beast::ip::Endpoint address; }; inline bool @@ -43,4 +43,4 @@ operator<(Endpoint const& lhs, Endpoint const& rhs) */ using Endpoints = std::vector; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Bootcache.h b/include/xrpl/peerfinder/detail/Bootcache.h index 2141a374fa..453d9c22d2 100644 --- a/include/xrpl/peerfinder/detail/Bootcache.h +++ b/include/xrpl/peerfinder/detail/Bootcache.h @@ -14,7 +14,7 @@ #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Stores IP addresses useful for gaining initial connections. @@ -65,7 +65,7 @@ private: }; using left_t = boost::bimaps:: - unordered_set_of, std::equal_to<>>; + unordered_set_of, std::equal_to<>>; using right_t = boost::bimaps::multiset_of>; using map_type = boost::bimap; using value_type = map_type::value_type; @@ -73,11 +73,11 @@ private: struct Transform { using first_argument_type = map_type::right_map::const_iterator::value_type const&; - using result_type = beast::IP::Endpoint const&; + using result_type = beast::ip::Endpoint const&; explicit Transform() = default; - beast::IP::Endpoint const& + beast::ip::Endpoint const& operator()(map_type::right_map::const_iterator::value_type const& v) const { return v.get_left(); @@ -121,7 +121,7 @@ public: size() const; /** - * IP::Endpoint iterators that traverse in decreasing valence. + * ip::Endpoint iterators that traverse in decreasing valence. */ /** @{ */ [[nodiscard]] const_iterator @@ -146,25 +146,25 @@ public: * Add a newly-learned address to the cache. */ bool - insert(beast::IP::Endpoint const& endpoint); + insert(beast::ip::Endpoint const& endpoint); /** * Add a staticallyconfigured address to the cache. */ bool - insertStatic(beast::IP::Endpoint const& endpoint); + insertStatic(beast::ip::Endpoint const& endpoint); /** * Called when an outbound connection handshake completes. */ void - onSuccess(beast::IP::Endpoint const& endpoint); + onSuccess(beast::ip::Endpoint const& endpoint); /** * Called when an outbound connection attempt fails to handshake. */ void - onFailure(beast::IP::Endpoint const& endpoint); + onFailure(beast::ip::Endpoint const& endpoint); /** * Stores the cache in the persistent database on a timer. @@ -189,4 +189,4 @@ private: flagForUpdate(); }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Checker.h b/include/xrpl/peerfinder/detail/Checker.h index 28ec83adb1..e1ac1d44e0 100644 --- a/include/xrpl/peerfinder/detail/Checker.h +++ b/include/xrpl/peerfinder/detail/Checker.h @@ -11,7 +11,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Tests remote listening sockets to make sure they are connectable. @@ -104,7 +104,7 @@ public: */ template void - asyncConnect(beast::IP::Endpoint const& endpoint, Handler&& handler); + asyncConnect(beast::ip::Endpoint const& endpoint, Handler&& handler); private: void @@ -179,7 +179,7 @@ Checker::wait() template template void -Checker::asyncConnect(beast::IP::Endpoint const& endpoint, Handler&& handler) +Checker::asyncConnect(beast::ip::Endpoint const& endpoint, Handler&& handler) { auto const op = std::make_shared>(*this, ioContext_, std::forward(handler)); @@ -202,4 +202,4 @@ Checker::remove(BasicAsyncOp& op) cond_.notify_all(); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Counts.h b/include/xrpl/peerfinder/detail/Counts.h index ce78eadce4..035103463e 100644 --- a/include/xrpl/peerfinder/detail/Counts.h +++ b/include/xrpl/peerfinder/detail/Counts.h @@ -10,7 +10,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Direction of a slot count adjustment. @@ -50,7 +50,7 @@ public: // Must be handshaked and in the right state XRPL_ASSERT( s.state() == Slot::State::Connected || s.state() == Slot::State::Accept, - "xrpl::PeerFinder::Counts::can_activate : valid input state"); + "xrpl::peer_finder::Counts::can_activate : valid input state"); if (s.fixed() || s.reserved()) return true; @@ -67,9 +67,9 @@ public: [[nodiscard]] std::size_t attemptsNeeded() const { - if (attempts_ >= Tuning::kMaxConnectAttempts) + if (attempts_ >= tuning::kMaxConnectAttempts) return 0; - return Tuning::kMaxConnectAttempts - attempts_; + return tuning::kMaxConnectAttempts - attempts_; } /** @@ -295,7 +295,7 @@ private: switch (s.state()) { case Slot::State::Accept: - XRPL_ASSERT(s.inbound(), "xrpl::PeerFinder::Counts::adjust : input is inbound"); + XRPL_ASSERT(s.inbound(), "xrpl::peer_finder::Counts::adjust : input is inbound"); acceptCount_ += n; break; @@ -303,7 +303,7 @@ private: case Slot::State::Connected: XRPL_ASSERT( !s.inbound(), - "xrpl::PeerFinder::Counts::adjust : input is not " + "xrpl::peer_finder::Counts::adjust : input is not " "inbound"); attempts_ += n; break; @@ -331,7 +331,7 @@ private: // LCOV_EXCL_START default: - UNREACHABLE("xrpl::PeerFinder::Counts::adjust : invalid input state"); + UNREACHABLE("xrpl::peer_finder::Counts::adjust : invalid input state"); break; // LCOV_EXCL_STOP }; @@ -391,4 +391,4 @@ private: int closingCount_{0}; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Fixed.h b/include/xrpl/peerfinder/detail/Fixed.h index 6754ec6dbd..5a52fd7c3e 100644 --- a/include/xrpl/peerfinder/detail/Fixed.h +++ b/include/xrpl/peerfinder/detail/Fixed.h @@ -7,7 +7,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Metadata for a Fixed slot. @@ -36,8 +36,8 @@ public: void failure(clock_type::time_point const& now) { - failures_ = std::min(failures_ + 1, Tuning::kConnectionBackoff.size() - 1); - when_ = now + std::chrono::minutes(Tuning::kConnectionBackoff[failures_]); + failures_ = std::min(failures_ + 1, tuning::kConnectionBackoff.size() - 1); + when_ = now + std::chrono::minutes(tuning::kConnectionBackoff[failures_]); } /** @@ -55,4 +55,4 @@ private: std::size_t failures_{0}; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Handouts.h b/include/xrpl/peerfinder/detail/Handouts.h index cb5fd7f850..c20d4b2139 100644 --- a/include/xrpl/peerfinder/detail/Handouts.h +++ b/include/xrpl/peerfinder/detail/Handouts.h @@ -12,7 +12,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { namespace detail { @@ -28,7 +28,7 @@ template std::size_t handoutOne(Target& t, HopContainer& h) { - XRPL_ASSERT(!t.full(), "xrpl::PeerFinder::detail::handoutOne : target is not full"); + XRPL_ASSERT(!t.full(), "xrpl::peer_finder::detail::handoutOne : target is not full"); for (auto it = h.begin(); it != h.end(); ++it) { auto const& e = *it; @@ -95,7 +95,7 @@ public: [[nodiscard]] bool full() const { - return list_.size() >= Tuning::kRedirectEndpointCount; + return list_.size() >= tuning::kRedirectEndpointCount; } [[nodiscard]] SlotImp::ptr const& @@ -124,7 +124,7 @@ private: template RedirectHandouts::RedirectHandouts(SlotImp::ptr slot) : slot_(std::move(slot)) { - list_.reserve(Tuning::kRedirectEndpointCount); + list_.reserve(tuning::kRedirectEndpointCount); } template @@ -138,7 +138,7 @@ RedirectHandouts::tryInsert(Endpoint const& ep) // addresses in a peer HTTP handshake instead of // the tmENDPOINTS message. // - if (ep.hops > Tuning::kMaxHops) + if (ep.hops > tuning::kMaxHops) return false; // Don't send them our address @@ -181,7 +181,7 @@ public: [[nodiscard]] bool full() const { - return list_.size() >= Tuning::kNumberOfEndpoints; + return list_.size() >= tuning::kNumberOfEndpoints; } void @@ -210,7 +210,7 @@ private: template SlotHandouts::SlotHandouts(SlotImp::ptr slot) : slot_(std::move(slot)) { - list_.reserve(Tuning::kNumberOfEndpoints); + list_.reserve(tuning::kNumberOfEndpoints); } template @@ -220,7 +220,7 @@ SlotHandouts::tryInsert(Endpoint const& ep) if (full()) return false; - if (ep.hops > Tuning::kMaxHops) + if (ep.hops > tuning::kMaxHops) return false; if (slot_->recent.filter(ep.address, ep.hops)) @@ -259,9 +259,9 @@ class ConnectHandouts public: // Keeps track of addresses we have made outgoing connections // to, for the purposes of not connecting to them too frequently. - using Squelches = beast::aged_set; + using Squelches = beast::aged_set; - using list_type = std::vector; + using list_type = std::vector; private: std::size_t needed_; @@ -274,7 +274,7 @@ public: template bool - tryInsert(beast::IP::Endpoint const& endpoint); + tryInsert(beast::ip::Endpoint const& endpoint); [[nodiscard]] bool empty() const @@ -316,13 +316,13 @@ ConnectHandouts::ConnectHandouts(std::size_t needed, Squelches& squelches) template bool -ConnectHandouts::tryInsert(beast::IP::Endpoint const& endpoint) +ConnectHandouts::tryInsert(beast::ip::Endpoint const& endpoint) { if (full()) return false; // Make sure the address isn't already in our list - if (std::ranges::any_of(list_, [&endpoint](beast::IP::Endpoint const& other) { + if (std::ranges::any_of(list_, [&endpoint](beast::ip::Endpoint const& other) { // Ignore port for security reasons return other.address() == endpoint.address(); })) @@ -341,4 +341,4 @@ ConnectHandouts::tryInsert(beast::IP::Endpoint const& endpoint) return true; } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Livecache.h b/include/xrpl/peerfinder/detail/Livecache.h index cac284d1cc..ec797065e5 100644 --- a/include/xrpl/peerfinder/detail/Livecache.h +++ b/include/xrpl/peerfinder/detail/Livecache.h @@ -29,7 +29,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { template class Livecache; @@ -188,10 +188,10 @@ class Livecache : protected detail::LivecacheBase { private: using cache_type = beast::aged_map< - beast::IP::Endpoint, + beast::ip::Endpoint, Element, std::chrono::steady_clock, - std::less, + std::less, Allocator>; beast::Journal journal_; @@ -220,8 +220,8 @@ public: // but not given out (since they would exceed maxHops). They // are used for automatic connection attempts. // - using Histogram = std::array; - using lists_type = std::array; + using Histogram = std::array; + using lists_type = std::array; template struct Transform @@ -400,7 +400,7 @@ Livecache::expire() { std::size_t n(0); typename cache_type::time_point const expired( - cache_.clock().now() - Tuning::kLiveCacheSecondsToLive); + cache_.clock().now() - tuning::kLiveCacheSecondsToLive); for (auto iter(cache_.chronological.begin()); iter != cache_.chronological.end() && iter.when() <= expired;) { @@ -427,8 +427,8 @@ Livecache::insert(Endpoint const& ep) // when redirecting. // XRPL_ASSERT( - ep.hops <= (Tuning::kMaxHops + 1), - "xrpl::PeerFinder::Livecache::insert : maximum input hops"); + ep.hops <= (tuning::kMaxHops + 1), + "xrpl::peer_finder::Livecache::insert : maximum input hops"); auto result = cache_.emplace(ep.address, ep); Element& e(result.first->second); if (result.second) @@ -468,7 +468,7 @@ void Livecache::onWrite(beast::PropertyStream::Map& map) { typename cache_type::time_point const expired( - cache_.clock().now() - Tuning::kLiveCacheSecondsToLive); + cache_.clock().now() - tuning::kLiveCacheSecondsToLive); map["size"] = size(); map["hist"] = hops.histogram(); beast::PropertyStream::Set set("entries", map); @@ -527,8 +527,8 @@ void Livecache::HopsT::insert(Element& e) { XRPL_ASSERT( - e.endpoint.hops <= Tuning::kMaxHops + 1, - "xrpl::PeerFinder::Livecache::HopsT::insert : maximum input hops"); + e.endpoint.hops <= tuning::kMaxHops + 1, + "xrpl::peer_finder::Livecache::HopsT::insert : maximum input hops"); // This has security implications without a shuffle lists_[e.endpoint.hops].push_front(e); ++hist_[e.endpoint.hops]; @@ -539,8 +539,8 @@ void Livecache::HopsT::reinsert(Element& e, std::uint32_t numHops) { XRPL_ASSERT( - numHops <= Tuning::kMaxHops + 1, - "xrpl::PeerFinder::Livecache::HopsT::reinsert : maximum hops input"); + numHops <= tuning::kMaxHops + 1, + "xrpl::peer_finder::Livecache::HopsT::reinsert : maximum hops input"); auto& list = lists_[e.endpoint.hops]; list.erase(list.iterator_to(e)); @@ -561,4 +561,4 @@ Livecache::HopsT::remove(Element& e) list.erase(list.iterator_to(e)); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Logic.h b/include/xrpl/peerfinder/detail/Logic.h index c623263884..4821054280 100644 --- a/include/xrpl/peerfinder/detail/Logic.h +++ b/include/xrpl/peerfinder/detail/Logic.h @@ -43,7 +43,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * The Logic for maintaining the list of Slot addresses. @@ -57,7 +57,7 @@ public: // Maps remote endpoints to slots. Since a slot has a // remote endpoint upon construction, this holds all counts_. // - using Slots = std::map>; + using Slots = std::map>; beast::Journal journal; clock_type& clock; @@ -81,7 +81,7 @@ private: Counts counts_; // A list of slots that should always be connected - std::map fixed_; + std::map fixed_; public: // Live livecache from mtENDPOINTS messages @@ -96,7 +96,7 @@ public: // The addresses (but not port) we are connected to. This includes // outgoing connection attempts. Note that this set can contain // duplicates (since the port is not set) - std::multiset connectedAddresses; + std::multiset connectedAddresses; // Set of public keys belonging to active peers std::set keys; @@ -170,13 +170,13 @@ public: } void - addFixedPeer(std::string_view name, beast::IP::Endpoint const& ep) + addFixedPeer(std::string_view name, beast::ip::Endpoint const& ep) { - addFixedPeer(name, std::vector{ep}); + addFixedPeer(name, std::vector{ep}); } void - addFixedPeer(std::string_view name, std::vector const& addresses) + addFixedPeer(std::string_view name, std::vector const& addresses) { std::scoped_lock const _(lock); @@ -213,8 +213,8 @@ public: // Called when the Checker completes a connectivity test void checkComplete( - beast::IP::Endpoint const& remoteAddress, - beast::IP::Endpoint const& checkedAddress, + beast::ip::Endpoint const& remoteAddress, + beast::ip::Endpoint const& checkedAddress, boost::system::error_code ec) { if (ec == boost::asio::error::operation_aborted) @@ -256,8 +256,8 @@ public: std::pair newInboundSlot( - beast::IP::Endpoint const& localEndpoint, - beast::IP::Endpoint const& remoteEndpoint) + beast::ip::Endpoint const& localEndpoint, + beast::ip::Endpoint const& remoteEndpoint) { JLOG(journal.debug()) << std::left << std::setw(18) << "Logic accept" << remoteEndpoint << " on local " << localEndpoint; @@ -293,7 +293,7 @@ public: // Remote address must not already exist XRPL_ASSERT( result.second, - "xrpl::PeerFinder::Logic::new_inbound_slot : remote endpoint " + "xrpl::peer_finder::Logic::new_inbound_slot : remote endpoint " "inserted"); // Add to the connected address list connectedAddresses.emplace(remoteEndpoint.address()); @@ -306,7 +306,7 @@ public: // Can't check for self-connect because we don't know the local endpoint std::pair - newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint) + newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint) { JLOG(journal.debug()) << std::left << std::setw(18) << "Logic connect " << remoteEndpoint; @@ -329,7 +329,7 @@ public: // Remote address must not already exist XRPL_ASSERT( result.second, - "xrpl::PeerFinder::Logic::new_outbound_slot : remote endpoint " + "xrpl::peer_finder::Logic::new_outbound_slot : remote endpoint " "inserted"); // Add to the connected address list @@ -342,7 +342,7 @@ public: } bool - onConnected(SlotImp::ptr const& slot, beast::IP::Endpoint const& localEndpoint) + onConnected(SlotImp::ptr const& slot, beast::ip::Endpoint const& localEndpoint) { beast::WrappedSink sink{journal.sink(), slot->prefix()}; beast::Journal const journal{sink}; @@ -354,7 +354,7 @@ public: // The object must exist in our table XRPL_ASSERT( slots.contains(slot->remoteEndpoint()), - "xrpl::PeerFinder::Logic::onConnected : valid slot input"); + "xrpl::peer_finder::Logic::onConnected : valid slot input"); // Assign the local endpoint now that it's known slot->localEndpoint(localEndpoint); @@ -365,7 +365,7 @@ public: { XRPL_ASSERT( iter->second->localEndpoint() == slot->remoteEndpoint(), - "xrpl::PeerFinder::Logic::onConnected : local and remote " + "xrpl::peer_finder::Logic::onConnected : local and remote " "endpoints do match"); JLOG(journal.warn()) << "Logic dropping as self connect"; return false; @@ -393,11 +393,11 @@ public: // The object must exist in our table XRPL_ASSERT( slots.contains(slot->remoteEndpoint()), - "xrpl::PeerFinder::Logic::activate : valid slot input"); + "xrpl::peer_finder::Logic::activate : valid slot input"); // Must be accepted or connected XRPL_ASSERT( slot->state() == Slot::State::Accept || slot->state() == Slot::State::Connected, - "xrpl::PeerFinder::Logic::activate : valid slot state"); + "xrpl::peer_finder::Logic::activate : valid slot state"); // Check for duplicate connection by key if (keys.contains(key)) @@ -425,7 +425,7 @@ public: { [[maybe_unused]] bool const inserted = keys.insert(key).second; // Public key must not already exist - XRPL_ASSERT(inserted, "xrpl::PeerFinder::Logic::activate : public key inserted"); + XRPL_ASSERT(inserted, "xrpl::peer_finder::Logic::activate : public key inserted"); } // Change state and update counts @@ -443,7 +443,7 @@ public: if (iter == fixed_.end()) { logicError( - "PeerFinder::Logic::activate(): remote_endpoint " + "peer_finder::Logic::activate(): remote_endpoint " "missing from fixed_"); } @@ -476,10 +476,10 @@ public: // VFALCO TODO This should add the returned addresses to the // squelch list in one go once the list is built, // rather than having each module add to the squelch list. - std::vector + std::vector autoconnect() { - std::vector none; + std::vector none; std::scoped_lock const _(lock); @@ -635,7 +635,7 @@ public: // either. ipv6 has a slightly more compact string // representation of 0, so use that for self entries. ep.address = - beast::IP::Endpoint(beast::IP::AddressV6()).atPort(config_.listeningPort); + beast::ip::Endpoint(beast::ip::AddressV6()).atPort(config_.listeningPort); for (auto& t : targets) t.insert(ep); } @@ -656,7 +656,7 @@ public: result.emplace_back(slot, list); } - whenBroadcast = now + Tuning::kSecondsPerMessage; + whenBroadcast = now + tuning::kSecondsPerMessage; } return result; @@ -675,7 +675,7 @@ public: entry.second->expire(); // Expire the recent attempts table - beast::expire(squelches, Tuning::kRecentAttemptDuration); + beast::expire(squelches, tuning::kRecentAttemptDuration); bootcache.periodicActivity(); } @@ -692,7 +692,7 @@ public: Endpoint& ep(*iter); // Enforce hop limit - if (ep.hops > Tuning::kMaxHops) + if (ep.hops > tuning::kMaxHops) { JLOG(journal.debug()) << std::left << std::setw(18) << "Endpoints drop " << ep.address << " for excess hops " << ep.hops; @@ -754,10 +754,10 @@ public: beast::Journal const journal{sink}; // If we're sent too many endpoints, sample them at random: - if (list.size() > Tuning::kNumberOfEndpointsMax) + if (list.size() > tuning::kNumberOfEndpointsMax) { std::shuffle(list.begin(), list.end(), defaultPrng()); - list.resize(Tuning::kNumberOfEndpointsMax); + list.resize(tuning::kNumberOfEndpointsMax); } JLOG(journal.trace()) << "Endpoints contained " << list.size() @@ -768,12 +768,12 @@ public: // The object must exist in our table XRPL_ASSERT( slots.contains(slot->remoteEndpoint()), - "xrpl::PeerFinder::Logic::onEndpoints : valid slot input"); + "xrpl::peer_finder::Logic::onEndpoints : valid slot input"); // Must be handshaked! XRPL_ASSERT( slot->state() == Slot::State::Active, - "xrpl::PeerFinder::Logic::onEndpoints : valid slot state"); + "xrpl::peer_finder::Logic::onEndpoints : valid slot state"); clock_type::time_point const now(clock.now()); @@ -785,7 +785,7 @@ public: for (auto const& ep : list) { - XRPL_ASSERT(ep.hops, "xrpl::PeerFinder::Logic::onEndpoints : nonzero hops"); + XRPL_ASSERT(ep.hops, "xrpl::peer_finder::Logic::onEndpoints : nonzero hops"); slot->recent.insert(ep.address, ep.hops); @@ -837,7 +837,7 @@ public: bootcache.insert(ep.address); } - slot->whenAcceptEndpoints = now + Tuning::kSecondsPerMessage; + slot->whenAcceptEndpoints = now + tuning::kSecondsPerMessage; } //-------------------------------------------------------------------------- @@ -851,7 +851,7 @@ public: if (iter == slots.end()) { logicError( - "PeerFinder::Logic::remove(): remote_endpoint " + "peer_finder::Logic::remove(): remote_endpoint " "missing from slots_"); } @@ -866,7 +866,7 @@ public: if (iter == keys.end()) { logicError( - "PeerFinder::Logic::remove(): public_key missing " + "peer_finder::Logic::remove(): public_key missing " "from keys_"); } @@ -879,7 +879,7 @@ public: if (iter == connectedAddresses.end()) { logicError( - "PeerFinder::Logic::remove(): remote_endpoint " + "peer_finder::Logic::remove(): remote_endpoint " "address missing from connectedAddresses_"); } @@ -907,7 +907,7 @@ public: if (iter == fixed_.end()) { logicError( - "PeerFinder::Logic::on_closed(): remote_endpoint " + "peer_finder::Logic::on_closed(): remote_endpoint " "missing from fixed_"); } @@ -943,7 +943,7 @@ public: // LCOV_EXCL_START default: UNREACHABLE( - "xrpl::PeerFinder::Logic::on_closed : invalid slot " + "xrpl::peer_finder::Logic::on_closed : invalid slot " "state"); break; // LCOV_EXCL_STOP @@ -968,17 +968,17 @@ public: // Returns `true` if the address matches a fixed slot address // Must have the lock held bool - fixed(beast::IP::Endpoint const& endpoint) const + fixed(beast::ip::Endpoint const& endpoint) const { return std::ranges::any_of( fixed_, [&endpoint](auto const& entry) { return entry.first == endpoint; }); } // Returns `true` if the address matches a fixed slot address - // Note that this does not use the port information in the IP::Endpoint + // Note that this does not use the port information in the ip::Endpoint // Must have the lock held bool - fixed(beast::IP::Address const& address) const + fixed(beast::ip::Address const& address) const { return std::ranges::any_of( fixed_, [&address](auto const& entry) { return entry.first.address() == address; }); @@ -1097,9 +1097,9 @@ public: // //-------------------------------------------------------------------------- - // Returns true if the IP::Endpoint contains no invalid data. + // Returns true if the ip::Endpoint contains no invalid data. bool - isValidAddress(beast::IP::Endpoint const& address) + isValidAddress(beast::ip::Endpoint const& address) { if (isUnspecified(address)) return false; @@ -1220,7 +1220,7 @@ Logic::onRedirects( { std::scoped_lock const _(lock); std::size_t n = 0; - for (; first != last && n < Tuning::kMaxRedirects; ++first, ++n) + for (; first != last && n < tuning::kMaxRedirects; ++first, ++n) bootcache.insert(beast::IPAddressConversion::fromAsio(*first)); if (n > 0) { @@ -1229,4 +1229,4 @@ Logic::onRedirects( } } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/SlotImp.h b/include/xrpl/peerfinder/detail/SlotImp.h index 35c61b13cf..db86183f64 100644 --- a/include/xrpl/peerfinder/detail/SlotImp.h +++ b/include/xrpl/peerfinder/detail/SlotImp.h @@ -12,7 +12,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { class SlotImp : public Slot { @@ -21,13 +21,13 @@ public: // inbound SlotImp( - beast::IP::Endpoint const& localEndpoint, - beast::IP::Endpoint remoteEndpoint, + beast::ip::Endpoint const& localEndpoint, + beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock); // outbound - SlotImp(beast::IP::Endpoint remoteEndpoint, bool fixed, clock_type& clock); + SlotImp(beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock); bool inbound() const override @@ -53,13 +53,13 @@ public: return state_; } - beast::IP::Endpoint const& + beast::ip::Endpoint const& remoteEndpoint() const override { return remoteEndpoint_; } - std::optional const& + std::optional const& localEndpoint() const override { return localEndpoint_; @@ -93,13 +93,13 @@ public: } void - localEndpoint(beast::IP::Endpoint const& endpoint) + localEndpoint(beast::ip::Endpoint const& endpoint) { localEndpoint_ = endpoint; } void - remoteEndpoint(beast::IP::Endpoint const& endpoint) + remoteEndpoint(beast::ip::Endpoint const& endpoint) { remoteEndpoint_ = endpoint; } @@ -140,20 +140,20 @@ public: * sending a slot the same address too frequently. */ void - insert(beast::IP::Endpoint const& ep, std::uint32_t hops); + insert(beast::ip::Endpoint const& ep, std::uint32_t hops); /** * Returns `true` if we should not send endpoint to the slot. */ bool - filter(beast::IP::Endpoint const& ep, std::uint32_t hops); + filter(beast::ip::Endpoint const& ep, std::uint32_t hops); private: void expire(); friend class SlotImp; - beast::aged_unordered_map cache_; + beast::aged_unordered_map cache_; } recent; void @@ -167,8 +167,8 @@ private: bool const fixed_; bool reserved_; State state_; - beast::IP::Endpoint remoteEndpoint_; - std::optional localEndpoint_; + beast::ip::Endpoint remoteEndpoint_; + std::optional localEndpoint_; std::optional publicKey_; static std::int32_t constexpr kUnknownPort = -1; @@ -196,4 +196,4 @@ public: clock_type::time_point whenAcceptEndpoints; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Source.h b/include/xrpl/peerfinder/detail/Source.h index 5cdb535bdd..09aa4e216a 100644 --- a/include/xrpl/peerfinder/detail/Source.h +++ b/include/xrpl/peerfinder/detail/Source.h @@ -7,7 +7,7 @@ #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * A static or dynamic source of peer addresses. @@ -46,4 +46,4 @@ public: fetch(Results& results, beast::Journal journal) = 0; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/SourceStrings.h b/include/xrpl/peerfinder/detail/SourceStrings.h index 325a024764..e9783c775f 100644 --- a/include/xrpl/peerfinder/detail/SourceStrings.h +++ b/include/xrpl/peerfinder/detail/SourceStrings.h @@ -6,7 +6,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Provides addresses from a static set of strings. @@ -22,4 +22,4 @@ public: make(std::string const& name, Strings const& strings); }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Store.h b/include/xrpl/peerfinder/detail/Store.h index 9393ef6c2b..1f9352c6ec 100644 --- a/include/xrpl/peerfinder/detail/Store.h +++ b/include/xrpl/peerfinder/detail/Store.h @@ -6,7 +6,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Abstract persistence for PeerFinder data. @@ -17,7 +17,7 @@ public: virtual ~Store() = default; // load the bootstrap cache - using load_callback = std::function; + using load_callback = std::function; virtual std::size_t load(load_callback const& cb) = 0; @@ -26,11 +26,11 @@ public: { explicit Entry() = default; - beast::IP::Endpoint endpoint; + beast::ip::Endpoint endpoint; int valence{}; }; virtual void save(std::vector const& v) = 0; }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/peerfinder/detail/Tuning.h b/include/xrpl/peerfinder/detail/Tuning.h index ea4637dd9d..b4ccfae167 100644 --- a/include/xrpl/peerfinder/detail/Tuning.h +++ b/include/xrpl/peerfinder/detail/Tuning.h @@ -9,7 +9,7 @@ * Heuristically tuned constants. */ /** @{ */ -namespace xrpl::PeerFinder::Tuning { +namespace xrpl::peer_finder::tuning { //--------------------------------------------------------- // @@ -111,5 +111,5 @@ constexpr std::chrono::seconds kLiveCacheSecondsToLive(30); // Note that we ignore the port for purposes of comparison. constexpr std::chrono::seconds kRecentAttemptDuration(60); -} // namespace xrpl::PeerFinder::Tuning +} // namespace xrpl::peer_finder::tuning /** @} */ diff --git a/include/xrpl/peerfinder/make_Manager.h b/include/xrpl/peerfinder/make_Manager.h index 5da372e588..e514734d8b 100644 --- a/include/xrpl/peerfinder/make_Manager.h +++ b/include/xrpl/peerfinder/make_Manager.h @@ -10,7 +10,7 @@ #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * @brief Create a new Manager. @@ -33,4 +33,4 @@ makeManager( Store& store, beast::insight::Collector::ptr const& collector); -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/include/xrpl/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h index c3292e6074..b52e705b38 100644 --- a/include/xrpl/protocol/ApiVersion.h +++ b/include/xrpl/protocol/ApiVersion.h @@ -33,7 +33,7 @@ namespace xrpl { * Command line Requests use apiCommandLineVersion. */ -namespace RPC { +namespace rpc { template static constexpr std::integral_constant kApiVersion = {}; @@ -60,7 +60,7 @@ static_assert(kApiMaximumValidVersion >= kApiMaximumSupportedVersion); inline void setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled) { - XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::RPC::setVersion : input is valid"); + XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::rpc::setVersion : input is valid"); auto& retObj = parent[jss::version] = json::ValueType::Object; @@ -99,12 +99,12 @@ setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled) inline unsigned int getAPIVersionNumber(json::Value const& jv, bool betaEnabled) { - static json::Value const kMinVersion(RPC::kApiMinimumSupportedVersion); + static json::Value const kMinVersion(rpc::kApiMinimumSupportedVersion); json::Value const maxVersion( - betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion); + betaEnabled ? rpc::kApiBetaVersion : rpc::kApiMaximumSupportedVersion); if (!jv.isObject() || !jv.isMember(jss::api_version)) - return RPC::kApiVersionIfUnspecified; + return rpc::kApiVersionIfUnspecified; try { @@ -113,33 +113,33 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled) { case json::ValueType::Int: if (rawVersion.asInt() < 0) - return RPC::kApiInvalidVersion; + return rpc::kApiInvalidVersion; [[fallthrough]]; case json::ValueType::UInt: { auto const apiVersion = rawVersion.asUInt(); if (apiVersion < kMinVersion || apiVersion > maxVersion) - return RPC::kApiInvalidVersion; + return rpc::kApiInvalidVersion; return apiVersion; } default: - return RPC::kApiInvalidVersion; + return rpc::kApiInvalidVersion; } } catch (...) { - return RPC::kApiInvalidVersion; + return rpc::kApiInvalidVersion; } } -} // namespace RPC +} // namespace rpc template void forApiVersions(Fn const& fn, Args&&... args) requires // (MaxVer >= MinVer) && // - (MinVer >= RPC::kApiMinimumSupportedVersion) && // - (RPC::kApiMaximumValidVersion >= MaxVer) && requires { + (MinVer >= rpc::kApiMinimumSupportedVersion) && // + (rpc::kApiMaximumValidVersion >= MaxVer) && requires { fn(std::integral_constant{}, std::forward(args)...); fn(std::integral_constant{}, std::forward(args)...); } @@ -158,11 +158,11 @@ template void forAllApiVersions(Fn const& fn, Args&&... args) requires requires { - forApiVersions( + forApiVersions( fn, std::forward(args)...); } { - forApiVersions( + forApiVersions( fn, std::forward(args)...); } diff --git a/include/xrpl/protocol/BuildInfo.h b/include/xrpl/protocol/BuildInfo.h index 18ba20f23c..c3f90d8f9f 100644 --- a/include/xrpl/protocol/BuildInfo.h +++ b/include/xrpl/protocol/BuildInfo.h @@ -8,7 +8,7 @@ * Versioning information for this build. */ // VFALCO The namespace is deprecated -namespace xrpl::BuildInfo { +namespace xrpl::build_info { /** * Server version. @@ -84,4 +84,4 @@ isXrpldVersion(std::uint64_t version); bool isNewerVersion(std::uint64_t version); -} // namespace xrpl::BuildInfo +} // namespace xrpl::build_info diff --git a/include/xrpl/protocol/ErrorCodes.h b/include/xrpl/protocol/ErrorCodes.h index 8ac7c8c58f..465b6d711f 100644 --- a/include/xrpl/protocol/ErrorCodes.h +++ b/include/xrpl/protocol/ErrorCodes.h @@ -167,7 +167,7 @@ enum WarningCodeI { // VFALCO NOTE these should probably not be in the RPC namespace. -namespace RPC { +namespace rpc { /** * Maps an rpc error code to its token, default message, and HTTP status. @@ -337,7 +337,7 @@ containsError(json::Value const& json); int errorCodeHttpStatus(ErrorCodeI code); -} // namespace RPC +} // namespace rpc /** * Returns a single string with the contents of an RPC error. diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 9a4882ec55..a0029fa491 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -188,6 +188,6 @@ struct MultiApiJson // Wrapper for Json for all supported API versions. using MultiApiJson = - detail::MultiApiJson; + detail::MultiApiJson; } // namespace xrpl diff --git a/include/xrpl/protocol/NFTSyntheticSerializer.h b/include/xrpl/protocol/NFTSyntheticSerializer.h index bef05b9a8f..df4fedb707 100644 --- a/include/xrpl/protocol/NFTSyntheticSerializer.h +++ b/include/xrpl/protocol/NFTSyntheticSerializer.h @@ -6,7 +6,7 @@ #include -namespace xrpl::RPC { +namespace xrpl::rpc { /** * Adds common synthetic fields to transaction-related JSON responses @@ -16,4 +16,4 @@ void insertNFTSyntheticInJson(json::Value&, std::shared_ptr const&, TxMeta const&); /** @} */ -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index 9938a9b768..567f66d339 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -139,7 +139,7 @@ tenthBipsOfValue(T value, TenthBips bips) return value * bips.value() / kTenthBipsPerUnity.value(); } -namespace Lending { +namespace lending { /** * The maximum management fee rate allowed by a loan broker in 1/10 bips. * @@ -236,7 +236,7 @@ static constexpr int kLoanPaymentsPerFeeIncrement = 5; * without an amendment */ static constexpr int kLoanMaximumPaymentsPerTransaction = 100; -} // namespace Lending +} // namespace lending /** * The maximum length of a URI inside an NFT diff --git a/include/xrpl/protocol/PublicKey.h b/include/xrpl/protocol/PublicKey.h index 98301af487..833078d741 100644 --- a/include/xrpl/protocol/PublicKey.h +++ b/include/xrpl/protocol/PublicKey.h @@ -260,7 +260,7 @@ calcAccountID(PublicKey const& pk); inline std::string getFingerprint( - beast::IP::Endpoint const& address, + beast::ip::Endpoint const& address, std::optional const& publicKey = std::nullopt, std::optional const& id = std::nullopt) { diff --git a/include/xrpl/protocol/XChainAttestations.h b/include/xrpl/protocol/XChainAttestations.h index 8f1c7a4ce3..ed8ffeb88e 100644 --- a/include/xrpl/protocol/XChainAttestations.h +++ b/include/xrpl/protocol/XChainAttestations.h @@ -20,7 +20,7 @@ namespace xrpl { -namespace Attestations { +namespace attestations { struct AttestationBase { @@ -227,7 +227,7 @@ struct CmpByCreateCount } }; -}; // namespace Attestations +}; // namespace attestations // Result when checking when two attestation match. enum class AttestationMatch { @@ -241,7 +241,7 @@ enum class AttestationMatch { struct XChainClaimAttestation { - using TSignedAttestation = Attestations::AttestationClaim; + using TSignedAttestation = attestations::AttestationClaim; static SField const& arrayFieldName; AccountID keyAccount; @@ -297,7 +297,7 @@ struct XChainClaimAttestation struct XChainCreateAccountAttestation { - using TSignedAttestation = Attestations::AttestationCreateAccount; + using TSignedAttestation = attestations::AttestationCreateAccount; static SField const& arrayFieldName; AccountID keyAccount; diff --git a/include/xrpl/resource/Charge.h b/include/xrpl/resource/Charge.h index 12ea548fd2..b5bb8dd52e 100644 --- a/include/xrpl/resource/Charge.h +++ b/include/xrpl/resource/Charge.h @@ -4,7 +4,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * A consumption charge. @@ -32,7 +32,7 @@ public: label() const; /** - * Return the cost of the charge in Resource::Manager units. + * Return the cost of the charge in resource::Manager units. */ [[nodiscard]] value_type cost() const; @@ -60,4 +60,4 @@ private: std::ostream& operator<<(std::ostream& os, Charge const& v); -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/Consumer.h b/include/xrpl/resource/Consumer.h index 9abcbffc82..01539e3a39 100644 --- a/include/xrpl/resource/Consumer.h +++ b/include/xrpl/resource/Consumer.h @@ -8,7 +8,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { struct Entry; class Logic; @@ -96,4 +96,4 @@ private: std::ostream& operator<<(std::ostream& os, Consumer const& v); -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/Disposition.h b/include/xrpl/resource/Disposition.h index cd5bceafa5..28dd4edf62 100644 --- a/include/xrpl/resource/Disposition.h +++ b/include/xrpl/resource/Disposition.h @@ -1,6 +1,6 @@ #pragma once -namespace xrpl::Resource { +namespace xrpl::resource { /** * The disposition of a consumer after applying a load charge. @@ -24,4 +24,4 @@ enum class Disposition { Drop }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/Fees.h b/include/xrpl/resource/Fees.h index 5001b504d6..411169253d 100644 --- a/include/xrpl/resource/Fees.h +++ b/include/xrpl/resource/Fees.h @@ -2,7 +2,7 @@ #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * Schedule of fees charged for imposing load on the server. @@ -31,4 +31,4 @@ extern Charge const kFeeWarning; // The cost of receiving a warning. extern Charge const kFeeDrop; // The cost of being dropped for excess load. /** @} */ -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/Gossip.h b/include/xrpl/resource/Gossip.h index 4ad5852de0..0d8ccb100c 100644 --- a/include/xrpl/resource/Gossip.h +++ b/include/xrpl/resource/Gossip.h @@ -4,7 +4,7 @@ #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * Data format for exchanging consumption information across peers. @@ -21,10 +21,10 @@ struct Gossip explicit Item() = default; int balance{}; - beast::IP::Endpoint address; + beast::ip::Endpoint address; }; std::vector items; }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/README.md b/include/xrpl/resource/README.md index 545d4e9ca0..96b6c3d603 100644 --- a/include/xrpl/resource/README.md +++ b/include/xrpl/resource/README.md @@ -1,4 +1,4 @@ -# Resource::Manager +# resource::Manager The ResourceManager module has these responsibilities: @@ -36,7 +36,7 @@ to the general public. ## Consumer Types Consumers are placed into three classifications (as identified by the -Resource::Kind enumeration): +resource::Kind enumeration): - InBound, - OutBound, and @@ -72,6 +72,6 @@ drop connections to those IP addresses that occur commonly in the gossip. ## Access -In xrpld, the Application holds a unique instance of Resource::Manager, +In xrpld, the Application holds a unique instance of resource::Manager, which may be retrieved by calling the method `Application::getResourceManager()`. diff --git a/include/xrpl/resource/ResourceManager.h b/include/xrpl/resource/ResourceManager.h index 03aab60c75..267cfb16e3 100644 --- a/include/xrpl/resource/ResourceManager.h +++ b/include/xrpl/resource/ResourceManager.h @@ -14,7 +14,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * Tracks load and resource consumption. @@ -32,10 +32,10 @@ public: * IP if proxied. */ virtual Consumer - newInboundEndpoint(beast::IP::Endpoint const& address) = 0; + newInboundEndpoint(beast::ip::Endpoint const& address) = 0; virtual Consumer newInboundEndpoint( - beast::IP::Endpoint const& address, + beast::ip::Endpoint const& address, bool const proxy, std::string_view forwardedFor) = 0; @@ -43,13 +43,13 @@ public: * Create a new endpoint keyed by outbound IP address and port. */ virtual Consumer - newOutboundEndpoint(beast::IP::Endpoint const& address) = 0; + newOutboundEndpoint(beast::ip::Endpoint const& address) = 0; /** * Create a new unlimited endpoint keyed by forwarded IP. */ virtual Consumer - newUnlimitedEndpoint(beast::IP::Endpoint const& address) = 0; + newUnlimitedEndpoint(beast::ip::Endpoint const& address) = 0; /** * Extract packaged consumer information for export. @@ -78,4 +78,4 @@ public: std::unique_ptr makeManager(beast::insight::Collector::ptr const& collector, beast::Journal journal); -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Entry.h b/include/xrpl/resource/detail/Entry.h index 1336bda6ab..ec5a328b8b 100644 --- a/include/xrpl/resource/detail/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -12,7 +12,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { using clock_type = beast::AbstractClock; @@ -91,4 +91,4 @@ operator<<(std::ostream& os, Entry const& v) return os; } -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Import.h b/include/xrpl/resource/detail/Import.h index b19dbc4d1a..c5366146c1 100644 --- a/include/xrpl/resource/detail/Import.h +++ b/include/xrpl/resource/detail/Import.h @@ -5,7 +5,7 @@ #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * A set of imported consumer data from a gossip origin. @@ -32,4 +32,4 @@ struct Import std::vector items; }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Key.h b/include/xrpl/resource/detail/Key.h index a0f11422a7..180e868319 100644 --- a/include/xrpl/resource/detail/Key.h +++ b/include/xrpl/resource/detail/Key.h @@ -7,17 +7,17 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { // The consumer key struct Key { Kind kind; - beast::IP::Endpoint address; + beast::ip::Endpoint address; Key() = delete; - Key(Kind k, beast::IP::Endpoint addr) : kind(k), address(std::move(addr)) + Key(Kind k, beast::ip::Endpoint addr) : kind(k), address(std::move(addr)) { } @@ -47,4 +47,4 @@ struct Key }; }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Kind.h b/include/xrpl/resource/detail/Kind.h index ce2e0773cf..9af760d252 100644 --- a/include/xrpl/resource/detail/Kind.h +++ b/include/xrpl/resource/detail/Kind.h @@ -1,6 +1,6 @@ #pragma once -namespace xrpl::Resource { +namespace xrpl::resource { /** * Kind of consumer. @@ -12,4 +12,4 @@ namespace xrpl::Resource { */ enum class Kind { Inbound, Outbound, Unlimited }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index 3f36ad84a3..aaaeb4fdd1 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -24,7 +24,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { class Logic { @@ -96,7 +96,7 @@ public: } Consumer - newInboundEndpoint(beast::IP::Endpoint const& address) + newInboundEndpoint(beast::ip::Endpoint const& address) { Entry* entry(nullptr); @@ -126,7 +126,7 @@ public: } Consumer - newOutboundEndpoint(beast::IP::Endpoint const& address) + newOutboundEndpoint(beast::ip::Endpoint const& address) { Entry* entry(nullptr); @@ -159,7 +159,7 @@ public: * enabled. */ Consumer - newUnlimitedEndpoint(beast::IP::Endpoint const& address) + newUnlimitedEndpoint(beast::ip::Endpoint const& address) { Entry* entry(nullptr); @@ -387,7 +387,7 @@ public: { std::scoped_lock const _(lock_); Entry& entry(iter->second); - XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used"); + XRPL_ASSERT(entry.refcount == 0, "xrpl::resource::Logic::erase : entry not used"); inactive_.erase(inactive_.iteratorTo(entry)); table_.erase(iter); } @@ -421,7 +421,7 @@ public: default: // LCOV_EXCL_START UNREACHABLE( - "xrpl::Resource::Logic::release : invalid entry " + "xrpl::resource::Logic::release : invalid entry " "kind"); break; // LCOV_EXCL_STOP @@ -440,7 +440,7 @@ public: static_assert( kFeeLogAsWarn > kFeeLogAsInfo && kFeeLogAsInfo > kFeeLogAsDebug && kFeeLogAsDebug > 10); - static auto kGetStream = [](Resource::Charge::value_type cost, beast::Journal& journal) { + static auto kGetStream = [](resource::Charge::value_type cost, beast::Journal& journal) { if (cost >= kFeeLogAsWarn) return journal.warn(); if (cost >= kFeeLogAsInfo) @@ -564,4 +564,4 @@ public: } }; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/resource/detail/Tuning.h b/include/xrpl/resource/detail/Tuning.h index 62f7fa3f9d..d631aaddba 100644 --- a/include/xrpl/resource/detail/Tuning.h +++ b/include/xrpl/resource/detail/Tuning.h @@ -2,7 +2,7 @@ #include -namespace xrpl::Resource { +namespace xrpl::resource { /** * Tunable constants. @@ -26,4 +26,4 @@ static constexpr std::chrono::seconds kSecondsUntilExpiration{300}; // Number of seconds until imported gossip expires static constexpr std::chrono::seconds kGossipExpirationSeconds{30}; -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/include/xrpl/server/InfoSub.h b/include/xrpl/server/InfoSub.h index 2e9bd857c7..4bf88cd53b 100644 --- a/include/xrpl/server/InfoSub.h +++ b/include/xrpl/server/InfoSub.h @@ -62,7 +62,7 @@ public: using ref = std::shared_ptr const&; - using Consumer = Resource::Consumer; + using Consumer = resource::Consumer; public: /** diff --git a/include/xrpl/server/Session.h b/include/xrpl/server/Session.h index be8d9a497c..03ac767c25 100644 --- a/include/xrpl/server/Session.h +++ b/include/xrpl/server/Session.h @@ -52,7 +52,7 @@ public: /** * Returns the remote address of the connection. */ - virtual beast::IP::Endpoint + virtual beast::ip::Endpoint remoteAddress() = 0; /** diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index c7553c1da3..6020d3cc65 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -157,7 +157,7 @@ protected: return port_; } - beast::IP::Endpoint + beast::ip::Endpoint remoteAddress() override { return beast::IPAddressConversion::fromAsio(remoteAddress_); diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 59a866ab8c..b1670865bd 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -196,7 +196,7 @@ BaseWSPeer::run() startTimer(); closeOnTimer_ = true; impl().ws_.set_option(boost::beast::websocket::stream_base::decorator([](auto& res) { - res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString()); + res.set(boost::beast::http::field::server, build_info::getFullVersionString()); })); impl().ws_.async_accept( request_, bind_executor(strand_, [self = impl().shared_from_this()](error_code const& ec) { diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 25e95b7fc5..53739fed8a 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -255,7 +255,7 @@ public: if (ec == boost::asio::error::operation_aborted) return; - std::vector addresses; + std::vector addresses; auto iter = results.begin(); // If we get an error message back, we don't return any @@ -283,7 +283,7 @@ public: // first attempt to parse as an endpoint (IP addr + port). // If that doesn't succeed, fall back to generic name + port parsing - if (auto const result = beast::IP::Endpoint::fromStringChecked(str)) + if (auto const result = beast::ip::Endpoint::fromStringChecked(str)) { return make_pair(result->address().to_string(), std::to_string(result->port())); } diff --git a/src/libxrpl/basics/StringUtilities.cpp b/src/libxrpl/basics/StringUtilities.cpp index f4edaf5aca..2b7deecb8e 100644 --- a/src/libxrpl/basics/StringUtilities.cpp +++ b/src/libxrpl/basics/StringUtilities.cpp @@ -74,7 +74,7 @@ parseUrl(ParsedUrl& pUrl, std::string const& strUrl) // We need to use Endpoint to parse the domain to // strip surrounding brackets from IPv6 addresses, // e.g. [::1] => ::1. - auto const result = beast::IP::Endpoint::fromStringChecked(domain); + auto const result = beast::ip::Endpoint::fromStringChecked(domain); pUrl.domain = result ? result->address().to_string() : domain; std::string const port = smMatch[5]; if (!port.empty()) diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index 3cff5d93b5..72fe6189a5 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -207,7 +207,7 @@ private: static constexpr auto kMaxPacketSize = 1472; Journal journal_; - IP::Endpoint address_; + ip::Endpoint address_; std::string prefix_; boost::asio::io_context ioContext_; std::optional> work_; @@ -222,13 +222,13 @@ private: std::thread thread_; static boost::asio::ip::udp::endpoint - toEndpoint(IP::Endpoint const& ep) + toEndpoint(ip::Endpoint const& ep) { return boost::asio::ip::udp::endpoint(ep.address(), ep.port()); } public: - StatsDCollectorImp(IP::Endpoint address, std::string prefix, Journal journal) + StatsDCollectorImp(ip::Endpoint address, std::string prefix, Journal journal) : journal_(journal) , address_(std::move(address)) , prefix_(std::move(prefix)) @@ -707,7 +707,7 @@ StatsDMeterImpl::doProcess() //------------------------------------------------------------------------------ std::shared_ptr -StatsDCollector::make(IP::Endpoint const& address, std::string const& prefix, Journal journal) +StatsDCollector::make(ip::Endpoint const& address, std::string const& prefix, Journal journal) { return std::make_shared(address, prefix, journal); } diff --git a/src/libxrpl/beast/net/IPAddressConversion.cpp b/src/libxrpl/beast/net/IPAddressConversion.cpp index c0a37d234e..bf24ef75c1 100644 --- a/src/libxrpl/beast/net/IPAddressConversion.cpp +++ b/src/libxrpl/beast/net/IPAddressConversion.cpp @@ -5,7 +5,7 @@ #include #include -namespace beast::IP { +namespace beast::ip { Endpoint fromAsio(boost::asio::ip::address const& address) @@ -31,4 +31,4 @@ toAsioEndpoint(Endpoint const& endpoint) return boost::asio::ip::tcp::endpoint{endpoint.address(), endpoint.port()}; } -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/libxrpl/beast/net/IPAddressV4.cpp b/src/libxrpl/beast/net/IPAddressV4.cpp index f9b0c96022..2a59fe1cc4 100644 --- a/src/libxrpl/beast/net/IPAddressV4.cpp +++ b/src/libxrpl/beast/net/IPAddressV4.cpp @@ -1,6 +1,6 @@ #include -namespace beast::IP { +namespace beast::ip { bool isPrivate(AddressV4 const& addr) @@ -62,4 +62,4 @@ getClass(AddressV4 const& addr) return kTable[(addr.to_uint() & 0xE0000000) >> 29]; } -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/libxrpl/beast/net/IPAddressV6.cpp b/src/libxrpl/beast/net/IPAddressV6.cpp index c75ccaf1cc..e5ef55065f 100644 --- a/src/libxrpl/beast/net/IPAddressV6.cpp +++ b/src/libxrpl/beast/net/IPAddressV6.cpp @@ -4,7 +4,7 @@ #include -namespace beast::IP { +namespace beast::ip { bool isPrivate(AddressV6 const& addr) @@ -58,4 +58,4 @@ isPublic(AddressV6 const& addr) return true; } -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/libxrpl/beast/net/IPEndpoint.cpp b/src/libxrpl/beast/net/IPEndpoint.cpp index 5877151187..02ed5e37c5 100644 --- a/src/libxrpl/beast/net/IPEndpoint.cpp +++ b/src/libxrpl/beast/net/IPEndpoint.cpp @@ -14,7 +14,7 @@ #include #include -namespace beast::IP { +namespace beast::ip { Endpoint::Endpoint() : port_(0) { @@ -176,4 +176,4 @@ operator>>(std::istream& is, Endpoint& endpoint) return is; } -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/libxrpl/ledger/helpers/LendingHelpers.cpp b/src/libxrpl/ledger/helpers/LendingHelpers.cpp index dac2c67181..89b03a03a7 100644 --- a/src/libxrpl/ledger/helpers/LendingHelpers.cpp +++ b/src/libxrpl/ledger/helpers/LendingHelpers.cpp @@ -131,7 +131,7 @@ isRounded(Asset const& asset, Number const& value, std::int32_t scale) roundToAsset(asset, value, scale, Number::RoundingMode::Upward); } -namespace Accrual { +namespace accrual { AccountingDeltas loanOriginationDeltas(Number const& principalRequested, Number const& interestDue) @@ -169,9 +169,9 @@ loanPaymentDeltas(LoanPaymentParts const& parts) .debtTotalDelta = (parts.principalPaid + parts.interestPaid) - parts.valueChange}; } -} // namespace Accrual +} // namespace accrual -namespace CashBasis { +namespace cash_basis { AccountingDeltas loanOriginationDeltas(Number const& principalRequested) @@ -196,7 +196,7 @@ loanPaymentDeltas(LoanPaymentParts const& parts) return {.assetsTotalDelta = parts.interestPaid, .debtTotalDelta = parts.principalPaid}; } -} // namespace CashBasis +} // namespace cash_basis namespace { @@ -219,8 +219,8 @@ loanOriginationDeltas( Number const& interestDue) { return cashBasisEnabled(vaultSle) - ? CashBasis::loanOriginationDeltas(principalRequested) - : Accrual::loanOriginationDeltas(principalRequested, interestDue); + ? cash_basis::loanOriginationDeltas(principalRequested) + : accrual::loanOriginationDeltas(principalRequested, interestDue); } bool @@ -235,21 +235,21 @@ loanOriginationExceedsVaultMaximum( return false; auto const vaultMaximum = vaultSle->at(sfAssetsMaximum); - return Accrual::loanOriginationExceedsVaultMaximum(vaultMaximum, vaultTotal, interestDue); + return accrual::loanOriginationExceedsVaultMaximum(vaultMaximum, vaultTotal, interestDue); } Number loanVaultExposure(SLE::const_ref vaultSle, SLE::const_ref loanSle) { - return cashBasisEnabled(vaultSle) ? CashBasis::loanVaultExposure(loanSle) - : Accrual::loanVaultExposure(loanSle); + return cashBasisEnabled(vaultSle) ? cash_basis::loanVaultExposure(loanSle) + : accrual::loanVaultExposure(loanSle); } AccountingDeltas loanPaymentDeltas(SLE::const_ref vaultSle, LoanPaymentParts const& parts) { - return cashBasisEnabled(vaultSle) ? CashBasis::loanPaymentDeltas(parts) - : Accrual::loanPaymentDeltas(parts); + return cashBasisEnabled(vaultSle) ? cash_basis::loanPaymentDeltas(parts) + : accrual::loanPaymentDeltas(parts); } namespace detail { @@ -1617,7 +1617,7 @@ makeRegularPayment( LoanPaymentType const paymentType, beast::Journal j) { - using namespace Lending; + using namespace lending; XRPL_ASSERT_PARTS( paymentType == LoanPaymentType::Regular || paymentType == LoanPaymentType::Overpayment, diff --git a/src/libxrpl/peerfinder/Bootcache.cpp b/src/libxrpl/peerfinder/Bootcache.cpp index a2a56b4d01..4f9b5fc816 100644 --- a/src/libxrpl/peerfinder/Bootcache.cpp +++ b/src/libxrpl/peerfinder/Bootcache.cpp @@ -16,7 +16,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { Bootcache::Bootcache(Store& store, clock_type& clock, beast::Journal journal) : store_(store), clock_(clock), journal_(journal), whenUpdate_(clock_.now()) @@ -78,7 +78,7 @@ void Bootcache::load() { clear(); - auto const n(store_.load([this](beast::IP::Endpoint const& endpoint, int valence) { + auto const n(store_.load([this](beast::ip::Endpoint const& endpoint, int valence) { auto const result(this->map_.insert(value_type(endpoint, valence))); if (!result.second) { @@ -96,7 +96,7 @@ Bootcache::load() } bool -Bootcache::insert(beast::IP::Endpoint const& endpoint) +Bootcache::insert(beast::ip::Endpoint const& endpoint) { auto const result(map_.insert(value_type(endpoint, 0))); if (result.second) @@ -109,7 +109,7 @@ Bootcache::insert(beast::IP::Endpoint const& endpoint) } bool -Bootcache::insertStatic(beast::IP::Endpoint const& endpoint) +Bootcache::insertStatic(beast::ip::Endpoint const& endpoint) { auto result(map_.insert(value_type(endpoint, kStaticValence))); @@ -130,7 +130,7 @@ Bootcache::insertStatic(beast::IP::Endpoint const& endpoint) } void -Bootcache::onSuccess(beast::IP::Endpoint const& endpoint) +Bootcache::onSuccess(beast::ip::Endpoint const& endpoint) { auto result(map_.insert(value_type(endpoint, 1))); if (result.second) @@ -144,7 +144,7 @@ Bootcache::onSuccess(beast::IP::Endpoint const& endpoint) ++entry.valence(); map_.erase(result.first); result = map_.insert(value_type(endpoint, entry)); - XRPL_ASSERT(result.second, "xrpl::PeerFinder::Bootcache::onSuccess : endpoint inserted"); + XRPL_ASSERT(result.second, "xrpl::peer_finder::Bootcache::onSuccess : endpoint inserted"); } Entry const& entry(result.first->right); JLOG(journal_.info()) << std::left << std::setw(18) << "Bootcache connect " << endpoint @@ -154,7 +154,7 @@ Bootcache::onSuccess(beast::IP::Endpoint const& endpoint) } void -Bootcache::onFailure(beast::IP::Endpoint const& endpoint) +Bootcache::onFailure(beast::ip::Endpoint const& endpoint) { auto result(map_.insert(value_type(endpoint, -1))); if (result.second) @@ -168,7 +168,7 @@ Bootcache::onFailure(beast::IP::Endpoint const& endpoint) --entry.valence(); map_.erase(result.first); result = map_.insert(value_type(endpoint, entry)); - XRPL_ASSERT(result.second, "xrpl::PeerFinder::Bootcache::onFailure : endpoint inserted"); + XRPL_ASSERT(result.second, "xrpl::peer_finder::Bootcache::onFailure : endpoint inserted"); } Entry const& entry(result.first->right); auto const n(std::abs(entry.valence())); @@ -201,11 +201,11 @@ Bootcache::onWrite(beast::PropertyStream::Map& map) void Bootcache::prune() { - if (size() <= Tuning::kBootcacheSize) + if (size() <= tuning::kBootcacheSize) return; // Calculate the amount to remove - auto count((size() * Tuning::kBootcachePrunePercent) / 100); + auto count((size() * tuning::kBootcachePrunePercent) / 100); decltype(count) pruned(0); // Work backwards because bimap doesn't handle @@ -215,7 +215,7 @@ Bootcache::prune() { --count; --iter; - beast::IP::Endpoint const& endpoint(iter->get_left()); + beast::ip::Endpoint const& endpoint(iter->get_left()); Entry const& entry(iter->get_right()); JLOG(journal_.trace()) << std::left << std::setw(18) << "Bootcache pruned" << endpoint << " at valence " << entry.valence(); @@ -244,7 +244,7 @@ Bootcache::update() store_.save(list); // Reset the flag and cooldown timer needsUpdate_ = false; - whenUpdate_ = clock_.now() + Tuning::kBootcacheCooldownTime; + whenUpdate_ = clock_.now() + tuning::kBootcacheCooldownTime; } // Checks the clock and calls update if we are off the cooldown. @@ -263,4 +263,4 @@ Bootcache::flagForUpdate() checkUpdate(); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/peerfinder/Config.cpp b/src/libxrpl/peerfinder/Config.cpp index 3e2f74f42b..60ac0ca547 100644 --- a/src/libxrpl/peerfinder/Config.cpp +++ b/src/libxrpl/peerfinder/Config.cpp @@ -7,13 +7,13 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { std::size_t Config::calcOutPeers() const { return std::max( - ((maxPeers * Tuning::kOutPercent) + 50) / 100, std::size_t(Tuning::kMinOutCount)); + ((maxPeers * tuning::kOutPercent) + 50) / 100, std::size_t(tuning::kMinOutCount)); } void @@ -26,8 +26,8 @@ Config::applyTuning() // IP addresses. ipLimit = 2; - if (inPeers > Tuning::kDefaultMaxPeers) - ipLimit += std::min(5, static_cast(inPeers / Tuning::kDefaultMaxPeers)); + if (inPeers > tuning::kDefaultMaxPeers) + ipLimit += std::min(5, static_cast(inPeers / tuning::kDefaultMaxPeers)); } // We don't allow a single IP to consume all incoming slots, @@ -58,7 +58,7 @@ Config::makeConfig( int ipLimit, bool verifyEndpoints) { - PeerFinder::Config config; + peer_finder::Config config; if (!limits.maxPeers) { @@ -85,7 +85,7 @@ Config::makeConfig( if (limits.maxPeers && *limits.maxPeers != 0) config.maxPeers = *limits.maxPeers; - config.maxPeers = std::max(config.maxPeers, Tuning::kMinOutCount); + config.maxPeers = std::max(config.maxPeers, tuning::kMinOutCount); config.outPeers = config.calcOutPeers(); // Calculate the number of outbound peers we want. If we dont want @@ -132,4 +132,4 @@ Config::makeConfig( return config; } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/peerfinder/Endpoint.cpp b/src/libxrpl/peerfinder/Endpoint.cpp index 12f2725ea5..6f3e2289f9 100644 --- a/src/libxrpl/peerfinder/Endpoint.cpp +++ b/src/libxrpl/peerfinder/Endpoint.cpp @@ -5,11 +5,11 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { -Endpoint::Endpoint(beast::IP::Endpoint ep, std::uint32_t hops) - : hops(std::min(hops, Tuning::kMaxHops + 1)), address(std::move(ep)) +Endpoint::Endpoint(beast::ip::Endpoint ep, std::uint32_t hops) + : hops(std::min(hops, tuning::kMaxHops + 1)), address(std::move(ep)) { } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/peerfinder/PeerfinderManager.cpp b/src/libxrpl/peerfinder/PeerfinderManager.cpp index 2219627f09..0cce2389ec 100644 --- a/src/libxrpl/peerfinder/PeerfinderManager.cpp +++ b/src/libxrpl/peerfinder/PeerfinderManager.cpp @@ -29,7 +29,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { class ManagerImp : public Manager { @@ -98,7 +98,7 @@ public: } void - addFixedPeer(std::string_view name, std::vector const& addresses) override + addFixedPeer(std::string_view name, std::vector const& addresses) override { logic_.addFixedPeer(name, addresses); } @@ -119,14 +119,14 @@ public: std::pair, Result> newInboundSlot( - beast::IP::Endpoint const& localEndpoint, - beast::IP::Endpoint const& remoteEndpoint) override + beast::ip::Endpoint const& localEndpoint, + beast::ip::Endpoint const& remoteEndpoint) override { return logic_.newInboundSlot(localEndpoint, remoteEndpoint); } std::pair, Result> - newOutboundSlot(beast::IP::Endpoint const& remoteEndpoint) override + newOutboundSlot(beast::ip::Endpoint const& remoteEndpoint) override { return logic_.newOutboundSlot(remoteEndpoint); } @@ -163,7 +163,7 @@ public: //-------------------------------------------------------------------------- bool - onConnected(std::shared_ptr const& slot, beast::IP::Endpoint const& localEndpoint) + onConnected(std::shared_ptr const& slot, beast::ip::Endpoint const& localEndpoint) override { SlotImp::ptr const impl(std::dynamic_pointer_cast(slot)); @@ -184,7 +184,7 @@ public: return logic_.redirect(impl); } - std::vector + std::vector autoconnect() override { return logic_.autoconnect(); @@ -265,4 +265,4 @@ makeManager( return std::make_unique(ioContext, clock, journal, store, collector); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/peerfinder/SlotImp.cpp b/src/libxrpl/peerfinder/SlotImp.cpp index 0a4f32fd62..5209bd51ab 100644 --- a/src/libxrpl/peerfinder/SlotImp.cpp +++ b/src/libxrpl/peerfinder/SlotImp.cpp @@ -9,11 +9,11 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { SlotImp::SlotImp( - beast::IP::Endpoint const& localEndpoint, - beast::IP::Endpoint remoteEndpoint, + beast::ip::Endpoint const& localEndpoint, + beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock) : recent(clock) @@ -30,7 +30,7 @@ SlotImp::SlotImp( { } -SlotImp::SlotImp(beast::IP::Endpoint remoteEndpoint, bool fixed, clock_type& clock) +SlotImp::SlotImp(beast::ip::Endpoint remoteEndpoint, bool fixed, clock_type& clock) : recent(clock) , inbound_(false) , fixed_(fixed) @@ -49,29 +49,29 @@ SlotImp::state(State state) { // Must go through activate() to set active state XRPL_ASSERT( - state != State::Active, "xrpl::PeerFinder::SlotImp::state : input state is not active"); + state != State::Active, "xrpl::peer_finder::SlotImp::state : input state is not active"); // The state must be different XRPL_ASSERT( state_ != state, - "xrpl::PeerFinder::SlotImp::state : input state is different from " + "xrpl::peer_finder::SlotImp::state : input state is different from " "current"); // You can't transition into the initial states XRPL_ASSERT( state != State::Accept && state != State::Connect, - "xrpl::PeerFinder::SlotImp::state : input state is not an initial"); + "xrpl::peer_finder::SlotImp::state : input state is not an initial"); // Can only become connected from outbound connect state XRPL_ASSERT( state != State::Connected || (!inbound_ && state_ == State::Connect), - "xrpl::PeerFinder::SlotImp::state : input state is not connected an " + "xrpl::peer_finder::SlotImp::state : input state is not connected an " "invalid state"); // Can't gracefully close on an outbound connection attempt XRPL_ASSERT( state != State::Closing || state_ != State::Connect, - "xrpl::PeerFinder::SlotImp::state : input state is not closing an " + "xrpl::peer_finder::SlotImp::state : input state is not closing an " "invalid state"); state_ = state; @@ -83,7 +83,7 @@ SlotImp::activate(clock_type::time_point const& now) // Can only become active from the accept or connected state XRPL_ASSERT( state_ == State::Accept || state_ == State::Connected, - "xrpl::PeerFinder::SlotImp::activate : valid state"); + "xrpl::peer_finder::SlotImp::activate : valid state"); state_ = State::Active; whenAcceptEndpoints = now; @@ -100,7 +100,7 @@ SlotImp::RecentT::RecentT(clock_type& clock) : cache_(clock) } void -SlotImp::RecentT::insert(beast::IP::Endpoint const& ep, std::uint32_t hops) +SlotImp::RecentT::insert(beast::ip::Endpoint const& ep, std::uint32_t hops) { auto const result(cache_.emplace(ep, hops)); if (!result.second) @@ -115,7 +115,7 @@ SlotImp::RecentT::insert(beast::IP::Endpoint const& ep, std::uint32_t hops) } bool -SlotImp::RecentT::filter(beast::IP::Endpoint const& ep, std::uint32_t hops) +SlotImp::RecentT::filter(beast::ip::Endpoint const& ep, std::uint32_t hops) { auto const iter(cache_.find(ep)); if (iter == cache_.end()) @@ -129,7 +129,7 @@ SlotImp::RecentT::filter(beast::IP::Endpoint const& ep, std::uint32_t hops) void SlotImp::RecentT::expire() { - beast::expire(cache_, Tuning::kLiveCacheSecondsToLive); + beast::expire(cache_, tuning::kLiveCacheSecondsToLive); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/peerfinder/SourceStrings.cpp b/src/libxrpl/peerfinder/SourceStrings.cpp index f47e0cd51d..ca6ff07cba 100644 --- a/src/libxrpl/peerfinder/SourceStrings.cpp +++ b/src/libxrpl/peerfinder/SourceStrings.cpp @@ -8,7 +8,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { class SourceStringsImp : public SourceStrings { @@ -33,9 +33,9 @@ public: results.addresses.reserve(strings_.size()); for (auto const& str : strings_) { - beast::IP::Endpoint ep(beast::IP::Endpoint::fromString(str)); + beast::ip::Endpoint ep(beast::ip::Endpoint::fromString(str)); if (isUnspecified(ep)) - ep = beast::IP::Endpoint::fromString(str); + ep = beast::ip::Endpoint::fromString(str); if (!isUnspecified(ep)) results.addresses.push_back(ep); } @@ -54,4 +54,4 @@ SourceStrings::make(std::string const& name, Strings const& strings) return std::make_shared(name, strings); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/libxrpl/protocol/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp index 6ac352f3e1..8a18b3f228 100644 --- a/src/libxrpl/protocol/BuildInfo.cpp +++ b/src/libxrpl/protocol/BuildInfo.cpp @@ -13,7 +13,7 @@ #include #include -namespace xrpl::BuildInfo { +namespace xrpl::build_info { namespace { @@ -173,4 +173,4 @@ isNewerVersion(std::uint64_t version) return false; } -} // namespace xrpl::BuildInfo +} // namespace xrpl::build_info diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 87761ce13e..e81f975844 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -9,7 +9,7 @@ #include namespace xrpl { -namespace RPC { +namespace rpc { namespace detail { @@ -215,12 +215,12 @@ errorCodeHttpStatus(ErrorCodeI code) return getErrorInfo(code).httpStatus; } -} // namespace RPC +} // namespace rpc std::string rpcErrorString(json::Value const& jv) { - XRPL_ASSERT(RPC::containsError(jv), "xrpl::RPC::rpcErrorString : input contains an error"); + XRPL_ASSERT(rpc::containsError(jv), "xrpl::rpc::rpcErrorString : input contains an error"); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/NFTSyntheticSerializer.cpp b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp index 4f0a2d5071..fd44ae1f33 100644 --- a/src/libxrpl/protocol/NFTSyntheticSerializer.cpp +++ b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp @@ -9,7 +9,7 @@ #include -namespace xrpl::RPC { +namespace xrpl::rpc { void insertNFTSyntheticInJson( @@ -21,4 +21,4 @@ insertNFTSyntheticInJson( insertNFTokenOfferID(response[jss::meta], transaction, transactionMeta); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/libxrpl/protocol/RPCErr.cpp b/src/libxrpl/protocol/RPCErr.cpp index ec9a3dee9d..c172a1898d 100644 --- a/src/libxrpl/protocol/RPCErr.cpp +++ b/src/libxrpl/protocol/RPCErr.cpp @@ -13,7 +13,7 @@ json::Value rpcError(ErrorCodeI iError) { json::Value jvResult(json::ValueType::Object); - RPC::injectError(iError, jvResult); + rpc::injectError(iError, jvResult); return jvResult; } diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index 33ca5424d1..6ab272b3d1 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -48,7 +48,7 @@ namespace xrpl { -namespace STParsedJSONDetail { +namespace st_parsed_json_detail { template constexpr U toUnsigned(S value) @@ -93,7 +93,7 @@ makeName(std::string const& object, std::string const& field) static inline json::Value notAnObject(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' is not a JSON object."); } @@ -106,33 +106,33 @@ notAnObject(std::string const& object) static inline json::Value notAnArray(std::string const& object) { - return RPC::makeError(RpcInvalidParams, "Field '" + object + "' is not a JSON array."); + return rpc::makeError(RpcInvalidParams, "Field '" + object + "' is not a JSON array."); } static inline json::Value unknownField(std::string const& object, std::string const& field) { - return RPC::makeError(RpcInvalidParams, "Field '" + makeName(object, field) + "' is unknown."); + return rpc::makeError(RpcInvalidParams, "Field '" + makeName(object, field) + "' is unknown."); } static inline json::Value outOfRange(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' is out of range."); } static inline json::Value badType(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' has bad type."); } static inline json::Value invalidData(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' has invalid data."); } @@ -145,14 +145,14 @@ invalidData(std::string const& object) static inline json::Value arrayExpected(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a JSON array."); } static inline json::Value arrayTooBig(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' exceeds allowed JSON array size of " + std::to_string(kMaxParsedJsonArraySize) + " elements per field."); @@ -161,20 +161,20 @@ arrayTooBig(std::string const& object, std::string const& field) static inline json::Value stringExpected(std::string const& object, std::string const& field) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + makeName(object, field) + "' must be a string."); } static inline json::Value tooDeep(std::string const& object) { - return RPC::makeError(RpcInvalidParams, "Field '" + object + "' exceeds nesting depth limit."); + return rpc::makeError(RpcInvalidParams, "Field '" + object + "' exceeds nesting depth limit."); } static inline json::Value singletonExpected(std::string const& object, unsigned int index) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Field '" + object + "[" + std::to_string(index) + "]' must be an object with a single key/object value."); @@ -183,7 +183,7 @@ singletonExpected(std::string const& object, unsigned int index) static inline json::Value templateMismatch(SField const& sField) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Object '" + sField.getName() + "' contents did not meet requirements for that type."); } @@ -191,7 +191,7 @@ templateMismatch(SField const& sField) static inline json::Value nonObjectInArray(std::string const& item, json::UInt index) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Item '" + item + "' at index " + std::to_string(index) + " is not an object. Arrays may only contain objects."); @@ -791,7 +791,7 @@ parseLeaf( if (pathEl.isMember(jss::currency) && pathEl.isMember(jss::mpt_issuance_id)) { - error = RPC::makeError(RpcInvalidParams, "Invalid Asset."); + error = rpc::makeError(RpcInvalidParams, "Invalid Asset."); return ret; } @@ -1195,13 +1195,13 @@ parseArray( } } -} // namespace STParsedJSONDetail +} // namespace st_parsed_json_detail //------------------------------------------------------------------------------ STParsedJSONObject::STParsedJSONObject(std::string const& name, json::Value const& json) { - using namespace STParsedJSONDetail; + using namespace st_parsed_json_detail; object = parseObject(name, json, sfGeneric, 0, error); } diff --git a/src/libxrpl/protocol/XChainAttestations.cpp b/src/libxrpl/protocol/XChainAttestations.cpp index 792fe5da9d..7c887e785b 100644 --- a/src/libxrpl/protocol/XChainAttestations.cpp +++ b/src/libxrpl/protocol/XChainAttestations.cpp @@ -24,7 +24,7 @@ #include namespace xrpl { -namespace Attestations { +namespace attestations { AttestationBase::AttestationBase( AccountID attestationSignerAccount, @@ -385,7 +385,7 @@ operator==(AttestationCreateAccount const& lhs, AttestationCreateAccount const& std::tie(rhs.createCount, rhs.toCreate, rhs.rewardAmount); } -} // namespace Attestations +} // namespace attestations SField const& XChainClaimAttestation::arrayFieldName{sfXChainClaimAttestations}; SField const& XChainCreateAccountAttestation::arrayFieldName{sfXChainCreateAccountAttestations}; diff --git a/src/libxrpl/resource/Charge.cpp b/src/libxrpl/resource/Charge.cpp index e174c13522..f80588b143 100644 --- a/src/libxrpl/resource/Charge.cpp +++ b/src/libxrpl/resource/Charge.cpp @@ -6,7 +6,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { Charge::Charge(value_type cost, std::string label) : cost_(cost), label_(std::move(label)) { @@ -57,4 +57,4 @@ Charge::operator*(value_type m) const return Charge(cost_ * m, label_); } -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index 58d5775a31..934aaddbf5 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -12,7 +12,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { Consumer::Consumer(Logic& logic, Entry& entry) : logic_(&logic), entry_(&entry) { @@ -99,14 +99,14 @@ Consumer::charge(Charge const& what, std::string const& context) bool Consumer::warn() { - XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::warn : non-null entry"); + XRPL_ASSERT(entry_, "xrpl::resource::Consumer::warn : non-null entry"); return logic_->warn(*entry_); } bool Consumer::disconnect(beast::Journal const& j) { - XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::disconnect : non-null entry"); + XRPL_ASSERT(entry_, "xrpl::resource::Consumer::disconnect : non-null entry"); bool const d = logic_->disconnect(*entry_); if (d) { @@ -118,14 +118,14 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::balance : non-null entry"); + XRPL_ASSERT(entry_, "xrpl::resource::Consumer::balance : non-null entry"); return logic_->balance(*entry_); } Entry& Consumer::entry() { - XRPL_ASSERT(entry_, "xrpl::Resource::Consumer::entry : non-null entry"); + XRPL_ASSERT(entry_, "xrpl::resource::Consumer::entry : non-null entry"); return *entry_; } @@ -142,4 +142,4 @@ operator<<(std::ostream& os, Consumer const& v) return os; } -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/src/libxrpl/resource/Fees.cpp b/src/libxrpl/resource/Fees.cpp index bb825fa3c7..037f60051e 100644 --- a/src/libxrpl/resource/Fees.cpp +++ b/src/libxrpl/resource/Fees.cpp @@ -2,7 +2,7 @@ #include -namespace xrpl::Resource { +namespace xrpl::resource { Charge const kFeeMalformedRequest(200, "malformed request"); Charge const kFeeRequestNoReply(10, "unsatisfiable request"); @@ -23,6 +23,6 @@ Charge const kFeeHeavyBurdenPeer(2000, "heavy peer request"); Charge const kFeeWarning(4000, "received warning"); Charge const kFeeDrop(6000, "dropped"); -// See also Resource::Logic::charge for log level cutoff values +// See also resource::Logic::charge for log level cutoff values -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/src/libxrpl/resource/ResourceManager.cpp b/src/libxrpl/resource/ResourceManager.cpp index e3b4d9cc5c..cdfa95facd 100644 --- a/src/libxrpl/resource/ResourceManager.cpp +++ b/src/libxrpl/resource/ResourceManager.cpp @@ -23,7 +23,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { class ManagerImp : public Manager { @@ -58,14 +58,14 @@ public: } Consumer - newInboundEndpoint(beast::IP::Endpoint const& address) override + newInboundEndpoint(beast::ip::Endpoint const& address) override { return logic_.newInboundEndpoint(address); } Consumer newInboundEndpoint( - beast::IP::Endpoint const& address, + beast::ip::Endpoint const& address, bool const proxy, std::string_view forwardedFor) override { @@ -85,13 +85,13 @@ public: } Consumer - newOutboundEndpoint(beast::IP::Endpoint const& address) override + newOutboundEndpoint(beast::ip::Endpoint const& address) override { return logic_.newOutboundEndpoint(address); } Consumer - newUnlimitedEndpoint(beast::IP::Endpoint const& address) override + newUnlimitedEndpoint(beast::ip::Endpoint const& address) override { return logic_.newUnlimitedEndpoint(address); } @@ -136,7 +136,7 @@ private: void run() { - beast::setCurrentThreadName("Resource::Mngr"); + beast::setCurrentThreadName("resource::Mngr"); for (;;) { logic_.periodicActivity(); @@ -164,4 +164,4 @@ makeManager(beast::insight::Collector::ptr const& collector, beast::Journal jour return std::make_unique(collector, journal); } -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/src/libxrpl/server/InfoSub.cpp b/src/libxrpl/server/InfoSub.cpp index 353c295856..39883873fb 100644 --- a/src/libxrpl/server/InfoSub.cpp +++ b/src/libxrpl/server/InfoSub.cpp @@ -104,7 +104,7 @@ InfoSub::~InfoSub() } } -Resource::Consumer& +resource::Consumer& InfoSub::getConsumer() { return consumer_; diff --git a/src/libxrpl/server/JSONRPCUtil.cpp b/src/libxrpl/server/JSONRPCUtil.cpp index f38ff280ac..d59582fc1a 100644 --- a/src/libxrpl/server/JSONRPCUtil.cpp +++ b/src/libxrpl/server/JSONRPCUtil.cpp @@ -42,7 +42,7 @@ httpReply(int nStatus, std::string const& content, json::Output const& output, b // CHECKME this returns a different version than the replies below. Is // this by design or an accident or should it be using - // BuildInfo::getFullVersionString () as well? + // build_info::getFullVersionString () as well? output("Server: " + systemName() + "-json-rpc/v1"); output("\r\n"); @@ -123,7 +123,7 @@ httpReply(int nStatus, std::string const& content, json::Output const& output, b "Content-Type: application/json; charset=UTF-8\r\n"); output("Server: " + systemName() + "-json-rpc/"); - output(BuildInfo::getFullVersionString()); + output(build_info::getFullVersionString()); output( "\r\n" "\r\n"); diff --git a/src/libxrpl/server/Port.cpp b/src/libxrpl/server/Port.cpp index c1a79019af..694d4448d5 100644 --- a/src/libxrpl/server/Port.cpp +++ b/src/libxrpl/server/Port.cpp @@ -107,7 +107,7 @@ populate( { // First, check to see if 0.0.0.0 or ipv6 equivalent was configured, // which means all IP addresses. - auto const addr = beast::IP::Endpoint::fromStringChecked(ip); + auto const addr = beast::ip::Endpoint::fromStringChecked(ip); if (addr) { if (isUnspecified(*addr)) diff --git a/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp b/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp index e03cb56fd5..cbfb93c386 100644 --- a/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp +++ b/src/libxrpl/tx/transactors/bridge/XChainBridge.cpp @@ -864,7 +864,7 @@ applyClaimAttestations( return std::unexpected(tecXCHAIN_NO_CLAIM_ID); // Add claims that are part of the signer's list to the "claims" vector - std::vector atts; + std::vector atts; atts.reserve(std::distance(attBegin, attEnd)); for (auto att = attBegin; att != attEnd; ++att) { @@ -1042,7 +1042,7 @@ applyCreateAccountAttestations( return std::unexpected(tecINSUFFICIENT_RESERVE); } - std::vector atts; + std::vector atts; atts.reserve(std::distance(attBegin, attEnd)); for (auto att = attBegin; att != attEnd; ++att) { @@ -1160,8 +1160,8 @@ std::optional toClaim(STTx const& tx) { static_assert( - std::is_same_v || - std::is_same_v); + std::is_same_v || + std::is_same_v); try { @@ -1301,10 +1301,10 @@ attestationDoApply(ApplyContext& ctx) auto const& [srcChain, signersList, quorum, thisDoor, bridgeK] = scopeResult.value(); static_assert( - std::is_same_v || - std::is_same_v); + std::is_same_v || + std::is_same_v); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { return applyClaimAttestations( ctx.view(), @@ -1317,7 +1317,7 @@ attestationDoApply(ApplyContext& ctx) quorum, ctx.journal); } - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) { return applyCreateAccountAttestations( ctx.view(), @@ -2067,19 +2067,19 @@ XChainCreateClaimID::doApply() NotTEC XChainAddClaimAttestation::preflight(PreflightContext const& ctx) { - return attestationPreflight(ctx); + return attestationPreflight(ctx); } TER XChainAddClaimAttestation::preclaim(PreclaimContext const& ctx) { - return attestationPreclaim(ctx); + return attestationPreclaim(ctx); } TER XChainAddClaimAttestation::doApply() { - return attestationDoApply(ctx_); + return attestationDoApply(ctx_); } //------------------------------------------------------------------------------ @@ -2087,19 +2087,19 @@ XChainAddClaimAttestation::doApply() NotTEC XChainAddAccountCreateAttestation::preflight(PreflightContext const& ctx) { - return attestationPreflight(ctx); + return attestationPreflight(ctx); } TER XChainAddAccountCreateAttestation::preclaim(PreclaimContext const& ctx) { - return attestationPreclaim(ctx); + return attestationPreclaim(ctx); } TER XChainAddAccountCreateAttestation::doApply() { - return attestationDoApply(ctx_); + return attestationDoApply(ctx_); } //------------------------------------------------------------------------------ diff --git a/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp b/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp index e9c153404c..b12cfb692f 100644 --- a/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanBrokerSet.cpp @@ -34,7 +34,7 @@ LoanBrokerSet::checkExtraFeatures(PreflightContext const& ctx) NotTEC LoanBrokerSet::preflight(PreflightContext const& ctx) { - using namespace Lending; + using namespace lending; auto const& tx = ctx.tx; if (auto const data = tx[~sfData]; diff --git a/src/libxrpl/tx/transactors/lending/LoanPay.cpp b/src/libxrpl/tx/transactors/lending/LoanPay.cpp index 0053ed496e..74e8efeda2 100644 --- a/src/libxrpl/tx/transactors/lending/LoanPay.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanPay.cpp @@ -73,7 +73,7 @@ LoanPay::preflight(PreflightContext const& ctx) XRPAmount LoanPay::calculateBaseFee(ReadView const& view, STTx const& tx) { - using namespace Lending; + using namespace lending; auto const normalCost = Transactor::calculateBaseFee(view, tx); diff --git a/src/libxrpl/tx/transactors/lending/LoanSet.cpp b/src/libxrpl/tx/transactors/lending/LoanSet.cpp index bafadd7c1d..95a9581dd3 100644 --- a/src/libxrpl/tx/transactors/lending/LoanSet.cpp +++ b/src/libxrpl/tx/transactors/lending/LoanSet.cpp @@ -53,7 +53,7 @@ LoanSet::getFlagsMask(PreflightContext const& ctx) NotTEC LoanSet::preflight(PreflightContext const& ctx) { - using namespace Lending; + using namespace lending; auto const& tx = ctx.tx; diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index ffaf26b5a7..5230a1f7dd 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -3179,7 +3179,7 @@ class Batch_test : public beast::unit_test::Suite auto const brokerKeylet = keylet::loanBroker(lender.id(), env.seq(lender)); { - using namespace loanBroker; + using namespace loan_broker; env(set(lender, vaultKeylet.key), kManagementFeeRate(TenthBips16(100)), kDebtMaximum(debtMaximumValue), diff --git a/src/test/app/Delegate_test.cpp b/src/test/app/Delegate_test.cpp index 257ed33619..788514e284 100644 --- a/src/test/app/Delegate_test.cpp +++ b/src/test/app/Delegate_test.cpp @@ -2823,15 +2823,15 @@ class Delegate_test : public beast::unit_test::Suite auto [createTx, keylet] = vault.create({.owner = alice, .asset = xrpIssue()}); env(createTx); - env(loanBroker::set(alice, keylet.key), delegate::As(bob), Ter(temINVALID)); - env(loanBroker::del(alice, keylet.key), delegate::As(bob), Ter(temINVALID)); - env(loanBroker::coverDeposit(alice, keylet.key, XRP(1)), + env(loan_broker::set(alice, keylet.key), delegate::As(bob), Ter(temINVALID)); + env(loan_broker::del(alice, keylet.key), delegate::As(bob), Ter(temINVALID)); + env(loan_broker::coverDeposit(alice, keylet.key, XRP(1)), delegate::As(bob), Ter(temINVALID)); - env(loanBroker::coverWithdraw(alice, keylet.key, XRP(1)), + env(loan_broker::coverWithdraw(alice, keylet.key, XRP(1)), delegate::As(bob), Ter(temINVALID)); - env(loanBroker::coverClawback(alice), delegate::As(bob), Ter(temINVALID)); + env(loan_broker::coverClawback(alice), delegate::As(bob), Ter(temINVALID)); env(loan::set(alice, keylet.key, Number(100)), delegate::As(bob), Ter(temINVALID)); env(loan::manage(alice, keylet.key, 0), delegate::As(bob), Ter(temINVALID)); diff --git a/src/test/app/FixNFTokenPageLinks_test.cpp b/src/test/app/FixNFTokenPageLinks_test.cpp index 7b13fc060b..9be01b2abe 100644 --- a/src/test/app/FixNFTokenPageLinks_test.cpp +++ b/src/test/app/FixNFTokenPageLinks_test.cpp @@ -139,7 +139,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite env.fund(XRP(1000), alice); auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(temDISABLED)); + env(ledger_state_fix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(temDISABLED)); } Env env{*this, testableAmendments()}; @@ -151,38 +151,38 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite { // Fail preflight1. Can't combine AccountTxnID and ticket. - json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledger_state_fix::nftPageLinks(alice, alice); tx[sfAccountTxnID.jsonName] = "00000000000000000000000000000000" "00000000000000000000000000000000"; env(tx, ticket::Use(ticketSeq), Ter(temINVALID)); } // Fee too low. - env(ledgerStateFix::nftPageLinks(alice, alice), Ter(telINSUF_FEE_P)); + env(ledger_state_fix::nftPageLinks(alice, alice), Ter(telINSUF_FEE_P)); // Invalid flags. auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(alice, alice), + env(ledger_state_fix::nftPageLinks(alice, alice), Fee(linkFixFee), Txflags(tfPassive), Ter(temINVALID_FLAG)); { - // ledgerStateFix::nftPageLinks requires an Owner field. - json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + // ledger_state_fix::nftPageLinks requires an Owner field. + json::Value tx = ledger_state_fix::nftPageLinks(alice, alice); tx.removeMember(sfOwner.jsonName); env(tx, Fee(linkFixFee), Ter(temINVALID)); } { // NFTokenPageLink fixes require sfOwner and reject fields that // belong to other LedgerStateFix types. - json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledger_state_fix::nftPageLinks(alice, alice); tx[sfBookDirectory.jsonName] = to_string(uint256{1}); env(tx, Fee(linkFixFee), Ter(temINVALID)); } { // Invalid LedgerFixType codes. - json::Value tx = ledgerStateFix::nftPageLinks(alice, alice); + json::Value tx = ledger_state_fix::nftPageLinks(alice, alice); tx[sfLedgerFixType.jsonName] = 0; env(tx, Fee(linkFixFee), Ter(tefINVALID_LEDGER_FIX_TYPE)); @@ -193,7 +193,9 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite // Preclaim Account const carol("carol"); env.memoize(carol); - env(ledgerStateFix::nftPageLinks(alice, carol), Fee(linkFixFee), Ter(tecOBJECT_NOT_FOUND)); + env(ledger_state_fix::nftPageLinks(alice, carol), + Fee(linkFixFee), + Ter(tecOBJECT_NOT_FOUND)); } void @@ -214,13 +216,17 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite // Owner has no pages to fix. auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); + env(ledger_state_fix::nftPageLinks(alice, alice), + Fee(linkFixFee), + Ter(tecFAILED_PROCESSING)); // Alice has only one page. env(token::mint(alice), Txflags(tfTransferable)); env.close(); - env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); + env(ledger_state_fix::nftPageLinks(alice, alice), + Fee(linkFixFee), + Ter(tecFAILED_PROCESSING)); // Alice has at least three pages. for (std::uint32_t i = 0; i < 64; ++i) @@ -229,7 +235,9 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite env.close(); } - env(ledgerStateFix::nftPageLinks(alice, alice), Fee(linkFixFee), Ter(tecFAILED_PROCESSING)); + env(ledger_state_fix::nftPageLinks(alice, alice), + Fee(linkFixFee), + Ter(tecFAILED_PROCESSING)); } void @@ -439,7 +447,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite //********************************************************************** // Verify that the LedgerStateFix transaction is not enabled. auto const linkFixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::nftPageLinks(daria, alice), Fee(linkFixFee), Ter(temDISABLED)); + env(ledger_state_fix::nftPageLinks(daria, alice), Fee(linkFixFee), Ter(temDISABLED)); // Wait 15 ledgers so the LedgerStateFix transaction is no longer // retried. @@ -475,7 +483,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite env(noop(daria)); // daria fixes the links in alice's NFToken directory. - env(ledgerStateFix::nftPageLinks(daria, alice), Fee(linkFixFee)); + env(ledger_state_fix::nftPageLinks(daria, alice), Fee(linkFixFee)); env.close(); // alice's last page should now be present and include no links. @@ -516,7 +524,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite } // daria fixes the links in bob's NFToken directory. - env(ledgerStateFix::nftPageLinks(daria, bob), Fee(linkFixFee)); + env(ledger_state_fix::nftPageLinks(daria, bob), Fee(linkFixFee)); env.close(); // bob's last page should now be present and include a previous @@ -574,7 +582,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::Suite } // carol fixes the links in their own NFToken directory. - env(ledgerStateFix::nftPageLinks(carol, carol), Fee(linkFixFee)); + env(ledger_state_fix::nftPageLinks(carol, carol), Fee(linkFixFee)); env.close(); { diff --git a/src/test/app/Invariants_test.cpp b/src/test/app/Invariants_test.cpp index ac6d8e068f..9bc9524f80 100644 --- a/src/test/app/Invariants_test.cpp +++ b/src/test/app/Invariants_test.cpp @@ -2412,7 +2412,7 @@ class Invariants_test : public beast::unit_test::Suite vaultID = vKeylet.key; // Create Loan Broker - using namespace loanBroker; + using namespace loan_broker; auto const loanBrokerKeylet = keylet::loanBroker(a.id(), env.seq(a)); // Create a Loan Broker with all default values. @@ -2721,7 +2721,7 @@ class Invariants_test : public beast::unit_test::Suite brokerKeylet = this->createLoanBroker(alice, env, asset); if (!BEAST_EXPECT(env.le(brokerKeylet))) return false; - env(loanBroker::coverDeposit(alice, brokerKeylet.key, asset(10))); + env(loan_broker::coverDeposit(alice, brokerKeylet.key, asset(10))); env.close(); return BEAST_EXPECT(env.le(brokerKeylet)); }; diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 4cc83608d6..7b521402a4 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -280,13 +280,13 @@ public: send(std::shared_ptr const& m) override { } - [[nodiscard]] beast::IP::Endpoint + [[nodiscard]] beast::ip::Endpoint getRemoteAddress() const override { return {}; } void - charge(Resource::Charge const& fee, std::string const& context = {}) override + charge(resource::Charge const& fee, std::string const& context = {}) override { } [[nodiscard]] id_t @@ -1206,7 +1206,7 @@ struct LedgerReplayer_test : public beast::unit_test::Suite if (serverResult != expecting) return false; - beast::IP::Address const addr = boost::asio::ip::make_address("172.1.1.100"); + beast::ip::Address const addr = boost::asio::ip::make_address("172.1.1.100"); jtx::Env serverEnv(*this); serverEnv.app().config().ledgerReplay = server; auto httpResp = xrpl::makeResponse( diff --git a/src/test/app/LendingHelpers_test.cpp b/src/test/app/LendingHelpers_test.cpp index 1235920fab..5d67cdc3c5 100644 --- a/src/test/app/LendingHelpers_test.cpp +++ b/src/test/app/LendingHelpers_test.cpp @@ -1475,7 +1475,7 @@ class LendingHelpers_test : public beast::unit_test::Suite void testAccrualLoanOriginationDeltas() { - using namespace xrpl::Accrual; + using namespace xrpl::accrual; struct TestCase { @@ -1495,7 +1495,7 @@ class LendingHelpers_test : public beast::unit_test::Suite for (auto const& tc : testCases) { - testcase("Accrual::loanOriginationDeltas: " + tc.name); + testcase("accrual::loanOriginationDeltas: " + tc.name); auto const deltas = loanOriginationDeltas(tc.principalRequested, tc.interestDue); BEAST_EXPECTS( @@ -1513,9 +1513,9 @@ class LendingHelpers_test : public beast::unit_test::Suite void testCashBasisLoanOriginationDeltas() { - using namespace xrpl::CashBasis; + using namespace xrpl::cash_basis; - testcase("CashBasis::loanOriginationDeltas: interestDue is ignored"); + testcase("cash_basis::loanOriginationDeltas: interestDue is ignored"); Number const principalRequested{1'000}; Number const interestDue{75}; @@ -1533,7 +1533,7 @@ class LendingHelpers_test : public beast::unit_test::Suite void testAccrualLoanOriginationExceedsVaultMaximum() { - using namespace xrpl::Accrual; + using namespace xrpl::accrual; struct TestCase { @@ -1569,7 +1569,7 @@ class LendingHelpers_test : public beast::unit_test::Suite for (auto const& tc : testCases) { - testcase("Accrual::loanOriginationExceedsVaultMaximum: " + tc.name); + testcase("accrual::loanOriginationExceedsVaultMaximum: " + tc.name); BEAST_EXPECT( loanOriginationExceedsVaultMaximum( tc.vaultMaximum, tc.vaultTotal, tc.interestDue) == tc.expected); @@ -1613,19 +1613,19 @@ class LendingHelpers_test : public beast::unit_test::Suite void testAccrualLoanVaultExposure() { - testcase("Accrual::loanVaultExposure"); + testcase("accrual::loanVaultExposure"); auto sle = makeLoanSle(Number{1'000}, Number{800}, Number{50}); - BEAST_EXPECT(xrpl::Accrual::loanVaultExposure(sle) == Number{950}); + BEAST_EXPECT(xrpl::accrual::loanVaultExposure(sle) == Number{950}); } void testCashBasisLoanVaultExposure() { - testcase("CashBasis::loanVaultExposure"); + testcase("cash_basis::loanVaultExposure"); auto sle = makeLoanSle(Number{1'000}, Number{800}, Number{50}); - BEAST_EXPECT(xrpl::CashBasis::loanVaultExposure(sle) == Number{800}); + BEAST_EXPECT(xrpl::cash_basis::loanVaultExposure(sle) == Number{800}); } void @@ -1641,8 +1641,8 @@ class LendingHelpers_test : public beast::unit_test::Suite .feePaid = Number{3}}; { - testcase("Accrual::loanPaymentDeltas: nonzero valueChange"); - auto const deltas = xrpl::Accrual::loanPaymentDeltas(parts); + testcase("accrual::loanPaymentDeltas: nonzero valueChange"); + auto const deltas = xrpl::accrual::loanPaymentDeltas(parts); BEAST_EXPECT(deltas.assetsTotalDelta == parts.valueChange); BEAST_EXPECT( deltas.debtTotalDelta == @@ -1650,8 +1650,8 @@ class LendingHelpers_test : public beast::unit_test::Suite } { - testcase("CashBasis::loanPaymentDeltas: nonzero valueChange ignored"); - auto const deltas = xrpl::CashBasis::loanPaymentDeltas(parts); + testcase("cash_basis::loanPaymentDeltas: nonzero valueChange ignored"); + auto const deltas = xrpl::cash_basis::loanPaymentDeltas(parts); BEAST_EXPECT(deltas.assetsTotalDelta == parts.interestPaid); BEAST_EXPECT(deltas.debtTotalDelta == parts.principalPaid); } @@ -1675,7 +1675,7 @@ class LendingHelpers_test : public beast::unit_test::Suite Env const env{*this}; auto const deltas = loanOriginationDeltas(legacyVault, principalRequested, interestDue); auto const expected = - xrpl::Accrual::loanOriginationDeltas(principalRequested, interestDue); + xrpl::accrual::loanOriginationDeltas(principalRequested, interestDue); BEAST_EXPECT(deltas.assetsTotalDelta == expected.assetsTotalDelta); BEAST_EXPECT(deltas.debtTotalDelta == expected.debtTotalDelta); } @@ -1687,7 +1687,7 @@ class LendingHelpers_test : public beast::unit_test::Suite Env const env{*this}; auto const deltas = loanOriginationDeltas(cashBasisVault, principalRequested, interestDue); - auto const expected = xrpl::CashBasis::loanOriginationDeltas(principalRequested); + auto const expected = xrpl::cash_basis::loanOriginationDeltas(principalRequested); BEAST_EXPECT(deltas.assetsTotalDelta == expected.assetsTotalDelta); BEAST_EXPECT(deltas.debtTotalDelta == expected.debtTotalDelta); } @@ -1713,7 +1713,7 @@ class LendingHelpers_test : public beast::unit_test::Suite Env const env{*this}; BEAST_EXPECT( loanOriginationExceedsVaultMaximum(legacyVault, vaultTotal, interestDue) == - xrpl::Accrual::loanOriginationExceedsVaultMaximum( + xrpl::accrual::loanOriginationExceedsVaultMaximum( vaultMaximum, vaultTotal, interestDue)); } @@ -1741,7 +1741,7 @@ class LendingHelpers_test : public beast::unit_test::Suite Env const env{*this}; auto sle = makeLoanSle(Number{1'000}, Number{800}, Number{50}); BEAST_EXPECT( - loanVaultExposure(legacyVault, sle) == xrpl::Accrual::loanVaultExposure(sle)); + loanVaultExposure(legacyVault, sle) == xrpl::accrual::loanVaultExposure(sle)); } { @@ -1752,7 +1752,7 @@ class LendingHelpers_test : public beast::unit_test::Suite Env const env{*this}; auto sle = makeLoanSle(Number{1'000}, Number{800}, Number{50}); BEAST_EXPECT( - loanVaultExposure(cashBasisVault, sle) == xrpl::CashBasis::loanVaultExposure(sle)); + loanVaultExposure(cashBasisVault, sle) == xrpl::cash_basis::loanVaultExposure(sle)); } } @@ -1774,7 +1774,7 @@ class LendingHelpers_test : public beast::unit_test::Suite testcase("loanPaymentDeltas dispatcher: amendment enabled, legacy vault picks Accrual"); Env const env{*this}; auto const deltas = loanPaymentDeltas(legacyVault, parts); - auto const expected = xrpl::Accrual::loanPaymentDeltas(parts); + auto const expected = xrpl::accrual::loanPaymentDeltas(parts); BEAST_EXPECT(deltas.assetsTotalDelta == expected.assetsTotalDelta); BEAST_EXPECT(deltas.debtTotalDelta == expected.debtTotalDelta); } @@ -1786,7 +1786,7 @@ class LendingHelpers_test : public beast::unit_test::Suite "picks CashBasis"); Env const env{*this}; auto const deltas = loanPaymentDeltas(cashBasisVault, parts); - auto const expected = xrpl::CashBasis::loanPaymentDeltas(parts); + auto const expected = xrpl::cash_basis::loanPaymentDeltas(parts); BEAST_EXPECT(deltas.assetsTotalDelta == expected.assetsTotalDelta); BEAST_EXPECT(deltas.debtTotalDelta == expected.debtTotalDelta); } diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index f6f85a0cca..ee398bfc3b 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -93,7 +93,7 @@ class LoanBroker_test : public beast::unit_test::Suite env.close(); BEAST_EXPECT(static_cast(env.le(keylet)) == goodVault); - using namespace loanBroker; + using namespace loan_broker; // Can't create a loan broker regardless of whether the vault exists env(set(alice, keylet.key), Ter(temDISABLED)); auto const brokerKeylet = keylet::loanBroker(alice.id(), env.seq(alice)); @@ -168,7 +168,7 @@ class LoanBroker_test : public beast::unit_test::Suite } using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; // Bogus assets to use in test cases static PrettyAsset const kBadMptAsset = [&]() { @@ -645,8 +645,8 @@ class LoanBroker_test : public beast::unit_test::Suite } } - using namespace loanBroker; - using namespace xrpl::Lending; + using namespace loan_broker; + using namespace xrpl::lending; TenthBips32 const tenthBipsZero{0}; @@ -862,7 +862,7 @@ class LoanBroker_test : public beast::unit_test::Suite LoanBrokerTest brokerTest) { using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; Env env(*this); @@ -1093,7 +1093,7 @@ class LoanBroker_test : public beast::unit_test::Suite { testcase("Invalid LoanBrokerCoverClawback"); using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; // preflight { @@ -1220,7 +1220,7 @@ class LoanBroker_test : public beast::unit_test::Suite auto const brokerKeylet = keylet::loanBroker(alice.id(), env.seq(alice)); // Create LoanBroker pointing to the vault - env(loanBroker::set(alice, vaultKeylet.key)); + env(loan_broker::set(alice, vaultKeylet.key)); env.close(); // Build the CoverDeposit STTx directly @@ -1256,7 +1256,7 @@ class LoanBroker_test : public beast::unit_test::Suite { testcase("Require Auth - Implicit Pseudo-account authorization"); using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; @@ -1364,7 +1364,7 @@ class LoanBroker_test : public beast::unit_test::Suite { testcase("testLoanBrokerSetDebtMaximum"); using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; Env env(*this); @@ -1550,10 +1550,10 @@ class LoanBroker_test : public beast::unit_test::Suite auto const brokerKeylet = keylet::loanBroker(broker, env.seq(broker)); - env(loanBroker::set(broker, keylet.key)); + env(loan_broker::set(broker, keylet.key)); env.close(); - env(loanBroker::coverDeposit(broker, brokerKeylet.key, deposit), Ter(err)); + env(loan_broker::coverDeposit(broker, brokerKeylet.key, deposit), Ter(err)); env.close(); }; @@ -1621,7 +1621,7 @@ class LoanBroker_test : public beast::unit_test::Suite auto const vaultPseudoAcct = Account("VaultPseudo", vaultPseudo); env(trust(issuer, vaultPseudoAcct["IOU"](0), tfSetFreeze)); - env(loanBroker::set(lender, vaultKeylet.key), Ter(tecFROZEN)); + env(loan_broker::set(lender, vaultKeylet.key), Ter(tecFROZEN)); } void @@ -1629,7 +1629,7 @@ class LoanBroker_test : public beast::unit_test::Suite { testcase << "LoanBrokerDelete - locked broker pseudo-account MPT"; using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer("issuer"); Account const alice("alice"); @@ -1749,7 +1749,7 @@ class LoanBroker_test : public beast::unit_test::Suite { testcase << "LoanBrokerDelete - frozen broker pseudo-account IOU"; using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer("issuer"); Account const alice("alice"); @@ -1833,7 +1833,7 @@ class LoanBroker_test : public beast::unit_test::Suite testCoverDepositFreezes() { using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; @@ -1984,7 +1984,7 @@ class LoanBroker_test : public beast::unit_test::Suite testcase("LoanBrokerCoverWithdraw IOU self-withdrawal while individually frozen"); using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; @@ -2046,7 +2046,7 @@ class LoanBroker_test : public beast::unit_test::Suite testCoverWithdrawFreezes() { using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; @@ -2351,7 +2351,7 @@ class LoanBroker_test : public beast::unit_test::Suite env.close(); env(vault.withdraw({.depositor = broker, .id = keylet.key, .amount = token(1'000)}), - loanBroker::kDestination(dest), + loan_broker::kDestination(dest), Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); @@ -2361,14 +2361,14 @@ class LoanBroker_test : public beast::unit_test::Suite // Test LoanBroker withdraw auto const brokerKeylet = keylet::loanBroker(broker, env.seq(broker)); - env(loanBroker::set(broker, keylet.key)); + env(loan_broker::set(broker, keylet.key)); env.close(); - env(loanBroker::coverDeposit(broker, brokerKeylet.key, token(1'000))); + env(loan_broker::coverDeposit(broker, brokerKeylet.key, token(1'000))); env.close(); - env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::kDestination(dest), + env(loan_broker::coverWithdraw(broker, brokerKeylet.key, token(100)), + loan_broker::kDestination(dest), Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); @@ -2379,8 +2379,8 @@ class LoanBroker_test : public beast::unit_test::Suite env(fclear(issuer, asfRequireAuth)); env.close(); - env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::kDestination(dest), + env(loan_broker::coverWithdraw(broker, brokerKeylet.key, token(100)), + loan_broker::kDestination(dest), Ter(std::ignore)); BEAST_EXPECT(env.ter() == tecNO_LINE); env.close(); @@ -2472,7 +2472,7 @@ class LoanBroker_test : public beast::unit_test::Suite env.close(); env(vault.withdraw({.depositor = broker, .id = keylet.key, .amount = token(1'000)}), - loanBroker::kDestination(dest), + loan_broker::kDestination(dest), Ter(std::ignore)); // Shouldn't fail if at MaximumAmount since no new tokens are issued @@ -2489,14 +2489,14 @@ class LoanBroker_test : public beast::unit_test::Suite // Test LoanBroker withdraw auto const brokerKeylet = keylet::loanBroker(broker, env.seq(broker)); - env(loanBroker::set(broker, keylet.key)); + env(loan_broker::set(broker, keylet.key)); env.close(); - env(loanBroker::coverDeposit(broker, brokerKeylet.key, token(1'000))); + env(loan_broker::coverDeposit(broker, brokerKeylet.key, token(1'000))); env.close(); - env(loanBroker::coverWithdraw(broker, brokerKeylet.key, token(100)), - loanBroker::kDestination(dest), + env(loan_broker::coverWithdraw(broker, brokerKeylet.key, token(100)), + loan_broker::kDestination(dest), Ter(std::ignore)); BEAST_EXPECT(env.ter() == err); env.close(); @@ -2522,7 +2522,7 @@ class LoanBroker_test : public beast::unit_test::Suite testCoverPrecisionGuard() { using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Account const issuer{"issuer"}; Account const alice{"alice"}; diff --git a/src/test/app/Loan_test.cpp b/src/test/app/Loan_test.cpp index 8a6f1669df..977cdb443c 100644 --- a/src/test/app/Loan_test.cpp +++ b/src/test/app/Loan_test.cpp @@ -545,7 +545,7 @@ protected: auto const keylet = keylet::loanBroker(lender.id(), env.seq(lender)); - using namespace loanBroker; + using namespace loan_broker; env(set(lender, vaultKeylet.key, params.flags), kData(params.data), kManagementFeeRate(params.managementFeeRate), @@ -1533,7 +1533,7 @@ protected: auto const borrowerStartingBalance = env.balance(borrower, broker.asset); // Try to delete the loan broker with an active loan - env(loanBroker::del(lender, broker.brokerID), Ter(tecHAS_OBLIGATIONS)); + env(loan_broker::del(lender, broker.brokerID), Ter(tecHAS_OBLIGATIONS)); // Ensure the above tx doesn't get ordered after the LoanDelete and // delete our broker! env.close(); @@ -1608,7 +1608,7 @@ protected: int interestExponent) { using namespace jtx; - using namespace Lending; + using namespace lending; auto const& asset = broker.asset.raw(); auto const currencyLabel = getCurrencyLabel(asset); @@ -2072,7 +2072,7 @@ protected: Number const& startingCoverAvailable, Number const& amountToBeCovered) { coverAvailable(broker.brokerID, startingCoverAvailable - amountToBeCovered); - env(loanBroker::coverDeposit( + env(loan_broker::coverDeposit( brokerAcct, broker.brokerID, STAmount{broker.asset, amountToBeCovered})); coverAvailable(broker.brokerID, startingCoverAvailable); env.close(); @@ -3572,7 +3572,7 @@ protected: BEAST_EXPECT(brokerSle->at(sfDebtTotal) == 0); auto const coverAvailable = brokerSle->at(sfCoverAvailable); - env(loanBroker::coverWithdraw( + env(loan_broker::coverWithdraw( lender, broker.brokerID, STAmount(broker.asset, coverAvailable))); env.close(); @@ -3580,7 +3580,7 @@ protected: BEAST_EXPECT(brokerSle && brokerSle->at(sfCoverAvailable) == 0); } // Verify we can delete the loan broker - env(loanBroker::del(lender, broker.brokerID)); + env(loan_broker::del(lender, broker.brokerID)); env.close(); } } @@ -4659,7 +4659,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - using namespace Lending; + using namespace lending; Env env(*this, features); Account const issuer{"issuer"}; @@ -4818,7 +4818,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - using namespace Lending; + using namespace lending; Env env(*this, features); Account const issuer{"issuer"}; @@ -4959,7 +4959,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - using namespace Lending; + using namespace lending; Env env(*this, features); Account const issuer{"issuer"}; @@ -5060,7 +5060,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - using namespace Lending; + using namespace lending; Env env(*this, features); Account const issuer{"issuer"}; @@ -5084,7 +5084,7 @@ protected: BrokerInfo const broker{createVaultAndBroker(env, iouAsset, lender)}; { auto const coverDepositValue = broker.asset(broker.params.coverDeposit * 10).value(); - env(loanBroker::coverDeposit(lender, broker.brokerID, coverDepositValue)); + env(loan_broker::coverDeposit(lender, broker.brokerID, coverDepositValue)); env.close(); } @@ -5145,7 +5145,7 @@ protected: using namespace jtx; using namespace std::chrono_literals; - using namespace Lending; + using namespace lending; Env env{*this, features}; Account const issuer{"issuer"}; @@ -5450,7 +5450,7 @@ protected: testcase("Lending: CanTrade disabled has no impact"); using namespace jtx; using namespace loan; - using namespace loanBroker; + using namespace loan_broker; Env env(*this, all_); @@ -5671,7 +5671,7 @@ protected: using namespace jtx; using namespace loan; - using namespace loanBroker; + using namespace loan_broker; Env env(*this, features); @@ -6283,7 +6283,7 @@ protected: auto const brokerKeyLet = keylet::loanBroker(lender.id(), env.seq(lender)); - env(loanBroker::set(lender, vaultKeyLet.key), txFee); + env(loan_broker::set(lender, vaultKeyLet.key), txFee); env.close(); // BrokerInfo brokerInfo{xrpIssue(), keylet, vaultKeyLet, {}}; @@ -6317,7 +6317,7 @@ protected: testcase("Minimum cover rounding allows undercoverage (XRP)"); using namespace jtx; - using namespace loanBroker; + using namespace loan_broker; Env env{*this, features}; @@ -6488,7 +6488,7 @@ protected: auto const brokerKeylet = keylet::loanBroker(broker.id(), env.seq(broker)); - env(loanBroker::set(broker, vaultKeylet.key), txFee); + env(loan_broker::set(broker, vaultKeylet.key), txFee); env.close(); auto const serviceFee = 101; @@ -6767,7 +6767,7 @@ protected: // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. auto const additionalCover = iou(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{iou, additionalCover})); + env(loan_broker::coverDeposit(broker, brokerInfo.brokerID, STAmount{iou, additionalCover})); env.close(); // Verify broker owner has a trustline auto const brokerTrustline = keylet::trustLine(broker, iou); @@ -6847,7 +6847,7 @@ protected: // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. auto const additionalCover = mpt(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); + env(loan_broker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); env.close(); // Verify broker owner is authorized auto const brokerMpt = keylet::mptoken(mptt.issuanceID(), broker); @@ -6947,7 +6947,7 @@ protected: // at least 1,000 cover. Default cover is 1,000, so we add more to be // safe. auto const additionalCover = mpt(50'000).value(); - env(loanBroker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); + env(loan_broker::coverDeposit(broker, brokerInfo.brokerID, STAmount{mpt, additionalCover})); env.close(); // Verify broker owner is authorized auto const brokerMpt = keylet::mptoken(mptt.issuanceID(), broker); @@ -7062,7 +7062,7 @@ protected: using namespace jtx; using namespace loan; - using namespace loanBroker; + using namespace loan_broker; Env env{*this, features}; @@ -7923,8 +7923,8 @@ protected: env.close(); auto const brokerKeylet = keylet::loanBroker(lender.id(), env.seq(lender)); - env(loanBroker::set(lender, vaultKeylet.key), - loanBroker::kDebtMaximum(Number{100}), + env(loan_broker::set(lender, vaultKeylet.key), + loan_broker::kDebtMaximum(Number{100}), Fee(env.current()->fees().base * 2)); env.close(); @@ -8168,7 +8168,7 @@ protected: { using namespace jtx; using namespace loan; - using namespace loanBroker; + using namespace loan_broker; bool const withAmendment = features[fixCleanup3_2_0]; @@ -8726,9 +8726,9 @@ protected: BrokerInfo const broker{createVaultAndBroker(env, xrpAsset, lender, brokerParams)}; - env(loanBroker::set(lender, broker.vaultID), - loanBroker::kLoanBrokerId(broker.brokerID), - loanBroker::kDebtMaximum(debtMaximum), + env(loan_broker::set(lender, broker.vaultID), + loan_broker::kLoanBrokerId(broker.brokerID), + loan_broker::kDebtMaximum(debtMaximum), Fee(env.current()->fees().base * 2)); env.close(); diff --git a/src/test/app/PathMPT_test.cpp b/src/test/app/PathMPT_test.cpp index 3ba67b58a6..ff4a024cb8 100644 --- a/src/test/app/PathMPT_test.cpp +++ b/src/test/app/PathMPT_test.cpp @@ -112,10 +112,10 @@ public: MPTTester({.env = env, .issuer = gw, .holders = {alice, bob}, .maxAmt = 100}); auto& app = env.app(); - Resource::Charge loadType = Resource::kFeeReferenceRpc; - Resource::Consumer c; + resource::Charge loadType = resource::kFeeReferenceRpc; + resource::Consumer c; - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = env.journal, .app = app, .loadType = loadType, @@ -125,39 +125,39 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::kApiVersionIfUnspecified}, + .apiVersion = rpc::kApiVersionIfUnspecified}, {}, {}}; json::Value result; Gate g; - // Test RPC::Tuning::max_src_cur source currencies. + // Test rpc::tuning::max_src_cur source currencies. std::vector numSrc; - numSrc.reserve(RPC::Tuning::kMaxSrcCur); - for (std::uint8_t i = 0; i < RPC::Tuning::kMaxSrcCur; ++i) + numSrc.reserve(rpc::tuning::kMaxSrcCur); + for (std::uint8_t i = 0; i < rpc::tuning::kMaxSrcCur; ++i) numSrc.push_back(makeMptID(i, bob)); app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = xrpl::test::detail::rpf(alice, bob, usd, numSrc); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); - // Test more than RPC::Tuning::max_src_cur source currencies. - numSrc.push_back(makeMptID(RPC::Tuning::kMaxSrcCur, bob)); + // Test more than rpc::tuning::max_src_cur source currencies. + numSrc.push_back(makeMptID(rpc::tuning::kMaxSrcCur, bob)); app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = xrpl::test::detail::rpf(alice, bob, usd, numSrc); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); - // Test RPC::Tuning::max_auto_src_cur source currencies. + // Test rpc::tuning::max_auto_src_cur source currencies. numSrc.clear(); - for (auto i = 0; i < (RPC::Tuning::kMaxAutoSrcCur - 1); ++i) + for (auto i = 0; i < (rpc::tuning::kMaxAutoSrcCur - 1); ++i) { auto curm = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); numSrc.push_back(curm.issuanceID()); @@ -165,18 +165,18 @@ public: app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = xrpl::test::detail::rpf(alice, bob, usd, {}); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); - // Test more than RPC::Tuning::max_auto_src_cur source currencies. + // Test more than rpc::tuning::max_auto_src_cur source currencies. auto curm = MPTTester({.env = env, .issuer = alice, .holders = {bob}}); app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = xrpl::test::detail::rpf(alice, bob, usd, {}); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index 8f19a419a0..409a9e86f8 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -151,10 +151,10 @@ public: using namespace jtx; auto& app = env.app(); - Resource::Charge loadType = Resource::kFeeReferenceRpc; - Resource::Consumer c; + resource::Charge loadType = resource::kFeeReferenceRpc; + resource::Consumer c; - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = env.journal, .app = app, .loadType = loadType, @@ -164,7 +164,7 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::kApiVersionIfUnspecified}, + .apiVersion = rpc::kApiVersionIfUnspecified}, {}, {}}; @@ -190,7 +190,7 @@ public: app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = std::move(params); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); @@ -262,10 +262,10 @@ public: env.close(); auto& app = env.app(); - Resource::Charge loadType = Resource::kFeeReferenceRpc; - Resource::Consumer c; + resource::Charge loadType = resource::kFeeReferenceRpc; + resource::Consumer c; - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = env.journal, .app = app, .loadType = loadType, @@ -275,49 +275,49 @@ public: .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::kApiVersionIfUnspecified}, + .apiVersion = rpc::kApiVersionIfUnspecified}, {}, {}}; json::Value result; Gate g; - // Test RPC::Tuning::max_src_cur source currencies. + // Test rpc::tuning::max_src_cur source currencies. app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { - context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::kMaxSrcCur); + context.params = rpf(Account("alice"), Account("bob"), rpc::tuning::kMaxSrcCur); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); - // Test more than RPC::Tuning::max_src_cur source currencies. + // Test more than rpc::tuning::max_src_cur source currencies. app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { - context.params = rpf(Account("alice"), Account("bob"), RPC::Tuning::kMaxSrcCur + 1); + context.params = rpf(Account("alice"), Account("bob"), rpc::tuning::kMaxSrcCur + 1); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(result.isMember(jss::error)); - // Test RPC::Tuning::max_auto_src_cur source currencies. - for (auto i = 0; i < (RPC::Tuning::kMaxAutoSrcCur - 1); ++i) + // Test rpc::tuning::max_auto_src_cur source currencies. + for (auto i = 0; i < (rpc::tuning::kMaxAutoSrcCur - 1); ++i) env.trust(Account("alice")[std::to_string(i + 100)](100), "bob"); app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = rpf(Account("alice"), Account("bob"), 0); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); BEAST_EXPECT(!result.isMember(jss::error)); - // Test more than RPC::Tuning::max_auto_src_cur source currencies. + // Test more than rpc::tuning::max_auto_src_cur source currencies. env.trust(Account("alice")["AUD"](100), "bob"); app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = rpf(Account("alice"), Account("bob"), 0); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); BEAST_EXPECT(g.waitFor(5s)); diff --git a/src/test/app/PermissionedDEX_test.cpp b/src/test/app/PermissionedDEX_test.cpp index 67cb7602a0..68b2fa99a7 100644 --- a/src/test/app/PermissionedDEX_test.cpp +++ b/src/test/app/PermissionedDEX_test.cpp @@ -1816,7 +1816,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite env.fund(XRP(1000), carol); env.close(); - env(ledgerStateFix::bookExchangeRate(carol, uint256{1}), Ter(temDISABLED)); + env(ledger_state_fix::bookExchangeRate(carol, uint256{1}), Ter(temDISABLED)); } { @@ -1829,13 +1829,13 @@ class PermissionedDEX_test : public beast::unit_test::Suite env.close(); // BookExchangeRate fixes require sfBookDirectory. - auto missingBookDirectory = ledgerStateFix::bookExchangeRate(carol, uint256{1}); + auto missingBookDirectory = ledger_state_fix::bookExchangeRate(carol, uint256{1}); missingBookDirectory.removeMember(sfBookDirectory.jsonName); env(missingBookDirectory, Ter(temINVALID)); // BookExchangeRate fixes reject fields that belong to other // LedgerStateFix types. - auto extraOwner = ledgerStateFix::bookExchangeRate(carol, uint256{1}); + auto extraOwner = ledger_state_fix::bookExchangeRate(carol, uint256{1}); extraOwner[sfOwner.jsonName] = carol.human(); env(extraOwner, Ter(temINVALID)); } @@ -1847,7 +1847,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite { // Preclaim check: the target directory must exist. - env(ledgerStateFix::bookExchangeRate(setup.carol, uint256{1}), + env(ledger_state_fix::bookExchangeRate(setup.carol, uint256{1}), Fee(fixFee), Ter(tecOBJECT_NOT_FOUND)); } @@ -1861,7 +1861,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite BEAST_EXPECT(ownerDirSle); BEAST_EXPECT(!ownerDirSle->isFieldPresent(sfExchangeRate)); - env(ledgerStateFix::bookExchangeRate(setup.carol, ownerDir.key), + env(ledger_state_fix::bookExchangeRate(setup.carol, ownerDir.key), Fee(fixFee), Ter(tecNO_PERMISSION)); } @@ -1885,7 +1885,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite BEAST_EXPECT(exchangeRate == quality); } - env(ledgerStateFix::bookExchangeRate(setup.carol, dirKey), + env(ledger_state_fix::bookExchangeRate(setup.carol, dirKey), Fee(fixFee), Ter(tecNO_PERMISSION)); } @@ -1932,7 +1932,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite env.close(); auto const fixFee = drops(env.current()->fees().increment); - env(ledgerStateFix::bookExchangeRate(carol_, openDirKey), Fee(fixFee)); + env(ledger_state_fix::bookExchangeRate(carol_, openDirKey), Fee(fixFee)); env.close(); // Confirm sfExchangeRate now matches the key quality. @@ -1947,7 +1947,7 @@ class PermissionedDEX_test : public beast::unit_test::Suite } // Submitting again should fail — nothing to fix. - env(ledgerStateFix::bookExchangeRate(carol_, openDirKey), + env(ledger_state_fix::bookExchangeRate(carol_, openDirKey), Fee(fixFee), Ter(tecNO_PERMISSION)); } diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 537ee4c177..6ee7442d23 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -60,7 +60,7 @@ class SHAMapStore_test : public beast::unit_test::Suite static bool goodLedger(jtx::Env& env, json::Value const& json, std::string ledgerID, bool checkDB = false) { - auto good = json.isMember(jss::result) && !RPC::containsError(json[jss::result]) && + auto good = json.isMember(jss::result) && !rpc::containsError(json[jss::result]) && json[jss::result][jss::ledger][jss::ledger_index] == ledgerID; if (!good || !checkDB) return good; @@ -99,7 +99,7 @@ class SHAMapStore_test : public beast::unit_test::Suite static bool bad(json::Value const& json, ErrorCodeI error = RpcLgrNotFound) { - return json.isMember(jss::result) && RPC::containsError(json[jss::result]) && + return json.isMember(jss::result) && rpc::containsError(json[jss::result]) && json[jss::result][jss::error_code] == error; } @@ -347,11 +347,11 @@ public: BEAST_EXPECT(lastRotated != 2); auto canDelete = env.rpc("can_delete"); - BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(!rpc::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0); canDelete = env.rpc("can_delete", "never"); - BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(!rpc::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == 0); auto const firstBatch = kDeleteInterval + ledgerSeq; @@ -370,7 +370,7 @@ public: // This does not kick off a cleanup canDelete = env.rpc("can_delete", std::to_string(ledgerSeq + (kDeleteInterval / 2))); - BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(!rpc::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq + (kDeleteInterval / 2)); store.rendezvous(); @@ -423,7 +423,7 @@ public: // This does not kick off a cleanup canDelete = env.rpc("can_delete", "always"); - BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(!rpc::containsError(canDelete[jss::result])); BEAST_EXPECT( canDelete[jss::result][jss::can_delete] == std::numeric_limits::max()); @@ -457,7 +457,7 @@ public: // This does not kick off a cleanup canDelete = env.rpc("can_delete", "now"); - BEAST_EXPECT(!RPC::containsError(canDelete[jss::result])); + BEAST_EXPECT(!rpc::containsError(canDelete[jss::result])); BEAST_EXPECT(canDelete[jss::result][jss::can_delete] == ledgerSeq - 1); for (; ledgerSeq < lastRotated + kDeleteInterval; ++ledgerSeq) diff --git a/src/test/app/Sponsor_test.cpp b/src/test/app/Sponsor_test.cpp index f20aac68f9..393a6e58f7 100644 --- a/src/test/app/Sponsor_test.cpp +++ b/src/test/app/Sponsor_test.cpp @@ -1664,11 +1664,11 @@ public: env.close(); auto const brokerKeylet = keylet::loanBroker(alice.id(), env.seq(alice)); - env(loanBroker::set(alice, vaultKeylet.key), - loanBroker::kDebtMaximum(xrpAsset(1000).value()), - loanBroker::kManagementFeeRate(TenthBips16{0}), - loanBroker::kCoverRateMinimum(TenthBips32{0}), - loanBroker::kCoverRateLiquidation(TenthBips32{0})); + env(loan_broker::set(alice, vaultKeylet.key), + loan_broker::kDebtMaximum(xrpAsset(1000).value()), + loan_broker::kManagementFeeRate(TenthBips16{0}), + loan_broker::kCoverRateMinimum(TenthBips32{0}), + loan_broker::kCoverRateLiquidation(TenthBips32{0})); env.close(); auto const loanKeylet = keylet::loan(brokerKeylet.key, 1); @@ -2019,7 +2019,7 @@ public: env(sponsor::set_fee(sponsor, 0, fixFee), sponsor::SponseeAcc(alice)); env.close(); - env(ledgerStateFix::nftPageLinks(alice, alice), + env(ledger_state_fix::nftPageLinks(alice, alice), Fee(fixFee), sponsor::As(sponsor, spfSponsorFee), Ter(tecFAILED_PROCESSING)); @@ -2043,7 +2043,7 @@ public: OpenView overlay(&*env.closed()); auto jt = env.jt( - ledgerStateFix::nftPageLinks(alice, alice), + ledger_state_fix::nftPageLinks(alice, alice), Fee(fixFee), sponsor::As(sponsor, spfSponsorFee)); diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 3175e742d9..1fe48add27 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -2571,7 +2571,7 @@ public: auto fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) + BEAST_EXPECT(!rpc::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; BEAST_EXPECT( @@ -2600,7 +2600,7 @@ public: fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) + BEAST_EXPECT(!rpc::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; BEAST_EXPECT( @@ -3225,7 +3225,7 @@ public: { auto const info = env.rpc("json", "account_info", to_string(prevLedgerWithQueue)); - BEAST_EXPECT(info.isMember(jss::result) && RPC::containsError(info[jss::result])); + BEAST_EXPECT(info.isMember(jss::result) && rpc::containsError(info[jss::result])); } env.close(); @@ -4630,7 +4630,7 @@ public: auto const fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) + BEAST_EXPECT(!rpc::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; @@ -4688,7 +4688,7 @@ public: auto const fee = env.rpc("fee"); if (BEAST_EXPECT(fee.isMember(jss::result)) && - BEAST_EXPECT(!RPC::containsError(fee[jss::result]))) + BEAST_EXPECT(!rpc::containsError(fee[jss::result]))) { auto const& result = fee[jss::result]; diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index bd596d6149..791cf216c3 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -3936,7 +3936,7 @@ class Vault_test : public beast::unit_test::Suite // Deposit 100 IOU → 1000 shares. Borrow 40 → assetsAvailable=60. // Clawback 80 IOU → clamped to 60, then share math uses truncation. testCase(1, [&, this](Env& env, Data d) { - using namespace loanBroker; + using namespace loan_broker; using namespace loan; testcase("Scale clawback clamped with outstanding loan"); @@ -4410,7 +4410,7 @@ class Vault_test : public beast::unit_test::Suite testVaultClawbackBurnShares() { using namespace test::jtx; - using namespace loanBroker; + using namespace loan_broker; using namespace loan; Env env(*this, beast::Severity::Warning); @@ -4670,7 +4670,7 @@ class Vault_test : public beast::unit_test::Suite testVaultClawbackAssets() { using namespace test::jtx; - using namespace loanBroker; + using namespace loan_broker; using namespace loan; Env env(*this); env.enableFeature(fixCleanup3_1_3); @@ -6093,7 +6093,7 @@ class Vault_test : public beast::unit_test::Suite // Loan broker: no cover, no management fee, debt cap 10x principal. f.brokerID = keylet::loanBroker(f.lender.id(), env.seq(f.lender)).key; { - using namespace loanBroker; + using namespace loan_broker; env(set(f.lender, vaultKeylet.key), kDebtMaximum((*f.asset)(kStuckPrincipal * 10).value())); env.close(); diff --git a/src/test/basics/PerfLog_test.cpp b/src/test/basics/PerfLog_test.cpp index 41b5f81f5d..24ea971515 100644 --- a/src/test/basics/PerfLog_test.cpp +++ b/src/test/basics/PerfLog_test.cpp @@ -312,7 +312,7 @@ public: // Get the all the labels we can use for RPC interfaces without // causing an assert. - std::vector labels = test::jtx::makeVector(xrpl::RPC::getHandlerNames()); + std::vector labels = test::jtx::makeVector(xrpl::rpc::getHandlerNames()); std::shuffle(labels.begin(), labels.end(), defaultPrng()); // Get two IDs to associate with each label. Errors tend to happen at @@ -483,7 +483,7 @@ public: json::Value parsedLastLine; json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) + if (!BEAST_EXPECT(!rpc::containsError(parsedLastLine))) { // Avoid cascade of failures return; @@ -804,7 +804,7 @@ public: json::Value parsedLastLine; json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) + if (!BEAST_EXPECT(!rpc::containsError(parsedLastLine))) { // Avoid cascade of failures return; @@ -944,7 +944,7 @@ public: json::Value parsedLastLine; json::Reader().parse(lastLine, parsedLastLine); - if (!BEAST_EXPECT(!RPC::containsError(parsedLastLine))) + if (!BEAST_EXPECT(!rpc::containsError(parsedLastLine))) { // Avoid cascade of failures return; diff --git a/src/test/beast/IPEndpointCommon.h b/src/test/beast/IPEndpointCommon.h index 45d036476c..6fb2bd9569 100644 --- a/src/test/beast/IPEndpointCommon.h +++ b/src/test/beast/IPEndpointCommon.h @@ -7,7 +7,7 @@ #include -namespace beast::IP { +namespace beast::ip { inline Endpoint randomEP(bool v4 = true) @@ -44,4 +44,4 @@ randomEP(bool v4 = true) randInt(1, UINT16_MAX)}; } -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/test/beast/IPEndpoint_test.cpp b/src/test/beast/IPEndpoint_test.cpp index bc04087891..b61878aa76 100644 --- a/src/test/beast/IPEndpoint_test.cpp +++ b/src/test/beast/IPEndpoint_test.cpp @@ -22,7 +22,7 @@ #include #include -namespace beast::IP { +namespace beast::ip { //------------------------------------------------------------------------------ @@ -475,4 +475,4 @@ public: BEAST_DEFINE_TESTSUITE(IPEndpoint, beast, beast); -} // namespace beast::IP +} // namespace beast::ip diff --git a/src/test/jtx/AMM.h b/src/test/jtx/AMM.h index 68b6d9f745..435e32b7b4 100644 --- a/src/test/jtx/AMM.h +++ b/src/test/jtx/AMM.h @@ -199,7 +199,7 @@ public: std::optional const& asset2 = std::nullopt, std::optional const& ammAccount = std::nullopt, bool ignoreParams = false, - unsigned apiVersion = RPC::kApiInvalidVersion) const; + unsigned apiVersion = rpc::kApiInvalidVersion) const; [[nodiscard]] json::Value ammRpcInfo( diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index a175fd5006..5cb841578a 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -1081,7 +1081,7 @@ Env::rpc( Args&&... args) { return doRpc( - RPC::kApiCommandLineVersion, + rpc::kApiCommandLineVersion, std::vector{cmd, std::forward(args)...}, headers); } diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index e7a2808f07..d5cd8e66b8 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -876,7 +876,7 @@ checkMetrics( /* LoanBroker */ /******************************************************************************/ -namespace loanBroker { +namespace loan_broker { json::Value set(AccountID const& account, uint256 const& vaultId, std::uint32_t flags = 0); @@ -917,7 +917,7 @@ auto const kCoverRateLiquidation = auto const kDestination = JTxFieldWrapper(sfDestination); -} // namespace loanBroker +} // namespace loan_broker /* Loan */ /******************************************************************************/ diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 8effce288e..74232037ce 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -234,7 +234,7 @@ AMM::ammRpcInfo( jv[jss::amm_account] = *ammAccount; } auto jr = - (apiVersion == RPC::kApiInvalidVersion + (apiVersion == rpc::kApiInvalidVersion ? env_.rpc("json", "amm_info", to_string(jv)) : env_.rpc(apiVersion, "json", "amm_info", to_string(jv))); if (jr.isObject() && jr.isMember(jss::result) && jr[jss::result].isMember(jss::status)) diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 4da2e2b521..35553bdeb2 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -498,9 +498,9 @@ Env::postconditions( !test.expect( parsed.rpcCode == jt.rpcCode->first && parsed.rpcMessage == jt.rpcCode->second, "apply " + locStr + ": Got RPC result "s + - (parsed.rpcCode ? RPC::getErrorInfo(*parsed.rpcCode).token.cStr() : "NO RESULT") + + (parsed.rpcCode ? rpc::getErrorInfo(*parsed.rpcCode).token.cStr() : "NO RESULT") + " (" + parsed.rpcMessage + "); Expected " + - RPC::getErrorInfo(jt.rpcCode->first).token.cStr() + " (" + jt.rpcCode->second + + rpc::getErrorInfo(jt.rpcCode->first).token.cStr() + " (" + jt.rpcCode->second + ")")) || bad; // If we have an rpcCode (just checked), then the rpcException check is diff --git a/src/test/jtx/impl/TestHelpers.cpp b/src/test/jtx/impl/TestHelpers.cpp index 4d3869b4f9..d73eb8adf4 100644 --- a/src/test/jtx/impl/TestHelpers.cpp +++ b/src/test/jtx/impl/TestHelpers.cpp @@ -211,10 +211,10 @@ findPathsRequest( using namespace jtx; auto& app = env.app(); - Resource::Charge loadType = Resource::kFeeReferenceRpc; - Resource::Consumer c; + resource::Charge loadType = resource::kFeeReferenceRpc; + resource::Consumer c; - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = env.journal, .app = app, .loadType = loadType, @@ -224,7 +224,7 @@ findPathsRequest( .role = Role::USER, .coro = {}, .infoSub = {}, - .apiVersion = RPC::kApiVersionIfUnspecified}, + .apiVersion = rpc::kApiVersionIfUnspecified}, {}, {}}; @@ -252,7 +252,7 @@ findPathsRequest( app.getJobQueue().postCoro(JtClient, "RPC-Client", [&](auto const& coro) { context.params = std::move(params); context.coro = coro; - RPC::doCommand(context, result); + rpc::doCommand(context, result); g.signal(); }); @@ -743,7 +743,7 @@ issueHelperMPT(IssuerArgs const& args) /* LoanBroker */ /******************************************************************************/ -namespace loanBroker { +namespace loan_broker { json::Value set(AccountID const& account, uint256 const& vaultId, uint32_t flags) @@ -809,7 +809,7 @@ coverClawback(AccountID const& account, std::uint32_t flags) return jv; } -} // namespace loanBroker +} // namespace loan_broker /* Loan */ /******************************************************************************/ diff --git a/src/test/jtx/impl/attester.cpp b/src/test/jtx/impl/attester.cpp index ac946a1bf3..3799d957e9 100644 --- a/src/test/jtx/impl/attester.cpp +++ b/src/test/jtx/impl/attester.cpp @@ -24,7 +24,7 @@ signClaimAttestation( std::uint64_t claimID, std::optional const& dst) { - auto const toSign = Attestations::AttestationClaim::message( + auto const toSign = attestations::AttestationClaim::message( bridge, sendingAccount, sendingAmount, rewardAccount, wasLockingChainSend, claimID, dst); return sign(pk, sk, makeSlice(toSign)); } @@ -42,7 +42,7 @@ signCreateAccountAttestation( std::uint64_t createCount, AccountID const& dst) { - auto const toSign = Attestations::AttestationCreateAccount::message( + auto const toSign = attestations::AttestationCreateAccount::message( bridge, sendingAccount, sendingAmount, diff --git a/src/test/jtx/impl/ledgerStateFixes.cpp b/src/test/jtx/impl/ledgerStateFixes.cpp index 30c6659124..ae195021b8 100644 --- a/src/test/jtx/impl/ledgerStateFixes.cpp +++ b/src/test/jtx/impl/ledgerStateFixes.cpp @@ -9,7 +9,7 @@ #include -namespace xrpl::test::jtx::ledgerStateFix { +namespace xrpl::test::jtx::ledger_state_fix { // Fix NFTokenPage links on owner's account. acct pays fee. json::Value @@ -35,4 +35,4 @@ bookExchangeRate(jtx::Account const& acct, uint256 const& bookDir) return jv; } -} // namespace xrpl::test::jtx::ledgerStateFix +} // namespace xrpl::test::jtx::ledger_state_fix diff --git a/src/test/jtx/ledgerStateFix.h b/src/test/jtx/ledgerStateFix.h index 2fe5c8accc..4ae22f891e 100644 --- a/src/test/jtx/ledgerStateFix.h +++ b/src/test/jtx/ledgerStateFix.h @@ -8,7 +8,7 @@ /** * LedgerStateFix operations. */ -namespace xrpl::test::jtx::ledgerStateFix { +namespace xrpl::test::jtx::ledger_state_fix { /** * Repair the links in an NFToken directory. @@ -22,4 +22,4 @@ nftPageLinks(jtx::Account const& acct, jtx::Account const& owner); json::Value bookExchangeRate(jtx::Account const& acct, uint256 const& bookDir); -} // namespace xrpl::test::jtx::ledgerStateFix +} // namespace xrpl::test::jtx::ledger_state_fix diff --git a/src/test/jtx/rpc.h b/src/test/jtx/rpc.h index 9bd99c15f8..7fd550563c 100644 --- a/src/test/jtx/rpc.h +++ b/src/test/jtx/rpc.h @@ -48,7 +48,7 @@ public: jt.ter = telENV_RPC_FAILED; if (code_) { - auto const& errorInfo = RPC::getErrorInfo(*code_); + auto const& errorInfo = rpc::getErrorInfo(*code_); // When an RPC request returns an error code ('error_code'), it // always includes an error message ('error_message'), and sometimes // includes an error token ('error'). If it does, the error token is diff --git a/src/test/overlay/TMGetObjectByHash_test.cpp b/src/test/overlay/TMGetObjectByHash_test.cpp index f52220a90c..6c9105164a 100644 --- a/src/test/overlay/TMGetObjectByHash_test.cpp +++ b/src/test/overlay/TMGetObjectByHash_test.cpp @@ -44,7 +44,7 @@ using namespace jtx; * Test for TMGetObjectByHash reply size limiting. * * This verifies the fix that limits TMGetObjectByHash replies to - * Tuning::hardMaxReplyNodes to prevent excessive memory usage and + * tuning::hardMaxReplyNodes to prevent excessive memory usage and * potential DoS attacks from peers requesting large numbers of objects. */ class TMGetObjectByHash_test : public beast::unit_test::Suite @@ -61,11 +61,11 @@ class TMGetObjectByHash_test : public beast::unit_test::Suite public: PeerTest( Application& app, - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type&& request, PublicKey const& publicKey, ProtocolVersion protocol, - Resource::Consumer consumer, + resource::Consumer consumer, std::unique_ptr&& streamPtr, OverlayImpl& overlay) : PeerImp( @@ -133,8 +133,8 @@ class TMGetObjectByHash_test : public beast::unit_test::Suite auto streamPtr = std::make_unique(socket_type(env.app().getIOContext()), *context_); - beast::IP::Endpoint const local(boost::asio::ip::make_address("172.1.1.1"), 51235); - beast::IP::Endpoint const remote(boost::asio::ip::make_address("172.1.1.2"), 51235); + beast::ip::Endpoint const local(boost::asio::ip::make_address("172.1.1.1"), 51235); + beast::ip::Endpoint const remote(boost::asio::ip::make_address("172.1.1.2"), 51235); PublicKey const key(std::get<0>(randomKeyPair(KeyType::Ed25519))); auto consumer = overlay.resourceManager().newInboundEndpoint(remote); @@ -227,7 +227,7 @@ class TMGetObjectByHash_test : public beast::unit_test::Suite void run() override { - int const limit = static_cast(Tuning::kHardMaxReplyNodes); + int const limit = static_cast(tuning::kHardMaxReplyNodes); testReplyLimit(limit + 1, limit); testReplyLimit(limit, limit); testReplyLimit(limit - 1, limit - 1); diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index 60cc69a14f..a583a3aeab 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -413,7 +413,7 @@ public: return env; }; auto handshake = [&](int outboundEnable, int inboundEnable) { - beast::IP::Address const addr = boost::asio::ip::make_address("172.1.1.100"); + beast::ip::Address const addr = boost::asio::ip::make_address("172.1.1.100"); auto env = getEnv(outboundEnable); auto request = xrpl::makeRequest( diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 2f42313037..77920007de 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -92,13 +92,13 @@ public: send(std::shared_ptr const& m) override { } - [[nodiscard]] beast::IP::Endpoint + [[nodiscard]] beast::ip::Endpoint getRemoteAddress() const override { return {}; } void - charge(Resource::Charge const& fee, std::string const& context = {}) override + charge(resource::Charge const& fee, std::string const& context = {}) override { } [[nodiscard]] bool @@ -1610,7 +1610,7 @@ vp_base_squelch_max_selected_peers=2 env_.app().config().compression = c.compression; }; auto handshake = [&](int outboundEnable, int inboundEnable) { - beast::IP::Address const addr = boost::asio::ip::make_address("172.1.1.100"); + beast::ip::Address const addr = boost::asio::ip::make_address("172.1.1.100"); setEnv(outboundEnable); auto request = xrpl::makeRequest( diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 43f6ef2506..8626d3e19c 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -121,11 +121,11 @@ private: public: PeerTest( Application& app, - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type&& request, PublicKey const& publicKey, ProtocolVersion protocol, - Resource::Consumer consumer, + resource::Consumer consumer, std::unique_ptr&& streamPtr, OverlayImpl& overlay) : PeerImp( @@ -192,9 +192,9 @@ private: auto streamPtr = std::make_unique( socket_type(std::forward(env.app().getIOContext())), *context_); - beast::IP::Endpoint const local( + beast::ip::Endpoint const local( boost::asio::ip::make_address("172.1.1." + std::to_string(lid_))); - beast::IP::Endpoint const remote( + beast::ip::Endpoint const remote( boost::asio::ip::make_address("172.1.1." + std::to_string(rid_))); PublicKey const key(std::get<0>(randomKeyPair(KeyType::Ed25519))); auto consumer = overlay.resourceManager().newInboundEndpoint(remote); diff --git a/src/test/protocol/BuildInfo_test.cpp b/src/test/protocol/BuildInfo_test.cpp index 1741f45938..a669e3e292 100644 --- a/src/test/protocol/BuildInfo_test.cpp +++ b/src/test/protocol/BuildInfo_test.cpp @@ -11,7 +11,7 @@ public: { testcase("EncodeSoftwareVersion"); - auto encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.3-b7"); + auto encodedVersion = build_info::encodeSoftwareVersion("1.2.3-b7"); // the first two bytes identify the particular implementation, 0x183B BEAST_EXPECT((encodedVersion & 0xFFFF'0000'0000'0000LLU) == 0x183B'0000'0000'0000LLU); @@ -25,15 +25,15 @@ public: // 01 if a beta BEAST_EXPECT((encodedVersion & 0x0000'0000'00C0'0000LLU) >> 22 == 0b01); // 10 if an RC - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.4-rc7"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.4-rc7"); BEAST_EXPECT((encodedVersion & 0x0000'0000'00C0'0000LLU) >> 22 == 0b10); // 11 if neither an RC nor a beta - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.5"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.5"); BEAST_EXPECT((encodedVersion & 0x0000'0000'00C0'0000LLU) >> 22 == 0b11); } // the next six bits: rc/beta number (1-63) - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.6-b63"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.6-b63"); BEAST_EXPECT((encodedVersion & 0x0000'0000'003F'0000LLU) >> 16 == 63); // the last two bytes are zeros @@ -41,14 +41,14 @@ public: // Test some version strings with wrong formats: // no rc/beta number - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.3-b"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.3-b"); BEAST_EXPECT((encodedVersion & 0x0000'0000'00FF'0000LLU) == 0); // rc/beta number out of range - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.3-b64"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.3-b64"); BEAST_EXPECT((encodedVersion & 0x0000'0000'00FF'0000LLU) == 0); // Check that the rc/beta number of a release is 0: - encodedVersion = BuildInfo::encodeSoftwareVersion("1.2.6"); + encodedVersion = build_info::encodeSoftwareVersion("1.2.6"); BEAST_EXPECT((encodedVersion & 0x0000'0000'003F'0000LLU) == 0); } @@ -57,9 +57,9 @@ public: { testcase("IsXrpldVersion"); auto vFF = 0xFFFF'FFFF'FFFF'FFFFLLU; - BEAST_EXPECT(!BuildInfo::isXrpldVersion(vFF)); + BEAST_EXPECT(!build_info::isXrpldVersion(vFF)); auto vXrpld = 0x183B'0000'0000'0000LLU; - BEAST_EXPECT(BuildInfo::isXrpldVersion(vXrpld)); + BEAST_EXPECT(build_info::isXrpldVersion(vXrpld)); } void @@ -67,16 +67,16 @@ public: { testcase("IsNewerVersion"); auto vFF = 0xFFFF'FFFF'FFFF'FFFFLLU; - BEAST_EXPECT(!BuildInfo::isNewerVersion(vFF)); + BEAST_EXPECT(!build_info::isNewerVersion(vFF)); - auto v159 = BuildInfo::encodeSoftwareVersion("1.5.9"); - BEAST_EXPECT(!BuildInfo::isNewerVersion(v159)); + auto v159 = build_info::encodeSoftwareVersion("1.5.9"); + BEAST_EXPECT(!build_info::isNewerVersion(v159)); - auto vCurrent = BuildInfo::getEncodedVersion(); - BEAST_EXPECT(!BuildInfo::isNewerVersion(vCurrent)); + auto vCurrent = build_info::getEncodedVersion(); + BEAST_EXPECT(!build_info::isNewerVersion(vCurrent)); - auto vMax = BuildInfo::encodeSoftwareVersion("255.255.255"); - BEAST_EXPECT(BuildInfo::isNewerVersion(vMax)); + auto vMax = build_info::encodeSoftwareVersion("255.255.255"); + BEAST_EXPECT(build_info::isNewerVersion(vMax)); } void diff --git a/src/test/protocol/InnerObjectFormats_test.cpp b/src/test/protocol/InnerObjectFormats_test.cpp index 5154153ecf..73a283da39 100644 --- a/src/test/protocol/InnerObjectFormats_test.cpp +++ b/src/test/protocol/InnerObjectFormats_test.cpp @@ -5,7 +5,7 @@ #include #include // json::Reader #include -#include // RPC::containsError +#include // rpc::containsError #include // STParsedJSONObject #include @@ -13,7 +13,7 @@ namespace xrpl { -namespace InnerObjectFormatsUnitTestDetail { +namespace inner_object_formats_unit_test_detail { struct TestJSONTxt { @@ -149,7 +149,7 @@ static TestJSONTxt const kTestArray[] = { }; -} // namespace InnerObjectFormatsUnitTestDetail +} // namespace inner_object_formats_unit_test_detail class InnerObjectFormatsParsedJSON_test : public beast::unit_test::Suite { @@ -157,7 +157,7 @@ public: void run() override { - using namespace InnerObjectFormatsUnitTestDetail; + using namespace inner_object_formats_unit_test_detail; // Instantiate a jtx::Env so debugLog writes are exercised. test::jtx::Env const env(*this); @@ -166,7 +166,7 @@ public: { json::Value req; json::Reader().parse(test.txt, req); - if (RPC::containsError(req)) + if (rpc::containsError(req)) { Throw( "Internal InnerObjectFormatsParsedJSON error. Bad JSON."); diff --git a/src/test/protocol/MultiApiJson_test.cpp b/src/test/protocol/MultiApiJson_test.cpp index c6f844a206..2f0d4cb3ec 100644 --- a/src/test/protocol/MultiApiJson_test.cpp +++ b/src/test/protocol/MultiApiJson_test.cpp @@ -62,35 +62,35 @@ struct MultiApiJson_test : beast::unit_test::Suite // Some static data for test inputs static int const kPrimes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; - static_assert(std::size(kPrimes) > RPC::kApiMaximumValidVersion); + static_assert(std::size(kPrimes) > rpc::kApiMaximumValidVersion); MultiApiJson<1, 3> s1{}; static_assert( - s1.kSize == RPC::kApiMaximumValidVersion + 1 - RPC::kApiMinimumSupportedVersion); + s1.kSize == rpc::kApiMaximumValidVersion + 1 - rpc::kApiMinimumSupportedVersion); int productAllVersions = 1; - for (unsigned i = RPC::kApiMinimumSupportedVersion; i <= RPC::kApiMaximumValidVersion; + for (unsigned i = rpc::kApiMinimumSupportedVersion; i <= rpc::kApiMaximumValidVersion; ++i) { - auto const index = i - RPC::kApiMinimumSupportedVersion; + auto const index = i - rpc::kApiMinimumSupportedVersion; BEAST_EXPECT(index == s1.index(i)); BEAST_EXPECT(s1.valid(i)); s1.val[index] = makeJson("value", kPrimes[i]); productAllVersions *= kPrimes[i]; } BEAST_EXPECT(!s1.valid(0)); - BEAST_EXPECT(!s1.valid(RPC::kApiMaximumValidVersion + 1)); + BEAST_EXPECT(!s1.valid(rpc::kApiMaximumValidVersion + 1)); BEAST_EXPECT(!s1.valid( - std::numeric_limits::max())); + std::numeric_limits::max())); int result = 1; - static_assert(RPC::kApiMinimumSupportedVersion + 1 <= RPC::kApiMaximumValidVersion); - forApiVersions( + static_assert(rpc::kApiMinimumSupportedVersion + 1 <= rpc::kApiMaximumValidVersion); + forApiVersions( std::as_const(s1).visit(), [this](json::Value const& json, unsigned int version, int* result) { BEAST_EXPECT( - version >= RPC::kApiMinimumSupportedVersion && - version <= RPC::kApiMinimumSupportedVersion + 1); + version >= rpc::kApiMinimumSupportedVersion && + version <= rpc::kApiMinimumSupportedVersion + 1); if (BEAST_EXPECT(json.isMember("value"))) { *result *= json["value"].asInt(); @@ -99,8 +99,8 @@ struct MultiApiJson_test : beast::unit_test::Suite &result); BEAST_EXPECT( result == - kPrimes[RPC::kApiMinimumSupportedVersion] * - kPrimes[RPC::kApiMinimumSupportedVersion + 1]); + kPrimes[rpc::kApiMinimumSupportedVersion] * + kPrimes[rpc::kApiMinimumSupportedVersion + 1]); // Check all the values with mutable data forAllApiVersions(s1.visit(), [&s1, this](json::Value& json, auto version) { @@ -116,8 +116,8 @@ struct MultiApiJson_test : beast::unit_test::Suite std::as_const(s1).visit(), [this](json::Value const& json, unsigned int version, int* result) { BEAST_EXPECT( - version >= RPC::kApiMinimumSupportedVersion && - version <= RPC::kApiMaximumValidVersion); + version >= rpc::kApiMinimumSupportedVersion && + version <= rpc::kApiMaximumValidVersion); if (BEAST_EXPECT(json.isMember("value"))) { *result *= json["value"].asInt(); diff --git a/src/test/rpc/AccountLines_test.cpp b/src/test/rpc/AccountLines_test.cpp index 8d55c5e19d..cb20de9bf5 100644 --- a/src/test/rpc/AccountLines_test.cpp +++ b/src/test/rpc/AccountLines_test.cpp @@ -34,7 +34,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { class AccountLines_test : public beast::unit_test::Suite { @@ -51,7 +51,7 @@ public: auto const lines = env.rpc("json", "account_lines", "{ }"); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::missingFieldError(jss::account)[jss::error_message]); + rpc::missingFieldError(jss::account)[jss::error_message]); } { // account_lines with a malformed account. @@ -60,7 +60,7 @@ public: auto const lines = env.rpc("json", "account_lines", to_string(params)); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::makeError(RpcActMalformed)[jss::error_message]); + rpc::makeError(RpcActMalformed)[jss::error_message]); } { // test account non-string @@ -87,7 +87,7 @@ public: auto const lines = env.rpc("json", "account_lines", to_string(params)); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::makeError(RpcActNotFound)[jss::error_message]); + rpc::makeError(RpcActNotFound)[jss::error_message]); } env.fund(XRP(10000), alice); env.close(); @@ -250,7 +250,7 @@ public: auto const lines = env.rpc("json", "account_lines", to_string(params)); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::makeError(RpcActMalformed)[jss::error_message]); + rpc::makeError(RpcActMalformed)[jss::error_message]); } { // A negative limit should fail. @@ -260,7 +260,7 @@ public: auto const lines = env.rpc("json", "account_lines", to_string(params)); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); } { // Limit the response to 1 trust line. @@ -297,7 +297,7 @@ public: auto const linesD = env.rpc("json", "account_lines", to_string(paramsD)); BEAST_EXPECT( linesD[jss::result][jss::error_message] == - RPC::makeError(RpcInvalidParams)[jss::error_message]); + rpc::makeError(RpcInvalidParams)[jss::error_message]); } { // A non-string marker should also fail. @@ -307,7 +307,7 @@ public: auto const lines = env.rpc("json", "account_lines", to_string(params)); BEAST_EXPECT( lines[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::marker, "string")); + rpc::expectedFieldMessage(jss::marker, "string")); } { // Check that the flags we expect from alice to gw2 are present. @@ -496,7 +496,7 @@ public: auto const linesEnd = env.rpc("json", "account_lines", to_string(linesEndParams)); BEAST_EXPECT( linesEnd[jss::result][jss::error_message] == - RPC::makeError(RpcInvalidParams)[jss::error_message]); + rpc::makeError(RpcInvalidParams)[jss::error_message]); } void @@ -728,7 +728,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::missingFieldError(jss::account)[jss::error_message]); + rpc::missingFieldError(jss::account)[jss::error_message]); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -746,7 +746,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::makeError(RpcActMalformed)[jss::error_message]); + rpc::makeError(RpcActMalformed)[jss::error_message]); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -765,7 +765,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::makeError(RpcActNotFound)[jss::error_message]); + rpc::makeError(RpcActNotFound)[jss::error_message]); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -998,7 +998,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::makeError(RpcActMalformed)[jss::error_message]); + rpc::makeError(RpcActMalformed)[jss::error_message]); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -1017,7 +1017,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -1090,7 +1090,7 @@ public: auto const linesD = env.rpc("json2", to_string(requestD)); BEAST_EXPECT( linesD[jss::error][jss::message] == - RPC::makeError(RpcInvalidParams)[jss::error_message]); + rpc::makeError(RpcInvalidParams)[jss::error_message]); BEAST_EXPECT(linesD.isMember(jss::jsonrpc) && linesD[jss::jsonrpc] == "2.0"); BEAST_EXPECT(linesD.isMember(jss::ripplerpc) && linesD[jss::ripplerpc] == "2.0"); BEAST_EXPECT(linesD.isMember(jss::id) && linesD[jss::id] == 5); @@ -1109,7 +1109,7 @@ public: auto const lines = env.rpc("json2", to_string(request)); BEAST_EXPECT( lines[jss::error][jss::message] == - RPC::expectedFieldMessage(jss::marker, "string")); + rpc::expectedFieldMessage(jss::marker, "string")); BEAST_EXPECT(lines.isMember(jss::jsonrpc) && lines[jss::jsonrpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::ripplerpc) && lines[jss::ripplerpc] == "2.0"); BEAST_EXPECT(lines.isMember(jss::id) && lines[jss::id] == 5); @@ -1266,7 +1266,7 @@ public: auto const linesEnd = env.rpc("json2", to_string(linesEndRequest)); BEAST_EXPECT( linesEnd[jss::error][jss::message] == - RPC::makeError(RpcInvalidParams)[jss::error_message]); + rpc::makeError(RpcInvalidParams)[jss::error_message]); BEAST_EXPECT(linesEnd.isMember(jss::jsonrpc) && linesEnd[jss::jsonrpc] == "2.0"); BEAST_EXPECT(linesEnd.isMember(jss::ripplerpc) && linesEnd[jss::ripplerpc] == "2.0"); BEAST_EXPECT(linesEnd.isMember(jss::id) && linesEnd[jss::id] == 5); @@ -1286,4 +1286,4 @@ public: BEAST_DEFINE_TESTSUITE(AccountLines, rpc, xrpl); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/test/rpc/AccountTx_test.cpp b/src/test/rpc/AccountTx_test.cpp index f1fbc2871b..b144a6dc84 100644 --- a/src/test/rpc/AccountTx_test.cpp +++ b/src/test/rpc/AccountTx_test.cpp @@ -199,7 +199,7 @@ class AccountTx_test : public beast::unit_test::Suite auto isErr = [](json::Value const& j, ErrorCodeI code) { return j.isMember(jss::result) && j[jss::result].isMember(jss::error) && - j[jss::result][jss::error] == RPC::getErrorInfo(code).token; + j[jss::result][jss::error] == rpc::getErrorInfo(code).token; }; json::Value jParams; @@ -425,56 +425,56 @@ class AccountTx_test : public beast::unit_test::Suite p[jss::limit] = 1.2; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = "10" should fail (string instead of integer) p[jss::limit] = "10"; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = true should fail (boolean instead of integer) p[jss::limit] = true; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = false should fail (boolean instead of integer) p[jss::limit] = false; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = -1 should fail (negative number) p[jss::limit] = -1; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = [] should fail (array instead of integer) p[jss::limit] = json::Value(json::ValueType::Array); BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = {} should fail (object instead of integer) p[jss::limit] = json::Value(json::ValueType::Object); BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = "malformed" should fail (malformed string) p[jss::limit] = "malformed"; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = ["limit"] should fail (array with string) p[jss::limit] = json::Value(json::ValueType::Array); p[jss::limit].append("limit"); BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = {"limit": 10} should fail (object with // property) @@ -482,7 +482,7 @@ class AccountTx_test : public beast::unit_test::Suite p[jss::limit][jss::limit] = 10; BEAST_EXPECT( env.rpc("json", "account_tx", to_string(p))[jss::result][jss::error_message] == - RPC::expectedFieldMessage(jss::limit, "unsigned integer")); + rpc::expectedFieldMessage(jss::limit, "unsigned integer")); // Test case: limit = 10 should succeed (valid integer) p[jss::limit] = 10; diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index 83f7b64b4b..646cf190ff 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -1548,7 +1548,7 @@ public: auto usd = gw["USD"]; - for (auto i = 0; i <= RPC::Tuning::kBookOffers.rmax; i++) + for (auto i = 0; i <= rpc::tuning::kBookOffers.rmax; i++) env(offer(gw, XRP(50 + (1 * i)), usd(1.0 + (0.1 * i)))); if (asAdmin) @@ -1565,15 +1565,15 @@ public: BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? 1u : 0u)); // NOTE - a marker field is not returned for this method - jvParams[jss::limit] = RPC::Tuning::kBookOffers.rmax + 1; + jvParams[jss::limit] = rpc::tuning::kBookOffers.rmax + 1; jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result]; BEAST_EXPECT(jrr[jss::offers].isArray()); - BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? RPC::Tuning::kBookOffers.rmax + 1 : 0u)); + BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? rpc::tuning::kBookOffers.rmax + 1 : 0u)); jvParams[jss::limit] = json::ValueType::Null; jrr = env.rpc("json", "book_offers", to_string(jvParams))[jss::result]; BEAST_EXPECT(jrr[jss::offers].isArray()); - BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? RPC::Tuning::kBookOffers.rDefault : 0u)); + BEAST_EXPECT(jrr[jss::offers].size() == (asAdmin ? rpc::tuning::kBookOffers.rDefault : 0u)); } void diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index e900b92fc3..be78864cac 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -88,7 +88,7 @@ class Handler_test : public beast::unit_test::Suite std::random_device dev; std::ranlux48 prng(dev()); - std::vector names = test::jtx::makeVector(xrpl::RPC::getHandlerNames()); + std::vector names = test::jtx::makeVector(xrpl::rpc::getHandlerNames()); std::uniform_int_distribution distr{0, names.size() - 1}; @@ -96,7 +96,7 @@ class Handler_test : public beast::unit_test::Suite auto const [mean, stdev, n] = time( 1'000'000, [&](std::size_t i) { - auto const d = RPC::getHandler(1, false, names[i]); + auto const d = rpc::getHandler(1, false, names[i]); dummy = dummy + i + (int)d->role; }, [&]() -> std::size_t { return distr(prng); }); diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index e18974e7e7..efba4075c7 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -36,7 +36,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { struct TxnTestData { @@ -2248,7 +2248,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == baseFee); } @@ -2268,7 +2268,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == baseFee); } @@ -2285,7 +2285,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2306,7 +2306,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2325,7 +2325,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2344,7 +2344,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2400,7 +2400,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT(req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 10); } @@ -2422,7 +2422,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT(req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 10); } @@ -2450,7 +2450,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 8889); } @@ -2473,7 +2473,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2496,7 +2496,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee)); } @@ -2519,7 +2519,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 8889); } @@ -2542,7 +2542,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); } { @@ -2563,7 +2563,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); } { @@ -2585,7 +2585,7 @@ public: env.app().getTxQ(), env.app()); - BEAST_EXPECT(RPC::containsError(result)); + BEAST_EXPECT(rpc::containsError(result)); } env.close(); @@ -2598,7 +2598,7 @@ public: auto rpcResult = env.rpc("json", "sign", to_string(toSign)); auto result = rpcResult[jss::result]; - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "10"); BEAST_EXPECT( @@ -2624,7 +2624,7 @@ public: auto rpcResult = env.rpc("json", "sign", to_string(toSign)); auto result = rpcResult[jss::result]; - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "7813"); @@ -2651,7 +2651,7 @@ public: auto rpcResult = env.rpc("json", "sign", to_string(toSign)); auto result = rpcResult[jss::result]; - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "47"); BEAST_EXPECT( @@ -2682,7 +2682,7 @@ public: auto rpcResult = env.rpc("json", "sign", to_string(toSign)); auto result = rpcResult[jss::result]; - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "6806"); @@ -2711,7 +2711,7 @@ public: auto rpcResult = env.rpc("json", "sign", to_string(toSign)); auto result = rpcResult[jss::result]; - BEAST_EXPECT(!RPC::containsError(result)); + BEAST_EXPECT(!rpc::containsError(result)); BEAST_EXPECT( result[jss::tx_json].isMember(jss::NetworkID) && result[jss::tx_json][jss::NetworkID] == 1025); @@ -2791,7 +2791,7 @@ public: { json::Value req; json::Reader().parse(txnTest.json, req); - if (RPC::containsError(req)) + if (rpc::containsError(req)) Throw("Internal JSONRPC_test error. Bad test JSON."); static Role const kTestedRoles[] = { @@ -2815,7 +2815,7 @@ public: } std::string errStr; - if (RPC::containsError(result)) + if (rpc::containsError(result)) errStr = result["error_message"].asString(); if (errStr == txnTest.expMsg[get<3>(testFunc)]) @@ -2848,4 +2848,4 @@ public: BEAST_DEFINE_TESTSUITE(JSONRPC, rpc, xrpl); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/test/rpc/KeyGeneration_test.cpp b/src/test/rpc/KeyGeneration_test.cpp index aafe6f75a5..2b056fc6d2 100644 --- a/src/test/rpc/KeyGeneration_test.cpp +++ b/src/test/rpc/KeyGeneration_test.cpp @@ -15,7 +15,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { struct KeyStrings { @@ -800,4 +800,4 @@ public: BEAST_DEFINE_TESTSUITE(WalletPropose, rpc, xrpl); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index 7adb5a4518..b8301d5656 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -349,7 +349,7 @@ class LedgerEntry_test : public beast::unit_test::Suite json::Value const jrr = env.rpc( apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result]; auto const expectedErrMsg = - RPC::expectedFieldMessage(fieldName, getTypeName(typeID)); + rpc::expectedFieldMessage(fieldName, getTypeName(typeID)); checkErrorValue(jrr, expectedError, expectedErrMsg, location); }; @@ -383,13 +383,13 @@ class LedgerEntry_test : public beast::unit_test::Suite json::Value const jrr = env.rpc( apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result]; checkErrorValue( - jrr, "malformedRequest", RPC::missingFieldMessage(fieldName.cStr()), location); + jrr, "malformedRequest", rpc::missingFieldMessage(fieldName.cStr()), location); correctRequest[parentFieldName][fieldName] = json::ValueType::Null; json::Value const jrr2 = env.rpc( apiVersion, "json", "ledger_entry", to_string(correctRequest))[jss::result]; checkErrorValue( - jrr2, "malformedRequest", RPC::missingFieldMessage(fieldName.cStr()), location); + jrr2, "malformedRequest", rpc::missingFieldMessage(fieldName.cStr()), location); } auto tryField = [&](json::Value fieldValue) -> void { correctRequest[parentFieldName][fieldName] = fieldValue; @@ -399,7 +399,7 @@ class LedgerEntry_test : public beast::unit_test::Suite checkErrorValue( jrr, expectedError, - RPC::expectedFieldMessage(fieldName, getTypeName(typeID)), + rpc::expectedFieldMessage(fieldName, getTypeName(typeID)), location); }; @@ -1083,8 +1083,8 @@ class LedgerEntry_test : public beast::unit_test::Suite json::Value const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; auto const expectedErrMsg = fieldValue.isNull() - ? RPC::missingFieldMessage(jss::issuer.cStr()) - : RPC::expectedFieldMessage(jss::issuer, "AccountID"); + ? rpc::missingFieldMessage(jss::issuer.cStr()) + : rpc::expectedFieldMessage(jss::issuer, "AccountID"); checkErrorValue(jrr, "malformedAuthorizedCredentials", expectedErrMsg); }; @@ -1114,7 +1114,7 @@ class LedgerEntry_test : public beast::unit_test::Suite checkErrorValue( jrr[jss::result], "malformedAuthorizedCredentials", - RPC::expectedFieldMessage(jss::authorized_credentials, "array")); + rpc::expectedFieldMessage(jss::authorized_credentials, "array")); } { @@ -1134,8 +1134,8 @@ class LedgerEntry_test : public beast::unit_test::Suite json::Value const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; auto const expectedErrMsg = fieldValue.isNull() - ? RPC::missingFieldMessage(jss::credential_type.cStr()) - : RPC::expectedFieldMessage(jss::credential_type, "hex string"); + ? rpc::missingFieldMessage(jss::credential_type.cStr()) + : rpc::expectedFieldMessage(jss::credential_type, "hex string"); checkErrorValue(jrr, "malformedAuthorizedCredentials", expectedErrMsg); }; @@ -1836,7 +1836,7 @@ class LedgerEntry_test : public beast::unit_test::Suite checkErrorValue( jrr, "malformedAddress", - RPC::expectedFieldMessage(jss::accounts, "array of Accounts")); + rpc::expectedFieldMessage(jss::accounts, "array of Accounts")); } { @@ -1851,7 +1851,7 @@ class LedgerEntry_test : public beast::unit_test::Suite checkErrorValue( jrr, "malformedAddress", - RPC::expectedFieldMessage(jss::accounts, "array of Accounts")); + rpc::expectedFieldMessage(jss::accounts, "array of Accounts")); } }; diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index 3a2c957691..af93108ff2 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -158,7 +158,7 @@ class LedgerRPC_test : public beast::unit_test::Suite { // Request a ledger with a very large (double) sequence. auto const ret = env.rpc("json", "ledger", "{ \"ledger_index\" : 2e15 }"); - BEAST_EXPECT(RPC::containsError(ret)); + BEAST_EXPECT(rpc::containsError(ret)); BEAST_EXPECT(ret[jss::error_message] == "Invalid parameters."); } diff --git a/src/test/rpc/LedgerRequest_test.cpp b/src/test/rpc/LedgerRequest_test.cpp index 93feee9497..98bde4e5a5 100644 --- a/src/test/rpc/LedgerRequest_test.cpp +++ b/src/test/rpc/LedgerRequest_test.cpp @@ -15,7 +15,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { class LedgerRequest_test : public beast::unit_test::Suite { @@ -43,28 +43,28 @@ public: // arbitrary text is converted to 0. auto const result = env.rpc("ledger_request", "arbitrary_text"); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Ledger index too small"); } { auto const result = env.rpc("ledger_request", "-1"); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Ledger index too small"); } { auto const result = env.rpc("ledger_request", "0"); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Ledger index too small"); } { auto const result = env.rpc("ledger_request", "1"); BEAST_EXPECT( - !RPC::containsError(result[jss::result]) && + !rpc::containsError(result[jss::result]) && result[jss::result][jss::ledger_index] == 1 && result[jss::result].isMember(jss::ledger)); BEAST_EXPECT( @@ -75,7 +75,7 @@ public: { auto const result = env.rpc("ledger_request", "2"); BEAST_EXPECT( - !RPC::containsError(result[jss::result]) && + !rpc::containsError(result[jss::result]) && result[jss::result][jss::ledger_index] == 2 && result[jss::result].isMember(jss::ledger)); BEAST_EXPECT( @@ -86,7 +86,7 @@ public: { auto const result = env.rpc("ledger_request", "3"); BEAST_EXPECT( - !RPC::containsError(result[jss::result]) && + !rpc::containsError(result[jss::result]) && result[jss::result][jss::ledger_index] == 3 && result[jss::result].isMember(jss::ledger)); BEAST_EXPECT( @@ -98,7 +98,7 @@ public: { auto const r = env.rpc("ledger_request", ledgerHash); BEAST_EXPECT( - !RPC::containsError(r[jss::result]) && r[jss::result][jss::ledger_index] == 3 && + !rpc::containsError(r[jss::result]) && r[jss::result][jss::ledger_index] == 3 && r[jss::result].isMember(jss::ledger)); BEAST_EXPECT( r[jss::result][jss::ledger].isMember(jss::ledger_hash) && @@ -112,7 +112,7 @@ public: auto const result = env.rpc("ledger_request", ledgerHash); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Invalid field 'ledger_hash', not hex string."); } @@ -123,21 +123,21 @@ public: auto const result = env.rpc("ledger_request", ledgerHash); BEAST_EXPECT( - !RPC::containsError(result[jss::result]) && + !rpc::containsError(result[jss::result]) && result[jss::result][jss::have_header] == false); } { auto const result = env.rpc("ledger_request", "4"); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Ledger index too large"); } { auto const result = env.rpc("ledger_request", "5"); BEAST_EXPECT( - RPC::containsError(result[jss::result]) && + rpc::containsError(result[jss::result]) && result[jss::result][jss::error_message] == "Ledger index too large"); } } @@ -357,4 +357,4 @@ public: BEAST_DEFINE_TESTSUITE(LedgerRequest, rpc, xrpl); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/test/rpc/NoRippleCheck_test.cpp b/src/test/rpc/NoRippleCheck_test.cpp index 9c17d291a1..6e30f944c7 100644 --- a/src/test/rpc/NoRippleCheck_test.cpp +++ b/src/test/rpc/NoRippleCheck_test.cpp @@ -286,9 +286,9 @@ class NoRippleCheckLimits_test : public beast::unit_test::Suite // be better if we could add this functionality to Env somehow // or otherwise disable endpoint charging for certain test // cases. - using namespace xrpl::Resource; + using namespace xrpl::resource; using namespace std::chrono; - using namespace beast::IP; + using namespace beast::ip; auto c = env.app().getResourceManager().newInboundEndpoint( Endpoint::fromString(test::getEnvLocalhostAddr())); @@ -301,7 +301,7 @@ class NoRippleCheckLimits_test : public beast::unit_test::Suite } }; - for (auto i = 0; i < xrpl::RPC::Tuning::kNoRippleCheck.rmax + 5; ++i) + for (auto i = 0; i < xrpl::rpc::tuning::kNoRippleCheck.rmax + 5; ++i) { if (!admin) checkBalance(); diff --git a/src/test/rpc/RPCCall_test.cpp b/src/test/rpc/RPCCall_test.cpp index 4b5ab1f230..ef3213008c 100644 --- a/src/test/rpc/RPCCall_test.cpp +++ b/src/test/rpc/RPCCall_test.cpp @@ -5855,8 +5855,8 @@ public: { testcase << "RPCCall API version " << apiVersion; if (!BEAST_EXPECT( - apiVersion >= RPC::kApiMinimumSupportedVersion && - apiVersion <= RPC::kApiMaximumValidVersion)) + apiVersion >= rpc::kApiMinimumSupportedVersion && + apiVersion <= rpc::kApiMaximumValidVersion)) return; test::jtx::Env const env(*this, makeNetworkConfig(11111)); // Used only for its Journal. @@ -5870,8 +5870,8 @@ public: std::vector const args{rpcCallTest.args.begin(), rpcCallTest.args.end()}; char const* const expVersioned = - (apiVersion - RPC::kApiMinimumSupportedVersion) < rpcCallTest.exp.size() - ? rpcCallTest.exp[apiVersion - RPC::kApiMinimumSupportedVersion] + (apiVersion - rpc::kApiMinimumSupportedVersion) < rpcCallTest.exp.size() + ? rpcCallTest.exp[apiVersion - rpc::kApiMinimumSupportedVersion] : rpcCallTest.exp.back(); // Note that, over the long term, kNone of these tests should diff --git a/src/test/rpc/RPCHelpers_test.cpp b/src/test/rpc/RPCHelpers_test.cpp index 1458c0aa80..25368235a3 100644 --- a/src/test/rpc/RPCHelpers_test.cpp +++ b/src/test/rpc/RPCHelpers_test.cpp @@ -19,50 +19,50 @@ public: // Test no type. json::Value tx = json::ValueType::Object; - auto result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status::kOK); + auto result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status::kOK); BEAST_EXPECT(result.second == 0); // Test empty type. tx[jss::type] = ""; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status{RpcInvalidParams}); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status{RpcInvalidParams}); BEAST_EXPECT(result.second == 0); // Test type using canonical name in mixedcase. tx[jss::type] = "MPTokenIssuance"; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status::kOK); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status::kOK); BEAST_EXPECT(result.second == ltMPTOKEN_ISSUANCE); // Test type using canonical name in lowercase. tx[jss::type] = "mptokenissuance"; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status::kOK); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status::kOK); BEAST_EXPECT(result.second == ltMPTOKEN_ISSUANCE); // Test type using RPC name with exact match. tx[jss::type] = "mpt_issuance"; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status::kOK); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status::kOK); BEAST_EXPECT(result.second == ltMPTOKEN_ISSUANCE); // Test type using RPC name with inexact match. tx[jss::type] = "MPT_Issuance"; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status{RpcInvalidParams}); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status{RpcInvalidParams}); BEAST_EXPECT(result.second == 0); // Test invalid type. tx[jss::type] = 1234; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status{RpcInvalidParams}); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status{RpcInvalidParams}); BEAST_EXPECT(result.second == 0); // Test unknown type. tx[jss::type] = "unknown"; - result = RPC::chooseLedgerEntryType(tx); - BEAST_EXPECT(result.first == RPC::Status{RpcInvalidParams}); + result = rpc::chooseLedgerEntryType(tx); + BEAST_EXPECT(result.first == rpc::Status{RpcInvalidParams}); BEAST_EXPECT(result.second == 0); } diff --git a/src/test/rpc/Status_test.cpp b/src/test/rpc/Status_test.cpp index c4f8544980..aaf696e9af 100644 --- a/src/test/rpc/Status_test.cpp +++ b/src/test/rpc/Status_test.cpp @@ -12,7 +12,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { class codeString_test : public beast::unit_test::Suite { @@ -202,6 +202,6 @@ public: } }; -BEAST_DEFINE_TESTSUITE(fillJson, rpc, RPC); +BEAST_DEFINE_TESTSUITE(fillJson, rpc, xrpl); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/test/rpc/TransactionEntry_test.cpp b/src/test/rpc/TransactionEntry_test.cpp index 38a95e84f8..b57c615b71 100644 --- a/src/test/rpc/TransactionEntry_test.cpp +++ b/src/test/rpc/TransactionEntry_test.cpp @@ -183,7 +183,7 @@ class TransactionEntry_test : public beast::unit_test::Suite { json::Value expected; json::Reader().parse(expectedJson, expected); - if (RPC::containsError(expected)) + if (rpc::containsError(expected)) Throw("Internal JSONRPC_test error. Bad test JSON."); for (auto memberIt = expected.begin(); memberIt != expected.end(); memberIt++) diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index 4dae475b63..2921c63c17 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -62,9 +62,9 @@ class Transaction_test : public beast::unit_test::Suite char const* command = jss::tx.cStr(); char const* binary = jss::binary.cStr(); - char const* notFound = RPC::getErrorInfo(RpcTxnNotFound).token; - char const* invalid = RPC::getErrorInfo(RpcInvalidLgrRange).token; - char const* excessive = RPC::getErrorInfo(RpcExcessiveLgrRange).token; + char const* notFound = rpc::getErrorInfo(RpcTxnNotFound).token; + char const* invalid = rpc::getErrorInfo(RpcInvalidLgrRange).token; + char const* excessive = rpc::getErrorInfo(RpcExcessiveLgrRange).token; Env env{*this, features}; auto const alice = Account("alice"); @@ -301,9 +301,9 @@ class Transaction_test : public beast::unit_test::Suite char const* command = jss::tx.cStr(); char const* binary = jss::binary.cStr(); - char const* notFound = RPC::getErrorInfo(RpcTxnNotFound).token; - char const* invalid = RPC::getErrorInfo(RpcInvalidLgrRange).token; - char const* excessive = RPC::getErrorInfo(RpcExcessiveLgrRange).token; + char const* notFound = rpc::getErrorInfo(RpcTxnNotFound).token; + char const* invalid = rpc::getErrorInfo(RpcInvalidLgrRange).token; + char const* excessive = rpc::getErrorInfo(RpcExcessiveLgrRange).token; Env env{*this, makeNetworkConfig(11111)}; uint32_t const netID = env.app().getNetworkIDService().getNetworkID(); @@ -333,7 +333,7 @@ class Transaction_test : public beast::unit_test::Suite auto const result = env.rpc( command, // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - *RPC::encodeCTID(startLegSeq + i, txnIdx, netID), + *rpc::encodeCTID(startLegSeq + i, txnIdx, netID), binary, to_string(startLegSeq), to_string(endLegSeq)); @@ -345,7 +345,7 @@ class Transaction_test : public beast::unit_test::Suite auto const tx = env.jt(noop(alice), Seq(env.seq(alice))).stx; // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ctid = *RPC::encodeCTID(endLegSeq, tx->getSeqValue(), netID); + auto const ctid = *rpc::encodeCTID(endLegSeq, tx->getSeqValue(), netID); for (int deltaEndSeq = 0; deltaEndSeq < 2; ++deltaEndSeq) { auto const result = env.rpc( @@ -374,7 +374,7 @@ class Transaction_test : public beast::unit_test::Suite auto const result = env.rpc( command, // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - *RPC::encodeCTID(startLegSeq + i, txnIdx, netID), + *rpc::encodeCTID(startLegSeq + i, txnIdx, netID), binary, to_string(endLegSeq + 1), to_string(endLegSeq + 100)); @@ -434,7 +434,7 @@ class Transaction_test : public beast::unit_test::Suite auto const result = env.rpc( command, // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - *RPC::encodeCTID(endLegSeq, txnIdx, netID), + *rpc::encodeCTID(endLegSeq, txnIdx, netID), to_string(startLegSeq), to_string(deletedLedger - 1)); @@ -527,75 +527,75 @@ class Transaction_test : public beast::unit_test::Suite // Test case 1: Valid input values auto const expected11 = std::optional("CFFFFFFFFFFFFFFF"); - BEAST_EXPECT(RPC::encodeCTID(0x0FFF'FFFFUL, 0xFFFFU, 0xFFFFU) == expected11); + BEAST_EXPECT(rpc::encodeCTID(0x0FFF'FFFFUL, 0xFFFFU, 0xFFFFU) == expected11); auto const expected12 = std::optional("C000000000000000"); - BEAST_EXPECT(RPC::encodeCTID(0, 0, 0) == expected12); + BEAST_EXPECT(rpc::encodeCTID(0, 0, 0) == expected12); auto const expected13 = std::optional("C000000100020003"); - BEAST_EXPECT(RPC::encodeCTID(1U, 2U, 3U) == expected13); + BEAST_EXPECT(rpc::encodeCTID(1U, 2U, 3U) == expected13); auto const expected14 = std::optional("C0CA2AA7326FFFFF"); - BEAST_EXPECT(RPC::encodeCTID(13249191UL, 12911U, 65535U) == expected14); + BEAST_EXPECT(rpc::encodeCTID(13249191UL, 12911U, 65535U) == expected14); // Test case 2: ledger_seq greater than 0xFFFFFFF - BEAST_EXPECT(!RPC::encodeCTID(0x1000'0000UL, 0xFFFFU, 0xFFFFU)); + BEAST_EXPECT(!rpc::encodeCTID(0x1000'0000UL, 0xFFFFU, 0xFFFFU)); // Test case 3: txn_index greater than 0xFFFF - BEAST_EXPECT(!RPC::encodeCTID(0x0FFF'FFFF, 0x1'0000, 0xFFFF)); + BEAST_EXPECT(!rpc::encodeCTID(0x0FFF'FFFF, 0x1'0000, 0xFFFF)); // Test case 4: network_id greater than 0xFFFF - BEAST_EXPECT(!RPC::encodeCTID(0x0FFF'FFFFUL, 0xFFFFU, 0x1'0000U)); + BEAST_EXPECT(!rpc::encodeCTID(0x0FFF'FFFFUL, 0xFFFFU, 0x1'0000U)); // Test case 5: Valid input values auto const expected51 = std::optional>(std::make_tuple(0, 0, 0)); - BEAST_EXPECT(RPC::decodeCTID("C000000000000000") == expected51); + BEAST_EXPECT(rpc::decodeCTID("C000000000000000") == expected51); auto const expected52 = std::optional>(std::make_tuple(1U, 2U, 3U)); - BEAST_EXPECT(RPC::decodeCTID("C000000100020003") == expected52); + BEAST_EXPECT(rpc::decodeCTID("C000000100020003") == expected52); auto const expected53 = std::optional>( std::make_tuple(13249191UL, 12911U, 49221U)); - BEAST_EXPECT(RPC::decodeCTID("C0CA2AA7326FC045") == expected53); + BEAST_EXPECT(rpc::decodeCTID("C0CA2AA7326FC045") == expected53); // Test case 6: ctid not a string or big int - BEAST_EXPECT(!RPC::decodeCTID(0xCFF)); + BEAST_EXPECT(!rpc::decodeCTID(0xCFF)); // Test case 7: ctid not a hexadecimal string - BEAST_EXPECT(!RPC::decodeCTID("C003FFFFFFFFFFFG")); + BEAST_EXPECT(!rpc::decodeCTID("C003FFFFFFFFFFFG")); // Test case 8: ctid not exactly 16 nibbles - BEAST_EXPECT(!RPC::decodeCTID("C003FFFFFFFFFFF")); + BEAST_EXPECT(!rpc::decodeCTID("C003FFFFFFFFFFF")); // Test case 9: ctid too large to be a valid CTID value - BEAST_EXPECT(!RPC::decodeCTID("CFFFFFFFFFFFFFFFF")); + BEAST_EXPECT(!rpc::decodeCTID("CFFFFFFFFFFFFFFFF")); // Test case 10: ctid doesn't start with a C nibble - BEAST_EXPECT(!RPC::decodeCTID("FFFFFFFFFFFFFFFF")); + BEAST_EXPECT(!rpc::decodeCTID("FFFFFFFFFFFFFFFF")); // Test case 11: Valid input values BEAST_EXPECT( - (RPC::decodeCTID(0xCFFF'FFFF'FFFF'FFFFULL) == + (rpc::decodeCTID(0xCFFF'FFFF'FFFF'FFFFULL) == std::optional>( std::make_tuple(0x0FFF'FFFFUL, 0xFFFFU, 0xFFFFU)))); BEAST_EXPECT( - (RPC::decodeCTID(0xC000'0000'0000'0000ULL) == + (rpc::decodeCTID(0xC000'0000'0000'0000ULL) == std::optional>(std::make_tuple(0, 0, 0)))); BEAST_EXPECT( - (RPC::decodeCTID(0xC000'0001'0002'0003ULL) == + (rpc::decodeCTID(0xC000'0001'0002'0003ULL) == std::optional>(std::make_tuple(1U, 2U, 3U)))); BEAST_EXPECT( - (RPC::decodeCTID(0xC0CA'2AA7'326F'C045ULL) == + (rpc::decodeCTID(0xC0CA'2AA7'326F'C045ULL) == std::optional>( std::make_tuple(1324'9191UL, 12911U, 49221U)))); // Test case 12: ctid not exactly 16 nibbles - BEAST_EXPECT(!RPC::decodeCTID(0xC003'FFFF'FFFF'FFF)); + BEAST_EXPECT(!rpc::decodeCTID(0xC003'FFFF'FFFF'FFF)); // Test case 13: ctid too large to be a valid CTID value // this test case is not possible in c++ because it would overflow the // type, left in for completeness - // BEAST_EXPECT(!RPC::decodeCTID(0xCFFFFFFFFFFFFFFFFULL)); + // BEAST_EXPECT(!rpc::decodeCTID(0xCFFFFFFFFFFFFFFFFULL)); // Test case 14: ctid doesn't start with a C nibble - BEAST_EXPECT(!RPC::decodeCTID(0xFFFF'FFFF'FFFF'FFFFULL)); + BEAST_EXPECT(!rpc::decodeCTID(0xFFFF'FFFF'FFFF'FFFFULL)); } void @@ -619,7 +619,7 @@ class Transaction_test : public beast::unit_test::Suite env(pay(alice, bob, XRP(10))); env.close(); - auto const ctid = RPC::encodeCTID(startLegSeq, 0, netID); + auto const ctid = rpc::encodeCTID(startLegSeq, 0, netID); if (netID > 0xFFFF) { // Concise transaction IDs do not support a network ID > 0xFFFF. @@ -650,7 +650,7 @@ class Transaction_test : public beast::unit_test::Suite env.close(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - std::string const ctid = *RPC::encodeCTID(startLegSeq, 0, netID); + std::string const ctid = *rpc::encodeCTID(startLegSeq, 0, netID); auto isUpper = [](char c) { return std::isupper(c) != 0; }; // Verify that there are at least two upper case letters in ctid and @@ -705,7 +705,7 @@ class Transaction_test : public beast::unit_test::Suite BEAST_EXPECT(jrr.isMember(jss::ctid) == (netID <= 0xFFFF)); if (jrr.isMember(jss::ctid)) { - auto const ctid = RPC::encodeCTID(ledgerSeq, 0, netID); + auto const ctid = rpc::encodeCTID(ledgerSeq, 0, netID); BEAST_EXPECT( jrr[jss::ctid] == *ctid); // NOLINT(bugprone-unchecked-optional-access) } @@ -725,7 +725,7 @@ class Transaction_test : public beast::unit_test::Suite env.close(); // NOLINTNEXTLINE(bugprone-unchecked-optional-access) - auto const ctid = *RPC::encodeCTID(startLegSeq, 0, netID + 1); + auto const ctid = *rpc::encodeCTID(startLegSeq, 0, netID + 1); json::Value jsonTx; jsonTx[jss::binary] = false; jsonTx[jss::ctid] = ctid; diff --git a/src/test/rpc/Version_test.cpp b/src/test/rpc/Version_test.cpp index 71830c2219..b5c1abc160 100644 --- a/src/test/rpc/Version_test.cpp +++ b/src/test/rpc/Version_test.cpp @@ -32,7 +32,7 @@ class Version_test : public beast::unit_test::Suite auto jrr = env.rpc( "json", "version", - "{\"api_version\": " + std::to_string(RPC::kApiMaximumSupportedVersion) + + "{\"api_version\": " + std::to_string(rpc::kApiMaximumSupportedVersion) + "}")[jss::result]; BEAST_EXPECT(isCorrectReply(jrr)); @@ -62,7 +62,7 @@ class Version_test : public beast::unit_test::Suite auto re = env.rpc( "json", "version", - "{\"api_version\": " + std::to_string(RPC::kApiMinimumSupportedVersion - 1) + "}"); + "{\"api_version\": " + std::to_string(rpc::kApiMinimumSupportedVersion - 1) + "}"); BEAST_EXPECT(badVersion(re)); BEAST_EXPECT(env.app().config().betaRpcApi); @@ -71,7 +71,7 @@ class Version_test : public beast::unit_test::Suite "version", "{\"api_version\": " + std::to_string( - std::max(RPC::kApiMaximumSupportedVersion.value, RPC::kApiBetaVersion.value) + + std::max(rpc::kApiMaximumSupportedVersion.value, rpc::kApiBetaVersion.value) + 1) + "}"); BEAST_EXPECT(badVersion(re)); @@ -86,38 +86,38 @@ class Version_test : public beast::unit_test::Suite testcase("test getAPIVersionNumber function"); unsigned int const versionIfUnspecified = - RPC::kApiVersionIfUnspecified < RPC::kApiMinimumSupportedVersion - ? RPC::kApiInvalidVersion - : RPC::kApiVersionIfUnspecified; + rpc::kApiVersionIfUnspecified < rpc::kApiMinimumSupportedVersion + ? rpc::kApiInvalidVersion + : rpc::kApiVersionIfUnspecified; json::Value const jArray = json::Value(json::ValueType::Array); json::Value const jNull = json::Value(json::ValueType::Null); - BEAST_EXPECT(RPC::getAPIVersionNumber(jArray, false) == versionIfUnspecified); - BEAST_EXPECT(RPC::getAPIVersionNumber(jNull, false) == versionIfUnspecified); + BEAST_EXPECT(rpc::getAPIVersionNumber(jArray, false) == versionIfUnspecified); + BEAST_EXPECT(rpc::getAPIVersionNumber(jNull, false) == versionIfUnspecified); json::Value jObject = json::Value(json::ValueType::Object); - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == versionIfUnspecified); - jObject[jss::api_version] = RPC::kApiVersionIfUnspecified.value; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == versionIfUnspecified); + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == versionIfUnspecified); + jObject[jss::api_version] = rpc::kApiVersionIfUnspecified.value; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == versionIfUnspecified); - jObject[jss::api_version] = RPC::kApiMinimumSupportedVersion.value; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiMinimumSupportedVersion); - jObject[jss::api_version] = RPC::kApiMaximumSupportedVersion.value; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiMaximumSupportedVersion); + jObject[jss::api_version] = rpc::kApiMinimumSupportedVersion.value; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiMinimumSupportedVersion); + jObject[jss::api_version] = rpc::kApiMaximumSupportedVersion.value; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiMaximumSupportedVersion); - jObject[jss::api_version] = RPC::kApiMinimumSupportedVersion - 1; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiInvalidVersion); - jObject[jss::api_version] = RPC::kApiMaximumSupportedVersion + 1; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiInvalidVersion); - jObject[jss::api_version] = RPC::kApiBetaVersion.value; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, true) == RPC::kApiBetaVersion); - jObject[jss::api_version] = RPC::kApiBetaVersion + 1; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, true) == RPC::kApiInvalidVersion); + jObject[jss::api_version] = rpc::kApiMinimumSupportedVersion - 1; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiInvalidVersion); + jObject[jss::api_version] = rpc::kApiMaximumSupportedVersion + 1; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiInvalidVersion); + jObject[jss::api_version] = rpc::kApiBetaVersion.value; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, true) == rpc::kApiBetaVersion); + jObject[jss::api_version] = rpc::kApiBetaVersion + 1; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, true) == rpc::kApiInvalidVersion); - jObject[jss::api_version] = RPC::kApiInvalidVersion.value; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiInvalidVersion); + jObject[jss::api_version] = rpc::kApiInvalidVersion.value; + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiInvalidVersion); jObject[jss::api_version] = "a"; - BEAST_EXPECT(RPC::getAPIVersionNumber(jObject, false) == RPC::kApiInvalidVersion); + BEAST_EXPECT(rpc::getAPIVersionNumber(jObject, false) == rpc::kApiInvalidVersion); } void @@ -141,7 +141,7 @@ class Version_test : public beast::unit_test::Suite "\"method\": \"version\", " "\"params\": { " "\"api_version\": " + - std::to_string(RPC::kApiMaximumSupportedVersion) + "}}"; + std::to_string(rpc::kApiMaximumSupportedVersion) + "}}"; auto re = env.rpc("json2", '[' + withoutApiVerion + ", " + withApiVerion + ']'); if (!BEAST_EXPECT(re.isArray())) @@ -176,7 +176,7 @@ class Version_test : public beast::unit_test::Suite "\"params\": { " "\"api_version\": " + std::to_string( - std::max(RPC::kApiMaximumSupportedVersion.value, RPC::kApiBetaVersion.value) + 1) + + std::max(rpc::kApiMaximumSupportedVersion.value, rpc::kApiBetaVersion.value) + 1) + "}}"; auto re = env.rpc("json2", '[' + withoutApiVerion + ", " + withWrongApiVerion + ']'); @@ -226,15 +226,15 @@ class Version_test : public beast::unit_test::Suite auto jrr = env.rpc( "json", "version", - "{\"api_version\": " + std::to_string(RPC::kApiBetaVersion) + "}")[jss::result]; + "{\"api_version\": " + std::to_string(rpc::kApiBetaVersion) + "}")[jss::result]; if (!BEAST_EXPECT(jrr.isMember(jss::version))) return; if (!BEAST_EXPECT(jrr[jss::version].isMember(jss::first)) && jrr[jss::version].isMember(jss::last)) return; - BEAST_EXPECT(jrr[jss::version][jss::first] == RPC::kApiMinimumSupportedVersion.value); - BEAST_EXPECT(jrr[jss::version][jss::last] == RPC::kApiBetaVersion.value); + BEAST_EXPECT(jrr[jss::version][jss::first] == rpc::kApiMinimumSupportedVersion.value); + BEAST_EXPECT(jrr[jss::version][jss::last] == rpc::kApiBetaVersion.value); } public: diff --git a/src/tests/libxrpl/helpers/TestServiceRegistry.h b/src/tests/libxrpl/helpers/TestServiceRegistry.h index f7b09bccd1..e763c8bde4 100644 --- a/src/tests/libxrpl/helpers/TestServiceRegistry.h +++ b/src/tests/libxrpl/helpers/TestServiceRegistry.h @@ -213,7 +213,7 @@ public: throw std::logic_error("TestServiceRegistry::peerReservations() not implemented"); } - Resource::Manager& + resource::Manager& getResourceManager() override { throw std::logic_error("TestServiceRegistry::getResourceManager() not implemented"); diff --git a/src/tests/libxrpl/peerfinder/Livecache.cpp b/src/tests/libxrpl/peerfinder/Livecache.cpp index 464ec0e5da..298b09e04e 100644 --- a/src/tests/libxrpl/peerfinder/Livecache.cpp +++ b/src/tests/libxrpl/peerfinder/Livecache.cpp @@ -29,7 +29,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { namespace { class LivecacheTest : public ::testing::Test @@ -41,22 +41,22 @@ protected: return beast::Journal{TestSink::instance()}; } - static beast::IP::Endpoint + static beast::ip::Endpoint endpoint(std::uint16_t index, bool v4 = true) { auto const port = static_cast(10000 + index); if (v4) { - auto bytes = beast::IP::AddressV4::bytes_type{ + auto bytes = beast::ip::AddressV4::bytes_type{ {54, static_cast((index / 256) % 256), static_cast(index % 256), 1}}; - return beast::IP::Endpoint{beast::IP::Address{beast::IP::AddressV4{bytes}}, port}; + return beast::ip::Endpoint{beast::ip::Address{beast::ip::AddressV4{bytes}}, port}; } - auto bytes = beast::IP::AddressV6::bytes_type{ + auto bytes = beast::ip::AddressV6::bytes_type{ {0x20, 0x01, 0x0d, @@ -73,11 +73,11 @@ protected: static_cast((index / 256) % 256), static_cast(index % 256), 1}}; - return beast::IP::Endpoint{beast::IP::Address{beast::IP::AddressV6{bytes}}, port}; + return beast::ip::Endpoint{beast::ip::Address{beast::ip::AddressV6{bytes}}, port}; } void - addEndpoint(beast::IP::Endpoint const& ep, std::uint32_t hops = 0) + addEndpoint(beast::ip::Endpoint const& ep, std::uint32_t hops = 0) { cache_.insert(Endpoint{ep, hops}); } @@ -161,7 +161,7 @@ TEST_F(LivecacheTest, hop_iterators_support_const_reverse_and_move_back) TEST_F(LivecacheTest, on_write_reports_entries_and_expiration) { cache_.insert(Endpoint{endpoint(1), 1}); - cache_.insert(Endpoint{endpoint(2), Tuning::kMaxHops + 1}); + cache_.insert(Endpoint{endpoint(2), tuning::kMaxHops + 1}); JsonPropertyStream stream; { @@ -190,7 +190,7 @@ TEST_F(LivecacheTest, expire_removes_entries_after_ttl) cache_.expire(); EXPECT_EQ(cache_.size(), 1u); - clock_.advance(Tuning::kLiveCacheSecondsToLive - 1s); + clock_.advance(tuning::kLiveCacheSecondsToLive - 1s); cache_.expire(); EXPECT_EQ(cache_.size(), 1u); @@ -206,7 +206,7 @@ TEST_F(LivecacheTest, expire_removes_multiple_entries_after_ttl) cache_.insert(Endpoint{endpoint(1), 1}); cache_.insert(Endpoint{endpoint(2), 2}); - clock_.advance(Tuning::kLiveCacheSecondsToLive); + clock_.advance(tuning::kLiveCacheSecondsToLive); cache_.expire(); EXPECT_TRUE(cache_.empty()); } @@ -240,11 +240,11 @@ TEST_F(LivecacheTest, shuffle_preserves_bucket_contents) { for (auto i = 0; i < 100; ++i) { - addEndpoint(endpoint(static_cast(i)), xrpl::randInt(Tuning::kMaxHops + 1)); + addEndpoint(endpoint(static_cast(i)), xrpl::randInt(tuning::kMaxHops + 1)); } using AtHop = std::vector; - using AllHops = std::array; + using AllHops = std::array; auto const compareEndpoint = [](Endpoint const& lhs, Endpoint const& rhs) { return rhs.hops < lhs.hops || (rhs.hops == lhs.hops && rhs.address < lhs.address); @@ -291,4 +291,4 @@ TEST_F(LivecacheTest, shuffle_preserves_bucket_contents) EXPECT_FALSE(allBucketsKeptOriginalOrder); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/tests/libxrpl/peerfinder/PeerFinder.cpp b/src/tests/libxrpl/peerfinder/PeerFinder.cpp index 31fa59d1ce..3a52bbb5aa 100644 --- a/src/tests/libxrpl/peerfinder/PeerFinder.cpp +++ b/src/tests/libxrpl/peerfinder/PeerFinder.cpp @@ -38,7 +38,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { namespace { using ::testing::_; @@ -51,10 +51,10 @@ journal() return beast::Journal{TestSink::instance()}; } -beast::IP::Endpoint +beast::ip::Endpoint endpoint(std::string const& value) { - return beast::IP::Endpoint::fromString(value); + return beast::ip::Endpoint::fromString(value); } class MockStore : public Store @@ -86,7 +86,7 @@ public: }; Store::Entry -storeEntry(beast::IP::Endpoint const& endpoint, int valence) +storeEntry(beast::ip::Endpoint const& endpoint, int valence) { Store::Entry entry; entry.endpoint = endpoint; @@ -106,15 +106,15 @@ class MockChecker public: MOCK_METHOD(void, stop, ()); MOCK_METHOD(void, wait, ()); - MOCK_METHOD(void, recordAsyncConnect, (beast::IP::Endpoint const& ep)); + MOCK_METHOD(void, recordAsyncConnect, (beast::ip::Endpoint const& ep)); boost::system::error_code nextError; bool completeAsync = true; - std::vector asyncConnects; + std::vector asyncConnects; template void - asyncConnect(beast::IP::Endpoint const& ep, Handler&& handler) + asyncConnect(beast::ip::Endpoint const& ep, Handler&& handler) { asyncConnects.push_back(ep); recordAsyncConnect(ep); @@ -204,7 +204,7 @@ protected: }; int -savedValence(std::vector const& entries, beast::IP::Endpoint const& endpoint) +savedValence(std::vector const& entries, beast::ip::Endpoint const& endpoint) { for (auto const& entry : entries) { @@ -458,7 +458,7 @@ TEST(PeerFinderCounts, tracks_slot_states_and_capacity) EXPECT_EQ(counts.outboundSlotsFree(), 1); EXPECT_EQ(counts.totalActive(), 0); EXPECT_FALSE(counts.isConnectedToNetwork()); - EXPECT_EQ(counts.attemptsNeeded(), Tuning::kMaxConnectAttempts); + EXPECT_EQ(counts.attemptsNeeded(), tuning::kMaxConnectAttempts); EXPECT_EQ(counts.stateString(), "0/1 out, 0/1 in, 0 connecting, 0 closing"); SlotImp inbound(endpoint("65.0.0.1:10001"), endpoint("65.0.0.2:10002"), false, clock); @@ -483,7 +483,7 @@ TEST(PeerFinderCounts, tracks_slot_states_and_capacity) counts.add(outbound); EXPECT_EQ(counts.attempts(), 1); EXPECT_EQ(counts.connectCount(), 1); - EXPECT_EQ(counts.attemptsNeeded(), Tuning::kMaxConnectAttempts - 1); + EXPECT_EQ(counts.attemptsNeeded(), tuning::kMaxConnectAttempts - 1); counts.remove(outbound); outbound.state(Slot::State::Connected); @@ -535,7 +535,7 @@ TEST(PeerFinderCounts, tracks_slot_states_and_capacity) Counts saturatedAttempts; saturatedAttempts.onConfig(config); std::vector> attempts; - for (int i = 0; i < Tuning::kMaxConnectAttempts; ++i) + for (int i = 0; i < tuning::kMaxConnectAttempts; ++i) { attempts.push_back( std::make_unique( @@ -544,7 +544,7 @@ TEST(PeerFinderCounts, tracks_slot_states_and_capacity) clock)); saturatedAttempts.add(*attempts.back()); } - EXPECT_EQ(saturatedAttempts.attempts(), Tuning::kMaxConnectAttempts); + EXPECT_EQ(saturatedAttempts.attempts(), tuning::kMaxConnectAttempts); EXPECT_EQ(saturatedAttempts.attemptsNeeded(), 0u); Config disconnected; @@ -563,7 +563,7 @@ TEST(PeerFinderHandouts, filters_redirect_slot_and_connect_targets) EXPECT_EQ(redirects.slot(), slot); EXPECT_TRUE(redirects.list().empty()); EXPECT_FALSE(redirects.full()); - EXPECT_FALSE(redirects.tryInsert(Endpoint{endpoint("65.0.0.3:10003"), Tuning::kMaxHops + 1})); + EXPECT_FALSE(redirects.tryInsert(Endpoint{endpoint("65.0.0.3:10003"), tuning::kMaxHops + 1})); EXPECT_FALSE(redirects.tryInsert(Endpoint{endpoint("65.0.0.3:10003"), 0})); EXPECT_FALSE(redirects.tryInsert(Endpoint{remote.atPort(12000), 1})); EXPECT_TRUE(redirects.tryInsert(Endpoint{endpoint("65.0.0.3:10003"), 1})); @@ -574,7 +574,7 @@ TEST(PeerFinderHandouts, filters_redirect_slot_and_connect_targets) EXPECT_EQ(slotHandouts.slot(), slot); EXPECT_FALSE(slotHandouts.full()); EXPECT_FALSE( - slotHandouts.tryInsert(Endpoint{endpoint("65.0.0.4:10004"), Tuning::kMaxHops + 1})); + slotHandouts.tryInsert(Endpoint{endpoint("65.0.0.4:10004"), tuning::kMaxHops + 1})); EXPECT_FALSE(slotHandouts.tryInsert(Endpoint{remote.atPort(12001), 1})); auto const recent = endpoint("65.0.0.5:10005"); @@ -620,7 +620,7 @@ TEST(PeerFinderHandouts, distributes_livecache_entries) EXPECT_FALSE(targets.front().list().empty()); EXPECT_FALSE(targets.back().list().empty()); - for (std::uint32_t i = 0; i < Tuning::kNumberOfEndpoints; ++i) + for (std::uint32_t i = 0; i < tuning::kNumberOfEndpoints; ++i) targets.front().insert(Endpoint{endpoint("65.1.0." + std::to_string(i + 1) + ":12000"), 1}); handout(targets.begin(), targets.begin() + 1, cache.hops.begin(), cache.hops.end()); @@ -633,7 +633,7 @@ TEST_F(PeerFinderTest, preprocess_filters_invalid_duplicate_and_extra_self_endpo auto const remote = endpoint("65.0.0.2:10002"); auto const slot = std::make_shared(local, remote, false, clock_); Endpoints endpoints{ - Endpoint{endpoint("65.0.0.3:10003"), Tuning::kMaxHops + 1}, + Endpoint{endpoint("65.0.0.3:10003"), tuning::kMaxHops + 1}, Endpoint{endpoint("0.0.0.0:2459"), 0}, Endpoint{endpoint("0.0.0.0:2460"), 0}, Endpoint{endpoint("10.0.0.1:10004"), 1}, @@ -677,7 +677,7 @@ TEST_F(PeerFinderTest, on_endpoints_checks_neighbor_before_caching_it) EXPECT_TRUE(slot->canAccept); EXPECT_TRUE(logic_.livecache.empty()); - clock_.advance(Tuning::kSecondsPerMessage); + clock_.advance(tuning::kSecondsPerMessage); logic_.onEndpoints(slot, advertised); EXPECT_EQ(logic_.livecache.size(), 1u); EXPECT_EQ(logic_.bootcache.size(), 1u); @@ -711,7 +711,7 @@ TEST_F(PeerFinderTest, on_endpoints_skips_failed_neighbor_connectivity_checks) EXPECT_TRUE(slot->checked); EXPECT_FALSE(slot->canAccept); - clock_.advance(Tuning::kSecondsPerMessage); + clock_.advance(tuning::kSecondsPerMessage); logic_.onEndpoints(slot, advertised); EXPECT_TRUE(logic_.livecache.empty()); @@ -740,7 +740,7 @@ TEST_F(PeerFinderTest, on_endpoints_waits_for_pending_connectivity_check) logic_.onEndpoints(slot, advertised); EXPECT_TRUE(slot->connectivityCheckInProgress); - clock_.advance(Tuning::kSecondsPerMessage); + clock_.advance(tuning::kSecondsPerMessage); logic_.onEndpoints(slot, advertised); EXPECT_EQ(checker_.asyncConnects.size(), 1u); EXPECT_TRUE(logic_.livecache.empty()); @@ -950,7 +950,7 @@ TEST(PeerFinderBootcache, periodic_activity_saves_after_cooldown) cache.periodicActivity(); EXPECT_TRUE(store.saves.empty()); - clock.advance(Tuning::kBootcacheCooldownTime + 1s); + clock.advance(tuning::kBootcacheCooldownTime + 1s); cache.periodicActivity(); ASSERT_EQ(store.saves.size(), 1u); @@ -967,23 +967,23 @@ TEST(PeerFinderBootcache, prunes_when_cache_exceeds_limit) TestStopwatch clock; Bootcache cache(store, clock, journal()); - for (std::uint16_t i = 0; i <= Tuning::kBootcacheSize; ++i) + for (std::uint16_t i = 0; i <= tuning::kBootcacheSize; ++i) { EXPECT_TRUE(cache.insert(endpoint( "65.0." + std::to_string((i / 256) % 256) + "." + std::to_string(i % 256) + ":" + std::to_string(10000 + i)))); } - EXPECT_LE(cache.size(), Tuning::kBootcacheSize); + EXPECT_LE(cache.size(), tuning::kBootcacheSize); } TEST(PeerFinderEndpoint, clamps_hops_to_overflow_bucket) { auto const address = endpoint("65.0.0.1:10001"); - Endpoint const ep(address, Tuning::kMaxHops + 10); + Endpoint const ep(address, tuning::kMaxHops + 10); EXPECT_EQ(ep.address, address); - EXPECT_EQ(ep.hops, Tuning::kMaxHops + 1); + EXPECT_EQ(ep.hops, tuning::kMaxHops + 1); } TEST(PeerFinderSlotImp, tracks_state_and_recent_endpoints) @@ -1001,7 +1001,7 @@ TEST(PeerFinderSlotImp, tracks_state_and_recent_endpoints) EXPECT_FALSE(inbound.reserved()); EXPECT_EQ(inbound.state(), State::Accept); EXPECT_EQ(inbound.remoteEndpoint(), remote); - EXPECT_EQ(inbound.localEndpoint(), std::optional{local}); + EXPECT_EQ(inbound.localEndpoint(), std::optional{local}); EXPECT_FALSE(inbound.publicKey()); EXPECT_FALSE(inbound.listeningPort()); EXPECT_FALSE(inbound.checked); @@ -1018,7 +1018,7 @@ TEST(PeerFinderSlotImp, tracks_state_and_recent_endpoints) inbound.reserved(true); inbound.setListeningPort(2459); - EXPECT_EQ(inbound.localEndpoint(), std::optional{newLocal}); + EXPECT_EQ(inbound.localEndpoint(), std::optional{newLocal}); EXPECT_EQ(inbound.remoteEndpoint(), newRemote); EXPECT_EQ(inbound.publicKey(), std::optional{publicKey}); EXPECT_TRUE(inbound.reserved()); @@ -1055,7 +1055,7 @@ TEST(PeerFinderSlotImp, tracks_state_and_recent_endpoints) EXPECT_TRUE(outbound.recent.filter(recent, 1)); EXPECT_FALSE(outbound.recent.filter(recent, 0)); - clock.advance(Tuning::kLiveCacheSecondsToLive + 1s); + clock.advance(tuning::kLiveCacheSecondsToLive + 1s); outbound.expire(); EXPECT_FALSE(outbound.recent.filter(recent, 1)); } @@ -1112,7 +1112,7 @@ TEST(PeerFinderConfig, calculates_outbound_peers_and_clamps_ip_limits) { Config config; config.maxPeers = 1; - EXPECT_EQ(config.calcOutPeers(), Tuning::kMinOutCount); + EXPECT_EQ(config.calcOutPeers(), tuning::kMinOutCount); config.maxPeers = 100; EXPECT_EQ(config.calcOutPeers(), 15u); @@ -1267,4 +1267,4 @@ TEST(PeerFinderConfig, rejects_incomplete_or_out_of_range_peer_limits) } } // namespace -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/tests/libxrpl/protocol/ApiVersion.cpp b/src/tests/libxrpl/protocol/ApiVersion.cpp index 8af7787102..5bb6a158cf 100644 --- a/src/tests/libxrpl/protocol/ApiVersion.cpp +++ b/src/tests/libxrpl/protocol/ApiVersion.cpp @@ -6,21 +6,21 @@ using namespace xrpl; TEST(ApiVersion, invariants) { - static_assert(RPC::kApiMinimumSupportedVersion <= RPC::kApiMaximumSupportedVersion); - static_assert(RPC::kApiMinimumSupportedVersion <= RPC::kApiMaximumValidVersion); - static_assert(RPC::kApiMaximumSupportedVersion <= RPC::kApiMaximumValidVersion); - static_assert(RPC::kApiBetaVersion <= RPC::kApiMaximumValidVersion); + static_assert(rpc::kApiMinimumSupportedVersion <= rpc::kApiMaximumSupportedVersion); + static_assert(rpc::kApiMinimumSupportedVersion <= rpc::kApiMaximumValidVersion); + static_assert(rpc::kApiMaximumSupportedVersion <= rpc::kApiMaximumValidVersion); + static_assert(rpc::kApiBetaVersion <= rpc::kApiMaximumValidVersion); } // Update when we change versions TEST(ApiVersion, versions) { - static_assert(RPC::kApiMinimumSupportedVersion >= 1); - static_assert(RPC::kApiMinimumSupportedVersion < 2); - static_assert(RPC::kApiMaximumSupportedVersion >= 2); - static_assert(RPC::kApiMaximumSupportedVersion < 3); - static_assert(RPC::kApiMaximumValidVersion >= 3); - static_assert(RPC::kApiMaximumValidVersion < 4); - static_assert(RPC::kApiBetaVersion >= 3); - static_assert(RPC::kApiBetaVersion < 4); + static_assert(rpc::kApiMinimumSupportedVersion >= 1); + static_assert(rpc::kApiMinimumSupportedVersion < 2); + static_assert(rpc::kApiMaximumSupportedVersion >= 2); + static_assert(rpc::kApiMaximumSupportedVersion < 3); + static_assert(rpc::kApiMaximumValidVersion >= 3); + static_assert(rpc::kApiMaximumValidVersion < 4); + static_assert(rpc::kApiBetaVersion >= 3); + static_assert(rpc::kApiBetaVersion < 4); } diff --git a/src/tests/libxrpl/resource/Logic.cpp b/src/tests/libxrpl/resource/Logic.cpp index a3362b4540..b38ca2e051 100644 --- a/src/tests/libxrpl/resource/Logic.cpp +++ b/src/tests/libxrpl/resource/Logic.cpp @@ -24,7 +24,7 @@ #include #include -namespace xrpl::Resource { +namespace xrpl::resource { class ResourceManagerTest : public ::testing::Test { @@ -68,13 +68,13 @@ protected: { Gossip::Item item; item.balance = 100 + randInt(499); - beast::IP::AddressV4::bytes_type const d = {{ + beast::ip::AddressV4::bytes_type const d = {{ 192, 0, 2, static_cast(v + i), }}; - item.address = beast::IP::Endpoint{beast::IP::AddressV4{d}}; + item.address = beast::ip::Endpoint{beast::ip::AddressV4{d}}; gossip.items.push_back(std::move(item)); } return gossip; @@ -86,7 +86,7 @@ TEST_F(ResourceManagerTest, limited_warn_drop) TestLogic logic{j_}; Charge const fee{kDropThreshold + 1}; - beast::IP::Endpoint const addr{beast::IP::Endpoint::fromString("192.0.2.2")}; + beast::ip::Endpoint const addr{beast::ip::Endpoint::fromString("192.0.2.2")}; { Consumer c{logic.newInboundEndpoint(addr)}; @@ -158,7 +158,7 @@ TEST_F(ResourceManagerTest, unlimited_warn_drop) TestLogic logic{j_}; Charge const fee{kDropThreshold + 1}; - beast::IP::Endpoint const addr{beast::IP::Endpoint::fromString("192.0.2.2")}; + beast::ip::Endpoint const addr{beast::ip::Endpoint::fromString("192.0.2.2")}; Consumer c{logic.newUnlimitedEndpoint(addr)}; // Create load until we get a warning @@ -185,7 +185,7 @@ TEST_F(ResourceManagerTest, charges) TestLogic logic{j_}; { - beast::IP::Endpoint const address{beast::IP::Endpoint::fromString("192.0.2.1")}; + beast::ip::Endpoint const address{beast::ip::Endpoint::fromString("192.0.2.1")}; Consumer c{logic.newInboundEndpoint(address)}; Charge const fee{1000}; JLOG(j_.info()) << "Charging " << c.toString() << " " << fee << " per second"; @@ -199,7 +199,7 @@ TEST_F(ResourceManagerTest, charges) } { - beast::IP::Endpoint const address{beast::IP::Endpoint::fromString("192.0.2.2")}; + beast::ip::Endpoint const address{beast::ip::Endpoint::fromString("192.0.2.2")}; Consumer c{logic.newInboundEndpoint(address)}; Charge const fee{1000}; JLOG(j_.info()) << "Charging " << c.toString() << " " << fee << " per second"; @@ -230,16 +230,16 @@ TEST_F(ResourceManagerTest, import) Gossip g; Gossip::Item item; item.balance = 100; - beast::IP::AddressV4::bytes_type const d = {{ + beast::ip::AddressV4::bytes_type const d = {{ 192, 0, 2, 1, }}; - item.address = beast::IP::Endpoint{beast::IP::AddressV4{d}}; + item.address = beast::ip::Endpoint{beast::ip::AddressV4{d}}; g.items.push_back(std::move(item)); logic.importConsumers("g", g); } -} // namespace xrpl::Resource +} // namespace xrpl::resource diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 20421ab916..28b910c8e5 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -847,7 +847,7 @@ RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, RCLTxSet const& txns, // Report our server version every flag ledger: if (ledger.ledger->isVotingLedger()) - v.setFieldU64(sfServerVersion, BuildInfo::getEncodedVersion()); + v.setFieldU64(sfServerVersion, build_info::getEncodedVersion()); // Report our load { diff --git a/src/xrpld/app/ledger/LedgerReplayer.h b/src/xrpld/app/ledger/LedgerReplayer.h index 6feb187df6..b2806ee813 100644 --- a/src/xrpld/app/ledger/LedgerReplayer.h +++ b/src/xrpld/app/ledger/LedgerReplayer.h @@ -24,7 +24,7 @@ namespace test { class LedgerReplayClient; } // namespace test -namespace LedgerReplayParameters { +namespace ledger_replay_parameters { // timeout value for LedgerReplayTask constexpr auto kTaskTimeout = std::chrono::milliseconds{500}; @@ -53,7 +53,7 @@ constexpr std::uint32_t kMaxTaskSize = 256; // to limit the number of LedgerReplay related jobs in JobQueue constexpr std::uint32_t kMaxQueuedTasks = 100; -} // namespace LedgerReplayParameters +} // namespace ledger_replay_parameters /** * Manages the lifetime of ledger replay tasks. diff --git a/src/xrpld/app/ledger/LedgerToJson.h b/src/xrpld/app/ledger/LedgerToJson.h index 1eac4d68f1..e1172e897a 100644 --- a/src/xrpld/app/ledger/LedgerToJson.h +++ b/src/xrpld/app/ledger/LedgerToJson.h @@ -18,7 +18,7 @@ struct LedgerFill { LedgerFill( ReadView const& l, - RPC::Context const* ctx, + rpc::Context const* ctx, int o = 0, std::vector q = {}) : ledger(l), options(o), txQueue(std::move(q)), context(ctx) @@ -40,7 +40,7 @@ struct LedgerFill ReadView const& ledger; int options; std::vector txQueue; - RPC::Context const* context; + rpc::Context const* context; std::optional closeTime; }; diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index b3dafcf5e6..246c7d567b 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -879,7 +879,7 @@ InboundLedger::receiveNode( { JLOG(journal_.warn()) << "Got invalid node data for ledger " << hash_ << " from peer " << peer->id(); - peer->charge(Resource::kFeeInvalidData, "ledger_node.node_data invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_node.node_data invalid"); san.incInvalid(); return; } @@ -889,7 +889,7 @@ InboundLedger::receiveNode( { JLOG(journal_.warn()) << "Got invalid node id for ledger " << hash_ << " from peer " << peer->id(); - peer->charge(Resource::kFeeInvalidData, "ledger_node.node_id invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_node.node_id invalid"); san.incInvalid(); return; } @@ -903,7 +903,7 @@ InboundLedger::receiveNode( { JLOG(journal_.warn()) << "Got invalid node " << *nodeID << " for ledger " << hash_ << " from peer " << peer->id(); - peer->charge(Resource::kFeeInvalidData, "ledger_node invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_node invalid"); return; } } @@ -1068,7 +1068,7 @@ InboundLedger::gotData( * Returns the number of useful nodes */ // VFALCO NOTE, it is not necessary to pass the entire Peer, -// we can get away with just a Resource::Consumer endpoint. +// we can get away with just a resource::Consumer endpoint. // // TODO Change peer to Consumer // @@ -1080,7 +1080,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co if (packet.nodes().empty()) { JLOG(journal_.warn()) << peer->id() << ": empty header data"; - peer->charge(Resource::kFeeMalformedRequest, "ledger_data empty header"); + peer->charge(resource::kFeeMalformedRequest, "ledger_data empty header"); return -1; } @@ -1095,7 +1095,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co if (!takeHeader(packet.nodes(0).nodedata())) { JLOG(journal_.warn()) << "Got invalid header data"; - peer->charge(Resource::kFeeMalformedRequest, "ledger_data invalid header"); + peer->charge(resource::kFeeMalformedRequest, "ledger_data invalid header"); return -1; } @@ -1109,7 +1109,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co << " from peer " << peer->id(); if (san.isInvalid()) { - peer->charge(Resource::kFeeInvalidData, "ledger_data invalid AS root"); + peer->charge(resource::kFeeInvalidData, "ledger_data invalid AS root"); return -1; } } @@ -1121,7 +1121,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co << " from peer " << peer->id(); if (san.isInvalid()) { - peer->charge(Resource::kFeeInvalidData, "ledger_data invalid TX root"); + peer->charge(resource::kFeeInvalidData, "ledger_data invalid TX root"); return -1; } } @@ -1131,7 +1131,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co JLOG(journal_.warn()) << "Included AS/TX root invalid for ledger " << hash_ << " from peer " << peer->id() << ": " << ex.what(); using namespace std::string_literals; - peer->charge(Resource::kFeeInvalidData, "ledger_data "s + ex.what()); + peer->charge(resource::kFeeInvalidData, "ledger_data "s + ex.what()); return -1; } @@ -1147,7 +1147,7 @@ InboundLedger::processData(std::shared_ptr peer, protocol::TMLedgerData co if (packet.nodes().empty()) { JLOG(journal_.info()) << peer->id() << ": response with no nodes"; - peer->charge(Resource::kFeeMalformedRequest, "ledger_data no nodes"); + peer->charge(resource::kFeeMalformedRequest, "ledger_data no nodes"); return -1; } diff --git a/src/xrpld/app/ledger/detail/InboundTransactions.cpp b/src/xrpld/app/ledger/detail/InboundTransactions.cpp index d735a97d28..62897fe617 100644 --- a/src/xrpld/app/ledger/detail/InboundTransactions.cpp +++ b/src/xrpld/app/ledger/detail/InboundTransactions.cpp @@ -138,7 +138,7 @@ public: if (ta == nullptr) { - peer->charge(Resource::kFeeUselessData, "ledger_data useless"); + peer->charge(resource::kFeeUselessData, "ledger_data useless"); return; } @@ -152,7 +152,7 @@ public: { JLOG(j_.warn()) << "Got invalid node data for TX set " << hash << " from peer " << peer->id(); - peer->charge(Resource::kFeeInvalidData, "ledger_node.node_data invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_node.node_data invalid"); return; } @@ -161,7 +161,7 @@ public: { JLOG(j_.warn()) << "Got invalid node id for TX set " << hash << " from peer " << peer->id(); - peer->charge(Resource::kFeeInvalidData, "ledger_node.node_id invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_node.node_id invalid"); return; } @@ -171,11 +171,11 @@ public: auto const san = ta->takeNodes(std::move(data), peer); if (san.isInvalid()) { - peer->charge(Resource::kFeeInvalidData, "ledger_data invalid"); + peer->charge(resource::kFeeInvalidData, "ledger_data invalid"); } else if (!san.isUseful()) { - peer->charge(Resource::kFeeUselessData, "ledger_data useless"); + peer->charge(resource::kFeeUselessData, "ledger_data useless"); } } diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index 7ac85b892e..344d5cb8fc 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -43,10 +43,10 @@ LedgerDeltaAcquire::LedgerDeltaAcquire( : TimeoutCounter( app, ledgerHash, - LedgerReplayParameters::kSubTaskTimeout, + ledger_replay_parameters::kSubTaskTimeout, {.jobType = JtReplayTask, .jobName = "LedReplDelta", - .jobLimit = LedgerReplayParameters::kMaxQueuedTasks}, + .jobLimit = ledger_replay_parameters::kMaxQueuedTasks}, app.getJournal("LedgerReplayDelta")) , inboundLedgers_(inboundLedgers) , ledgerSeq_(ledgerSeq) @@ -101,10 +101,10 @@ LedgerDeltaAcquire::trigger(std::size_t limit, ScopedLockType& sl) } else { - if (++noFeaturePeerCount_ >= LedgerReplayParameters::kMaxNoFeaturePeerCount) + if (++noFeaturePeerCount_ >= ledger_replay_parameters::kMaxNoFeaturePeerCount) { JLOG(journal_.debug()) << "Fall back for " << hash_; - timerInterval_ = LedgerReplayParameters::kSubTaskFallbackTimeout; + timerInterval_ = ledger_replay_parameters::kSubTaskFallbackTimeout; fallBack_ = true; } } @@ -119,7 +119,7 @@ void LedgerDeltaAcquire::onTimer(bool progress, ScopedLockType& sl) { JLOG(journal_.trace()) << "timeouts_=" << timeouts_ << " for " << hash_; - if (timeouts_ > LedgerReplayParameters::kSubTaskMaxTimeouts) + if (timeouts_ > ledger_replay_parameters::kSubTaskMaxTimeouts) { failed_ = true; JLOG(journal_.debug()) << "too many timeouts " << hash_; diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 9a0335fc3c..83d76bcd2a 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -1042,8 +1042,8 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) if (v->isFieldPresent(sfServerVersion)) { auto version = v->getFieldU64(sfServerVersion); - higherVersionCount += BuildInfo::isNewerVersion(version) ? 1 : 0; - xrpldCount += BuildInfo::isXrpldVersion(version) ? 1 : 0; + higherVersionCount += build_info::isNewerVersion(version) ? 1 : 0; + xrpldCount += build_info::isXrpldVersion(version) ? 1 : 0; } } // We report only if (1) we have accumulated validation messages @@ -2088,21 +2088,21 @@ LedgerMaster::makeFetchPack( if (!have) { JLOG(journal_.info()) << "Peer requests fetch pack for ledger we don't have: " << have; - peer->charge(Resource::kFeeRequestNoReply, "get_object ledger"); + peer->charge(resource::kFeeRequestNoReply, "get_object ledger"); return; } if (have->open()) { JLOG(journal_.warn()) << "Peer requests fetch pack from open ledger: " << have; - peer->charge(Resource::kFeeMalformedRequest, "get_object ledger open"); + peer->charge(resource::kFeeMalformedRequest, "get_object ledger open"); return; } if (have->header().seq < getEarliestFetch()) { JLOG(journal_.debug()) << "Peer requests fetch pack that is too early"; - peer->charge(Resource::kFeeMalformedRequest, "get_object ledger early"); + peer->charge(resource::kFeeMalformedRequest, "get_object ledger early"); return; } @@ -2112,7 +2112,7 @@ LedgerMaster::makeFetchPack( { JLOG(journal_.info()) << "Peer requests fetch pack for ledger whose predecessor we " << "don't have: " << have; - peer->charge(Resource::kFeeRequestNoReply, "get_object ledger no parent"); + peer->charge(resource::kFeeRequestNoReply, "get_object ledger no parent"); return; } diff --git a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index e7cd031247..3d7b1e0f92 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -87,18 +87,18 @@ LedgerReplayTask::LedgerReplayTask( : TimeoutCounter( app, parameter.finishHash, - LedgerReplayParameters::kTaskTimeout, + ledger_replay_parameters::kTaskTimeout, {.jobType = JtReplayTask, .jobName = "LedReplTask", - .jobLimit = LedgerReplayParameters::kMaxQueuedTasks}, + .jobLimit = ledger_replay_parameters::kMaxQueuedTasks}, app.getJournal("LedgerReplayTask")) , inboundLedgers_(inboundLedgers) , replayer_(replayer) , parameter_(parameter) , maxTimeouts_( std::max( - LedgerReplayParameters::kTaskMaxTimeoutsMinimum, - parameter.totalLedgers * LedgerReplayParameters::kTaskMaxTimeoutsMultiplier)) + ledger_replay_parameters::kTaskMaxTimeoutsMinimum, + parameter.totalLedgers * ledger_replay_parameters::kTaskMaxTimeoutsMultiplier)) , skipListAcquirer_(skipListAcquirer) { JLOG(journal_.trace()) << "Create " << hash_; diff --git a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp index 3bb5ca9434..52184c1723 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp @@ -51,7 +51,7 @@ LedgerReplayer::replay( { XRPL_ASSERT( finishLedgerHash.isNonZero() && totalNumLedgers > 0 && - totalNumLedgers <= LedgerReplayParameters::kMaxTaskSize, + totalNumLedgers <= ledger_replay_parameters::kMaxTaskSize, "xrpl::LedgerReplayer::replay : valid inputs"); // NOLINTNEXTLINE(misc-const-correctness) @@ -64,7 +64,7 @@ LedgerReplayer::replay( std::scoped_lock const lock(mtx_); if (app_.isStopping()) return; - if (tasks_.size() >= LedgerReplayParameters::kMaxTasks) + if (tasks_.size() >= ledger_replay_parameters::kMaxTasks) { JLOG(j_.info()) << "Too many replay tasks, dropping new task " << parameter.finishHash; return; diff --git a/src/xrpld/app/ledger/detail/LedgerToJson.cpp b/src/xrpld/app/ledger/detail/LedgerToJson.cpp index 7a581e2389..9d3820e9f7 100644 --- a/src/xrpld/app/ledger/detail/LedgerToJson.cpp +++ b/src/xrpld/app/ledger/detail/LedgerToJson.cpp @@ -135,7 +135,7 @@ fillJsonTx( { copyFrom(txJson[jss::tx_json], txn->getJson(JsonOptions::Values::DisableApiPriorV2, false)); txJson[jss::hash] = to_string(txn->getTransactionID()); - RPC::insertDeliverMax(txJson[jss::tx_json], txnType, fill.context->apiVersion); + rpc::insertDeliverMax(txJson[jss::tx_json], txnType, fill.context->apiVersion); if (stMeta) { @@ -144,7 +144,7 @@ fillJsonTx( // If applicable, insert delivered amount if (txnType == ttPAYMENT || txnType == ttCHECK_CASH) { - RPC::insertDeliveredAmount( + rpc::insertDeliveredAmount( txJson[jss::meta], fill.ledger, txn, @@ -152,7 +152,7 @@ fillJsonTx( } // If applicable, insert mpt issuance id - RPC::insertMPTokenIssuanceID( + rpc::insertMPTokenIssuanceID( txJson[jss::meta], txn, {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); } @@ -172,7 +172,7 @@ fillJsonTx( else { copyFrom(txJson, txn->getJson(JsonOptions::Values::None)); - RPC::insertDeliverMax(txJson, txnType, fill.context->apiVersion); + rpc::insertDeliverMax(txJson, txnType, fill.context->apiVersion); if (stMeta) { txJson[jss::metaData] = stMeta->getJson(JsonOptions::Values::None); @@ -180,7 +180,7 @@ fillJsonTx( // If applicable, insert delivered amount if (txnType == ttPAYMENT || txnType == ttCHECK_CASH) { - RPC::insertDeliveredAmount( + rpc::insertDeliveredAmount( txJson[jss::metaData], fill.ledger, txn, @@ -188,7 +188,7 @@ fillJsonTx( } // If applicable, insert mpt issuance id - RPC::insertMPTokenIssuanceID( + rpc::insertMPTokenIssuanceID( txJson[jss::metaData], txn, {txn->getTransactionID(), fill.ledger.seq(), *stMeta}); } } @@ -337,7 +337,7 @@ fillJson(json::Value& json, LedgerFill const& fill) fill.ledger.header(), bFull, ((fill.context != nullptr) ? fill.context->apiVersion - : RPC::kApiMaximumSupportedVersion)); + : rpc::kApiMaximumSupportedVersion)); } if (bFull || ((fill.options & static_cast(LedgerFill::Options::DumpTxrp)) != 0)) diff --git a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp index 8ebd14083a..97b50a9a3a 100644 --- a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp @@ -37,10 +37,10 @@ SkipListAcquire::SkipListAcquire( : TimeoutCounter( app, ledgerHash, - LedgerReplayParameters::kSubTaskTimeout, + ledger_replay_parameters::kSubTaskTimeout, {.jobType = JtReplayTask, .jobName = "SkipListAcq", - .jobLimit = LedgerReplayParameters::kMaxQueuedTasks}, + .jobLimit = ledger_replay_parameters::kMaxQueuedTasks}, app.getJournal("LedgerReplaySkipList")) , inboundLedgers_(inboundLedgers) , peerSet_(std::move(peerSet)) @@ -96,10 +96,10 @@ SkipListAcquire::trigger(std::size_t limit, ScopedLockType& sl) { JLOG(journal_.trace()) << "Add a no feature peer " << peer->id() << " for " << hash_; - if (++noFeaturePeerCount_ >= LedgerReplayParameters::kMaxNoFeaturePeerCount) + if (++noFeaturePeerCount_ >= ledger_replay_parameters::kMaxNoFeaturePeerCount) { JLOG(journal_.debug()) << "Fall back for " << hash_; - timerInterval_ = LedgerReplayParameters::kSubTaskFallbackTimeout; + timerInterval_ = ledger_replay_parameters::kSubTaskFallbackTimeout; fallBack_ = true; } } @@ -114,7 +114,7 @@ void SkipListAcquire::onTimer(bool progress, ScopedLockType& sl) { JLOG(journal_.trace()) << "timeouts_=" << timeouts_ << " for " << hash_; - if (timeouts_ > LedgerReplayParameters::kSubTaskMaxTimeouts) + if (timeouts_ > ledger_replay_parameters::kSubTaskMaxTimeouts) { failed_ = true; JLOG(journal_.debug()) << "too many timeouts " << hash_; diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 5c8fdad37c..52ec9ce544 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -230,7 +230,7 @@ public: std::optional> nodeIdentity_; ValidatorKeys const validatorKeys_; - std::unique_ptr resourceManager_; + std::unique_ptr resourceManager_; std::unique_ptr nodeStore_; NodeFamily nodeFamily_; @@ -375,7 +375,7 @@ public: , networkIDService_(std::make_unique(config_->networkId)) , validatorKeys_(*config_, journal_) , resourceManager_( - Resource::makeManager(collectorManager_->collector(), logs_->journal("Resource"))) + resource::makeManager(collectorManager_->collector(), logs_->journal("Resource"))) , nodeStore_(shaMapStore_->makeNodeStore( config_->prefetchWorkers > 0 ? config_->prefetchWorkers : 4)) , nodeFamily_(*this, *collectorManager_) @@ -673,7 +673,7 @@ public: return *loadManager_; } - Resource::Manager& + resource::Manager& getResourceManager() override { return *resourceManager_; @@ -1187,7 +1187,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) logs_->threshold(Severity::Debug); } - JLOG(journal_.info()) << "Process starting: " << BuildInfo::getFullVersionString() + JLOG(journal_.info()) << "Process starting: " << build_info::getFullVersionString() << ", Instance Cookie: " << instanceCookie_; if (numberOfThreads(*config_) < 2) @@ -1457,9 +1457,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) JLOG(journal_.fatal()) << "Startup RPC: " << jvCommand << std::endl; } - Resource::Charge loadType = Resource::kFeeReferenceRpc; - Resource::Consumer c; - RPC::JsonContext context{ + resource::Charge loadType = resource::kFeeReferenceRpc; + resource::Consumer c; + rpc::JsonContext context{ {.j = getJournal("RPCHandler"), .app = *this, .loadType = loadType, @@ -1469,11 +1469,11 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) .role = Role::ADMIN, .coro = {}, .infoSub = {}, - .apiVersion = RPC::kApiMaximumSupportedVersion}, + .apiVersion = rpc::kApiMaximumSupportedVersion}, jvCommand}; json::Value jvResult; - RPC::doCommand(context, jvResult); + rpc::doCommand(context, jvResult); if (!config_->quiet()) { @@ -1489,7 +1489,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) void ApplicationImp::start(bool withTimers) { - JLOG(journal_.info()) << "Application starting. Version is " << BuildInfo::getVersionString(); + JLOG(journal_.info()) << "Application starting. Version is " << build_info::getVersionString(); if (withTimers) { diff --git a/src/xrpld/app/main/CollectorManager.cpp b/src/xrpld/app/main/CollectorManager.cpp index 9e1278607f..87b5286f97 100644 --- a/src/xrpld/app/main/CollectorManager.cpp +++ b/src/xrpld/app/main/CollectorManager.cpp @@ -30,8 +30,8 @@ public: if (server == "statsd") { - beast::IP::Endpoint const address( - beast::IP::Endpoint::fromString(get(params, Keys::kAddress))); + beast::ip::Endpoint const address( + beast::ip::Endpoint::fromString(get(params, Keys::kAddress))); std::string const& prefix(get(params, Keys::kPrefix)); collector_ = beast::insight::StatsDCollector::make(address, prefix, journal); diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 1146cbdc08..1b20ff1d49 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -71,10 +71,10 @@ getEndpoint(std::string const& peer) peerClean = peer.substr(first + 1); } - std::optional endpoint = - beast::IP::Endpoint::fromStringChecked(peerClean); + std::optional endpoint = + beast::ip::Endpoint::fromStringChecked(peerClean); if (endpoint) - return beast::IP::toAsioEndpoint(endpoint.value()); + return beast::ip::toAsioEndpoint(endpoint.value()); } catch (std::exception const&) // NOLINT(bugprone-empty-catch) { @@ -92,8 +92,8 @@ GRPCServerImpl::CallData::CallData( BindListener bindListener, Handler handler, Forward forward, - RPC::Condition requiredCondition, - Resource::Charge loadType, + rpc::Condition requiredCondition, + resource::Charge loadType, std::vector const& secureGatewayIPs) : service_(service) , cq_(cq) @@ -195,7 +195,7 @@ GRPCServerImpl::CallData::process(std::shared_ptr context{ + rpc::GRPCContext context{ {app_.getJournal("gRPCServer"), app_, loadType, @@ -209,11 +209,11 @@ GRPCServerImpl::CallData::process(std::shared_ptr::isFinished() } template -Resource::Charge +resource::Charge GRPCServerImpl::CallData::getLoadType() { return loadType_; @@ -323,12 +323,12 @@ GRPCServerImpl::CallData::setIsUnlimited(Response& response, } template -Resource::Consumer +resource::Consumer GRPCServerImpl::CallData::getUsage() { auto endpoint = getClientEndpoint(); if (endpoint) - return app_.getResourceManager().newInboundEndpoint(beast::IP::fromAsio(endpoint.value())); + return app_.getResourceManager().newInboundEndpoint(beast::ip::fromAsio(endpoint.value())); Throw("Failed to get client endpoint"); } @@ -527,7 +527,7 @@ GRPCServerImpl::handleRpcs() std::vector> GRPCServerImpl::setupListeners() { - using RPC::Condition; + using rpc::Condition; std::vector> requests; auto addToRequests = [&requests](auto callData) { requests.push_back(std::move(callData)); }; @@ -545,7 +545,7 @@ GRPCServerImpl::setupListeners() doLedgerGrpc, &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedger, Condition::NoCondition, - Resource::kFeeMediumBurdenRpc, + resource::kFeeMediumBurdenRpc, secureGatewayIPs_)); } { @@ -562,7 +562,7 @@ GRPCServerImpl::setupListeners() doLedgerDataGrpc, &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerData, Condition::NoCondition, - Resource::kFeeMediumBurdenRpc, + resource::kFeeMediumBurdenRpc, secureGatewayIPs_)); } { @@ -579,7 +579,7 @@ GRPCServerImpl::setupListeners() doLedgerDiffGrpc, &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerDiff, Condition::NoCondition, - Resource::kFeeMediumBurdenRpc, + resource::kFeeMediumBurdenRpc, secureGatewayIPs_)); } { @@ -596,7 +596,7 @@ GRPCServerImpl::setupListeners() doLedgerEntryGrpc, &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerEntry, Condition::NoCondition, - Resource::kFeeMediumBurdenRpc, + resource::kFeeMediumBurdenRpc, secureGatewayIPs_)); } return requests; diff --git a/src/xrpld/app/main/GRPCServer.h b/src/xrpld/app/main/GRPCServer.h index db948cab99..98b50fcd0c 100644 --- a/src/xrpld/app/main/GRPCServer.h +++ b/src/xrpld/app/main/GRPCServer.h @@ -102,7 +102,7 @@ private: // typedef for actual handler (that populates a response) // handlers are defined in rpc/GRPCHandlers.h template - using Handler = std::function(RPC::GRPCContext&)>; + using Handler = std::function(rpc::GRPCContext&)>; // This implementation is currently limited to v1 of the API static constexpr unsigned kApiVersion = 1; @@ -189,10 +189,10 @@ private: Forward forward_; // Condition required for this RPC - RPC::Condition requiredCondition_; + rpc::Condition requiredCondition_; // Load type for this RPC - Resource::Charge loadType_; + resource::Charge loadType_; std::vector const& secureGatewayIPs_; @@ -209,8 +209,8 @@ private: BindListener bindListener, Handler handler, Forward forward, - RPC::Condition requiredCondition, - Resource::Charge loadType, + rpc::Condition requiredCondition, + resource::Charge loadType, std::vector const& secureGatewayIPs); CallData(CallData const&) = delete; @@ -233,7 +233,7 @@ private: process(std::shared_ptr coro); // return load type of this RPC - Resource::Charge + resource::Charge getLoadType(); // return the Role used for this RPC @@ -241,7 +241,7 @@ private: getRole(bool isUnlimited); // register endpoint with ResourceManager and return usage - Resource::Consumer + resource::Consumer getUsage(); // Returns the ip of the client @@ -290,7 +290,7 @@ private: // forward request to a p2p node void - forwardToP2p(RPC::GRPCContext& context); + forwardToP2p(rpc::GRPCContext& context); }; // CallData diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index d0b40efce8..a23b84f2e8 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -506,7 +506,7 @@ run(int argc, char** argv) if (vm.contains("version")) { // LCOV_EXCL_START - std::cout << "xrpld version " << BuildInfo::getVersionString() << std::endl; + std::cout << "xrpld version " << build_info::getVersionString() << std::endl; std::cout << "Git commit hash: " << xrpl::git::getCommitHash() << std::endl; std::cout << "Git build branch: " << xrpl::git::getBuildBranch() << std::endl; return 0; @@ -716,7 +716,7 @@ run(int argc, char** argv) // happen after the config file is loaded. if (vm.contains("rpc_ip")) { - auto endpoint = beast::IP::Endpoint::fromStringChecked(vm["rpc_ip"].as()); + auto endpoint = beast::ip::Endpoint::fromStringChecked(vm["rpc_ip"].as()); if (!endpoint) { std::cerr << "Invalid rpc_ip = " << vm["rpc_ip"].as() << "\n"; @@ -826,7 +826,7 @@ run(int argc, char** argv) // We have an RPC command to process: beast::setCurrentThreadName("xrpld: rpc"); - return RPCCall::fromCommandLine( + return rpc_call::fromCommandLine( *config, vm["parameters"].as>(), *logs); // LCOV_EXCL_STOP } diff --git a/src/xrpld/app/misc/DeliverMax.h b/src/xrpld/app/misc/DeliverMax.h index 73ccc95800..1683219c8b 100644 --- a/src/xrpld/app/misc/DeliverMax.h +++ b/src/xrpld/app/misc/DeliverMax.h @@ -6,7 +6,7 @@ namespace json { class Value; } // namespace json -namespace xrpl::RPC { +namespace xrpl::rpc { /** * Copy `Amount` field to `DeliverMax` field in transaction output JSON. @@ -22,4 +22,4 @@ insertDeliverMax(json::Value& txJson, TxType txnType, unsigned int apiVersion); /** @} */ -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 47cbebb901..8f31ce1eb3 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -1215,7 +1215,7 @@ NetworkOPsImp::processClusterTimer() n.set_nodename(node.name()); }); - Resource::Gossip const gossip = registry_.get().getResourceManager().exportConsumers(); + resource::Gossip const gossip = registry_.get().getResourceManager().exportConsumers(); for (auto& item : gossip.items) { protocol::TMLoadSource& node = *cluster.add_loadsources(); @@ -2487,7 +2487,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr const& val) // for consumers supporting different API versions MultiApiJson multiObj{jvObj}; multiObj.visit( - RPC::kApiVersion<1>, // + rpc::kApiVersion<1>, // [](json::Value& jvTx) { // Type conversion for older API versions to string if (jvTx.isMember(jss::ledger_index)) @@ -2688,7 +2688,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (!registry_.get().getApp().config().serverDomain.empty()) info[jss::server_domain] = registry_.get().getApp().config().serverDomain; - info[jss::build_version] = BuildInfo::getVersionString(); + info[jss::build_version] = build_info::getVersionString(); info[jss::server_state] = strOperatingMode(admin); @@ -3167,7 +3167,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) if (!streamMaps_[SBookChanges].empty()) { - json::Value const jvObj = xrpl::RPC::computeBookChanges(lpAccepted); + json::Value const jvObj = xrpl::rpc::computeBookChanges(lpAccepted); auto it = streamMaps_[SBookChanges].begin(); while (it != streamMaps_[SBookChanges].end()) @@ -3281,9 +3281,9 @@ NetworkOPsImp::transJson( if (meta) { jvObj[jss::meta] = meta->get().getJson(JsonOptions::Values::None); - RPC::insertDeliveredAmount(jvObj[jss::meta], *ledger, transaction, meta->get()); - RPC::insertNFTSyntheticInJson(jvObj, transaction, meta->get()); - RPC::insertMPTokenIssuanceID(jvObj[jss::meta], transaction, meta->get()); + rpc::insertDeliveredAmount(jvObj[jss::meta], *ledger, transaction, meta->get()); + rpc::insertNFTSyntheticInJson(jvObj, transaction, meta->get()); + rpc::insertMPTokenIssuanceID(jvObj[jss::meta], transaction, meta->get()); } // add CTID where the needed data for it exists @@ -3295,7 +3295,7 @@ NetworkOPsImp::transJson( if (transaction->isFieldPresent(sfNetworkID)) netID = transaction->getFieldU32(sfNetworkID); - if (std::optional ctid = RPC::encodeCTID(ledger->header().seq, txnSeq, netID); + if (std::optional ctid = rpc::encodeCTID(ledger->header().seq, txnSeq, netID); ctid) jvObj[jss::ctid] = *ctid; } @@ -3346,7 +3346,7 @@ NetworkOPsImp::transJson( forAllApiVersions( multiObj.visit(), // [&](json::Value& jvTx, std::integral_constant) { - RPC::insertDeliverMax(jvTx[jss::transaction], transaction->getTxnType(), Version); + rpc::insertDeliverMax(jvTx[jss::transaction], transaction->getTxnType(), Version); if constexpr (Version > 1) { @@ -3891,7 +3891,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) int feeChargeCount = 0; if (auto sptr = subInfo.sinkWptr.lock(); sptr) { - sptr->getConsumer().charge(Resource::kFeeMediumBurdenRpc); + sptr->getConsumer().charge(resource::kFeeMediumBurdenRpc); ++feeChargeCount; } else diff --git a/src/xrpld/app/misc/detail/DeliverMax.cpp b/src/xrpld/app/misc/detail/DeliverMax.cpp index add3cf89ee..e512b078c7 100644 --- a/src/xrpld/app/misc/detail/DeliverMax.cpp +++ b/src/xrpld/app/misc/detail/DeliverMax.cpp @@ -3,7 +3,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { void insertDeliverMax(json::Value& txJson, TxType txnType, unsigned int apiVersion) @@ -19,4 +19,4 @@ insertDeliverMax(json::Value& txJson, TxType txnType, unsigned int apiVersion) } } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index e29181bfe9..59cc4b6c4c 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -182,7 +182,7 @@ Transaction::getJson(JsonOptions options, bool binary) const if (txnSeq_ && netID) { - std::optional const ctid = RPC::encodeCTID(ledgerIndex_, *txnSeq_, *netID); + std::optional const ctid = rpc::encodeCTID(ledgerIndex_, *txnSeq_, *netID); if (ctid) ret[jss::ctid] = *ctid; } diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index 73e5081036..fd36cb5318 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -223,7 +223,7 @@ WorkBase::onStart() req_.target(path_.empty() ? "/" : path_); req_.version(11); req_.set("Host", host_ + ":" + port_); - req_.set("User-Agent", BuildInfo::getFullVersionString()); + req_.set("User-Agent", build_info::getFullVersionString()); req_.prepare_payload(); boost::beast::http::async_write( impl().stream(), diff --git a/src/xrpld/app/rdb/PeerFinder.h b/src/xrpld/app/rdb/PeerFinder.h index 5d916000a3..3ff7b7268b 100644 --- a/src/xrpld/app/rdb/PeerFinder.h +++ b/src/xrpld/app/rdb/PeerFinder.h @@ -44,6 +44,6 @@ readPeerFinderDB(soci::session& session, std::function const& v); +savePeerFinderDB(soci::session& session, std::vector const& v); } // namespace xrpl diff --git a/src/xrpld/app/rdb/detail/PeerFinder.cpp b/src/xrpld/app/rdb/detail/PeerFinder.cpp index 72a275c7cd..8d9af69ae3 100644 --- a/src/xrpld/app/rdb/detail/PeerFinder.cpp +++ b/src/xrpld/app/rdb/detail/PeerFinder.cpp @@ -108,7 +108,7 @@ updatePeerFinderDB(soci::session& session, int currentSchemaVersion, beast::Jour std::size_t count = 0; session << "SELECT COUNT(*) FROM PeerFinder_BootstrapCache;", soci::into(count); - std::vector list; + std::vector list; { list.reserve(count); @@ -125,8 +125,8 @@ updatePeerFinderDB(soci::session& session, int currentSchemaVersion, beast::Jour st.execute(); while (st.fetch()) { - PeerFinder::Store::Entry entry; - entry.endpoint = beast::IP::Endpoint::fromString(s); + peer_finder::Store::Entry entry; + entry.endpoint = beast::ip::Endpoint::fromString(s); if (!isUnspecified(entry.endpoint)) { entry.valence = valence; @@ -226,7 +226,7 @@ readPeerFinderDB(soci::session& session, std::function const& v) +savePeerFinderDB(soci::session& session, std::vector const& v) { soci::transaction tr(session); session << "DELETE FROM PeerFinder_BootstrapCache;"; diff --git a/src/xrpld/core/Config.h b/src/xrpld/core/Config.h index 852e46218a..d43a7a566d 100644 --- a/src/xrpld/core/Config.h +++ b/src/xrpld/core/Config.h @@ -277,7 +277,7 @@ public: std::size_t txRelayPercentage = 25; // These override the command line client settings - std::optional rpcIp; + std::optional rpcIp; std::unordered_set> features; diff --git a/src/xrpld/overlay/Overlay.h b/src/xrpld/overlay/Overlay.h index 6cc229f5a0..9ab80e6697 100644 --- a/src/xrpld/overlay/Overlay.h +++ b/src/xrpld/overlay/Overlay.h @@ -55,7 +55,7 @@ public: explicit Setup() = default; std::shared_ptr context; - beast::IP::Address publicIp; + beast::ip::Address publicIp; int ipLimit = 0; std::uint32_t crawlOptions = 0; std::optional networkID; @@ -92,7 +92,7 @@ public: * performed asynchronously. */ virtual void - connect(beast::IP::Endpoint const& address) = 0; + connect(beast::ip::Endpoint const& address) = 0; /** * Returns the maximum number of peers we are configured to allow. diff --git a/src/xrpld/overlay/Peer.h b/src/xrpld/overlay/Peer.h index 20a8730cf1..c2631cc7ce 100644 --- a/src/xrpld/overlay/Peer.h +++ b/src/xrpld/overlay/Peer.h @@ -15,9 +15,9 @@ namespace xrpl { -namespace Resource { +namespace resource { class Charge; -} // namespace Resource +} // namespace resource enum class ProtocolFeature { ValidatorListPropagation, @@ -51,7 +51,7 @@ public: virtual void send(std::shared_ptr const& m) = 0; - [[nodiscard]] virtual beast::IP::Endpoint + [[nodiscard]] virtual beast::ip::Endpoint getRemoteAddress() const = 0; /** @@ -76,7 +76,7 @@ public: * Adjust this peer's load balance based on the type of load imposed. */ virtual void - charge(Resource::Charge const& fee, std::string const& context) = 0; + charge(resource::Charge const& fee, std::string const& context) = 0; // // Identity diff --git a/src/xrpld/overlay/detail/ConnectAttempt.cpp b/src/xrpld/overlay/detail/ConnectAttempt.cpp index 0f0b3242de..b78b8eb7b8 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.cpp +++ b/src/xrpld/overlay/detail/ConnectAttempt.cpp @@ -49,10 +49,10 @@ ConnectAttempt::ConnectAttempt( Application& app, boost::asio::io_context& ioContext, endpoint_type remoteEndpoint, - Resource::Consumer usage, + resource::Consumer usage, shared_context const& context, Peer::id_t id, - std::shared_ptr const& slot, + std::shared_ptr const& slot, beast::Journal journal, OverlayImpl& overlay) : Child(overlay) @@ -462,7 +462,7 @@ ConnectAttempt::processResponse() auto const result = overlay_.peerFinder().activate(slot_, publicKey, static_cast(member)); - if (result != PeerFinder::Result::Success) + if (result != peer_finder::Result::Success) { fail("Outbound " + std::string(to_string(result))); return; diff --git a/src/xrpld/overlay/detail/ConnectAttempt.h b/src/xrpld/overlay/detail/ConnectAttempt.h index f9ba33571f..3ebffc529d 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.h +++ b/src/xrpld/overlay/detail/ConnectAttempt.h @@ -41,7 +41,7 @@ private: beast::WrappedSink sink_; beast::Journal const journal_; endpoint_type remoteEndpoint_; - Resource::Consumer usage_; + resource::Consumer usage_; boost::asio::strand strand_; boost::asio::basic_waitable_timer timer_; std::unique_ptr streamPtr_; @@ -49,7 +49,7 @@ private: stream_type& stream_; boost::beast::multi_buffer readBuf_; response_type response_; - std::shared_ptr slot_; + std::shared_ptr slot_; request_type req_; public: @@ -57,10 +57,10 @@ public: Application& app, boost::asio::io_context& ioContext, endpoint_type remoteEndpoint, - Resource::Consumer usage, + resource::Consumer usage, shared_context const& context, Peer::id_t id, - std::shared_ptr const& slot, + std::shared_ptr const& slot, beast::Journal journal, OverlayImpl& overlay); @@ -102,7 +102,7 @@ private: static boost::asio::ip::tcp::endpoint parseEndpoint(std::string const& s, boost::system::error_code& ec) { - beast::IP::Endpoint bep; + beast::ip::Endpoint bep; std::istringstream is(s); is >> bep; if (is.fail()) diff --git a/src/xrpld/overlay/detail/Handshake.cpp b/src/xrpld/overlay/detail/Handshake.cpp index a860d2d604..a12923d1c3 100644 --- a/src/xrpld/overlay/detail/Handshake.cpp +++ b/src/xrpld/overlay/detail/Handshake.cpp @@ -186,8 +186,8 @@ buildHandshake( boost::beast::http::fields& h, xrpl::uint256 const& sharedValue, std::optional networkID, - beast::IP::Address publicIp, - beast::IP::Address remoteIp, + beast::ip::Address publicIp, + beast::ip::Address remoteIp, Application& app) { if (networkID) @@ -213,7 +213,7 @@ buildHandshake( if (!app.config().serverDomain.empty()) h.insert("Server-Domain", app.config().serverDomain); - if (beast::IP::isPublic(remoteIp)) + if (beast::ip::isPublic(remoteIp)) h.insert("Remote-IP", remoteIp.to_string()); if (!publicIp.is_unspecified()) @@ -231,8 +231,8 @@ verifyHandshake( boost::beast::http::fields const& headers, xrpl::uint256 const& sharedValue, std::optional networkID, - beast::IP::Address publicIp, - beast::IP::Address remote, + beast::ip::Address publicIp, + beast::ip::Address remote, Application& app) { if (auto const iter = headers.find("Server-Domain"); iter != headers.end()) @@ -331,7 +331,7 @@ verifyHandshake( if (ec) throw std::runtime_error("Invalid Local-IP"); - if (beast::IP::isPublic(remote) && remote != localIp) + if (beast::ip::isPublic(remote) && remote != localIp) { throw std::runtime_error( "Incorrect Local-IP: " + remote.to_string() + " instead of " + localIp.to_string()); @@ -346,7 +346,7 @@ verifyHandshake( if (ec) throw std::runtime_error("Invalid Remote-IP"); - if (beast::IP::isPublic(remote) && !beast::IP::isUnspecified(publicIp)) + if (beast::ip::isPublic(remote) && !beast::ip::isUnspecified(publicIp)) { // We know our public IP and peer reports our connection came // from some other IP. @@ -374,7 +374,7 @@ makeRequest( m.method(boost::beast::http::verb::get); m.target("/"); m.version(11); - m.insert("User-Agent", BuildInfo::getFullVersionString()); + m.insert("User-Agent", build_info::getFullVersionString()); m.insert("Upgrade", supportedProtocolVersions()); m.insert("Connection", "Upgrade"); m.insert("Connect-As", "Peer"); @@ -390,8 +390,8 @@ http_response_type makeResponse( bool crawlPublic, http_request_type const& req, - beast::IP::Address publicIp, - beast::IP::Address remoteIp, + beast::ip::Address publicIp, + beast::ip::Address remoteIp, uint256 const& sharedValue, std::optional networkID, ProtocolVersion protocol, @@ -403,7 +403,7 @@ makeResponse( resp.insert("Connection", "Upgrade"); resp.insert("Upgrade", to_string(protocol)); resp.insert("Connect-As", "Peer"); - resp.insert("Server", BuildInfo::getFullVersionString()); + resp.insert("Server", build_info::getFullVersionString()); resp.insert("Crawl", crawlPublic ? "public" : "private"); resp.insert( "X-Protocol-Ctl", diff --git a/src/xrpld/overlay/detail/Handshake.h b/src/xrpld/overlay/detail/Handshake.h index 9a4e5ba507..d54cd3a0ea 100644 --- a/src/xrpld/overlay/detail/Handshake.h +++ b/src/xrpld/overlay/detail/Handshake.h @@ -47,8 +47,8 @@ buildHandshake( boost::beast::http::fields& h, uint256 const& sharedValue, std::optional networkID, - beast::IP::Address publicIp, - beast::IP::Address remoteIp, + beast::ip::Address publicIp, + beast::ip::Address remoteIp, Application& app); /** @@ -68,8 +68,8 @@ verifyHandshake( boost::beast::http::fields const& headers, uint256 const& sharedValue, std::optional networkID, - beast::IP::Address publicIp, - beast::IP::Address remote, + beast::ip::Address publicIp, + beast::ip::Address remote, Application& app); /** @@ -109,8 +109,8 @@ http_response_type makeResponse( bool crawlPublic, http_request_type const& req, - beast::IP::Address publicIp, - beast::IP::Address remoteIp, + beast::ip::Address publicIp, + beast::ip::Address remoteIp, uint256 const& sharedValue, std::optional networkID, ProtocolVersion version, diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index f9972548d1..81ead14111 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -93,13 +93,13 @@ namespace xrpl { -namespace CrawlOptions { +namespace crawl_options { static constexpr auto kDisabled = 0; static constexpr auto kOverlay = (1 << 0); static constexpr auto kServerInfo = (1 << 1); static constexpr auto kServerCounts = (1 << 2); static constexpr auto kUnl = (1 << 3); -} // namespace CrawlOptions +} // namespace crawl_options //------------------------------------------------------------------------------ @@ -155,7 +155,7 @@ OverlayImpl::Timer::onTimer(error_code ec) if (overlay_.app_.config().txReduceRelayEnable) overlay_.sendTxQueue(); - if ((++overlay_.timerCount_ % Tuning::kCheckIdlePeers) == 0) + if ((++overlay_.timerCount_ % tuning::kCheckIdlePeers) == 0) overlay_.deleteIdlePeers(); asyncWait(); @@ -167,7 +167,7 @@ OverlayImpl::OverlayImpl( Application& app, Setup setup, ServerHandler& serverHandler, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, Resolver& resolver, boost::asio::io_context& ioContext, BasicConfig const& config, @@ -182,7 +182,7 @@ OverlayImpl::OverlayImpl( , resourceManager_(resourceManager) , store_(app_.getJournal("PeerFinder")) , peerFinder_( - PeerFinder::makeManager( + peer_finder::makeManager( ioContext, stopwatch(), app_.getJournal("PeerFinder"), @@ -308,7 +308,7 @@ OverlayImpl::onHandoff( bool const reserved = static_cast(app_.getCluster().member(publicKey)) || app_.getPeerReservations().contains(publicKey); auto const result = peerFinder_->activate(slot, publicKey, reserved); - if (result != PeerFinder::Result::Success) + if (result != peer_finder::Result::Success) { peerFinder_->onClosed(slot); JLOG(journal.debug()) @@ -381,14 +381,14 @@ OverlayImpl::makePrefix(std::uint32_t id) std::shared_ptr OverlayImpl::makeRedirectResponse( - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type const& request, address_type remoteAddress) { boost::beast::http::response msg; msg.version(request.version()); msg.result(boost::beast::http::status::service_unavailable); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); { std::ostringstream ostr; ostr << remoteAddress; @@ -408,7 +408,7 @@ OverlayImpl::makeRedirectResponse( std::shared_ptr OverlayImpl::makeErrorResponse( - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type const& request, address_type remoteAddress, std::string const& text) @@ -417,7 +417,7 @@ OverlayImpl::makeErrorResponse( msg.version(request.version()); msg.result(boost::beast::http::status::bad_request); msg.reason("Bad Request (" + text + ")"); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Remote-Address", remoteAddress.to_string()); msg.insert(boost::beast::http::field::connection, "close"); msg.prepare_payload(); @@ -427,7 +427,7 @@ OverlayImpl::makeErrorResponse( //------------------------------------------------------------------------------ void -OverlayImpl::connect(beast::IP::Endpoint const& remoteEndpoint) +OverlayImpl::connect(beast::ip::Endpoint const& remoteEndpoint) { XRPL_ASSERT(work_, "xrpl::OverlayImpl::connect : work is set"); @@ -497,7 +497,7 @@ OverlayImpl::addActive(std::shared_ptr const& peer) } void -OverlayImpl::remove(std::shared_ptr const& slot) +OverlayImpl::remove(std::shared_ptr const& slot) { std::scoped_lock const lock(mutex_); auto const iter = peers_.find(slot); @@ -508,7 +508,7 @@ OverlayImpl::remove(std::shared_ptr const& slot) void OverlayImpl::start() { - PeerFinder::Config const config = PeerFinder::makeConfig( + peer_finder::Config const config = peer_finder::makeConfig( app_.config(), serverHandler_.setup().overlay.port(), app_.getValidationPublicKey().has_value(), @@ -541,7 +541,7 @@ OverlayImpl::start() resolver_.resolve( bootstrapIps, - [this](std::string const& name, std::vector const& addresses) { + [this](std::string const& name, std::vector const& addresses) { std::vector ips; ips.reserve(addresses.size()); for (auto const& addr : addresses) @@ -566,8 +566,8 @@ OverlayImpl::start() { resolver_.resolve( app_.config().ipsFixed, - [this](std::string const& name, std::vector const& addresses) { - std::vector ips; + [this](std::string const& name, std::vector const& addresses) { + std::vector ips; ips.reserve(addresses.size()); for (auto& addr : addresses) @@ -868,30 +868,30 @@ OverlayImpl::json() bool OverlayImpl::processCrawl(http_request_type const& req, Handoff& handoff) { - if (req.target() != "/crawl" || setup_.crawlOptions == CrawlOptions::kDisabled) + if (req.target() != "/crawl" || setup_.crawlOptions == crawl_options::kDisabled) return false; boost::beast::http::response msg; msg.version(req.version()); msg.result(boost::beast::http::status::ok); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Content-Type", "application/json"); msg.insert("Connection", "close"); msg.body()["version"] = json::Value(2u); - if ((setup_.crawlOptions & CrawlOptions::kOverlay) != 0u) + if ((setup_.crawlOptions & crawl_options::kOverlay) != 0u) { msg.body()["overlay"] = getOverlayInfo(); } - if ((setup_.crawlOptions & CrawlOptions::kServerInfo) != 0u) + if ((setup_.crawlOptions & crawl_options::kServerInfo) != 0u) { msg.body()["server"] = getServerInfo(); } - if ((setup_.crawlOptions & CrawlOptions::kServerCounts) != 0u) + if ((setup_.crawlOptions & crawl_options::kServerCounts) != 0u) { msg.body()["counts"] = getServerCounts(); } - if ((setup_.crawlOptions & CrawlOptions::kUnl) != 0u) + if ((setup_.crawlOptions & crawl_options::kUnl) != 0u) { msg.body()["unl"] = getUnlInfo(); } @@ -915,7 +915,7 @@ OverlayImpl::processValidatorList(http_request_type const& req, Handoff& handoff boost::beast::http::response msg; msg.version(req.version()); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Content-Type", "application/json"); msg.insert("Connection", "close"); @@ -972,7 +972,7 @@ OverlayImpl::processHealth(http_request_type const& req, Handoff& handoff) return false; boost::beast::http::response msg; msg.version(req.version()); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Content-Type", "application/json"); msg.insert("Connection", "close"); @@ -1535,7 +1535,7 @@ setupOverlay(BasicConfig const& config, beast::Journal j) { boost::system::error_code ec; setup.publicIp = boost::asio::ip::make_address(ip, ec); - if (ec || !beast::IP::isPublic(setup.publicIp)) + if (ec || !beast::ip::isPublic(setup.publicIp)) Throw("Configured public IP is invalid"); } @@ -1577,19 +1577,19 @@ setupOverlay(BasicConfig const& config, beast::Journal j) { if (get(section, Keys::kOverlay, true)) { - setup.crawlOptions |= CrawlOptions::kOverlay; + setup.crawlOptions |= crawl_options::kOverlay; } if (get(section, Keys::kServer, true)) { - setup.crawlOptions |= CrawlOptions::kServerInfo; + setup.crawlOptions |= crawl_options::kServerInfo; } if (get(section, Keys::kCounts, false)) { - setup.crawlOptions |= CrawlOptions::kServerCounts; + setup.crawlOptions |= crawl_options::kServerCounts; } if (get(section, Keys::kUnl, true)) { - setup.crawlOptions |= CrawlOptions::kUnl; + setup.crawlOptions |= crawl_options::kUnl; } } } @@ -1632,7 +1632,7 @@ makeOverlay( Application& app, Overlay::Setup const& setup, ServerHandler& serverHandler, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, Resolver& resolver, boost::asio::io_context& ioContext, BasicConfig const& config, diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index cd2c7d630b..f274bbba5a 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -109,11 +109,11 @@ private: Setup setup_; beast::Journal const journal_; ServerHandler& serverHandler_; - Resource::Manager& resourceManager_; - PeerFinder::StoreSqdb store_; - std::unique_ptr peerFinder_; + resource::Manager& resourceManager_; + peer_finder::StoreSqdb store_; + std::unique_ptr peerFinder_; TrafficCount traffic_; - hash_map, std::weak_ptr> peers_; + hash_map, std::weak_ptr> peers_; hash_map> ids_; Resolver& resolver_; std::atomic nextId_; @@ -141,7 +141,7 @@ public: Application& app, Setup setup, ServerHandler& serverHandler, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, Resolver& resolver, boost::asio::io_context& ioContext, BasicConfig const& config, @@ -157,13 +157,13 @@ public: void stop() override; - PeerFinder::Manager& + peer_finder::Manager& peerFinder() { return *peerFinder_; } - Resource::Manager& + resource::Manager& resourceManager() { return resourceManager_; @@ -182,7 +182,7 @@ public: endpoint_type remoteEndpoint) override; void - connect(beast::IP::Endpoint const& remoteEndpoint) override; + connect(beast::ip::Endpoint const& remoteEndpoint) override; int limit() override; @@ -252,7 +252,7 @@ public: addActive(std::shared_ptr const& peer); void - remove(std::shared_ptr const& slot); + remove(std::shared_ptr const& slot); /** * Called when a peer has connected successfully @@ -451,13 +451,13 @@ private: std::shared_ptr makeRedirectResponse( - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type const& request, address_type remoteAddress); static std::shared_ptr makeErrorResponse( - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type const& request, address_type remoteAddress, std::string const& msg); diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 688d0ac314..ca6fb180d4 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -125,11 +125,11 @@ constexpr std::chrono::seconds kPeerTimerInterval{60}; PeerImp::PeerImp( Application& app, id_t id, - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type&& request, PublicKey const& publicKey, ProtocolVersion protocol, - Resource::Consumer consumer, + resource::Consumer consumer, std::unique_ptr&& streamPtr, OverlayImpl& overlay) : Child(overlay) @@ -157,7 +157,7 @@ PeerImp::PeerImp( , creationTime_(clock_type::now()) , squelch_(app_.getJournal("Squelch")) , usage_(consumer) - , fee_{.fee = Resource::kFeeTrivialPeer, .context = ""} + , fee_{.fee = resource::kFeeTrivialPeer, .context = ""} , slot_(slot) , request_(std::move(request)) , headers_(request_) @@ -303,7 +303,7 @@ PeerImp::send(std::shared_ptr const& m) auto sendqSize = self->sendQueue_.size(); - if (sendqSize < Tuning::kTargetSendQueue) + if (sendqSize < tuning::kTargetSendQueue) { // To detect a peer that does not read from their // side of the connection, we expect a peer to have @@ -312,7 +312,7 @@ PeerImp::send(std::shared_ptr const& m) } else if ( auto sink = self->journal_.debug(); - sink && (sendqSize % Tuning::kSendQueueLogFreq) == 0) + sink && (sendqSize % tuning::kSendQueueLogFreq) == 0) { std::string const n = self->name(); sink << n << " sendq: " << sendqSize; @@ -374,10 +374,10 @@ PeerImp::removeTxQueue(uint256 const& hash) } void -PeerImp::charge(Resource::Charge const& fee, std::string const& context) +PeerImp::charge(resource::Charge const& fee, std::string const& context) { dispatch(strand_, [self = shared_from_this(), fee, context]() { - if ((self->usage_.charge(fee, context) == Resource::Disposition::Drop) && + if ((self->usage_.charge(fee, context) == resource::Disposition::Drop) && self->usage_.disconnect(self->pJournal_)) { // Idempotent: only the first worker to observe Drop counts the @@ -718,7 +718,7 @@ PeerImp::onTimer(error_code const& ec) return; } - if (largeSendq_++ >= Tuning::kSendqIntervals) + if (largeSendq_++ >= tuning::kSendqIntervals) { fail("Large send queue"); return; @@ -948,7 +948,7 @@ PeerImp::onReadMessage(error_code ec, std::size_t bytesTransferred) readBuffer_.commit(bytesTransferred); - auto hint = Tuning::kReadBufferBytes; + auto hint = tuning::kReadBufferBytes; while (readBuffer_.size() > 0) { @@ -980,7 +980,7 @@ PeerImp::onReadMessage(error_code ec, std::size_t bytesTransferred) // Timeout on writes only stream_.async_read_some( - readBuffer_.prepare(std::max(Tuning::kReadBufferBytes, hint)), + readBuffer_.prepare(std::max(tuning::kReadBufferBytes, hint)), bind_executor( strand_, [self = shared_from_this()](error_code const& ec, std::size_t bytesTransferred) { @@ -1056,7 +1056,7 @@ PeerImp::onMessageBegin( { auto const name = protocolMessageName(type); loadEvent_ = app_.getJobQueue().makeLoadEvent(JtPeer, name); - fee_ = {.fee = Resource::kFeeTrivialPeer, .context = name}; + fee_ = {.fee = resource::kFeeTrivialPeer, .context = name}; auto const category = TrafficCount::categorize(*m, static_cast(type), true); @@ -1100,12 +1100,12 @@ PeerImp::onMessage(std::shared_ptr const& m) if (s == 0) { - fee_.update(Resource::kFeeUselessData, "empty"); + fee_.update(resource::kFeeUselessData, "empty"); return; } if (s > 100) - fee_.update(Resource::kFeeModerateBurdenPeer, "oversize"); + fee_.update(resource::kFeeModerateBurdenPeer, "oversize"); app_.getJobQueue().addJob(JtManifest, "RcvManifests", [this, that = shared_from_this(), m]() { overlay_.onManifests(m, that); @@ -1118,7 +1118,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (m->type() == protocol::TMPing::ptPING) { // We have received a ping request, reply with a pong - fee_.update(Resource::kFeeModerateBurdenPeer, "ping request"); + fee_.update(resource::kFeeModerateBurdenPeer, "ping request"); m->set_type(protocol::TMPing::ptPONG); send(std::make_shared(*m, protocol::mtPING)); return; @@ -1159,7 +1159,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // VFALCO NOTE I think we should drop the peer immediately if (!cluster()) { - fee_.update(Resource::kFeeUselessData, "unknown cluster"); + fee_.update(resource::kFeeUselessData, "unknown cluster"); return; } @@ -1186,15 +1186,15 @@ PeerImp::onMessage(std::shared_ptr const& m) int const loadSources = m->loadsources().size(); if (loadSources != 0) { - Resource::Gossip gossip; + resource::Gossip gossip; gossip.items.reserve(loadSources); for (int i = 0; i < m->loadsources().size(); ++i) { protocol::TMLoadSource const& node = m->loadsources(i); - Resource::Gossip::Item item; - item.address = beast::IP::Endpoint::fromString(node.name()); + resource::Gossip::Item item; + item.address = beast::ip::Endpoint::fromString(node.name()); item.balance = node.cost(); - if (item.address != beast::IP::Endpoint()) + if (item.address != beast::ip::Endpoint()) gossip.items.push_back(item); } overlay_.resourceManager().importConsumers(name(), gossip); @@ -1234,17 +1234,17 @@ PeerImp::onMessage(std::shared_ptr const& m) // implication for the protocol. if (m->endpoints_v2().size() >= 1024) { - fee_.update(Resource::kFeeUselessData, "endpoints too large"); + fee_.update(resource::kFeeUselessData, "endpoints too large"); return; } - std::vector endpoints; + std::vector endpoints; endpoints.reserve(m->endpoints_v2().size()); auto malformed = 0; for (auto const& tm : m->endpoints_v2()) { - auto result = beast::IP::Endpoint::fromStringChecked(tm.endpoint()); + auto result = beast::ip::Endpoint::fromStringChecked(tm.endpoint()); if (!result) { @@ -1256,7 +1256,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // If hops == 0, this Endpoint describes the peer we are connected // to -- in that case, we take the remote address seen on the - // socket and store that in the IP::Endpoint. If this is the first + // socket and store that in the ip::Endpoint. If this is the first // time, then we'll verify that their listener can receive incoming // by performing a connectivity test. if hops > 0, then we just // take the address/port we were given @@ -1271,7 +1271,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (malformed > 0) { fee_.update( - Resource::kFeeInvalidData * malformed, + resource::kFeeInvalidData * malformed, std::to_string(malformed) + " malformed endpoints"); } @@ -1332,7 +1332,7 @@ PeerImp::handleTransaction( { JLOG(pJournal_.warn()) << "Ignoring Network relayed Tx containing " "tfInnerBatchTxn (handleTransaction)."; - fee_.update(Resource::kFeeModerateBurdenPeer, "inner batch txn"); + fee_.update(resource::kFeeModerateBurdenPeer, "inner batch txn"); return; } // LCOV_EXCL_STOP @@ -1345,7 +1345,7 @@ PeerImp::handleTransaction( // we have seen this transaction recently if (any(flags & HashRouterFlags::BAD)) { - fee_.update(Resource::kFeeUselessData, "known bad"); + fee_.update(resource::kFeeUselessData, "known bad"); JLOG(pJournal_.debug()) << "Ignoring known bad tx " << txID; } @@ -1419,7 +1419,7 @@ void PeerImp::onMessage(std::shared_ptr const& m) { auto badData = [&](std::string const& msg) { - fee_.update(Resource::kFeeInvalidData, "get_ledger " + msg); + fee_.update(resource::kFeeInvalidData, "get_ledger " + msg); JLOG(pJournal_.warn()) << "TMGetLedger: " << msg; }; auto const itype{m->itype()}; @@ -1499,7 +1499,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // Verify query depth if (m->has_querydepth()) { - if (m->querydepth() > Tuning::kMaxQueryDepth || itype == protocol::liBASE) + if (m->querydepth() > tuning::kMaxQueryDepth || itype == protocol::liBASE) { badData("Invalid query depth"); return; @@ -1517,10 +1517,10 @@ PeerImp::onMessage(std::shared_ptr const& m) bool tooManyNodeIds = false; if (itype != protocol::liBASE) { - nodeIDs.reserve(std::min(m->nodeids_size(), Tuning::kSoftMaxReplyNodes)); + nodeIDs.reserve(std::min(m->nodeids_size(), tuning::kSoftMaxReplyNodes)); for (auto const& nodeId : m->nodeids()) { - if (nodeIDs.size() >= Tuning::kSoftMaxReplyNodes) + if (nodeIDs.size() >= tuning::kSoftMaxReplyNodes) { // The peer requested too many node IDs. Continue processing the received node // IDs up to the limit. If the request is legitimate then at least they will get @@ -1531,7 +1531,7 @@ PeerImp::onMessage(std::shared_ptr const& m) auto parsed = deserializeSHAMapNodeID(nodeId); if (!parsed) { - peer->charge(Resource::kFeeInvalidData, "TMGetLedger: Invalid node ID"); + peer->charge(resource::kFeeInvalidData, "TMGetLedger: Invalid node ID"); return; } nodeIDs.push_back(std::move(*parsed)); @@ -1543,7 +1543,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // below is skipped for relay responses. if (tooManyNodeIds) { - peer->charge(Resource::kFeeModerateBurdenPeer, "TMGetLedger: too many node IDs"); + peer->charge(resource::kFeeModerateBurdenPeer, "TMGetLedger: too many node IDs"); // Truncate the request to what was actually parsed and charged for, so that if this // request ends up being relayed to another peer, we don't forward the oversized list. @@ -1553,7 +1553,7 @@ PeerImp::onMessage(std::shared_ptr const& m) } if (!m->has_requestcookie()) { - peer->charge(Resource::kFeeModerateBurdenPeer, "TMGetLedger: get ledger request"); + peer->charge(resource::kFeeModerateBurdenPeer, "TMGetLedger: get ledger request"); } peer->processLedgerRequest(m, std::move(nodeIDs)); @@ -1566,11 +1566,11 @@ PeerImp::onMessage(std::shared_ptr const& m) JLOG(pJournal_.trace()) << "onMessage, TMProofPathRequest"; if (!ledgerReplayEnabled_) { - fee_.update(Resource::kFeeMalformedRequest, "proof_path_request disabled"); + fee_.update(resource::kFeeMalformedRequest, "proof_path_request disabled"); return; } - fee_.update(Resource::kFeeModerateBurdenPeer, "received a proof path request"); + fee_.update(resource::kFeeModerateBurdenPeer, "received a proof path request"); std::weak_ptr const weak = shared_from_this(); app_.getJobQueue().addJob(JtReplayReq, "RcvProofPReq", [weak, m]() { if (auto peer = weak.lock()) @@ -1580,11 +1580,11 @@ PeerImp::onMessage(std::shared_ptr const& m) { if (reply.error() == protocol::TMReplyError::reBAD_REQUEST) { - peer->charge(Resource::kFeeMalformedRequest, "proof_path_request"); + peer->charge(resource::kFeeMalformedRequest, "proof_path_request"); } else { - peer->charge(Resource::kFeeRequestNoReply, "proof_path_request"); + peer->charge(resource::kFeeRequestNoReply, "proof_path_request"); } } else @@ -1600,13 +1600,13 @@ PeerImp::onMessage(std::shared_ptr const& m) { if (!ledgerReplayEnabled_) { - fee_.update(Resource::kFeeMalformedRequest, "proof_path_response disabled"); + fee_.update(resource::kFeeMalformedRequest, "proof_path_response disabled"); return; } if (!ledgerReplayMsgHandler_.processProofPathResponse(m)) { - fee_.update(Resource::kFeeInvalidData, "proof_path_response"); + fee_.update(resource::kFeeInvalidData, "proof_path_response"); } } @@ -1616,11 +1616,11 @@ PeerImp::onMessage(std::shared_ptr const& m) JLOG(pJournal_.trace()) << "onMessage, TMReplayDeltaRequest"; if (!ledgerReplayEnabled_) { - fee_.update(Resource::kFeeMalformedRequest, "replay_delta_request disabled"); + fee_.update(resource::kFeeMalformedRequest, "replay_delta_request disabled"); return; } - fee_.fee = Resource::kFeeModerateBurdenPeer; + fee_.fee = resource::kFeeModerateBurdenPeer; std::weak_ptr const weak = shared_from_this(); app_.getJobQueue().addJob(JtReplayReq, "RcvReplDReq", [weak, m]() { if (auto peer = weak.lock()) @@ -1630,11 +1630,11 @@ PeerImp::onMessage(std::shared_ptr const& m) { if (reply.error() == protocol::TMReplyError::reBAD_REQUEST) { - peer->charge(Resource::kFeeMalformedRequest, "replay_delta_request"); + peer->charge(resource::kFeeMalformedRequest, "replay_delta_request"); } else { - peer->charge(Resource::kFeeRequestNoReply, "replay_delta_request"); + peer->charge(resource::kFeeRequestNoReply, "replay_delta_request"); } } else @@ -1650,13 +1650,13 @@ PeerImp::onMessage(std::shared_ptr const& m) { if (!ledgerReplayEnabled_) { - fee_.update(Resource::kFeeMalformedRequest, "replay_delta_response disabled"); + fee_.update(resource::kFeeMalformedRequest, "replay_delta_response disabled"); return; } if (!ledgerReplayMsgHandler_.processReplayDeltaResponse(m)) { - fee_.update(Resource::kFeeInvalidData, "replay_delta_response"); + fee_.update(resource::kFeeInvalidData, "replay_delta_response"); } } @@ -1664,7 +1664,7 @@ void PeerImp::onMessage(std::shared_ptr const& m) { auto badData = [&](std::string const& msg) { - fee_.update(Resource::kFeeInvalidData, msg); + fee_.update(resource::kFeeInvalidData, msg); JLOG(pJournal_.warn()) << "TMLedgerData: " << msg; }; @@ -1715,7 +1715,7 @@ PeerImp::onMessage(std::shared_ptr const& m) } // Verify ledger nodes. - if (m->nodes_size() <= 0 || m->nodes_size() > Tuning::kHardMaxReplyNodes) + if (m->nodes_size() <= 0 || m->nodes_size() > tuning::kHardMaxReplyNodes) { badData("Invalid Ledger/TXset nodes " + std::to_string(m->nodes_size())); return; @@ -1875,14 +1875,14 @@ PeerImp::onMessage(std::shared_ptr const& m) (publicKeyType(makeSlice(set.nodepubkey())) != KeyType::Secp256k1)) { JLOG(pJournal_.warn()) << "Proposal: malformed"; - fee_.update(Resource::kFeeInvalidSignature, " signature can't be longer than 72 bytes"); + fee_.update(resource::kFeeInvalidSignature, " signature can't be longer than 72 bytes"); return; } if (!stringIsUInt256Sized(set.currenttxhash()) || !stringIsUInt256Sized(set.previousledger())) { JLOG(pJournal_.warn()) << "Proposal: malformed"; - fee_.update(Resource::kFeeMalformedRequest, "bad hashes"); + fee_.update(resource::kFeeMalformedRequest, "bad hashes"); return; } @@ -2164,13 +2164,13 @@ PeerImp::checkTracking(std::uint32_t seq1, std::uint32_t seq2) { std::uint32_t const diff = std::max(seq1, seq2) - std::min(seq1, seq2); - if (diff < Tuning::kConvergedLedgerLimit) + if (diff < tuning::kConvergedLedgerLimit) { // The peer's ledger sequence is close to the validation's tracking_ = Tracking::Converged; } - if ((diff > Tuning::kDivergedLedgerLimit) && (tracking_.load() != Tracking::Diverged)) + if ((diff > tuning::kDivergedLedgerLimit) && (tracking_.load() != Tracking::Diverged)) { // The peer's ledger sequence is way off the validation's std::scoped_lock const sl(recentLock_); @@ -2185,7 +2185,7 @@ PeerImp::onMessage(std::shared_ptr const& m) { if (!stringIsUInt256Sized(m->hash())) { - fee_.update(Resource::kFeeMalformedRequest, "bad hash"); + fee_.update(resource::kFeeMalformedRequest, "bad hash"); return; } @@ -2197,7 +2197,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (std::ranges::find(recentTxSets_, hash) != recentTxSets_.end()) { - fee_.update(Resource::kFeeUselessData, "duplicate (tsHAVE)"); + fee_.update(resource::kFeeUselessData, "duplicate (tsHAVE)"); return; } @@ -2218,7 +2218,7 @@ PeerImp::onValidatorListMessage( { JLOG(pJournal_.warn()) << "Ignored malformed " << messageType; // This shouldn't ever happen with a well-behaved peer - fee_.update(Resource::kFeeHeavyBurdenPeer, "no blobs"); + fee_.update(resource::kFeeHeavyBurdenPeer, "no blobs"); return; } @@ -2232,7 +2232,7 @@ PeerImp::onValidatorListMessage( // Charging this fee here won't hurt the peer in the normal // course of operation (ie. refresh every 5 minutes), but // will add up if the peer is misbehaving. - fee_.update(Resource::kFeeUselessData, "duplicate"); + fee_.update(resource::kFeeUselessData, "duplicate"); return; } @@ -2323,27 +2323,27 @@ PeerImp::onValidatorListMessage( // Charging this fee here won't hurt the peer in the normal // course of operation (ie. refresh every 5 minutes), but // will add up if the peer is misbehaving. - fee_.update(Resource::kFeeUselessData, " duplicate (same_sequence or known_sequence)"); + fee_.update(resource::kFeeUselessData, " duplicate (same_sequence or known_sequence)"); break; case ListDisposition::Stale: // There are very few good reasons for a peer to send an // old list, particularly more than once. - fee_.update(Resource::kFeeInvalidData, "expired"); + fee_.update(resource::kFeeInvalidData, "expired"); break; case ListDisposition::Untrusted: // Charging this fee here won't hurt the peer in the normal // course of operation (ie. refresh every 5 minutes), but // will add up if the peer is misbehaving. - fee_.update(Resource::kFeeUselessData, "untrusted"); + fee_.update(resource::kFeeUselessData, "untrusted"); break; case ListDisposition::Invalid: // This shouldn't ever happen with a well-behaved peer - fee_.update(Resource::kFeeInvalidSignature, "invalid list disposition"); + fee_.update(resource::kFeeInvalidSignature, "invalid list disposition"); break; case ListDisposition::UnsupportedVersion: // During a version transition, this may be legitimate. // If it happens frequently, that's probably bad. - fee_.update(Resource::kFeeInvalidData, "version"); + fee_.update(resource::kFeeInvalidData, "version"); break; // LCOV_EXCL_START default: @@ -2411,7 +2411,7 @@ PeerImp::onMessage(std::shared_ptr const& m) JLOG(pJournal_.debug()) << "ValidatorList: received validator list from peer using " << "protocol version " << to_string(protocol_) << " which shouldn't support this feature."; - fee_.update(Resource::kFeeUselessData, "unsupported peer"); + fee_.update(resource::kFeeUselessData, "unsupported peer"); return; } onValidatorListMessage( @@ -2421,7 +2421,7 @@ PeerImp::onMessage(std::shared_ptr const& m) { JLOG(pJournal_.warn()) << "ValidatorList: Exception, " << e.what(); using namespace std::string_literals; - fee_.update(Resource::kFeeInvalidData, e.what()); + fee_.update(resource::kFeeInvalidData, e.what()); } } @@ -2435,7 +2435,7 @@ PeerImp::onMessage(std::shared_ptr const& m JLOG(pJournal_.debug()) << "ValidatorListCollection: received validator list from peer " << "using protocol version " << to_string(protocol_) << " which shouldn't support this feature."; - fee_.update(Resource::kFeeUselessData, "unsupported peer"); + fee_.update(resource::kFeeUselessData, "unsupported peer"); return; } if (m->version() < 2) @@ -2444,7 +2444,7 @@ PeerImp::onMessage(std::shared_ptr const& m << "ValidatorListCollection: received invalid validator list " "version " << m->version() << " from peer using protocol version " << to_string(protocol_); - fee_.update(Resource::kFeeInvalidData, "wrong version"); + fee_.update(resource::kFeeInvalidData, "wrong version"); return; } onValidatorListMessage( @@ -2454,7 +2454,7 @@ PeerImp::onMessage(std::shared_ptr const& m { JLOG(pJournal_.warn()) << "ValidatorListCollection: Exception, " << e.what(); using namespace std::string_literals; - fee_.update(Resource::kFeeInvalidData, e.what()); + fee_.update(resource::kFeeInvalidData, e.what()); } } @@ -2464,7 +2464,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (m->validation().size() < 50) { JLOG(pJournal_.warn()) << "Validation: Too small"; - fee_.update(Resource::kFeeMalformedRequest, "too small"); + fee_.update(resource::kFeeMalformedRequest, "too small"); return; } @@ -2491,7 +2491,7 @@ PeerImp::onMessage(std::shared_ptr const& m) val->getSeenTime())) { JLOG(pJournal_.trace()) << "Validation: Not current"; - fee_.update(Resource::kFeeUselessData, "not current"); + fee_.update(resource::kFeeUselessData, "not current"); return; } @@ -2560,7 +2560,7 @@ PeerImp::onMessage(std::shared_ptr const& m) { JLOG(pJournal_.warn()) << "Exception processing validation: " << e.what(); using namespace std::string_literals; - fee_.update(Resource::kFeeMalformedRequest, e.what()); + fee_.update(resource::kFeeMalformedRequest, e.what()); } } @@ -2575,7 +2575,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (packet.query()) { // this is a query - if (sendQueue_.size() >= Tuning::kDropSendQueue) + if (sendQueue_.size() >= tuning::kDropSendQueue) { JLOG(pJournal_.debug()) << "GetObject: Large send queue"; return; @@ -2592,7 +2592,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (!txReduceRelayEnabled()) { JLOG(pJournal_.error()) << "TMGetObjectByHash: tx reduce-relay is disabled"; - fee_.update(Resource::kFeeMalformedRequest, "disabled"); + fee_.update(resource::kFeeMalformedRequest, "disabled"); return; } @@ -2609,19 +2609,19 @@ PeerImp::onMessage(std::shared_ptr const& m) if (!stringIsUInt256Sized(packet.ledgerhash())) { JLOG(pJournal_.debug()) << "GetObj: malformed ledgerhash from peer " << id_; - fee_.update(Resource::kFeeMalformedRequest, "get object ledger hash"); + fee_.update(resource::kFeeMalformedRequest, "get object ledger hash"); return; } } // Reject oversized requests before touching the NodeStore. // The legitimate upper bound (InboundLedger::getNeededHashes()) // is 8 hashes; anything beyond kHardMaxReplyNodes is non-conforming. - if (packet.objects_size() > Tuning::kHardMaxReplyNodes) + if (packet.objects_size() > tuning::kHardMaxReplyNodes) { JLOG(pJournal_.warn()) << "GetObj: oversized request from peer " << id_ << " (" << packet.objects_size() - << " > " << Tuning::kHardMaxReplyNodes << ")"; - fee_.update(Resource::kFeeInvalidData, "oversized get object request"); + << " > " << tuning::kHardMaxReplyNodes << ")"; + fee_.update(resource::kFeeInvalidData, "oversized get object request"); return; } @@ -2643,7 +2643,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // back through the resource model so a misbehaving peer // is still accountable rather than silently dropped. JLOG(peer->pJournal_.warn()) << "GetObj: handler threw: " << e.what(); - peer->charge(Resource::kFeeRequestNoReply, "get object handler exception"); + peer->charge(resource::kFeeRequestNoReply, "get object handler exception"); } }); if (!queued) @@ -2660,7 +2660,7 @@ PeerImp::onMessage(std::shared_ptr const& m) // uncharged DoS window. Charge the base burden up-front (after // a successful enqueue); the per-lookup differential is added // in the worker. - fee_.update(Resource::kFeeModerateBurdenPeer, "received a get object by hash request"); + fee_.update(resource::kFeeModerateBurdenPeer, "received a get object by hash request"); } else { @@ -2739,7 +2739,7 @@ PeerImp::processGetObjectByHash(std::shared_ptr con // a peer cannot drive unbounded NodeStore lookups by sending // non-existent hashes. int const requested = packet.objects_size(); - int const iterLimit = std::min(requested, Tuning::kHardMaxReplyNodes); + int const iterLimit = std::min(requested, tuning::kHardMaxReplyNodes); for (int i = 0; i < iterLimit; ++i) { @@ -2770,7 +2770,7 @@ PeerImp::processGetObjectByHash(std::shared_ptr con // JobQueue worker thread. charge( // We pass `requested` directly here, instead of actual lookups done. Which could be - // std::min(packet.objects_size(), static_cast(Tuning::kHardMaxReplyNodes)); + // std::min(packet.objects_size(), static_cast(tuning::kHardMaxReplyNodes)); // Because we want to charge as per the request size, to discourage large requests. computeGetObjectByHashFee(requested, reply.objects_size()), "processed get object by hash request"); @@ -2785,7 +2785,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (!txReduceRelayEnabled()) { JLOG(pJournal_.error()) << "TMHaveTransactions: tx reduce-relay is disabled"; - fee_.update(Resource::kFeeMalformedRequest, "disabled"); + fee_.update(resource::kFeeMalformedRequest, "disabled"); return; } @@ -2810,7 +2810,7 @@ PeerImp::handleHaveTransactions(std::shared_ptr co if (!stringIsUInt256Sized(m->hashes(i))) { JLOG(pJournal_.error()) << "TMHaveTransactions with invalid hash size"; - fee_.update(Resource::kFeeMalformedRequest, "hash size"); + fee_.update(resource::kFeeMalformedRequest, "hash size"); return; } @@ -2848,7 +2848,7 @@ PeerImp::onMessage(std::shared_ptr const& m) if (!txReduceRelayEnabled()) { JLOG(pJournal_.error()) << "TMTransactions: tx reduce-relay is disabled"; - fee_.update(Resource::kFeeMalformedRequest, "disabled"); + fee_.update(resource::kFeeMalformedRequest, "disabled"); return; } @@ -2872,14 +2872,14 @@ PeerImp::onMessage(std::shared_ptr const& m) dispatch(strand_, [self = shared_from_this(), m]() { if (!m->has_validatorpubkey()) { - self->fee_.update(Resource::kFeeInvalidData, "squelch no pubkey"); + self->fee_.update(resource::kFeeInvalidData, "squelch no pubkey"); return; } auto validator = m->validatorpubkey(); auto const slice{makeSlice(validator)}; if (!publicKeyType(slice)) { - self->fee_.update(Resource::kFeeInvalidData, "squelch bad pubkey"); + self->fee_.update(resource::kFeeInvalidData, "squelch bad pubkey"); return; } PublicKey const key(slice); @@ -2899,7 +2899,7 @@ PeerImp::onMessage(std::shared_ptr const& m) } else if (!self->squelch_.addSquelch(key, std::chrono::seconds{duration})) { - self->fee_.update(Resource::kFeeInvalidData, "squelch duration"); + self->fee_.update(resource::kFeeInvalidData, "squelch duration"); } JLOG(self->pJournal_.debug()) @@ -2939,11 +2939,11 @@ PeerImp::doFetchPack(std::shared_ptr const& packet) if (!stringIsUInt256Sized(packet->ledgerhash())) { JLOG(pJournal_.warn()) << "FetchPack hash size malformed"; - fee_.update(Resource::kFeeMalformedRequest, "hash size"); + fee_.update(resource::kFeeMalformedRequest, "hash size"); return; } - fee_.fee = Resource::kFeeHeavyBurdenPeer; + fee_.fee = resource::kFeeHeavyBurdenPeer; uint256 const hash = uint256::fromRaw(packet->ledgerhash()); @@ -2966,7 +2966,7 @@ PeerImp::doTransactions(std::shared_ptr const& pack if (packet->objects_size() > reduce_relay::kMaxTxQueueSize) { JLOG(pJournal_.error()) << "doTransactions, invalid number of hashes"; - fee_.update(Resource::kFeeMalformedRequest, "too big"); + fee_.update(resource::kFeeMalformedRequest, "too big"); return; } @@ -2976,7 +2976,7 @@ PeerImp::doTransactions(std::shared_ptr const& pack if (!stringIsUInt256Sized(obj.hash())) { - fee_.update(Resource::kFeeMalformedRequest, "hash size"); + fee_.update(resource::kFeeMalformedRequest, "hash size"); return; } @@ -2988,7 +2988,7 @@ PeerImp::doTransactions(std::shared_ptr const& pack { JLOG(pJournal_.error()) << "doTransactions, transaction not found " << Slice(hash.data(), hash.size()); - fee_.update(Resource::kFeeMalformedRequest, "tx not found"); + fee_.update(resource::kFeeMalformedRequest, "tx not found"); return; } @@ -3039,7 +3039,7 @@ PeerImp::checkTransaction( { JLOG(pJournal_.warn()) << "Ignoring Network relayed Tx containing " "tfInnerBatchTxn (checkSignature)."; - charge(Resource::kFeeModerateBurdenPeer, "inner batch txn"); + charge(resource::kFeeModerateBurdenPeer, "inner batch txn"); return; } // LCOV_EXCL_STOP @@ -3051,7 +3051,7 @@ PeerImp::checkTransaction( JLOG(pJournal_.info()) << "Marking transaction " << stx->getTransactionID() << "as BAD because it's expired"; app_.getHashRouter().setFlags(stx->getTransactionID(), HashRouterFlags::BAD); - charge(Resource::kFeeUselessData, "expired tx"); + charge(resource::kFeeUselessData, "expired tx"); return; } @@ -3082,7 +3082,7 @@ PeerImp::checkTransaction( if (!batch) { JLOG(pJournal_.debug()) << "Charging for pseudo-transaction tx " << tx->getID(); - charge(Resource::kFeeUselessData, "pseudo tx"); + charge(resource::kFeeUselessData, "pseudo tx"); } return; @@ -3104,7 +3104,7 @@ PeerImp::checkTransaction( // Probably not necessary to set HashRouterFlags::BAD, but // doesn't hurt. app_.getHashRouter().setFlags(stx->getTransactionID(), HashRouterFlags::BAD); - charge(Resource::kFeeInvalidSignature, "check transaction signature failure"); + charge(resource::kFeeInvalidSignature, "check transaction signature failure"); return; } } @@ -3123,7 +3123,7 @@ PeerImp::checkTransaction( JLOG(pJournal_.debug()) << "Exception checking transaction: " << reason; } app_.getHashRouter().setFlags(stx->getTransactionID(), HashRouterFlags::BAD); - charge(Resource::kFeeInvalidSignature, "tx (impossible)"); + charge(resource::kFeeInvalidSignature, "tx (impossible)"); return; } @@ -3135,7 +3135,7 @@ PeerImp::checkTransaction( JLOG(pJournal_.warn()) << "Exception in " << __func__ << ": " << ex.what(); app_.getHashRouter().setFlags(stx->getTransactionID(), HashRouterFlags::BAD); using namespace std::string_literals; - charge(Resource::kFeeInvalidData, "tx "s + ex.what()); + charge(resource::kFeeInvalidData, "tx "s + ex.what()); } } @@ -3154,7 +3154,7 @@ PeerImp::checkPropose( { std::string const desc{"Proposal fails sig check"}; JLOG(pJournal_.warn()) << desc; - charge(Resource::kFeeInvalidSignature, desc); + charge(resource::kFeeInvalidSignature, desc); return; } @@ -3198,7 +3198,7 @@ PeerImp::checkValidation( { std::string const desc{"Validation forwarded by peer is invalid"}; JLOG(pJournal_.debug()) << desc; - charge(Resource::kFeeInvalidSignature, desc); + charge(resource::kFeeInvalidSignature, desc); return; } @@ -3223,7 +3223,7 @@ PeerImp::checkValidation( { JLOG(pJournal_.trace()) << "Exception processing validation: " << ex.what(); using namespace std::string_literals; - charge(Resource::kFeeMalformedRequest, "validation "s + ex.what()); + charge(resource::kFeeMalformedRequest, "validation "s + ex.what()); } } @@ -3380,7 +3380,7 @@ PeerImp::getLedger(std::shared_ptr const& m) { // Do not resource charge a peer responding to a relay if (!m->has_requestcookie()) - charge(Resource::kFeeMalformedRequest, "get_ledger ledgerSeq"); + charge(resource::kFeeMalformedRequest, "get_ledger ledgerSeq"); ledger.reset(); JLOG(pJournal_.warn()) << "getLedger: Invalid ledger sequence " << ledgerSeq; @@ -3462,7 +3462,7 @@ PeerImp::processLedgerRequest( } else { - if (sendQueue_.size() >= Tuning::kDropSendQueue) + if (sendQueue_.size() >= tuning::kDropSendQueue) { JLOG(pJournal_.debug()) << "processLedgerRequest: Large send queue"; return; @@ -3522,12 +3522,12 @@ PeerImp::processLedgerRequest( auto const queryDepth{m->has_querydepth() ? m->querydepth() : defaultDepth}; std::vector data; - data.reserve(Tuning::kSoftMaxReplyNodes); + data.reserve(tuning::kSoftMaxReplyNodes); auto const useLedgerNodeDepth = supportsFeature(ProtocolFeature::LedgerNodeDepth); for (auto const& nodeID : nodeIDs) { - if (ledgerData.nodes_size() >= Tuning::kSoftMaxReplyNodes) + if (ledgerData.nodes_size() >= tuning::kSoftMaxReplyNodes) break; data.clear(); @@ -3541,7 +3541,7 @@ PeerImp::processLedgerRequest( for (auto const& d : data) { - if (ledgerData.nodes_size() >= Tuning::kHardMaxReplyNodes) + if (ledgerData.nodes_size() >= tuning::kHardMaxReplyNodes) break; protocol::TMLedgerNode* node{ledgerData.add_nodes()}; @@ -3639,30 +3639,30 @@ PeerImp::processLedgerRequest( // // Misses are billed first against the billable budget because a node store // seek dominates a cache hit and because invalid hashes are ~100% miss by construction. -Resource::Charge +resource::Charge PeerImp::computeGetObjectByHashFee(int const requested, int const found) { - int const billable = std::max(0, requested - static_cast(Tuning::kFreeObjectsPerRequest)); + int const billable = std::max(0, requested - static_cast(tuning::kFreeObjectsPerRequest)); // Clamp `missed` so a future caller passing found > requested cannot // produce a negative value that flips the hits/misses split. int const missed = std::max(0, requested - found); int const billableMisses = std::min(missed, billable); int const billableHits = billable - billableMisses; - int sizeBand = Tuning::kCostBandSmall; - if (requested > Tuning::kBandMediumMax) + int sizeBand = tuning::kCostBandSmall; + if (requested > tuning::kBandMediumMax) { - sizeBand = Tuning::kCostBandLarge; + sizeBand = tuning::kCostBandLarge; } - else if (requested > Tuning::kBandSmallMax) + else if (requested > tuning::kBandSmallMax) { - sizeBand = Tuning::kCostBandMedium; + sizeBand = tuning::kCostBandMedium; } - int const dynamic = (billableHits * Tuning::kCostPerLookupHit) + - (billableMisses * Tuning::kCostPerLookupMiss) + sizeBand; + int const dynamic = (billableHits * tuning::kCostPerLookupHit) + + (billableMisses * tuning::kCostPerLookupMiss) + sizeBand; - return Resource::Charge(dynamic, "GetObject differential"); + return resource::Charge(dynamic, "GetObject differential"); } int diff --git a/src/xrpld/overlay/detail/PeerImp.h b/src/xrpld/overlay/detail/PeerImp.h index de90e60955..3fcfe6359a 100644 --- a/src/xrpld/overlay/detail/PeerImp.h +++ b/src/xrpld/overlay/detail/PeerImp.h @@ -97,7 +97,7 @@ private: // Updated at each stage of the connection process to reflect // the current conditions as closely as possible. - beast::IP::Endpoint const remoteAddress_; + beast::ip::Endpoint const remoteAddress_; // These are up here to prevent warnings about order of initializations // @@ -161,11 +161,11 @@ private: struct ChargeWithContext { - Resource::Charge fee = Resource::kFeeTrivialPeer; + resource::Charge fee = resource::kFeeTrivialPeer; std::string context{}; // NOLINT(readability-redundant-member-init) void - update(Resource::Charge f, std::string const& add) + update(resource::Charge f, std::string const& add) { XRPL_ASSERT(f >= fee, "xrpl::PeerImp::ChargeWithContext::update : fee increases"); fee = f; @@ -179,7 +179,7 @@ private: std::mutex mutable recentLock_; protocol::TMStatusChange lastStatus_; - Resource::Consumer usage_; + resource::Consumer usage_; ChargeWithContext fee_; // One-shot guard so concurrent JobQueue workers cannot double-count @@ -187,7 +187,7 @@ private: // post duplicate fail() calls) when several queued requests cross // kDropThreshold before the first fail() lands on the strand. std::atomic chargeDisconnectFired_{false}; - std::shared_ptr const slot_; + std::shared_ptr const slot_; boost::beast::multi_buffer readBuffer_; http_request_type request_; http_response_type response_; @@ -258,11 +258,11 @@ public: PeerImp( Application& app, id_t id, - std::shared_ptr const& slot, + std::shared_ptr const& slot, http_request_type&& request, PublicKey const& publicKey, ProtocolVersion protocol, - Resource::Consumer consumer, + resource::Consumer consumer, std::unique_ptr&& streamPtr, OverlayImpl& overlay); @@ -275,9 +275,9 @@ public: Application& app, std::unique_ptr&& streamPtr, Buffers const& buffers, - std::shared_ptr&& slot, + std::shared_ptr&& slot, http_response_type&& response, - Resource::Consumer usage, + resource::Consumer usage, PublicKey const& publicKey, ProtocolVersion protocol, id_t id, @@ -291,7 +291,7 @@ public: return pJournal_; } - std::shared_ptr const& + std::shared_ptr const& slot() { return slot_; @@ -339,16 +339,18 @@ public: void sendEndpoints(FwdIt first, FwdIt last) requires( - std::is_same_v::value_type, PeerFinder::Endpoint>); + std::is_same_v< // + typename std::iterator_traits::value_type, + peer_finder::Endpoint>); - beast::IP::Endpoint + beast::ip::Endpoint getRemoteAddress() const override { return remoteAddress_; } void - charge(Resource::Charge const& fee, std::string const& context) override; + charge(resource::Charge const& fee, std::string const& context) override; // // Identity @@ -697,7 +699,7 @@ protected: * * Dispatched from `onMessage(TMGetObjectByHash)` to the JobQueue * (`JtLedgerReq`) so synchronous NodeStore lookups do not block the - * peer's I/O strand. Caps iteration at `Tuning::kHardMaxReplyNodes` + * peer's I/O strand. Caps iteration at `tuning::kHardMaxReplyNodes` * regardless of hit/miss outcome and applies differential pricing * via `computeGetObjectByHashFee()` after the fetch loop completes. * @@ -711,25 +713,25 @@ protected: * request based on how much work was actually performed. * * The charge has three components on top of the base - * `Resource::kFeeModerateBurdenPeer`: + * `resource::kFeeModerateBurdenPeer`: * - per-hit lookup cost (cheap; usually served from cache) * - per-miss lookup cost (expensive node store seeks) * - request-size band surcharge (escalates abusive batch sizes) * - * The first `Tuning::kFreeObjectsPerRequest` objects are free so + * The first `tuning::kFreeObjectsPerRequest` objects are free so * that legitimate `InboundLedger::getNeededHashes()` traffic * (at most 8 objects) is unaffected. * * @param requested Number of objects requested by the message. This * value is used for request-size pricing and may - * exceed `Tuning::kHardMaxReplyNodes` when this + * exceed `tuning::kHardMaxReplyNodes` when this * helper is called directly, even though processing - * caps the iterations to `Tuning::kHardMaxReplyNodes`. + * caps the iterations to `tuning::kHardMaxReplyNodes`. * @param found Number of objects successfully returned in the * reply. - * @return A `Resource::Charge` whose cost reflects the work performed. + * @return A `resource::Charge` whose cost reflects the work performed. */ - static Resource::Charge + static resource::Charge computeGetObjectByHashFee(int const requested, int const found); /** @@ -740,9 +742,9 @@ protected: * full JobQueue handler. Production callers should never read this back — * the value is consumed by `charge()`/`disconnect()` internally. * - * @return The current `Resource::Charge` accumulated on `fee_`. + * @return The current `resource::Charge` accumulated on `fee_`. */ - Resource::Charge + resource::Charge currentFeeCharge() const { return fee_.fee; @@ -756,9 +758,9 @@ PeerImp::PeerImp( Application& app, std::unique_ptr&& streamPtr, Buffers const& buffers, - std::shared_ptr&& slot, + std::shared_ptr&& slot, http_response_type&& response, - Resource::Consumer usage, + resource::Consumer usage, PublicKey const& publicKey, ProtocolVersion protocol, id_t id, @@ -788,7 +790,7 @@ PeerImp::PeerImp( , creationTime_(clock_type::now()) , squelch_(app_.getJournal("Squelch")) , usage_(usage) - , fee_{.fee = Resource::kFeeTrivialPeer} + , fee_{.fee = resource::kFeeTrivialPeer} , slot_(std::move(slot)) , response_(std::move(response)) , headers_(response_) @@ -815,7 +817,8 @@ PeerImp::PeerImp( template void PeerImp::sendEndpoints(FwdIt first, FwdIt last) - requires(std::is_same_v::value_type, PeerFinder::Endpoint>) + requires( + std::is_same_v::value_type, peer_finder::Endpoint>) { protocol::TMEndpoints tm; diff --git a/src/xrpld/overlay/detail/Tuning.h b/src/xrpld/overlay/detail/Tuning.h index 5488fab07b..7561a4f385 100644 --- a/src/xrpld/overlay/detail/Tuning.h +++ b/src/xrpld/overlay/detail/Tuning.h @@ -5,7 +5,7 @@ #include #include -namespace xrpl::Tuning { +namespace xrpl::tuning { /** * How many ledgers off a server can be and we will @@ -74,7 +74,7 @@ constexpr std::size_t kReadBufferBytes = 16384; * while a hit is usually served from cache. On top of that, a size-band * surcharge kicks in for larger requests so an attacker who crams a * single message with thousands of hashes blows past - * `Resource::kDropThreshold` and gets disconnected. + * `resource::kDropThreshold` and gets disconnected. * * The numbers below are picked to keep three things true given * `kDropThreshold = 25000`: @@ -165,4 +165,4 @@ static constexpr auto kLegitHashesPerType = 4; static constexpr auto kBandSmallMax = kLegitHashesPerType * SHAMapInnerNode::kBranchFactor; static constexpr auto kBandMediumMax = kBandSmallMax * SHAMapInnerNode::kBranchFactor; -} // namespace xrpl::Tuning +} // namespace xrpl::tuning diff --git a/src/xrpld/overlay/make_Overlay.h b/src/xrpld/overlay/make_Overlay.h index a62d4b49de..c730a05c54 100644 --- a/src/xrpld/overlay/make_Overlay.h +++ b/src/xrpld/overlay/make_Overlay.h @@ -27,7 +27,7 @@ makeOverlay( Application& app, Overlay::Setup const& setup, ServerHandler& serverHandler, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, Resolver& resolver, boost::asio::io_context& ioContext, BasicConfig const& config, diff --git a/src/xrpld/peerfinder/PeerfinderManager.h b/src/xrpld/peerfinder/PeerfinderManager.h index f96ea31943..5934e3bc4a 100644 --- a/src/xrpld/peerfinder/PeerfinderManager.h +++ b/src/xrpld/peerfinder/PeerfinderManager.h @@ -6,7 +6,7 @@ #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { Config makeConfig( @@ -16,4 +16,4 @@ makeConfig( int ipLimit, bool verifyEndpoints); -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/xrpld/peerfinder/detail/PeerfinderConfig.cpp b/src/xrpld/peerfinder/detail/PeerfinderConfig.cpp index a893b969e0..b222f6c077 100644 --- a/src/xrpld/peerfinder/detail/PeerfinderConfig.cpp +++ b/src/xrpld/peerfinder/detail/PeerfinderConfig.cpp @@ -5,7 +5,7 @@ #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { Config makeConfig( @@ -36,4 +36,4 @@ makeConfig( verifyEndpoints); } -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/xrpld/peerfinder/detail/StoreSqdb.h b/src/xrpld/peerfinder/detail/StoreSqdb.h index b0973a42b3..ce13d72c15 100644 --- a/src/xrpld/peerfinder/detail/StoreSqdb.h +++ b/src/xrpld/peerfinder/detail/StoreSqdb.h @@ -14,7 +14,7 @@ #include #include -namespace xrpl::PeerFinder { +namespace xrpl::peer_finder { /** * Database persistence for PeerFinder using SQLite @@ -50,7 +50,7 @@ public: std::size_t n(0); readPeerFinderDB(sqlDb_, [&](std::string const& s, int valence) { - beast::IP::Endpoint const endpoint(beast::IP::Endpoint::fromString(s)); + beast::ip::Endpoint const endpoint(beast::ip::Endpoint::fromString(s)); if (!isUnspecified(endpoint)) { @@ -90,4 +90,4 @@ private: } }; -} // namespace xrpl::PeerFinder +} // namespace xrpl::peer_finder diff --git a/src/xrpld/perflog/detail/PerfLogImp.h b/src/xrpld/perflog/detail/PerfLogImp.h index 14477512ff..7efdbe1b7f 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.h +++ b/src/xrpld/perflog/detail/PerfLogImp.h @@ -109,7 +109,7 @@ class PerfLogImp : public PerfLog Application& app_; beast::Journal const j_; std::function const signalStop_; - Counters counters_{xrpl::RPC::getHandlerNames(), JobTypes::instance()}; + Counters counters_{xrpl::rpc::getHandlerNames(), JobTypes::instance()}; std::ofstream logFile_; std::thread thread_; std::mutex mutex_; diff --git a/src/xrpld/rpc/BookChanges.h b/src/xrpld/rpc/BookChanges.h index 3c10ece78f..16f7ea8e43 100644 --- a/src/xrpld/rpc/BookChanges.h +++ b/src/xrpld/rpc/BookChanges.h @@ -32,7 +32,7 @@ class Transaction; class TxMeta; class STTx; -namespace RPC { +namespace rpc { template json::Value @@ -233,5 +233,5 @@ computeBookChanges(std::shared_ptr const& lpAccepted) return jvObj; } -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/CTID.h b/src/xrpld/rpc/CTID.h index 7566e0e143..71ded5834f 100644 --- a/src/xrpld/rpc/CTID.h +++ b/src/xrpld/rpc/CTID.h @@ -11,7 +11,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { // CTID stands for Concise Transaction ID. // @@ -111,4 +111,4 @@ decodeCTID(T const ctid) noexcept return std::make_tuple(ledgerSeq, txnIndex, networkID); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/Context.h b/src/xrpld/rpc/Context.h index 81ba068d8f..e85bf6dfe6 100644 --- a/src/xrpld/rpc/Context.h +++ b/src/xrpld/rpc/Context.h @@ -18,7 +18,7 @@ class Application; class NetworkOPs; class LedgerMaster; -namespace RPC { +namespace rpc { /** * The context of information needed to call an RPC. @@ -27,10 +27,10 @@ struct Context { beast::Journal const j; Application& app; - Resource::Charge& loadType; + resource::Charge& loadType; NetworkOPs& netOps; LedgerMaster& ledgerMaster; - Resource::Consumer& consumer; + resource::Consumer& consumer; Role role; std::shared_ptr coro; InfoSub::pointer infoSub; @@ -59,5 +59,5 @@ struct GRPCContext : public Context RequestType params; }; -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/DeliveredAmount.h b/src/xrpld/rpc/DeliveredAmount.h index dc635c6861..a7878070d6 100644 --- a/src/xrpld/rpc/DeliveredAmount.h +++ b/src/xrpld/rpc/DeliveredAmount.h @@ -17,7 +17,7 @@ class Transaction; class TxMeta; class STTx; -namespace RPC { +namespace rpc { struct JsonContext; @@ -41,23 +41,23 @@ insertDeliveredAmount( void insertDeliveredAmount( json::Value& meta, - RPC::JsonContext const&, + rpc::JsonContext const&, std::shared_ptr const&, TxMeta const&); void insertDeliveredAmount( json::Value& meta, - RPC::JsonContext const&, + rpc::JsonContext const&, std::shared_ptr const&, TxMeta const&); std::optional getDeliveredAmount( - RPC::Context const& context, + rpc::Context const& context, std::shared_ptr const& serializedTx, TxMeta const& transactionMeta, LedgerIndex const& ledgerIndex); /** @} */ -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/GRPCHandlers.h b/src/xrpld/rpc/GRPCHandlers.h index 9dc7e0b13a..cabd55d53b 100644 --- a/src/xrpld/rpc/GRPCHandlers.h +++ b/src/xrpld/rpc/GRPCHandlers.h @@ -14,22 +14,22 @@ namespace xrpl { /* * These handlers are for gRPC. They each take in a protobuf message that is - * nested inside RPC::GRPCContext, where T is the request type + * nested inside rpc::GRPCContext, where T is the request type * The return value is the response type, as well as a status * If the status is not Status::OK (meaning an error occurred), then only * the status will be sent to the client, and the response will be omitted */ std::pair -doLedgerGrpc(RPC::GRPCContext& context); +doLedgerGrpc(rpc::GRPCContext& context); std::pair -doLedgerEntryGrpc(RPC::GRPCContext& context); +doLedgerEntryGrpc(rpc::GRPCContext& context); std::pair -doLedgerDataGrpc(RPC::GRPCContext& context); +doLedgerDataGrpc(rpc::GRPCContext& context); std::pair -doLedgerDiffGrpc(RPC::GRPCContext& context); +doLedgerDiffGrpc(rpc::GRPCContext& context); } // namespace xrpl diff --git a/src/xrpld/rpc/MPTokenIssuanceID.h b/src/xrpld/rpc/MPTokenIssuanceID.h index f56826bfb8..678fda0369 100644 --- a/src/xrpld/rpc/MPTokenIssuanceID.h +++ b/src/xrpld/rpc/MPTokenIssuanceID.h @@ -8,7 +8,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { /** * Add a `mpt_issuance_id` field to the `meta` input/output parameter. @@ -32,4 +32,4 @@ insertMPTokenIssuanceID( TxMeta const& transactionMeta); /** @} */ -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/Output.h b/src/xrpld/rpc/Output.h index 30b5c090d7..f528efef56 100644 --- a/src/xrpld/rpc/Output.h +++ b/src/xrpld/rpc/Output.h @@ -5,7 +5,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { using Output = std::function; @@ -15,4 +15,4 @@ stringOutput(std::string& s) return [&](boost::string_ref const& b) { s.append(b.data(), b.size()); }; } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/RPCCall.h b/src/xrpld/rpc/RPCCall.h index a72b35e344..2fec78f93b 100644 --- a/src/xrpld/rpc/RPCCall.h +++ b/src/xrpld/rpc/RPCCall.h @@ -26,7 +26,7 @@ namespace xrpl { /** * Processes XRPL RPC calls. */ -namespace RPCCall { +namespace rpc_call { int fromCommandLine(Config const& config, std::vector const& vCmd, Logs& logs); @@ -47,7 +47,7 @@ fromNetwork( std::function callbackFuncP = std::function(), std::unordered_map headers = {}); -} // namespace RPCCall +} // namespace rpc_call json::Value rpcCmdToJson( diff --git a/src/xrpld/rpc/RPCHandler.h b/src/xrpld/rpc/RPCHandler.h index fcd0f54265..637a492943 100644 --- a/src/xrpld/rpc/RPCHandler.h +++ b/src/xrpld/rpc/RPCHandler.h @@ -8,7 +8,7 @@ #include -namespace xrpl::RPC { +namespace xrpl::rpc { struct JsonContext; @@ -16,9 +16,9 @@ struct JsonContext; * Execute an RPC command and store the results in a json::Value. */ Status -doCommand(RPC::JsonContext&, json::Value&); +doCommand(rpc::JsonContext&, json::Value&); Role roleRequired(unsigned int version, bool betaEnabled, std::string const& method); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/Role.h b/src/xrpld/rpc/Role.h index 2c2ae6b781..48c89333bd 100644 --- a/src/xrpld/rpc/Role.h +++ b/src/xrpld/rpc/Role.h @@ -40,13 +40,13 @@ requestRole( Role const& required, Port const& port, json::Value const& params, - beast::IP::Endpoint const& remoteIp, + beast::ip::Endpoint const& remoteIp, std::string_view user); -Resource::Consumer +resource::Consumer requestInboundEndpoint( - Resource::Manager& manager, - beast::IP::Endpoint const& remoteAddress, + resource::Manager& manager, + beast::ip::Endpoint const& remoteAddress, Role const& role, std::string_view user, std::string_view forwardedFor); @@ -66,7 +66,7 @@ isUnlimited(Role const& role); */ bool ipAllowed( - beast::IP::Address const& remoteIp, + beast::ip::Address const& remoteIp, std::vector const& nets4, std::vector const& nets6); diff --git a/src/xrpld/rpc/ServerHandler.h b/src/xrpld/rpc/ServerHandler.h index 054bec9b5b..a09fc1c18a 100644 --- a/src/xrpld/rpc/ServerHandler.h +++ b/src/xrpld/rpc/ServerHandler.h @@ -80,7 +80,7 @@ private: using stream_type = boost::beast::ssl_stream; Application& app_; - Resource::Manager& resourceManager_; + resource::Manager& resourceManager_; beast::Journal journal_; NetworkOPs& networkOPs_; std::unique_ptr server_; @@ -109,7 +109,7 @@ private: boost::asio::io_context&, JobQueue&, NetworkOPs&, - Resource::Manager&, + resource::Manager&, CollectorManager& cm); public: @@ -120,7 +120,7 @@ public: boost::asio::io_context& ioContext, JobQueue& jobQueue, NetworkOPs& networkOPs, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, CollectorManager& cm); ~ServerHandler(); @@ -196,7 +196,7 @@ private: processRequest( Port const& port, std::string const& request, - beast::IP::Endpoint const& remoteIPAddress, + beast::ip::Endpoint const& remoteIPAddress, Output const&, std::shared_ptr coro, std::string_view forwardedFor, @@ -215,7 +215,7 @@ makeServerHandler( boost::asio::io_context&, JobQueue&, NetworkOPs&, - Resource::Manager&, + resource::Manager&, CollectorManager& cm); } // namespace xrpl diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index dda1e89d31..e2716bd579 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -11,7 +11,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { /** * Status represents the results of an operation that might fail. @@ -56,9 +56,11 @@ public: { } - /* Returns a representation of the integer status Code as a string. - If the Status is OK, the result is an empty string. - */ + /** + * If the Status is OK, the result is an empty string. + * + * @return a representation of the integer status Code as a string. + */ [[nodiscard]] std::string codeString() const; @@ -86,7 +88,7 @@ public: [[nodiscard]] TER toTER() const { - XRPL_ASSERT(type_ == Type::TER, "xrpl::RPC::Status::toTER : type is TER"); + XRPL_ASSERT(type_ == Type::TER, "xrpl::rpc::Status::toTER : type is TER"); return TER::fromInt(code_); } @@ -97,7 +99,8 @@ public: [[nodiscard]] ErrorCodeI toErrorCode() const { - XRPL_ASSERT(type_ == Type::ErrorCodeI, "xrpl::RPC::Status::toTER : type is error code"); + XRPL_ASSERT( + type_ == Type::ErrorCodeI, "xrpl::rpc::Status::toErrorCode : type is error code"); return ErrorCodeI(code_); } @@ -155,4 +158,4 @@ private: Strings messages_; }; -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/DeliveredAmount.cpp b/src/xrpld/rpc/detail/DeliveredAmount.cpp index 8d8aac33bf..7b8c5e0623 100644 --- a/src/xrpld/rpc/detail/DeliveredAmount.cpp +++ b/src/xrpld/rpc/detail/DeliveredAmount.cpp @@ -16,7 +16,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { /* GetLedgerIndex and GetCloseTime are lambdas that allow the close time and @@ -114,7 +114,7 @@ insertDeliveredAmount( template static std::optional getDeliveredAmount( - RPC::Context const& context, + rpc::Context const& context, std::shared_ptr const& serializedTx, TxMeta const& transactionMeta, GetLedgerIndex const& getLedgerIndex) @@ -133,7 +133,7 @@ getDeliveredAmount( std::optional getDeliveredAmount( - RPC::Context const& context, + rpc::Context const& context, std::shared_ptr const& serializedTx, TxMeta const& transactionMeta, LedgerIndex const& ledgerIndex) @@ -145,7 +145,7 @@ getDeliveredAmount( void insertDeliveredAmount( json::Value& meta, - RPC::JsonContext const& context, + rpc::JsonContext const& context, std::shared_ptr const& transaction, TxMeta const& transactionMeta) { @@ -155,7 +155,7 @@ insertDeliveredAmount( void insertDeliveredAmount( json::Value& meta, - RPC::JsonContext const& context, + rpc::JsonContext const& context, std::shared_ptr const& transaction, TxMeta const& transactionMeta) { @@ -178,4 +178,4 @@ insertDeliveredAmount( } } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index 4f5ce34c1f..326af4f4ee 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -18,7 +18,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { namespace { /** @@ -33,8 +33,8 @@ byRef(Function const& f) if (result.type() != json::ValueType::Object) { // LCOV_EXCL_START - UNREACHABLE("xrpl::RPC::byRef : result is object"); - result = RPC::makeObjectValue(result); + UNREACHABLE("xrpl::rpc::byRef : result is object"); + result = rpc::makeObjectValue(result); // LCOV_EXCL_STOP } @@ -49,7 +49,7 @@ handle(JsonContext& context, Object& object) XRPL_ASSERT( context.apiVersion >= HandlerImpl::minApiVer && context.apiVersion <= HandlerImpl::maxApiVer, - "xrpl::RPC::handle : valid API version"); + "xrpl::rpc::handle : valid API version"); HandlerImpl handler(context); auto status = handler.check(); @@ -382,10 +382,10 @@ private: unsigned minVer, unsigned maxVer) { - XRPL_ASSERT(minVer <= maxVer, "xrpl::RPC::HandlerTable : valid API version range"); + XRPL_ASSERT(minVer <= maxVer, "xrpl::rpc::HandlerTable : valid API version range"); XRPL_ASSERT( - maxVer <= RPC::kApiMaximumValidVersion, - "xrpl::RPC::HandlerTable : valid max API version"); + maxVer <= rpc::kApiMaximumValidVersion, + "xrpl::rpc::HandlerTable : valid max API version"); return std::any_of( range.first, @@ -427,8 +427,8 @@ public: [[nodiscard]] Handler const* getHandler(unsigned version, bool betaEnabled, std::string const& name) const { - if (version < RPC::kApiMinimumSupportedVersion || - version > (betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion)) + if (version < rpc::kApiMinimumSupportedVersion || + version > (betaEnabled ? rpc::kApiBetaVersion : rpc::kApiMaximumSupportedVersion)) return nullptr; auto const range = table_.equal_range(name); @@ -457,8 +457,8 @@ private: addHandler() { static_assert(HandlerImpl::minApiVer <= HandlerImpl::maxApiVer); - static_assert(HandlerImpl::maxApiVer <= RPC::kApiMaximumValidVersion); - static_assert(RPC::kApiMinimumSupportedVersion <= HandlerImpl::minApiVer); + static_assert(HandlerImpl::maxApiVer <= rpc::kApiMaximumValidVersion); + static_assert(rpc::kApiMinimumSupportedVersion <= HandlerImpl::minApiVer); if (overlappingApiVersion( table_.equal_range(HandlerImpl::name), @@ -488,4 +488,4 @@ getHandlerNames() return HandlerTable::instance().getHandlerNames(); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/Handler.h b/src/xrpld/rpc/detail/Handler.h index 37259c8648..7342c5fcbf 100644 --- a/src/xrpld/rpc/detail/Handler.h +++ b/src/xrpld/rpc/detail/Handler.h @@ -20,7 +20,7 @@ namespace json { class Object; } // namespace json -namespace xrpl::RPC { +namespace xrpl::rpc { // Under what condition can we call this RPC? enum class Condition { @@ -38,7 +38,7 @@ struct Handler char const* name; Method valueMethod; Role role; - RPC::Condition condition; + rpc::Condition condition; unsigned minApiVer = kApiMinimumSupportedVersion; unsigned maxApiVer = kApiMaximumValidVersion; @@ -92,7 +92,7 @@ conditionMet(Condition conditionRequired, T& context) if (!context.app.config().standalone() && conditionRequired != Condition::NoCondition) { - if (context.ledgerMaster.getValidatedLedgerAge() > Tuning::kMaxValidatedLedgerAge) + if (context.ledgerMaster.getValidatedLedgerAge() > tuning::kMaxValidatedLedgerAge) { if (context.apiVersion == 1) return RpcNoCurrent; @@ -122,4 +122,4 @@ conditionMet(Condition conditionRequired, T& context) return RpcSuccess; } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/LegacyPathFind.cpp b/src/xrpld/rpc/detail/LegacyPathFind.cpp index 0bfa19a1f4..837d98084e 100644 --- a/src/xrpld/rpc/detail/LegacyPathFind.cpp +++ b/src/xrpld/rpc/detail/LegacyPathFind.cpp @@ -9,7 +9,7 @@ #include -namespace xrpl::RPC { +namespace xrpl::rpc { LegacyPathFind::LegacyPathFind(bool isAdmin, Application& app) { @@ -21,13 +21,13 @@ LegacyPathFind::LegacyPathFind(bool isAdmin, Application& app) } auto const& jobCount = app.getJobQueue().getJobCountGE(JtClient); - if (jobCount > Tuning::kMaxPathfindJobCount || app.getFeeTrack().isLoadedLocal()) + if (jobCount > tuning::kMaxPathfindJobCount || app.getFeeTrack().isLoadedLocal()) return; while (true) { int prevVal = inProgress.load(); - if (prevVal >= Tuning::kMaxPathfindsInProgress) + if (prevVal >= tuning::kMaxPathfindsInProgress) return; if (inProgress.compare_exchange_strong( @@ -47,4 +47,4 @@ LegacyPathFind::~LegacyPathFind() std::atomic LegacyPathFind::inProgress(0); -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/LegacyPathFind.h b/src/xrpld/rpc/detail/LegacyPathFind.h index 226191848f..30e176f245 100644 --- a/src/xrpld/rpc/detail/LegacyPathFind.h +++ b/src/xrpld/rpc/detail/LegacyPathFind.h @@ -6,7 +6,7 @@ namespace xrpl { class Application; -namespace RPC { +namespace rpc { class LegacyPathFind { @@ -26,5 +26,5 @@ private: bool isOk_{false}; }; -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/detail/MPTokenIssuanceID.cpp b/src/xrpld/rpc/detail/MPTokenIssuanceID.cpp index e34980aee2..4f57bab9ab 100644 --- a/src/xrpld/rpc/detail/MPTokenIssuanceID.cpp +++ b/src/xrpld/rpc/detail/MPTokenIssuanceID.cpp @@ -16,7 +16,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { bool canHaveMPTokenIssuanceID( @@ -67,4 +67,4 @@ insertMPTokenIssuanceID( response[jss::mpt_issuance_id] = to_string(result.value()); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/PathRequest.cpp b/src/xrpld/rpc/detail/PathRequest.cpp index 3c09917dad..fb132199bc 100644 --- a/src/xrpld/rpc/detail/PathRequest.cpp +++ b/src/xrpld/rpc/detail/PathRequest.cpp @@ -73,7 +73,7 @@ PathRequest::PathRequest( PathRequest::PathRequest( Application& app, std::function completion, - Resource::Consumer& consumer, + resource::Consumer& consumer, int id, PathRequestManager& owner, beast::Journal journal) @@ -344,7 +344,7 @@ PathRequest::parseJson(json::Value const& jvParams) { json::Value const& jvSrcCurrencies = jvParams[jss::source_currencies]; if (!jvSrcCurrencies.isArray() || jvSrcCurrencies.size() == 0 || - jvSrcCurrencies.size() > RPC::Tuning::kMaxSrcCur) + jvSrcCurrencies.size() > rpc::tuning::kMaxSrcCur) { jvStatus_ = rpcError(RpcSrcCurMalformed); return PFR_PJ_INVALID; @@ -556,7 +556,7 @@ PathRequest::findPaths( [&](TAsset const& a) { if (!sameAccount || a != saDstAmount_.asset()) { - if (sourceAssets.size() >= RPC::Tuning::kMaxAutoSrcCur) + if (sourceAssets.size() >= rpc::tuning::kMaxAutoSrcCur) return false; if constexpr (std::is_same_v) { diff --git a/src/xrpld/rpc/detail/PathRequest.h b/src/xrpld/rpc/detail/PathRequest.h index d40d9c82d6..f56b3d0652 100644 --- a/src/xrpld/rpc/detail/PathRequest.h +++ b/src/xrpld/rpc/detail/PathRequest.h @@ -64,7 +64,7 @@ public: PathRequest( Application& app, std::function completion, - Resource::Consumer& consumer, + resource::Consumer& consumer, int id, PathRequestManager&, beast::Journal journal); @@ -137,7 +137,7 @@ private: std::weak_ptr wpSubscriber_; // Who this request came from std::function fCompletion_; - Resource::Consumer& consumer_; // Charge according to source currencies + resource::Consumer& consumer_; // Charge according to source currencies json::Value jvId_; json::Value jvStatus_; // Last result diff --git a/src/xrpld/rpc/detail/PathRequestManager.cpp b/src/xrpld/rpc/detail/PathRequestManager.cpp index 4953634181..117bfbda1e 100644 --- a/src/xrpld/rpc/detail/PathRequestManager.cpp +++ b/src/xrpld/rpc/detail/PathRequestManager.cpp @@ -254,7 +254,7 @@ json::Value PathRequestManager::makeLegacyPathRequest( PathRequest::pointer& req, std::function completion, - Resource::Consumer& consumer, + resource::Consumer& consumer, std::shared_ptr const& inLedger, json::Value const& request) { @@ -285,7 +285,7 @@ PathRequestManager::makeLegacyPathRequest( json::Value PathRequestManager::doLegacyPathRequest( - Resource::Consumer& consumer, + resource::Consumer& consumer, std::shared_ptr const& inLedger, json::Value const& request) { diff --git a/src/xrpld/rpc/detail/PathRequestManager.h b/src/xrpld/rpc/detail/PathRequestManager.h index f6eb80d291..29a80e66c0 100644 --- a/src/xrpld/rpc/detail/PathRequestManager.h +++ b/src/xrpld/rpc/detail/PathRequestManager.h @@ -65,7 +65,7 @@ public: makeLegacyPathRequest( PathRequest::pointer& req, std::function completion, - Resource::Consumer& consumer, + resource::Consumer& consumer, std::shared_ptr const& inLedger, json::Value const& request); @@ -73,7 +73,7 @@ public: // with the ledger specified by the caller json::Value doLegacyPathRequest( - Resource::Consumer& consumer, + resource::Consumer& consumer, std::shared_ptr const& inLedger, json::Value const& request); diff --git a/src/xrpld/rpc/detail/RPCCall.cpp b/src/xrpld/rpc/detail/RPCCall.cpp index b5d5c680cd..a752858527 100644 --- a/src/xrpld/rpc/detail/RPCCall.cpp +++ b/src/xrpld/rpc/detail/RPCCall.cpp @@ -74,7 +74,7 @@ createHTTPPost( // CHECKME this uses a different version than the replies below use. Is // this by design or an accident or should it be using - // BuildInfo::getFullVersionString () as well? + // build_info::getFullVersionString () as well? s << "POST " << (strPath.empty() ? "/" : strPath) << " HTTP/1.0\r\n" << "User-Agent: " << systemName() << "-json-rpc/v1\r\n" @@ -149,7 +149,7 @@ private: return jvResult; } - return RPC::makeParamError( + return rpc::makeParamError( std::string("Invalid currency/issuer '") + strCurrencyIssuer + "'"); } @@ -355,7 +355,7 @@ private: } catch (std::exception const&) { - return RPC::invalidFieldError(jss::limit); + return rpc::invalidFieldError(jss::limit); } } @@ -369,7 +369,7 @@ private: } catch (std::exception const&) { - return RPC::invalidFieldError(jss::proof); + return rpc::invalidFieldError(jss::proof); } } @@ -1182,7 +1182,7 @@ private: std::string param = jvParams[index++].asString(); if (param.empty()) - return RPC::makeParamError("Invalid first parameter"); + return rpc::makeParamError("Invalid first parameter"); if (param[0] != 'r') { @@ -1196,7 +1196,7 @@ private: } if (size <= index) - return RPC::makeParamError("Invalid hotwallet"); + return rpc::makeParamError("Invalid hotwallet"); param = jvParams[index++].asString(); } @@ -1726,7 +1726,7 @@ rpcClient( { boost::asio::io_context isService; - RPCCall::fromNetwork( + rpc_call::fromNetwork( isService, setup.client.ip, setup.client.port, @@ -1813,12 +1813,12 @@ rpcClient( //------------------------------------------------------------------------------ -namespace RPCCall { +namespace rpc_call { int fromCommandLine(Config const& config, std::vector const& vCmd, Logs& logs) { - auto const result = rpcClient(vCmd, config, logs, RPC::kApiCommandLineVersion); + auto const result = rpcClient(vCmd, config, logs, rpc::kApiCommandLineVersion); std::cout << result.second.toStyledString(); @@ -1883,6 +1883,6 @@ fromNetwork( j); } -} // namespace RPCCall +} // namespace rpc_call } // namespace xrpl diff --git a/src/xrpld/rpc/detail/RPCHandler.cpp b/src/xrpld/rpc/detail/RPCHandler.cpp index 6f46aed62d..96d6bf72d7 100644 --- a/src/xrpld/rpc/detail/RPCHandler.cpp +++ b/src/xrpld/rpc/detail/RPCHandler.cpp @@ -24,7 +24,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { namespace { @@ -114,7 +114,7 @@ fillHandler(JsonContext& context, Handler const*& result) { // Count all jobs at jtCLIENT priority or higher. int const jobCount = context.app.getJobQueue().getJobCountGE(JtClient); - if (jobCount > Tuning::kMaxJobQueueClients) + if (jobCount > tuning::kMaxJobQueueClients) { JLOG(context.j.debug()) << "Too busy for command: " << jobCount; return RpcTooBusy; @@ -179,8 +179,8 @@ callMethod(JsonContext& context, Method method, std::string const& name, Object& perfLog.rpcError(name, curId); JLOG(context.j.info()) << "Caught throw: " << e.what(); - if (context.loadType == Resource::kFeeReferenceRpc) - context.loadType = Resource::kFeeExceptionRpc; + if (context.loadType == resource::kFeeReferenceRpc) + context.loadType = resource::kFeeExceptionRpc; injectError(RpcInternal, result); return RpcInternal; @@ -190,7 +190,7 @@ callMethod(JsonContext& context, Method method, std::string const& name, Object& } // namespace Status -doCommand(RPC::JsonContext& context, json::Value& result) +doCommand(rpc::JsonContext& context, json::Value& result) { Handler const* handler = nullptr; if (auto error = fillHandler(context, handler)) @@ -226,7 +226,7 @@ doCommand(RPC::JsonContext& context, json::Value& result) Role roleRequired(unsigned int version, bool betaEnabled, std::string const& method) { - auto handler = RPC::getHandler(version, betaEnabled, method); + auto handler = rpc::getHandler(version, betaEnabled, method); if (handler == nullptr) return Role::FORBID; @@ -234,4 +234,4 @@ roleRequired(unsigned int version, bool betaEnabled, std::string const& method) return handler->role; } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 1764375812..4fa0fab6f7 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -42,7 +42,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { std::uint64_t getStartHint(SLE::const_ref sle, AccountID const& accountID) @@ -116,7 +116,7 @@ parseAccountIds(json::Value const& jvArray) } std::optional -readLimitField(unsigned int& limit, Tuning::LimitRange const& range, JsonContext const& context) +readLimitField(unsigned int& limit, tuning::LimitRange const& range, JsonContext const& context) { limit = range.rDefault; if (!context.params.isMember(jss::limit) || context.params[jss::limit].isNull()) @@ -124,11 +124,11 @@ readLimitField(unsigned int& limit, Tuning::LimitRange const& range, JsonContext auto const& jvLimit = context.params[jss::limit]; if (!jvLimit.isUInt() && (!jvLimit.isInt() || jvLimit.asInt() < 0)) - return RPC::expectedFieldError(jss::limit, "unsigned integer"); + return rpc::expectedFieldError(jss::limit, "unsigned integer"); limit = jvLimit.asUInt(); if (limit == 0) - return RPC::invalidFieldError(jss::limit); + return rpc::invalidFieldError(jss::limit); if (!isUnlimited(context.role)) limit = std::max(range.rmin, std::min(range.rmax, limit)); @@ -184,7 +184,7 @@ getSeedFromRPC(json::Value const& params, json::Value& error) if (count != 1) { - error = RPC::makeParamError( + error = rpc::makeParamError( "Exactly one of the following must be specified: " + std::string(jss::passphrase) + ", " + std::string(jss::seed) + " or " + std::string(jss::seed_hex)); return std::nullopt; @@ -194,7 +194,7 @@ getSeedFromRPC(json::Value const& params, json::Value& error) auto const& param = params[seedType->first]; if (!param.isString()) { - error = RPC::expectedFieldError(seedType->first, "string"); + error = rpc::expectedFieldError(seedType->first, "string"); return std::nullopt; } @@ -232,13 +232,13 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int if (count == 0 || secretType == nullptr) { - error = RPC::missingFieldError(jss::secret); + error = rpc::missingFieldError(jss::secret); return {}; } if (count > 1) { - error = RPC::makeParamError( + error = rpc::makeParamError( "Exactly one of the following must be specified: " + std::string(jss::passphrase) + ", " + std::string(jss::secret) + ", " + std::string(jss::seed) + " or " + std::string(jss::seed_hex)); @@ -252,7 +252,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int { if (!params[jss::key_type].isString()) { - error = RPC::expectedFieldError(jss::key_type, "string"); + error = rpc::expectedFieldError(jss::key_type, "string"); return {}; } @@ -262,11 +262,11 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int { if (apiVersion > 1u) { - error = RPC::makeError(RpcBadKeyType); + error = rpc::makeError(RpcBadKeyType); } else { - error = RPC::invalidFieldError(jss::key_type); + error = rpc::invalidFieldError(jss::key_type); } return {}; } @@ -275,7 +275,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int // https://developercommunity.visualstudio.com/t/assigning-constexpr-char--to-static-cha/10021357?entry=problem) if (strcmp(secretType, jss::secret.cStr()) == 0) { - error = RPC::makeParamError( + error = rpc::makeParamError( "The secret field is not allowed if " + std::string(jss::key_type) + " is used."); return {}; } @@ -288,7 +288,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int // https://developercommunity.visualstudio.com/t/assigning-constexpr-char--to-static-cha/10021357?entry=problem) if (strcmp(secretType, jss::seed_hex.cStr()) != 0) { - seed = RPC::parseXrplLibSeed(params[secretType]); + seed = rpc::parseXrplLibSeed(params[secretType]); if (seed) { @@ -296,7 +296,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int // requested another key type, return an error. if (keyType.value_or(KeyType::Ed25519) != KeyType::Ed25519) { - error = RPC::makeError(RpcBadSeed, "Specified seed is for an Ed25519 wallet."); + error = rpc::makeError(RpcBadSeed, "Specified seed is for an Ed25519 wallet."); return {}; } @@ -317,7 +317,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int { if (!params[jss::secret].isString()) { - error = RPC::expectedFieldError(jss::secret, "string"); + error = rpc::expectedFieldError(jss::secret, "string"); return {}; } @@ -329,7 +329,7 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int { if (!containsError(error)) { - error = RPC::makeError(RpcBadSeed, RPC::invalidFieldMessage(secretType)); + error = rpc::makeError(RpcBadSeed, rpc::invalidFieldMessage(secretType)); } return {}; @@ -341,10 +341,10 @@ keypairForSignature(json::Value const& params, json::Value& error, unsigned int return generateKeyPair(*keyType, *seed); } -std::pair +std::pair chooseLedgerEntryType(json::Value const& params) { - std::pair result{RPC::Status::kOK, ltANY}; + std::pair result{rpc::Status::kOK, ltANY}; if (params.isMember(jss::type)) { static constexpr auto kTypes = @@ -363,10 +363,10 @@ chooseLedgerEntryType(json::Value const& params) auto const& p = params[jss::type]; if (!p.isString()) { - result.first = RPC::Status{RpcInvalidParams, "Invalid field 'type', not string."}; + result.first = rpc::Status{RpcInvalidParams, "Invalid field 'type', not string."}; XRPL_ASSERT( - result.first.type() == RPC::Status::Type::ErrorCodeI, - "xrpl::RPC::chooseLedgerEntryType : first valid result type"); + result.first.type() == rpc::Status::Type::ErrorCodeI, + "xrpl::rpc::chooseLedgerEntryType : first valid result type"); return result; } @@ -379,10 +379,10 @@ chooseLedgerEntryType(json::Value const& params) }); if (iter == kTypes.end()) { - result.first = RPC::Status{RpcInvalidParams, "Invalid field 'type'."}; + result.first = rpc::Status{RpcInvalidParams, "Invalid field 'type'."}; XRPL_ASSERT( - result.first.type() == RPC::Status::Type::ErrorCodeI, - "xrpl::RPC::chooseLedgerEntryType : second valid result " + result.first.type() == rpc::Status::Type::ErrorCodeI, + "xrpl::rpc::chooseLedgerEntryType : second valid result " "type"); return result; } @@ -466,4 +466,4 @@ parseSubUnsubJson( return RpcSuccess; } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index 881b758487..24c06021c0 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -27,7 +27,7 @@ namespace xrpl { class ReadView; -namespace RPC { +namespace rpc { struct JsonContext; @@ -85,7 +85,7 @@ parseAccountIds(json::Value const& jvArray); * std::nullopt on success. */ std::optional -readLimitField(unsigned int& limit, Tuning::LimitRange const& range, JsonContext const& context); +readLimitField(unsigned int& limit, tuning::LimitRange const& range, JsonContext const& context); /** * @brief Extracts a Seed from RPC parameters. @@ -123,7 +123,7 @@ parseXrplLibSeed(json::Value const& params); * @param params The JSON value containing RPC parameters. * @return A pair consisting of the RPC status and the chosen LedgerEntryType. */ -std::pair +std::pair chooseLedgerEntryType(json::Value const& params); /** @@ -172,6 +172,6 @@ parseSubUnsubJson( json::StaticString const& name, beast::Journal j); -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp b/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp index 6843c34b19..52e68e87f1 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp @@ -30,7 +30,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { namespace { @@ -40,7 +40,7 @@ isValidatedOld(LedgerMaster& ledgerMaster, bool standalone) if (standalone) return false; - return ledgerMaster.getValidatedLedgerAge() > Tuning::kMaxValidatedLedgerAge; + return ledgerMaster.getValidatedLedgerAge() > tuning::kMaxValidatedLedgerAge; } template @@ -282,19 +282,19 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context const& context) return {RpcNotSynced, "notSynced"}; } - XRPL_ASSERT(!ledger->open(), "xrpl::RPC::getLedger : validated is not open"); + XRPL_ASSERT(!ledger->open(), "xrpl::rpc::getLedger : validated is not open"); } else { if (shortcut == LedgerShortcut::Current) { ledger = context.ledgerMaster.getCurrentLedger(); - XRPL_ASSERT(ledger->open(), "xrpl::RPC::getLedger : current is open"); + XRPL_ASSERT(ledger->open(), "xrpl::rpc::getLedger : current is open"); } else if (shortcut == LedgerShortcut::Closed) { ledger = context.ledgerMaster.getClosedLedger(); - XRPL_ASSERT(!ledger->open(), "xrpl::RPC::getLedger : closed is not open"); + XRPL_ASSERT(!ledger->open(), "xrpl::rpc::getLedger : closed is not open"); } else { @@ -386,7 +386,7 @@ lookupLedger(std::shared_ptr& ledger, JsonContext const& context } std::expected, json::Value> -getOrAcquireLedger(RPC::JsonContext const& context) +getOrAcquireLedger(rpc::JsonContext const& context) { auto const hasHash = context.params.isMember(jss::ledger_hash); auto const hasIndex = context.params.isMember(jss::ledger_index); @@ -398,7 +398,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) if ((static_cast(hasHash) + static_cast(hasIndex)) != 1) { return std::unexpected( - RPC::makeParamError( + rpc::makeParamError( "Exactly one of 'ledger_hash' or " "'ledger_index' can be specified.")); } @@ -407,16 +407,16 @@ getOrAcquireLedger(RPC::JsonContext const& context) { auto const& jsonHash = context.params.get(jss::ledger_hash, json::ValueType::Null); if (!jsonHash.isString() || !ledgerHash.parseHex(jsonHash.asString())) - return std::unexpected(RPC::expectedFieldError(jss::ledger_hash, "hex string")); + return std::unexpected(rpc::expectedFieldError(jss::ledger_hash, "hex string")); } else { auto const& jsonIndex = context.params.get(jss::ledger_index, json::ValueType::Null); if (!jsonIndex.isInt() && !jsonIndex.isUInt()) - return std::unexpected(RPC::expectedFieldError(jss::ledger_index, "number")); + return std::unexpected(rpc::expectedFieldError(jss::ledger_index, "number")); // We need a validated ledger to get the hash from the sequence - if (ledgerMaster.getValidatedLedgerAge() > RPC::Tuning::kMaxValidatedLedgerAge) + if (ledgerMaster.getValidatedLedgerAge() > rpc::tuning::kMaxValidatedLedgerAge) { if (context.apiVersion == 1) return std::unexpected(rpcError(RpcNoCurrent)); @@ -427,9 +427,9 @@ getOrAcquireLedger(RPC::JsonContext const& context) auto ledger = ledgerMaster.getValidatedLedger(); if (ledgerIndex >= ledger->header().seq) - return std::unexpected(RPC::makeParamError("Ledger index too large")); + return std::unexpected(rpc::makeParamError("Ledger index too large")); if (ledgerIndex <= 0) - return std::unexpected(RPC::makeParamError("Ledger index too small")); + return std::unexpected(rpc::makeParamError("Ledger index too small")); auto const j = context.app.getJournal("RPCHandler"); // Try to get the hash of the desired ledger from the validated @@ -441,7 +441,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) // ledger auto const refIndex = getCandidateLedger(ledgerIndex); auto refHash = hashOfSeq(*ledger, refIndex, j); - XRPL_ASSERT(refHash, "xrpl::RPC::getOrAcquireLedger : nonzero ledger hash"); + XRPL_ASSERT(refHash, "xrpl::rpc::getOrAcquireLedger : nonzero ledger hash"); // NOLINTBEGIN(bugprone-unchecked-optional-access) assert above ledger = ledgerMaster.getLedgerByHash(*refHash); @@ -453,7 +453,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) if (auto il = context.app.getInboundLedgers().acquire( *refHash, refIndex, InboundLedger::Reason::GENERIC)) { - json::Value jvResult = RPC::makeError( + json::Value jvResult = rpc::makeError( RpcLgrNotFound, "acquiring ledger containing requested index"); jvResult[jss::acquiring] = getJson(LedgerFill(*il, &context)); return std::unexpected(jvResult); @@ -462,7 +462,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) if (auto il = context.app.getInboundLedgers().find(*refHash)) // NOLINTEND(bugprone-unchecked-optional-access) { - json::Value jvResult = RPC::makeError( + json::Value jvResult = rpc::makeError( RpcLgrNotFound, "acquiring ledger containing requested index"); jvResult[jss::acquiring] = il->getJson(0); return std::unexpected(jvResult); @@ -474,7 +474,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) neededHash = hashOfSeq(*ledger, ledgerIndex, j); } - XRPL_ASSERT(neededHash, "xrpl::RPC::getOrAcquireLedger : nonzero needed hash"); + XRPL_ASSERT(neededHash, "xrpl::rpc::getOrAcquireLedger : nonzero needed hash"); ledgerHash = neededHash ? *neededHash : beast::kZero; // kludge } @@ -494,7 +494,7 @@ getOrAcquireLedger(RPC::JsonContext const& context) return std::unexpected(il->getJson(0)); return std::unexpected( - RPC::makeError(RpcNotReady, "findCreate failed to return an inbound ledger")); + rpc::makeError(RpcNotReady, "findCreate failed to return an inbound ledger")); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.h b/src/xrpld/rpc/detail/RPCLedgerHelpers.h index cbd47d38e6..cad5141917 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.h +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.h @@ -21,7 +21,7 @@ namespace xrpl { class ReadView; class Transaction; -namespace RPC { +namespace rpc { struct JsonContext; @@ -172,8 +172,8 @@ ledgerFromSpecifier( * On failure, contains a json::Value describing the error. */ std::expected, json::Value> -getOrAcquireLedger(RPC::JsonContext const& context); +getOrAcquireLedger(rpc::JsonContext const& context); -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/detail/RPCSub.cpp b/src/xrpld/rpc/detail/RPCSub.cpp index 92e9849939..8cea8b6bdd 100644 --- a/src/xrpld/rpc/detail/RPCSub.cpp +++ b/src/xrpld/rpc/detail/RPCSub.cpp @@ -75,7 +75,7 @@ public: } path_ = pUrl.path; - JLOG(j_.info()) << "RPCCall::fromNetwork sub: ip=" << ip_ << " port=" << port_ + JLOG(j_.info()) << "rpc_call::fromNetwork sub: ip=" << ip_ << " port=" << port_ << " ssl= " << (ssl_ ? "yes" : "no") << " path='" << path_ << "'"; } @@ -87,14 +87,14 @@ public: std::scoped_lock const sl(lock_); auto jm = broadcast ? j_.debug() : j_.info(); - JLOG(jm) << "RPCCall::fromNetwork push: " << jvObj; + JLOG(jm) << "rpc_call::fromNetwork push: " << jvObj; deque_.emplace_back(seq_++, jvObj); if (!sending_) { // Start a sending thread. - JLOG(j_.info()) << "RPCCall::fromNetwork start"; + JLOG(j_.info()) << "rpc_call::fromNetwork start"; sending_ = jobQueue_.addJob(JtClientSubscribe, "RPCSubSendThr", [this]() { sendThread(); }); @@ -156,9 +156,9 @@ private: // XXX Might not need this in a try. try { - JLOG(j_.info()) << "RPCCall::fromNetwork: " << ip_; + JLOG(j_.info()) << "rpc_call::fromNetwork: " << ip_; - RPCCall::fromNetwork( + rpc_call::fromNetwork( ioContext_, ip_, port_, @@ -173,7 +173,7 @@ private: } catch (std::exception const& e) { - JLOG(j_.info()) << "RPCCall::fromNetwork exception: " << e.what(); + JLOG(j_.info()) << "rpc_call::fromNetwork exception: " << e.what(); } } } while (bSend); diff --git a/src/xrpld/rpc/detail/Role.cpp b/src/xrpld/rpc/detail/Role.cpp index 68c5fcc484..34970b0580 100644 --- a/src/xrpld/rpc/detail/Role.cpp +++ b/src/xrpld/rpc/detail/Role.cpp @@ -40,7 +40,7 @@ passwordUnrequiredOrSentCorrect(Port const& port, json::Value const& params) bool ipAllowed( - beast::IP::Address const& remoteIp, + beast::ip::Address const& remoteIp, std::vector const& nets4, std::vector const& nets6) { @@ -78,7 +78,7 @@ ipAllowed( } bool -isAdmin(Port const& port, json::Value const& params, beast::IP::Address const& remoteIp) +isAdmin(Port const& port, json::Value const& params, beast::ip::Address const& remoteIp) { return ipAllowed(remoteIp, port.adminNetsV4, port.adminNetsV6) && passwordUnrequiredOrSentCorrect(port, params); @@ -89,7 +89,7 @@ requestRole( Role const& required, Port const& port, json::Value const& params, - beast::IP::Endpoint const& remoteIp, + beast::ip::Endpoint const& remoteIp, std::string_view user) { if (isAdmin(port, params, remoteIp.address())) @@ -122,16 +122,16 @@ isUnlimited( Role const& required, Port const& port, json::Value const& params, - beast::IP::Endpoint const& remoteIp, + beast::ip::Endpoint const& remoteIp, std::string const& user) { return isUnlimited(requestRole(required, port, params, remoteIp, user)); } -Resource::Consumer +resource::Consumer requestInboundEndpoint( - Resource::Manager& manager, - beast::IP::Endpoint const& remoteAddress, + resource::Manager& manager, + beast::ip::Endpoint const& remoteAddress, Role const& role, std::string_view user, std::string_view forwardedFor) diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index 768cbf0dc0..0181d5b10f 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -93,7 +93,7 @@ statusRequestResponse(http_request_type const& request, boost::beast::http::stat response msg; msg.version(request.version()); msg.result(status); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Content-Type", "text/html"); msg.insert("Connection", "close"); msg.body() = "Invalid protocol."; @@ -129,7 +129,7 @@ ServerHandler::ServerHandler( boost::asio::io_context& ioContext, JobQueue& jobQueue, NetworkOPs& networkOPs, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, CollectorManager& cm) : app_(app) , resourceManager_(resourceManager) @@ -337,7 +337,7 @@ ServerHandler::onWSMessage( { json::Value jv; auto const size = boost::asio::buffer_size(buffers); - if (size > RPC::Tuning::kMaxRequestSize || !json::Reader{}.parse(jv, buffers) || !jv.isObject()) + if (size > rpc::tuning::kMaxRequestSize || !json::Reader{}.parse(jv, buffers) || !jv.isObject()) { json::Value jvResult(json::ValueType::Object); jvResult[jss::type] = jss::error; @@ -426,11 +426,11 @@ ServerHandler::processSession( // Requests without "command" are invalid. json::Value jr(json::ValueType::Object); - Resource::Charge loadType = Resource::kFeeReferenceRpc; + resource::Charge loadType = resource::kFeeReferenceRpc; try { - auto apiVersion = RPC::getAPIVersionNumber(jv, app_.config().betaRpcApi); - if (apiVersion == RPC::kApiInvalidVersion || + auto apiVersion = rpc::getAPIVersionNumber(jv, app_.config().betaRpcApi); + if (apiVersion == rpc::kApiInvalidVersion || (!jv.isMember(jss::command) && !jv.isMember(jss::method)) || (jv.isMember(jss::command) && !jv[jss::command].isString()) || (jv.isMember(jss::method) && !jv[jss::method].isString()) || @@ -439,7 +439,7 @@ ServerHandler::processSession( { jr[jss::type] = jss::response; jr[jss::status] = jss::error; - jr[jss::error] = apiVersion == RPC::kApiInvalidVersion ? jss::invalid_API_version + jr[jss::error] = apiVersion == rpc::kApiInvalidVersion ? jss::invalid_API_version : jss::missingCommand; jr[jss::request] = jv; if (jv.isMember(jss::id)) @@ -451,11 +451,11 @@ ServerHandler::processSession( if (jv.isMember(jss::api_version)) jr[jss::api_version] = jv[jss::api_version]; - is->getConsumer().charge(Resource::kFeeMalformedRpc); + is->getConsumer().charge(resource::kFeeMalformedRpc); return jr; } - auto required = RPC::roleRequired( + auto required = rpc::roleRequired( apiVersion, app_.config().betaRpcApi, jv.isMember(jss::command) ? jv[jss::command].asString() : jv[jss::method].asString()); @@ -463,16 +463,16 @@ ServerHandler::processSession( required, session->port(), jv, - beast::IP::fromAsio(session->remoteEndpoint().address()), + beast::ip::fromAsio(session->remoteEndpoint().address()), is->user()); if (Role::FORBID == role) { - loadType = Resource::kFeeMalformedRpc; + loadType = resource::kFeeMalformedRpc; jr[jss::result] = rpcError(RpcForbidden); } else { - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = app_.getJournal("RPCHandler"), .app = app_, .loadType = loadType, @@ -487,7 +487,7 @@ ServerHandler::processSession( {.user = is->user(), .forwardedFor = is->forwardedFor()}}; auto start = std::chrono::system_clock::now(); - RPC::doCommand(context, jr[jss::result]); + rpc::doCommand(context, jr[jss::result]); auto end = std::chrono::system_clock::now(); logDuration(jv, end - start, journal_); } @@ -495,7 +495,7 @@ ServerHandler::processSession( catch (std::exception const& ex) { // LCOV_EXCL_START - jr[jss::result] = RPC::makeError(RpcInternal); + jr[jss::result] = rpc::makeError(RpcInternal); JLOG(journal_.error()) << "Exception while processing WS: " << ex.what() << "\n" << "Input JSON: " << json::Compact{json::Value{jv}}; // LCOV_EXCL_STOP @@ -601,7 +601,7 @@ void ServerHandler::processRequest( Port const& port, std::string const& request, - beast::IP::Endpoint const& remoteIPAddress, + beast::ip::Endpoint const& remoteIPAddress, Output const& output, std::shared_ptr coro, std::string_view forwardedFor, @@ -612,7 +612,7 @@ ServerHandler::processRequest( json::Value jsonOrig; { json::Reader reader; - if ((request.size() > RPC::Tuning::kMaxRequestSize) || !reader.parse(request, jsonOrig) || + if ((request.size() > rpc::tuning::kMaxRequestSize) || !reader.parse(request, jsonOrig) || !jsonOrig || !jsonOrig.isObject()) { httpReply( @@ -652,21 +652,21 @@ ServerHandler::processRequest( continue; } - unsigned apiVersion = RPC::kApiVersionIfUnspecified; + unsigned apiVersion = rpc::kApiVersionIfUnspecified; if (jsonRPC.isMember(jss::params) && jsonRPC[jss::params].isArray() && jsonRPC[jss::params].size() > 0 && jsonRPC[jss::params][0u].isObject()) { - apiVersion = RPC::getAPIVersionNumber( + apiVersion = rpc::getAPIVersionNumber( jsonRPC[jss::params][json::UInt(0)], app_.config().betaRpcApi); } - if (apiVersion == RPC::kApiVersionIfUnspecified && batch) + if (apiVersion == rpc::kApiVersionIfUnspecified && batch) { // for batch request, api_version may be at a different level - apiVersion = RPC::getAPIVersionNumber(jsonRPC, app_.config().betaRpcApi); + apiVersion = rpc::getAPIVersionNumber(jsonRPC, app_.config().betaRpcApi); } - if (apiVersion == RPC::kApiInvalidVersion) + if (apiVersion == rpc::kApiInvalidVersion) { if (!batch) { @@ -685,7 +685,7 @@ ServerHandler::processRequest( auto required = Role::FORBID; if (jsonRPC.isMember(jss::method) && jsonRPC[jss::method].isString()) { - required = RPC::roleRequired( + required = rpc::roleRequired( apiVersion, app_.config().betaRpcApi, jsonRPC[jss::method].asString()); } @@ -700,7 +700,7 @@ ServerHandler::processRequest( role = requestRole(required, port, json::ValueType::Object, remoteIPAddress, user); } - Resource::Consumer usage; + resource::Consumer usage; if (isUnlimited(role)) { usage = resourceManager_.newUnlimitedEndpoint(remoteIPAddress); @@ -725,7 +725,7 @@ ServerHandler::processRequest( if (role == Role::FORBID) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); if (!batch) { httpReply(403, "Forbidden", output, rpcJ); @@ -739,7 +739,7 @@ ServerHandler::processRequest( if (!jsonRPC.isMember(jss::method) || jsonRPC[jss::method].isNull()) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); if (!batch) { httpReply(400, "Null method", output, rpcJ); @@ -754,7 +754,7 @@ ServerHandler::processRequest( json::Value const& method = jsonRPC[jss::method]; if (!method.isString()) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); if (!batch) { httpReply(400, "method is not string", output, rpcJ); @@ -769,7 +769,7 @@ ServerHandler::processRequest( std::string const strMethod = method.asString(); if (strMethod.empty()) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); if (!batch) { httpReply(400, "method is empty", output, rpcJ); @@ -797,7 +797,7 @@ ServerHandler::processRequest( } else if (!params.isArray() || params.size() != 1) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); httpReply(400, "params unparsable", output, rpcJ); return; } @@ -806,7 +806,7 @@ ServerHandler::processRequest( params = std::move(params[0u]); if (!params.isObjectOrNull()) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); httpReply(400, "params unparsable", output, rpcJ); return; } @@ -822,7 +822,7 @@ ServerHandler::processRequest( { if (!params[jss::ripplerpc].isString()) { - usage.charge(Resource::kFeeMalformedRpc); + usage.charge(resource::kFeeMalformedRpc); if (!batch) { httpReply(400, "ripplerpc is not a string", output, rpcJ); @@ -853,9 +853,9 @@ ServerHandler::processRequest( params[jss::command] = strMethod; JLOG(journal_.trace()) << "doRpcCommand:" << strMethod << ":" << params; - Resource::Charge loadType = Resource::kFeeReferenceRpc; + resource::Charge loadType = resource::kFeeReferenceRpc; - RPC::JsonContext context{ + rpc::JsonContext context{ {.j = journal_, .app = app_, .loadType = loadType, @@ -874,12 +874,12 @@ ServerHandler::processRequest( try { - RPC::doCommand(context, result); + rpc::doCommand(context, result); } catch (std::exception const& ex) { // LCOV_EXCL_START - result = RPC::makeError(RpcInternal); + result = rpc::makeError(RpcInternal); JLOG(journal_.error()) << "Internal error : " << ex.what() << " when processing request: " << json::Compact{json::Value{params}}; @@ -984,7 +984,7 @@ ServerHandler::processRequest( reply[jss::error][jss::error_code].isInt()) { int const errCode = reply[jss::error][jss::error_code].asInt(); - return RPC::errorCodeHttpStatus(static_cast(errCode)); + return rpc::errorCodeHttpStatus(static_cast(errCode)); } } // Return OK. @@ -1043,7 +1043,7 @@ ServerHandler::statusResponse(http_request_type const& request) const msg.body() = "Server cannot accept clients: " + reason + ""; } msg.version(request.version()); - msg.insert("Server", BuildInfo::getFullVersionString()); + msg.insert("Server", build_info::getFullVersionString()); msg.insert("Content-Type", "text/html"); msg.insert("Connection", "close"); msg.prepare_payload(); @@ -1208,7 +1208,7 @@ setupClient(ServerHandler::Setup& setup) if (iter == setup.ports.cend()) return; setup.client.secure = iter->protocol.contains("https"); - if (beast::IP::isUnspecified(iter->ip)) + if (beast::ip::isUnspecified(iter->ip)) { // VFALCO HACK! to make localhost work setup.client.ip = iter->ip.is_v6() ? "::1" : "127.0.0.1"; @@ -1256,7 +1256,7 @@ makeServerHandler( boost::asio::io_context& ioContext, JobQueue& jobQueue, NetworkOPs& networkOPs, - Resource::Manager& resourceManager, + resource::Manager& resourceManager, CollectorManager& cm) { return std::make_unique( diff --git a/src/xrpld/rpc/detail/Status.cpp b/src/xrpld/rpc/detail/Status.cpp index 58d2f8cb80..147f2b31e0 100644 --- a/src/xrpld/rpc/detail/Status.cpp +++ b/src/xrpld/rpc/detail/Status.cpp @@ -9,7 +9,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { std::string Status::codeString() const @@ -25,7 +25,7 @@ Status::codeString() const std::string s1, s2; [[maybe_unused]] auto const success = transResultInfo(toTER(), s1, s2); - XRPL_ASSERT(success, "xrpl::RPC::codeString : valid TER result"); + XRPL_ASSERT(success, "xrpl::rpc::codeString : valid TER result"); return s1 + ": " + s2; } @@ -39,7 +39,7 @@ Status::codeString() const } // LCOV_EXCL_START - UNREACHABLE("xrpl::RPC::codeString : invalid type"); + UNREACHABLE("xrpl::rpc::codeString : invalid type"); return ""; // LCOV_EXCL_STOP } @@ -85,4 +85,4 @@ Status::toString() const return ""; } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index e1c5180b5c..9c97577b27 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -64,7 +64,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { namespace detail { // Used to pass extra parameters used when returning a @@ -218,7 +218,7 @@ checkPayment( { if (txJson[jss::DeliverMax] != txJson[jss::Amount]) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Cannot specify differing 'Amount' and 'DeliverMax'"); } } @@ -231,31 +231,31 @@ checkPayment( } if (!txJson.isMember(jss::Amount)) - return RPC::missingFieldError("tx_json.Amount"); + return rpc::missingFieldError("tx_json.Amount"); STAmount amount; if (!amountFromJsonNoThrow(amount, txJson[jss::Amount])) - return RPC::invalidFieldError("tx_json.Amount"); + return rpc::invalidFieldError("tx_json.Amount"); if (!txJson.isMember(jss::Destination)) - return RPC::missingFieldError("tx_json.Destination"); + return rpc::missingFieldError("tx_json.Destination"); auto const dstAccountID = parseBase58(txJson[jss::Destination].asString()); if (!dstAccountID) - return RPC::invalidFieldError("tx_json.Destination"); + return rpc::invalidFieldError("tx_json.Destination"); if (params.isMember(jss::build_path) && (!doPath || (!app.getOpenLedger().current()->rules().enabled(featureMPTokensV2) && amount.holds()))) { - return RPC::makeError(RpcInvalidParams, "Field 'build_path' not allowed in this context."); + return rpc::makeError(RpcInvalidParams, "Field 'build_path' not allowed in this context."); } if (txJson.isMember(jss::Paths) && params.isMember(jss::build_path)) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "Cannot specify both 'tx_json.Paths' and 'build_path'"); } @@ -266,7 +266,7 @@ checkPayment( if (!txJson[sfDomainID.jsonName].isString() || !num.parseHex(txJson[sfDomainID.jsonName].asString())) { - return RPC::makeError(RpcDomainMalformed, "Unable to parse 'DomainID'."); + return rpc::makeError(RpcDomainMalformed, "Unable to parse 'DomainID'."); } domain = num; @@ -279,7 +279,7 @@ checkPayment( if (txJson.isMember(jss::SendMax)) { if (!amountFromJsonNoThrow(sendMax, txJson[jss::SendMax])) - return RPC::invalidFieldError("tx_json.SendMax"); + return rpc::invalidFieldError("tx_json.SendMax"); } else { @@ -291,7 +291,7 @@ checkPayment( } if (sendMax.native() && amount.native()) - return RPC::makeError(RpcInvalidParams, "Cannot build XRP to XRP paths."); + return rpc::makeError(RpcInvalidParams, "Cannot build XRP to XRP paths."); { LegacyPathFind const lpf(isUnlimited(role), app); @@ -357,19 +357,19 @@ checkTxJsonFields( if (!txJson.isObject()) { - ret.first = RPC::objectFieldError(jss::tx_json); + ret.first = rpc::objectFieldError(jss::tx_json); return ret; } if (!txJson.isMember(jss::TransactionType)) { - ret.first = RPC::missingFieldError("tx_json.TransactionType"); + ret.first = rpc::missingFieldError("tx_json.TransactionType"); return ret; } if (!txJson.isMember(jss::Account)) { - ret.first = RPC::makeError(RpcSrcActMissing, RPC::missingFieldMessage("tx_json.Account")); + ret.first = rpc::makeError(RpcSrcActMissing, rpc::missingFieldMessage("tx_json.Account")); return ret; } @@ -377,12 +377,12 @@ checkTxJsonFields( if (!srcAddressID) { - ret.first = RPC::makeError(RpcSrcActMalformed, RPC::invalidFieldMessage("tx_json.Account")); + ret.first = rpc::makeError(RpcSrcActMalformed, rpc::invalidFieldMessage("tx_json.Account")); return ret; } // Check for current ledger. - if (verify && !config.standalone() && (validatedLedgerAge > Tuning::kMaxValidatedLedgerAge)) + if (verify && !config.standalone() && (validatedLedgerAge > tuning::kMaxValidatedLedgerAge)) { if (apiVersion == 1) { @@ -415,12 +415,12 @@ checkNetworkID(json::Value const& txJson, uint32_t appNetworkId) if (!txJson.isMember(jss::NetworkID)) { return std::unexpected( - RPC::makeError(RpcInvalidParams, RPC::missingFieldMessage("tx_json.NetworkID"))); + rpc::makeError(RpcInvalidParams, rpc::missingFieldMessage("tx_json.NetworkID"))); } if (!txJson[jss::NetworkID].isIntegral() || txJson[jss::NetworkID].asUInt() != appNetworkId) { return std::unexpected( - RPC::makeError(RpcInvalidParams, RPC::invalidFieldMessage("tx_json.NetworkID"))); + rpc::makeError(RpcInvalidParams, rpc::invalidFieldMessage("tx_json.NetworkID"))); } } return std::expected(); @@ -490,13 +490,13 @@ transactionPreProcessImpl( { if (signatureTemplate == nullptr) { // Invalid target field - return RPC::makeError(RpcInvalidParams, signatureTarget->get().getName()); + return rpc::makeError(RpcInvalidParams, signatureTarget->get().getName()); } signingArgs.setSignatureTarget(signatureTarget); } if (!params.isMember(jss::tx_json)) - return RPC::missingFieldError(jss::tx_json); + return rpc::missingFieldError(jss::tx_json); json::Value& txJson(params[jss::tx_json]); @@ -510,14 +510,14 @@ transactionPreProcessImpl( app.getFeeTrack(), getAPIVersionNumber(params, app.config().betaRpcApi)); - if (RPC::containsError(txJsonResult)) + if (rpc::containsError(txJsonResult)) return std::move(txJsonResult); // This test covers the case where we're offline so the sequence number // cannot be determined locally. If we're offline then the caller must // provide the sequence number. if (!verify && !txJson.isMember(jss::Sequence)) - return RPC::missingFieldError("tx_json.Sequence"); + return rpc::missingFieldError("tx_json.Sequence"); SLE::const_pointer sle; if (verify) @@ -565,7 +565,7 @@ transactionPreProcessImpl( app.getTxQ(), app); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -573,7 +573,7 @@ transactionPreProcessImpl( json::Value err = checkPayment( params, txJson, srcAddressID, role, app, verify && signingArgs.editFields()); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -614,8 +614,8 @@ transactionPreProcessImpl( if (!ptrDelegatedAddressID) { - return RPC::makeError( - RpcSrcActMalformed, RPC::invalidFieldMessage("tx_json.Delegate")); + return rpc::makeError( + RpcSrcActMalformed, rpc::invalidFieldMessage("tx_json.Delegate")); } auto delegatedAddressID = *ptrDelegatedAddressID; @@ -672,17 +672,17 @@ transactionPreProcessImpl( } catch (STObject::FieldErr const& err) { - return RPC::makeError(RpcInvalidParams, err.what()); + return rpc::makeError(RpcInvalidParams, err.what()); } catch (std::exception&) { - return RPC::makeError( + return rpc::makeError( RpcInternal, "Exception occurred constructing serialized transaction"); } std::string reason; if (!passesLocalChecks(*stTx, reason)) - return RPC::makeError(RpcInvalidParams, reason); + return rpc::makeError(RpcInvalidParams, reason); // If multisign then return multiSignature, else set TxnSignature field. if (signingArgs.isMultiSigning()) @@ -716,7 +716,7 @@ transactionConstructImpl( tpTrans = std::make_shared(stTx, reason, app); if (tpTrans->getStatus() != TransStatus::NEW) { - ret.first = RPC::makeError(RpcInternal, "Unable to construct transaction: " + reason); + ret.first = rpc::makeError(RpcInternal, "Unable to construct transaction: " + reason); return ret; } } @@ -741,7 +741,7 @@ transactionConstructImpl( } if (checkValidity(app.getHashRouter(), *sttxNew, rules).first != Validity::Valid) { - ret.first = RPC::makeError(RpcInternal, "Invalid signature."); + ret.first = rpc::makeError(RpcInternal, "Invalid signature."); return ret; } @@ -766,7 +766,7 @@ transactionConstructImpl( if (!tpTrans) { - ret.first = RPC::makeError(RpcInternal, "Unable to sterilize transaction."); + ret.first = rpc::makeError(RpcInternal, "Unable to sterilize transaction."); return ret; } ret.second = std::move(tpTrans); @@ -789,7 +789,7 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion) jvResult[jss::tx_json] = tpTrans->getJson(JsonOptions::Values::None); } - RPC::insertDeliverMax( + rpc::insertDeliverMax( jvResult[jss::tx_json], tpTrans->getSTransaction()->getTxnType(), apiVersion); jvResult[jss::tx_blob] = strHex(tpTrans->getSTransaction()->getSerializer().peekData()); @@ -808,7 +808,7 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion) } catch (std::exception&) { - jvResult = RPC::makeError(RpcInternal, "Exception occurred during JSON handling."); + jvResult = rpc::makeError(RpcInternal, "Exception occurred during JSON handling."); } return jvResult; } @@ -922,7 +922,7 @@ getCurrentNetworkFee( { std::stringstream ss; ss << "Fee of " << fee << " exceeds the requested tx limit of " << *limit; - return RPC::makeError(RpcHighFee, ss.str()); + return rpc::makeError(RpcHighFee, ss.str()); } return fee.jsonClipped(); @@ -943,10 +943,10 @@ checkFee( return json::Value(); if (!doAutoFill) - return RPC::missingFieldError("tx_json.Fee"); + return rpc::missingFieldError("tx_json.Fee"); - int mult = Tuning::kDefaultAutoFillFeeMultiplier; - int div = Tuning::kDefaultAutoFillFeeDivisor; + int mult = tuning::kDefaultAutoFillFeeMultiplier; + int div = tuning::kDefaultAutoFillFeeDivisor; if (request.isMember(jss::fee_mult_max)) { if (request[jss::fee_mult_max].isInt()) @@ -954,15 +954,15 @@ checkFee( mult = request[jss::fee_mult_max].asInt(); if (mult < 0) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, - RPC::expectedFieldMessage(jss::fee_mult_max, "a positive integer")); + rpc::expectedFieldMessage(jss::fee_mult_max, "a positive integer")); } } else { - return RPC::makeError( - RpcHighFee, RPC::expectedFieldMessage(jss::fee_mult_max, "a positive integer")); + return rpc::makeError( + RpcHighFee, rpc::expectedFieldMessage(jss::fee_mult_max, "a positive integer")); } } if (request.isMember(jss::fee_div_max)) @@ -972,15 +972,15 @@ checkFee( div = request[jss::fee_div_max].asInt(); if (div <= 0) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, - RPC::expectedFieldMessage(jss::fee_div_max, "a positive integer")); + rpc::expectedFieldMessage(jss::fee_div_max, "a positive integer")); } } else { - return RPC::makeError( - RpcHighFee, RPC::expectedFieldMessage(jss::fee_div_max, "a positive integer")); + return rpc::makeError( + RpcHighFee, rpc::expectedFieldMessage(jss::fee_div_max, "a positive integer")); } } @@ -1071,7 +1071,7 @@ transactionSubmit( } catch (std::exception&) { - return RPC::makeError(RpcInternal, "Exception occurred during transaction submission."); + return rpc::makeError(RpcInternal, "Exception occurred during transaction submission."); } return transactionFormatResultImpl(txn.second, apiVersion); @@ -1084,21 +1084,21 @@ static json::Value checkMultiSignFields(json::Value const& jvRequest) { if (!jvRequest.isMember(jss::tx_json)) - return RPC::missingFieldError(jss::tx_json); + return rpc::missingFieldError(jss::tx_json); json::Value const& txJson(jvRequest[jss::tx_json]); if (!txJson.isObject()) - return RPC::invalidFieldMessage(jss::tx_json); + return rpc::invalidFieldMessage(jss::tx_json); // There are a couple of additional fields we need to check before // we serialize. If we serialize first then we generate less useful // error messages. if (!txJson.isMember(jss::Sequence)) - return RPC::missingFieldError("tx_json.Sequence"); + return rpc::missingFieldError("tx_json.Sequence"); if (!txJson.isMember(sfSigningPubKey.getJsonName())) - return RPC::missingFieldError("tx_json.SigningPubKey"); + return rpc::missingFieldError("tx_json.SigningPubKey"); // Multi-signing into a signature_target object field is fine, // because it means the signature is not for the transaction @@ -1106,7 +1106,7 @@ checkMultiSignFields(json::Value const& jvRequest) if (!jvRequest.isMember(jss::signature_target) && !txJson[sfSigningPubKey.getJsonName()].asString().empty()) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "When multi-signing 'tx_json.SigningPubKey' must be empty."); } @@ -1120,7 +1120,7 @@ static json::Value sortAndValidateSigners(STArray& signers, AccountID const& signingForID) { if (signers.empty()) - return RPC::makeParamError("Signers array may not be empty."); + return rpc::makeParamError("Signers array may not be empty."); // Signers must be sorted by Account. std::ranges::sort(signers, [](STObject const& a, STObject const& b) { @@ -1137,7 +1137,7 @@ sortAndValidateSigners(STArray& signers, AccountID const& signingForID) std::ostringstream err; err << "Duplicate Signers:Signer:Account entries (" << toBase58((*dupIter)[sfAccount]) << ") are not allowed."; - return RPC::makeParamError(err.str()); + return rpc::makeParamError(err.str()); } // An account may not sign for itself. @@ -1147,7 +1147,7 @@ sortAndValidateSigners(STArray& signers, AccountID const& signingForID) { std::ostringstream err; err << "A Signer may not be the transaction's Account (" << toBase58(signingForID) << ")."; - return RPC::makeParamError(err.str()); + return rpc::makeParamError(err.str()); } return {}; } @@ -1174,23 +1174,23 @@ transactionSignFor( char const accountField[] = "account"; if (!jvRequest.isMember(accountField)) - return RPC::missingFieldError(accountField); + return rpc::missingFieldError(accountField); // Turn the signer's account into an AccountID for multi-sign. auto const signerAccountID = parseBase58(jvRequest[accountField].asString()); if (!signerAccountID) { - return RPC::makeError(RpcSrcActMalformed, RPC::invalidFieldMessage(accountField)); + return rpc::makeError(RpcSrcActMalformed, rpc::invalidFieldMessage(accountField)); } if (!jvRequest.isMember(jss::tx_json)) - return RPC::missingFieldError(jss::tx_json); + return rpc::missingFieldError(jss::tx_json); { json::Value& txJson(jvRequest[jss::tx_json]); if (!txJson.isObject()) - return RPC::objectFieldError(jss::tx_json); + return rpc::objectFieldError(jss::tx_json); if (auto checkResult = detail::checkNetworkID(txJson, app.getNetworkIDService().getNetworkID()); @@ -1211,7 +1211,7 @@ transactionSignFor( using namespace detail; { json::Value err = checkMultiSignFields(jvRequest); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -1225,7 +1225,7 @@ transactionSignFor( return preprocResult.first; XRPL_ASSERT( - signForParams.validMultiSign(), "xrpl::RPC::transactionSignFor : valid multi-signature"); + signForParams.validMultiSign(), "xrpl::rpc::transactionSignFor : valid multi-signature"); { SLE::const_pointer const accountState = ledger->read(keylet::account(*signerAccountID)); @@ -1263,7 +1263,7 @@ transactionSignFor( // For delegated transactions, the delegate account is // the one forbidden from appearing in its own Signers array. auto err = sortAndValidateSigners(signers, sttx->getInitiator()); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -1299,7 +1299,7 @@ transactionSubmitMultiSigned( using namespace detail; { json::Value err = checkMultiSignFields(jvRequest); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -1314,7 +1314,7 @@ transactionSubmitMultiSigned( app.getFeeTrack(), getAPIVersionNumber(jvRequest, app.config().betaRpcApi)); - if (RPC::containsError(txJsonResult)) + if (rpc::containsError(txJsonResult)) return std::move(txJsonResult); SLE::const_pointer const sle = ledger->read(keylet::account(srcAddressID)); @@ -1332,12 +1332,12 @@ transactionSubmitMultiSigned( json::Value err = checkFee(jvRequest, role, false, app.config(), app.getFeeTrack(), app.getTxQ(), app); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; err = checkPayment(jvRequest, txJson, srcAddressID, role, app, false); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; } @@ -1359,17 +1359,17 @@ transactionSubmitMultiSigned( } catch (STObject::FieldErr const& err) { - return RPC::makeError(RpcInvalidParams, err.what()); + return rpc::makeError(RpcInvalidParams, err.what()); } catch (std::exception& ex) { std::string const reason(ex.what()); - return RPC::makeError( + return rpc::makeError( RpcInternal, "Exception while serializing transaction: " + reason); } std::string reason; if (!passesLocalChecks(*stTx, reason)) - return RPC::makeError(RpcInvalidParams, reason); + return rpc::makeError(RpcInvalidParams, reason); } // Validate the fields in the serialized transaction. @@ -1383,7 +1383,7 @@ transactionSubmitMultiSigned( std::ostringstream err; err << "Invalid " << sfSigningPubKey.fieldName << " field. Field must be empty when multi-signing."; - return RPC::makeError(RpcInvalidParams, err.str()); + return rpc::makeError(RpcInvalidParams, err.str()); } // There may not be a TxnSignature field. @@ -1397,26 +1397,26 @@ transactionSubmitMultiSigned( { std::ostringstream err; err << "Invalid " << sfFee.fieldName << " field. Fees must be specified in XRP."; - return RPC::makeError(RpcInvalidParams, err.str()); + return rpc::makeError(RpcInvalidParams, err.str()); } if (fee <= STAmount{0}) { std::ostringstream err; err << "Invalid " << sfFee.fieldName << " field. Fees must be greater than zero."; - return RPC::makeError(RpcInvalidParams, err.str()); + return rpc::makeError(RpcInvalidParams, err.str()); } } // Verify that the Signers field is present. if (!stTx->isFieldPresent(sfSigners)) - return RPC::missingFieldError("tx_json.Signers"); + return rpc::missingFieldError("tx_json.Signers"); // If the Signers field is present the SField guarantees it to be an array. // Get a reference to the Signers array so we can verify and sort it. auto& signers = stTx->peekFieldArray(sfSigners); if (signers.empty()) - return RPC::makeParamError("tx_json.Signers array may not be empty."); + return rpc::makeParamError("tx_json.Signers array may not be empty."); // The Signers array may only contain Signer objects. if (std::ranges::find_if_not(signers, [](STObject const& obj) { @@ -1427,14 +1427,14 @@ transactionSubmitMultiSigned( obj.isFieldPresent(sfTxnSignature) && obj.getCount() == 3); }) != signers.end()) { - return RPC::makeParamError("Signers array may only contain Signer entries."); + return rpc::makeParamError("Signers array may only contain Signer entries."); } // The array must be sorted and validated. // For delegated transactions, getInitiator() returns sfDelegate, // that account is the one forbidden from appearing in its own Signers array. auto err = sortAndValidateSigners(signers, stTx->getInitiator()); - if (RPC::containsError(err)) + if (rpc::containsError(err)) return err; // Make sure the SerializedTransaction makes a legitimate Transaction. @@ -1452,10 +1452,10 @@ transactionSubmitMultiSigned( } catch (std::exception&) { - return RPC::makeError(RpcInternal, "Exception occurred during transaction submission."); + return rpc::makeError(RpcInternal, "Exception occurred during transaction submission."); } return transactionFormatResultImpl(txn.second, apiVersion); } -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/detail/TransactionSign.h b/src/xrpld/rpc/detail/TransactionSign.h index dcb417dd16..9b07cbde20 100644 --- a/src/xrpld/rpc/detail/TransactionSign.h +++ b/src/xrpld/rpc/detail/TransactionSign.h @@ -20,7 +20,7 @@ class LoadFeeTrack; class Transaction; class TxQ; -namespace RPC { +namespace rpc { json::Value getCurrentNetworkFee( @@ -30,8 +30,8 @@ getCurrentNetworkFee( TxQ const& txQ, Application const& app, json::Value const& tx, - int mult = Tuning::kDefaultAutoFillFeeMultiplier, - int div = Tuning::kDefaultAutoFillFeeDivisor); + int mult = tuning::kDefaultAutoFillFeeMultiplier, + int div = tuning::kDefaultAutoFillFeeDivisor); /** * Fill in the fee on behalf of the client. @@ -140,5 +140,5 @@ transactionSubmitMultiSigned( Application& app, ProcessTransactionFn const& processTransaction); -} // namespace RPC +} // namespace rpc } // namespace xrpl diff --git a/src/xrpld/rpc/detail/Tuning.h b/src/xrpld/rpc/detail/Tuning.h index b904822698..5c47ab4365 100644 --- a/src/xrpld/rpc/detail/Tuning.h +++ b/src/xrpld/rpc/detail/Tuning.h @@ -6,7 +6,7 @@ * Tuned constants. */ /** @{ */ -namespace xrpl::RPC::Tuning { +namespace xrpl::rpc::tuning { /** * Represents RPC limit parameter values that have a min, default and max. @@ -98,5 +98,5 @@ static constexpr int kMaxSrcCur = 18; */ static constexpr int kMaxAutoSrcCur = 88; -} // namespace xrpl::RPC::Tuning +} // namespace xrpl::rpc::tuning /** @} */ diff --git a/src/xrpld/rpc/handlers/ChannelVerify.cpp b/src/xrpld/rpc/handlers/ChannelVerify.cpp index 64f616e829..ab54745a5d 100644 --- a/src/xrpld/rpc/handlers/ChannelVerify.cpp +++ b/src/xrpld/rpc/handlers/ChannelVerify.cpp @@ -27,13 +27,13 @@ namespace xrpl { // signature: signature to verify // } json::Value -doChannelVerify(RPC::JsonContext& context) +doChannelVerify(rpc::JsonContext& context) { auto const& params(context.params); for (auto const& p : {jss::public_key, jss::channel_id, jss::amount, jss::signature}) { if (!params.isMember(p)) - return RPC::missingFieldError(p); + return rpc::missingFieldError(p); } std::optional pk; diff --git a/src/xrpld/rpc/handlers/Handlers.h b/src/xrpld/rpc/handlers/Handlers.h index 7b347b2ecc..d192e8726c 100644 --- a/src/xrpld/rpc/handlers/Handlers.h +++ b/src/xrpld/rpc/handlers/Handlers.h @@ -7,147 +7,147 @@ namespace xrpl { json::Value -doAccountCurrencies(RPC::JsonContext&); +doAccountCurrencies(rpc::JsonContext&); json::Value -doAccountInfo(RPC::JsonContext&); +doAccountInfo(rpc::JsonContext&); json::Value -doAccountLines(RPC::JsonContext&); +doAccountLines(rpc::JsonContext&); json::Value -doAccountChannels(RPC::JsonContext&); +doAccountChannels(rpc::JsonContext&); json::Value -doAccountNFTs(RPC::JsonContext&); +doAccountNFTs(rpc::JsonContext&); json::Value -doAccountObjects(RPC::JsonContext&); +doAccountObjects(rpc::JsonContext&); json::Value -doAccountOffers(RPC::JsonContext&); +doAccountOffers(rpc::JsonContext&); json::Value -doAccountTx(RPC::JsonContext&); +doAccountTx(rpc::JsonContext&); json::Value -doAMMInfo(RPC::JsonContext&); +doAMMInfo(rpc::JsonContext&); json::Value -doBookOffers(RPC::JsonContext&); +doBookOffers(rpc::JsonContext&); json::Value -doBookChanges(RPC::JsonContext&); +doBookChanges(rpc::JsonContext&); json::Value -doBlackList(RPC::JsonContext&); +doBlackList(rpc::JsonContext&); json::Value -doCanDelete(RPC::JsonContext&); +doCanDelete(rpc::JsonContext&); json::Value -doChannelAuthorize(RPC::JsonContext&); +doChannelAuthorize(rpc::JsonContext&); json::Value -doChannelVerify(RPC::JsonContext&); +doChannelVerify(rpc::JsonContext&); json::Value -doConnect(RPC::JsonContext&); +doConnect(rpc::JsonContext&); json::Value -doConsensusInfo(RPC::JsonContext&); +doConsensusInfo(rpc::JsonContext&); json::Value -doDepositAuthorized(RPC::JsonContext&); +doDepositAuthorized(rpc::JsonContext&); json::Value -doFeature(RPC::JsonContext&); +doFeature(rpc::JsonContext&); json::Value -doFee(RPC::JsonContext&); +doFee(rpc::JsonContext&); json::Value -doFetchInfo(RPC::JsonContext&); +doFetchInfo(rpc::JsonContext&); json::Value -doGatewayBalances(RPC::JsonContext&); +doGatewayBalances(rpc::JsonContext&); json::Value -doGetCounts(RPC::JsonContext&); +doGetCounts(rpc::JsonContext&); json::Value -doGetAggregatePrice(RPC::JsonContext&); +doGetAggregatePrice(rpc::JsonContext&); json::Value -doLedgerAccept(RPC::JsonContext&); +doLedgerAccept(rpc::JsonContext&); json::Value -doLedgerCleaner(RPC::JsonContext&); +doLedgerCleaner(rpc::JsonContext&); json::Value -doLedgerClosed(RPC::JsonContext&); +doLedgerClosed(rpc::JsonContext&); json::Value -doLedgerCurrent(RPC::JsonContext&); +doLedgerCurrent(rpc::JsonContext&); json::Value -doLedgerData(RPC::JsonContext&); +doLedgerData(rpc::JsonContext&); json::Value -doLedgerEntry(RPC::JsonContext&); +doLedgerEntry(rpc::JsonContext&); json::Value -doLedgerHeader(RPC::JsonContext&); +doLedgerHeader(rpc::JsonContext&); json::Value -doLedgerRequest(RPC::JsonContext&); +doLedgerRequest(rpc::JsonContext&); json::Value -doLogLevel(RPC::JsonContext&); +doLogLevel(rpc::JsonContext&); json::Value -doLogRotate(RPC::JsonContext&); +doLogRotate(rpc::JsonContext&); json::Value -doManifest(RPC::JsonContext&); +doManifest(rpc::JsonContext&); json::Value -doNFTBuyOffers(RPC::JsonContext&); +doNFTBuyOffers(rpc::JsonContext&); json::Value -doNFTSellOffers(RPC::JsonContext&); +doNFTSellOffers(rpc::JsonContext&); json::Value -doNoRippleCheck(RPC::JsonContext&); +doNoRippleCheck(rpc::JsonContext&); json::Value -doOwnerInfo(RPC::JsonContext&); +doOwnerInfo(rpc::JsonContext&); json::Value -doPathFind(RPC::JsonContext&); +doPathFind(rpc::JsonContext&); json::Value -doPause(RPC::JsonContext&); +doPause(rpc::JsonContext&); json::Value -doPeers(RPC::JsonContext&); +doPeers(rpc::JsonContext&); json::Value -doPing(RPC::JsonContext&); +doPing(rpc::JsonContext&); json::Value -doPrint(RPC::JsonContext&); +doPrint(rpc::JsonContext&); json::Value -doRandom(RPC::JsonContext&); +doRandom(rpc::JsonContext&); json::Value -doResume(RPC::JsonContext&); +doResume(rpc::JsonContext&); json::Value -doPeerReservationsAdd(RPC::JsonContext&); +doPeerReservationsAdd(rpc::JsonContext&); json::Value -doPeerReservationsDel(RPC::JsonContext&); +doPeerReservationsDel(rpc::JsonContext&); json::Value -doPeerReservationsList(RPC::JsonContext&); +doPeerReservationsList(rpc::JsonContext&); json::Value -doRipplePathFind(RPC::JsonContext&); +doRipplePathFind(rpc::JsonContext&); json::Value -doServerDefinitions(RPC::JsonContext&); +doServerDefinitions(rpc::JsonContext&); json::Value -doServerInfo(RPC::JsonContext&); // for humans +doServerInfo(rpc::JsonContext&); // for humans json::Value -doServerState(RPC::JsonContext&); // for machines +doServerState(rpc::JsonContext&); // for machines json::Value -doSign(RPC::JsonContext&); +doSign(rpc::JsonContext&); json::Value -doSignFor(RPC::JsonContext&); +doSignFor(rpc::JsonContext&); json::Value -doSimulate(RPC::JsonContext&); +doSimulate(rpc::JsonContext&); json::Value -doStop(RPC::JsonContext&); +doStop(rpc::JsonContext&); json::Value -doSubmit(RPC::JsonContext&); +doSubmit(rpc::JsonContext&); json::Value -doSubmitMultiSigned(RPC::JsonContext&); +doSubmitMultiSigned(rpc::JsonContext&); json::Value -doSubscribe(RPC::JsonContext&); +doSubscribe(rpc::JsonContext&); json::Value -doTransactionEntry(RPC::JsonContext&); +doTransactionEntry(rpc::JsonContext&); json::Value -doTxJson(RPC::JsonContext&); +doTxJson(rpc::JsonContext&); json::Value -doTxHistory(RPC::JsonContext&); +doTxHistory(rpc::JsonContext&); json::Value -doTxReduceRelay(RPC::JsonContext&); +doTxReduceRelay(rpc::JsonContext&); json::Value -doUnlList(RPC::JsonContext&); +doUnlList(rpc::JsonContext&); json::Value -doUnsubscribe(RPC::JsonContext&); +doUnsubscribe(rpc::JsonContext&); json::Value -doValidationCreate(RPC::JsonContext&); +doValidationCreate(rpc::JsonContext&); json::Value -doWalletPropose(RPC::JsonContext&); +doWalletPropose(rpc::JsonContext&); json::Value -doValidators(RPC::JsonContext&); +doValidators(rpc::JsonContext&); json::Value -doValidatorListSites(RPC::JsonContext&); +doValidatorListSites(rpc::JsonContext&); json::Value -doValidatorInfo(RPC::JsonContext&); +doValidatorInfo(rpc::JsonContext&); json::Value -doVaultInfo(RPC::JsonContext&); +doVaultInfo(rpc::JsonContext&); } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/VaultInfo.cpp b/src/xrpld/rpc/handlers/VaultInfo.cpp index b6d2fe259f..034cd8383f 100644 --- a/src/xrpld/rpc/handlers/VaultInfo.cpp +++ b/src/xrpld/rpc/handlers/VaultInfo.cpp @@ -27,7 +27,7 @@ parseVault(json::Value const& params, json::Value& jvResult) { if (!uNodeIndex.parseHex(params[jss::vault_id].asString())) { - RPC::injectError(RpcInvalidParams, jvResult); + rpc::injectError(RpcInvalidParams, jvResult); return std::nullopt; } // else uNodeIndex holds the value we need @@ -37,14 +37,14 @@ parseVault(json::Value const& params, json::Value& jvResult) auto const id = parseBase58(params[jss::owner].asString()); if (!id) { - RPC::injectError(RpcActMalformed, jvResult); + rpc::injectError(RpcActMalformed, jvResult); return std::nullopt; } if (!(params[jss::seq].isInt() || params[jss::seq].isUInt()) || params[jss::seq].asDouble() <= 0.0 || params[jss::seq].asDouble() > double(json::Value::kMaxUInt)) { - RPC::injectError(RpcInvalidParams, jvResult); + rpc::injectError(RpcInvalidParams, jvResult); return std::nullopt; } @@ -53,7 +53,7 @@ parseVault(json::Value const& params, json::Value& jvResult) else { // Invalid combination of fields vault_id/owner/seq - RPC::injectError(RpcInvalidParams, jvResult); + rpc::injectError(RpcInvalidParams, jvResult); return std::nullopt; } @@ -61,10 +61,10 @@ parseVault(json::Value const& params, json::Value& jvResult) } json::Value -doVaultInfo(RPC::JsonContext& context) +doVaultInfo(rpc::JsonContext& context) { std::shared_ptr lpLedger; - auto jvResult = RPC::lookupLedger(lpLedger, context); + auto jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; diff --git a/src/xrpld/rpc/handlers/account/AccountChannels.cpp b/src/xrpld/rpc/handlers/account/AccountChannels.cpp index 8a5c7dc6e3..d50bf1cf07 100644 --- a/src/xrpld/rpc/handlers/account/AccountChannels.cpp +++ b/src/xrpld/rpc/handlers/account/AccountChannels.cpp @@ -69,17 +69,17 @@ addChannel(json::Value& jsonLines, SLE const& line) // marker: opaque // optional, resume previous query // } json::Value -doAccountChannels(RPC::JsonContext& context) +doAccountChannels(rpc::JsonContext& context) { auto const& params(context.params); if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -97,7 +97,7 @@ doAccountChannels(RPC::JsonContext& context) if (params.isMember(jss::destination_account)) { if (!params[jss::destination_account].isString()) - return RPC::invalidFieldError(jss::destination_account); + return rpc::invalidFieldError(jss::destination_account); strDst = params[jss::destination_account].asString(); } @@ -108,7 +108,7 @@ doAccountChannels(RPC::JsonContext& context) return rpcError(RpcActMalformed); unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kAccountChannels, context)) + if (auto err = readLimitField(limit, rpc::tuning::kAccountChannels, context)) return *err; json::Value jsonChannels{json::ValueType::Array}; @@ -126,7 +126,7 @@ doAccountChannels(RPC::JsonContext& context) if (params.isMember(jss::marker)) { if (!params[jss::marker].isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); // Marker is composed of a comma separated index and start hint. The // former will be read as hex, and the latter using boost lexical cast. @@ -157,7 +157,7 @@ doAccountChannels(RPC::JsonContext& context) if (!sle) return rpcError(RpcInvalidParams); - if (!RPC::isRelatedToAccount(*ledger, sle, accountID)) + if (!rpc::isRelatedToAccount(*ledger, sle, accountID)) return rpcError(RpcInvalidParams); } @@ -182,7 +182,7 @@ doAccountChannels(RPC::JsonContext& context) if (++count == limit) { marker = sleCur->key(); - nextHint = RPC::getStartHint(sleCur, visitData.accountID); + nextHint = rpc::getStartHint(sleCur, visitData.accountID); } if (count <= limit && sleCur->getType() == ltPAYCHAN && @@ -213,7 +213,7 @@ doAccountChannels(RPC::JsonContext& context) for (auto const& item : visitData.items) addChannel(jsonChannels, *item); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; result[jss::channels] = std::move(jsonChannels); return result; } diff --git a/src/xrpld/rpc/handlers/account/AccountCurrencies.cpp b/src/xrpld/rpc/handlers/account/AccountCurrencies.cpp index 058c10e224..d9cd41cbbc 100644 --- a/src/xrpld/rpc/handlers/account/AccountCurrencies.cpp +++ b/src/xrpld/rpc/handlers/account/AccountCurrencies.cpp @@ -19,30 +19,30 @@ namespace xrpl { json::Value -doAccountCurrencies(RPC::JsonContext& context) +doAccountCurrencies(rpc::JsonContext& context) { auto& params = context.params; if (!(params.isMember(jss::account) || params.isMember(jss::ident))) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); std::string strIdent; if (params.isMember(jss::account)) { if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); strIdent = params[jss::account].asString(); } else if (params.isMember(jss::ident)) { if (!params[jss::ident].isString()) - return RPC::invalidFieldError(jss::ident); + return rpc::invalidFieldError(jss::ident); strIdent = params[jss::ident].asString(); } // Get the current ledger std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -50,7 +50,7 @@ doAccountCurrencies(RPC::JsonContext& context) auto id = parseBase58(strIdent); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; diff --git a/src/xrpld/rpc/handlers/account/AccountInfo.cpp b/src/xrpld/rpc/handlers/account/AccountInfo.cpp index 3a96593452..c618ad3b3a 100644 --- a/src/xrpld/rpc/handlers/account/AccountInfo.cpp +++ b/src/xrpld/rpc/handlers/account/AccountInfo.cpp @@ -84,7 +84,7 @@ injectSLE(json::Value& jv, SLE const& sle) // TODO(tom): what is that "default"? json::Value -doAccountInfo(RPC::JsonContext& context) +doAccountInfo(rpc::JsonContext& context) { auto& params = context.params; @@ -92,22 +92,22 @@ doAccountInfo(RPC::JsonContext& context) if (params.isMember(jss::account)) { if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); strIdent = params[jss::account].asString(); } else if (params.isMember(jss::ident)) { if (!params[jss::ident].isString()) - return RPC::invalidFieldError(jss::ident); + return rpc::invalidFieldError(jss::ident); strIdent = params[jss::ident].asString(); } else { - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); } std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -116,7 +116,7 @@ doAccountInfo(RPC::JsonContext& context) auto id = parseBase58(strIdent); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; @@ -154,7 +154,7 @@ doAccountInfo(RPC::JsonContext& context) { // It doesn't make sense to request the queue // with any closed or validated ledger. - RPC::injectError(RpcInvalidParams, result); + rpc::injectError(RpcInvalidParams, result); return result; } @@ -206,7 +206,7 @@ doAccountInfo(RPC::JsonContext& context) if (context.apiVersion > 1u && params.isMember(jss::signer_lists) && !params[jss::signer_lists].isBool()) { - RPC::injectError(RpcInvalidParams, result); + rpc::injectError(RpcInvalidParams, result); return result; } @@ -331,7 +331,7 @@ doAccountInfo(RPC::JsonContext& context) else { result[jss::account] = toBase58(accountID); - RPC::injectError(RpcActNotFound, result); + rpc::injectError(RpcActNotFound, result); } return result; diff --git a/src/xrpld/rpc/handlers/account/AccountLines.cpp b/src/xrpld/rpc/handlers/account/AccountLines.cpp index e69f70ca5a..f134c8af92 100644 --- a/src/xrpld/rpc/handlers/account/AccountLines.cpp +++ b/src/xrpld/rpc/handlers/account/AccountLines.cpp @@ -82,24 +82,24 @@ addLine(json::Value& jsonLines, RPCTrustLine const& line) // this account's side) // } json::Value -doAccountLines(RPC::JsonContext& context) +doAccountLines(rpc::JsonContext& context) { auto const& params(context.params); if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; auto id = parseBase58(params[jss::account].asString()); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; @@ -116,12 +116,12 @@ doAccountLines(RPC::JsonContext& context) }(); if (!strPeer.empty() && !raPeerAccount) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kAccountLines, context)) + if (auto err = readLimitField(limit, rpc::tuning::kAccountLines, context)) return *err; // this flag allows the requester to ask incoming trustlines in default @@ -150,7 +150,7 @@ doAccountLines(RPC::JsonContext& context) if (params.isMember(jss::marker)) { if (!params[jss::marker].isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); // Marker is composed of a comma separated index and start hint. The // former will be read as hex, and the latter using boost lexical cast. @@ -181,7 +181,7 @@ doAccountLines(RPC::JsonContext& context) if (!sle) return rpcError(RpcInvalidParams); - if (!RPC::isRelatedToAccount(*ledger, sle, accountID)) + if (!rpc::isRelatedToAccount(*ledger, sle, accountID)) return rpcError(RpcInvalidParams); } @@ -207,7 +207,7 @@ doAccountLines(RPC::JsonContext& context) if (++count == limit) { marker = sleCur->key(); - nextHint = RPC::getStartHint(sleCur, visitData.accountID); + nextHint = rpc::getStartHint(sleCur, visitData.accountID); } if (sleCur->getType() != ltRIPPLE_STATE) @@ -259,7 +259,7 @@ doAccountLines(RPC::JsonContext& context) for (auto const& item : visitData.items) addLine(jsonLines, item); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return result; } diff --git a/src/xrpld/rpc/handlers/account/AccountNFTs.cpp b/src/xrpld/rpc/handlers/account/AccountNFTs.cpp index ea9bec0f45..580b93caa3 100644 --- a/src/xrpld/rpc/handlers/account/AccountNFTs.cpp +++ b/src/xrpld/rpc/handlers/account/AccountNFTs.cpp @@ -35,14 +35,14 @@ namespace xrpl { * } */ json::Value -doAccountNFTs(RPC::JsonContext& context) +doAccountNFTs(rpc::JsonContext& context) { auto const& params = context.params; if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); auto id = parseBase58(params[jss::account].asString()); if (!id) @@ -51,7 +51,7 @@ doAccountNFTs(RPC::JsonContext& context) } std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (ledger == nullptr) return result; auto const accountID{id.value()}; @@ -60,7 +60,7 @@ doAccountNFTs(RPC::JsonContext& context) return rpcError(RpcActNotFound); unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kAccountNfTokens, context)) + if (auto err = readLimitField(limit, rpc::tuning::kAccountNfTokens, context)) return *err; uint256 marker; @@ -70,10 +70,10 @@ doAccountNFTs(RPC::JsonContext& context) { auto const& m = params[jss::marker]; if (!m.isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); if (!marker.parseHex(m.asString())) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); } auto const first = keylet::nftokenPage(keylet::nftokenPageMin(accountID), marker); @@ -125,7 +125,7 @@ doAccountNFTs(RPC::JsonContext& context) } if (markerSet && !markerFound) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); pastMarker = true; @@ -160,10 +160,10 @@ doAccountNFTs(RPC::JsonContext& context) } if (markerSet && !markerFound) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); result[jss::account] = toBase58(accountID); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return result; } diff --git a/src/xrpld/rpc/handlers/account/AccountObjects.cpp b/src/xrpld/rpc/handlers/account/AccountObjects.cpp index ee2595bf94..e855ed65e6 100644 --- a/src/xrpld/rpc/handlers/account/AccountObjects.cpp +++ b/src/xrpld/rpc/handlers/account/AccountObjects.cpp @@ -265,24 +265,24 @@ getAccountObjects( } json::Value -doAccountObjects(RPC::JsonContext& context) +doAccountObjects(rpc::JsonContext& context) { auto const& params = context.params; if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (ledger == nullptr) return result; auto const id = parseBase58(params[jss::account].asString()); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; @@ -331,10 +331,10 @@ doAccountObjects(RPC::JsonContext& context) } else { - auto [rpcStatus, type] = RPC::chooseLedgerEntryType(params); + auto [rpcStatus, type] = rpc::chooseLedgerEntryType(params); - if (!RPC::isAccountObjectsValidType(type)) - return RPC::invalidFieldError(jss::type); + if (!rpc::isAccountObjectsValidType(type)) + return rpc::invalidFieldError(jss::type); if (rpcStatus) { @@ -349,7 +349,7 @@ doAccountObjects(RPC::JsonContext& context) } unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kAccountObjects, context)) + if (auto err = readLimitField(limit, rpc::tuning::kAccountObjects, context)) return *err; uint256 dirIndex; @@ -358,18 +358,18 @@ doAccountObjects(RPC::JsonContext& context) { auto const& marker = params[jss::marker]; if (!marker.isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); auto const& markerStr = marker.asString(); auto const& idx = markerStr.find(','); if (idx == std::string::npos) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); if (!dirIndex.parseHex(markerStr.substr(0, idx))) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); if (!entryIndex.parseHex(markerStr.substr(idx + 1))) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); } std::optional sponsoredFilter; @@ -377,17 +377,17 @@ doAccountObjects(RPC::JsonContext& context) { auto const& sponsoredJv = params[jss::sponsored]; if (!sponsoredJv.isBool()) - return RPC::expectedFieldError(jss::sponsored, "boolean"); + return rpc::expectedFieldError(jss::sponsored, "boolean"); sponsoredFilter = sponsoredJv.asBool(); } if (!getAccountObjects( *ledger, accountID, typeFilter, dirIndex, entryIndex, limit, sponsoredFilter, result)) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); result[jss::account] = toBase58(accountID); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return result; } diff --git a/src/xrpld/rpc/handlers/account/AccountOffers.cpp b/src/xrpld/rpc/handlers/account/AccountOffers.cpp index 4829ff56b1..1467b14b48 100644 --- a/src/xrpld/rpc/handlers/account/AccountOffers.cpp +++ b/src/xrpld/rpc/handlers/account/AccountOffers.cpp @@ -54,24 +54,24 @@ appendOfferJson(SLE::const_ref offer, json::Value& offers) // marker: opaque // optional, resume previous query // } json::Value -doAccountOffers(RPC::JsonContext& context) +doAccountOffers(rpc::JsonContext& context) { auto const& params(context.params); if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; auto id = parseBase58(params[jss::account].asString()); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; @@ -83,7 +83,7 @@ doAccountOffers(RPC::JsonContext& context) return rpcError(RpcActNotFound); unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kAccountOffers, context)) + if (auto err = readLimitField(limit, rpc::tuning::kAccountOffers, context)) return *err; json::Value& jsonOffers(result[jss::offers] = json::ValueType::Array); @@ -94,20 +94,20 @@ doAccountOffers(RPC::JsonContext& context) if (params.isMember(jss::marker)) { if (!params[jss::marker].isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); // Marker is composed of a comma separated index and start hint. The // former will be read as hex, and the latter using boost lexical cast. std::stringstream marker(params[jss::marker].asString()); std::string value; if (!std::getline(marker, value, ',')) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); if (!startAfter.parseHex(value)) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); if (!std::getline(marker, value, ',')) - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); try { @@ -115,7 +115,7 @@ doAccountOffers(RPC::JsonContext& context) } catch (boost::bad_lexical_cast&) { - return RPC::invalidFieldError(jss::marker); + return rpc::invalidFieldError(jss::marker); } // We then must check if the object pointed to by the marker is actually @@ -125,7 +125,7 @@ doAccountOffers(RPC::JsonContext& context) if (!sle) return rpcError(RpcInvalidParams); - if (!RPC::isRelatedToAccount(*ledger, sle, accountID)) + if (!rpc::isRelatedToAccount(*ledger, sle, accountID)) return rpcError(RpcInvalidParams); } @@ -150,7 +150,7 @@ doAccountOffers(RPC::JsonContext& context) if (++count == limit) { marker = sle->key(); - nextHint = RPC::getStartHint(sle, accountID); + nextHint = rpc::getStartHint(sle, accountID); } if (count <= limit && sle->getType() == ltOFFER) @@ -176,7 +176,7 @@ doAccountOffers(RPC::JsonContext& context) for (auto const& offer : offers) appendOfferJson(offer, jsonOffers); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return result; } diff --git a/src/xrpld/rpc/handlers/account/AccountTx.cpp b/src/xrpld/rpc/handlers/account/AccountTx.cpp index c43f560861..7b0c34e048 100644 --- a/src/xrpld/rpc/handlers/account/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/account/AccountTx.cpp @@ -43,11 +43,11 @@ static std::expected parseDelegateFilter(json::Value const& delegateNode) { if (!delegateNode.isObject()) - return std::unexpected(RPC::invalidFieldError(jss::delegate)); + return std::unexpected(rpc::invalidFieldError(jss::delegate)); if (!delegateNode.isMember(jss::delegate_filter) || !delegateNode[jss::delegate_filter].isString()) - return std::unexpected(RPC::invalidFieldError(jss::delegate_filter)); + return std::unexpected(rpc::invalidFieldError(jss::delegate_filter)); auto const& delegateFilterStr = delegateNode[jss::delegate_filter].asString(); @@ -58,7 +58,7 @@ parseDelegateFilter(json::Value const& delegateNode) if (delegateFilterStr == "authorizer") return DelegateType::Authorizer; - return std::unexpected(RPC::invalidFieldError(jss::delegate_filter)); + return std::unexpected(rpc::invalidFieldError(jss::delegate_filter)); }(); if (!typeResult) @@ -70,7 +70,7 @@ parseDelegateFilter(json::Value const& delegateNode) if (delegateNode.isMember(jss::counter_party)) { if (!delegateNode[jss::counter_party].isString()) - return std::unexpected(RPC::invalidFieldError(jss::counter_party)); + return std::unexpected(rpc::invalidFieldError(jss::counter_party)); counterparty = parseBase58(delegateNode[jss::counter_party].asString()); @@ -90,7 +90,7 @@ using LedgerSpecifier = RelationalDatabase::LedgerSpecifier; // parses args into a ledger specifier, or returns a Json object on error std::variant, json::Value> -parseLedgerArgs(RPC::Context& context, json::Value const& params) +parseLedgerArgs(rpc::Context& context, json::Value const& params) { json::Value response; // if ledger_index_min or max is specified, then ledger_hash or ledger_index @@ -100,7 +100,7 @@ parseLedgerArgs(RPC::Context& context, json::Value const& params) if ((params.isMember(jss::ledger_index_min) || params.isMember(jss::ledger_index_max)) && (params.isMember(jss::ledger_hash) || params.isMember(jss::ledger_index))) { - RPC::Status const status{RpcInvalidParams, "invalidParams"}; + rpc::Status const status{RpcInvalidParams, "invalidParams"}; status.inject(response); return response; } @@ -123,7 +123,7 @@ parseLedgerArgs(RPC::Context& context, json::Value const& params) auto& hashValue = params[jss::ledger_hash]; if (!hashValue.isString()) { - RPC::Status const status{RpcInvalidParams, "ledgerHashNotString"}; + rpc::Status const status{RpcInvalidParams, "ledgerHashNotString"}; status.inject(response); return response; } @@ -131,7 +131,7 @@ parseLedgerArgs(RPC::Context& context, json::Value const& params) LedgerHash hash; if (!hash.parseHex(hashValue.asString())) { - RPC::Status const status{RpcInvalidParams, "ledgerHashMalformed"}; + rpc::Status const status{RpcInvalidParams, "ledgerHashMalformed"}; status.inject(response); return response; } @@ -162,7 +162,7 @@ parseLedgerArgs(RPC::Context& context, json::Value const& params) } else { - RPC::Status const status{RpcInvalidParams, "ledger_index string malformed"}; + rpc::Status const status{RpcInvalidParams, "ledger_index string malformed"}; status.inject(response); return response; } @@ -172,8 +172,8 @@ parseLedgerArgs(RPC::Context& context, json::Value const& params) return std::optional{}; } -std::variant -getLedgerRange(RPC::Context& context, std::optional const& ledgerSpecifier) +std::variant +getLedgerRange(rpc::Context& context, std::optional const& ledgerSpecifier) { std::uint32_t uValidatedMin = 0; std::uint32_t uValidatedMax = 0; @@ -193,7 +193,7 @@ getLedgerRange(RPC::Context& context, std::optional const& ledg if (ledgerSpecifier) { auto status = std::visit( - [&](auto const& ls) -> RPC::Status { + [&](auto const& ls) -> rpc::Status { using T = std::decay_t; if constexpr (std::is_same_v) { @@ -241,7 +241,7 @@ getLedgerRange(RPC::Context& context, std::optional const& ledg } uLedgerMin = uLedgerMax = ledgerView->header().seq; } - return RPC::Status::kOK; + return rpc::Status::kOK; }, *ledgerSpecifier); @@ -251,15 +251,15 @@ getLedgerRange(RPC::Context& context, std::optional const& ledg return LedgerRange{.min = uLedgerMin, .max = uLedgerMax}; } -std::pair -doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args) +std::pair +doAccountTxHelp(rpc::Context& context, AccountTxArgs const& args) { - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; AccountTxResult result; auto lgrRange = getLedgerRange(context, args.ledger); - if (auto stat = std::get_if(&lgrRange)) + if (auto stat = std::get_if(&lgrRange)) { // An error occurred getting the requested ledger range return {result, *stat}; @@ -318,12 +318,12 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args) json::Value populateJsonResponse( - std::pair const& res, + std::pair const& res, AccountTxArgs const& args, - RPC::JsonContext const& context) + rpc::JsonContext const& context) { json::Value response; - RPC::Status const& error = res.second; + rpc::Status const& error = res.second; if (error.toErrorCode() != RpcSuccess) { error.inject(response); @@ -374,13 +374,13 @@ populateJsonResponse( } auto const& sttx = txn->getSTransaction(); - RPC::insertDeliverMax(jvObj[jsonTx], sttx->getTxnType(), context.apiVersion); + rpc::insertDeliverMax(jvObj[jsonTx], sttx->getTxnType(), context.apiVersion); if (txnMeta) { jvObj[jss::meta] = txnMeta->getJson(JsonOptions::Values::IncludeDate); insertDeliveredAmount(jvObj[jss::meta], context, txn, *txnMeta); - RPC::insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); - RPC::insertMPTokenIssuanceID(jvObj[jss::meta], sttx, *txnMeta); + rpc::insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); + rpc::insertMPTokenIssuanceID(jvObj[jss::meta], sttx, *txnMeta); } else { @@ -445,7 +445,7 @@ populateJsonResponse( // delegate-filtered query is only valid for a follow-up request that repeats // the same `delegate` object json::Value -doAccountTx(RPC::JsonContext& context) +doAccountTx(rpc::JsonContext& context) { if (!context.app.config().useTxTables()) return rpcError(RpcNotEnabled); @@ -460,24 +460,24 @@ doAccountTx(RPC::JsonContext& context) // onwards only if (context.apiVersion > 1u && params.isMember(jss::binary) && !params[jss::binary].isBool()) { - return RPC::invalidFieldError(jss::binary); + return rpc::invalidFieldError(jss::binary); } if (context.apiVersion > 1u && params.isMember(jss::forward) && !params[jss::forward].isBool()) { - return RPC::invalidFieldError(jss::forward); + return rpc::invalidFieldError(jss::forward); } - if (auto const err = RPC::readLimitField(args.limit, RPC::Tuning::kAccountTx, context)) + if (auto const err = rpc::readLimitField(args.limit, rpc::tuning::kAccountTx, context)) return *err; args.binary = params.isMember(jss::binary) && params[jss::binary].asBool(); args.forward = params.isMember(jss::forward) && params[jss::forward].asBool(); if (!params.isMember(jss::account)) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); auto const account = parseBase58(params[jss::account].asString()); if (!account) @@ -500,7 +500,7 @@ doAccountTx(RPC::JsonContext& context) !token[jss::ledger].isConvertibleTo(json::ValueType::UInt) || !token[jss::seq].isConvertibleTo(json::ValueType::UInt)) { - RPC::Status const status{ + rpc::Status const status{ RpcInvalidParams, "invalid marker. Provide ledger index via ledger field, and " "transaction sequence number via seq field"}; @@ -534,7 +534,7 @@ doAccountTx(RPC::JsonContext& context) params[jss::marker][jss::delegate].asBool(); if (markerFromDelegate != args.delegate.has_value()) { - RPC::Status const status{ + rpc::Status const status{ RpcInvalidParams, "Do not mix delegate and non-delegate pagination markers in account_tx; " "repeat the same `delegate` object when using a delegate marker."}; diff --git a/src/xrpld/rpc/handlers/account/GatewayBalances.cpp b/src/xrpld/rpc/handlers/account/GatewayBalances.cpp index a6730c8e2b..ff19d1d1e5 100644 --- a/src/xrpld/rpc/handlers/account/GatewayBalances.cpp +++ b/src/xrpld/rpc/handlers/account/GatewayBalances.cpp @@ -49,19 +49,19 @@ namespace xrpl { // gateway_balances [] [ [ ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; if (!(params.isMember(jss::account) || params.isMember(jss::ident))) - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); std::string const strIdent( params.isMember(jss::account) ? params[jss::account].asString() @@ -72,13 +72,13 @@ doGatewayBalances(RPC::JsonContext& context) if (!id) return rpcError(RpcActMalformed); auto const accountID{id.value()}; - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; result[jss::account] = toBase58(accountID); if (context.apiVersion > 1u && !ledger->exists(keylet::account(accountID))) { - RPC::injectError(RpcActNotFound, result); + rpc::injectError(RpcActNotFound, result); return result; } @@ -126,11 +126,11 @@ doGatewayBalances(RPC::JsonContext& context) // not have currency issued by the account from the request. if (context.apiVersion < 2u) { - RPC::injectError(RpcInvalidHotwallet, result); + rpc::injectError(RpcInvalidHotwallet, result); } else { - RPC::injectError(RpcInvalidParams, result); + rpc::injectError(RpcInvalidParams, result); } return result; } diff --git a/src/xrpld/rpc/handlers/account/NoRippleCheck.cpp b/src/xrpld/rpc/handlers/account/NoRippleCheck.cpp index d8bb65aba9..4be6e6f1af 100644 --- a/src/xrpld/rpc/handlers/account/NoRippleCheck.cpp +++ b/src/xrpld/rpc/handlers/account/NoRippleCheck.cpp @@ -26,7 +26,7 @@ namespace xrpl { static void fillTransaction( - RPC::JsonContext& context, + rpc::JsonContext& context, json::Value& txArray, AccountID const& accountID, std::uint32_t& sequence, @@ -49,17 +49,17 @@ fillTransaction( // transactions: true // optional, recommend transactions // } json::Value -doNoRippleCheck(RPC::JsonContext& context) +doNoRippleCheck(rpc::JsonContext& context) { auto const& params(context.params); if (!params.isMember(jss::account)) - return RPC::missingFieldError("account"); + return rpc::missingFieldError("account"); if (!params.isMember("role")) - return RPC::missingFieldError("role"); + return rpc::missingFieldError("role"); if (!params[jss::account].isString()) - return RPC::invalidFieldError(jss::account); + return rpc::invalidFieldError(jss::account); bool roleGateway = false; { @@ -70,12 +70,12 @@ doNoRippleCheck(RPC::JsonContext& context) } else if (role != "user") { - return RPC::invalidFieldError("role"); + return rpc::invalidFieldError("role"); } } unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kNoRippleCheck, context)) + if (auto err = readLimitField(limit, rpc::tuning::kNoRippleCheck, context)) return *err; bool transactions = false; @@ -89,11 +89,11 @@ doNoRippleCheck(RPC::JsonContext& context) if (context.apiVersion > 1u && params.isMember(jss::transactions) && !params[jss::transactions].isBool()) { - return RPC::invalidFieldError(jss::transactions); + return rpc::invalidFieldError(jss::transactions); } std::shared_ptr ledger; - auto result = RPC::lookupLedger(ledger, context); + auto result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -104,7 +104,7 @@ doNoRippleCheck(RPC::JsonContext& context) auto id = parseBase58(params[jss::account].asString()); if (!id) { - RPC::injectError(RpcActMalformed, result); + rpc::injectError(RpcActMalformed, result); return result; } auto const accountID{id.value()}; diff --git a/src/xrpld/rpc/handlers/account/OwnerInfo.cpp b/src/xrpld/rpc/handlers/account/OwnerInfo.cpp index 7cfed3cf53..2f5f76c619 100644 --- a/src/xrpld/rpc/handlers/account/OwnerInfo.cpp +++ b/src/xrpld/rpc/handlers/account/OwnerInfo.cpp @@ -17,11 +17,11 @@ namespace xrpl { // 'ident' : , // } json::Value -doOwnerInfo(RPC::JsonContext& context) +doOwnerInfo(rpc::JsonContext& context) { if (!context.params.isMember(jss::account) && !context.params.isMember(jss::ident)) { - return RPC::missingFieldError(jss::account); + return rpc::missingFieldError(jss::account); } std::string const strIdent = context.params.isMember(jss::account) diff --git a/src/xrpld/rpc/handlers/admin/BlackList.cpp b/src/xrpld/rpc/handlers/admin/BlackList.cpp index 5065a41ec4..7a72651373 100644 --- a/src/xrpld/rpc/handlers/admin/BlackList.cpp +++ b/src/xrpld/rpc/handlers/admin/BlackList.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doBlackList(RPC::JsonContext& context) +doBlackList(rpc::JsonContext& context) { auto& rm = context.app.getResourceManager(); if (context.params.isMember(jss::threshold)) diff --git a/src/xrpld/rpc/handlers/admin/UnlList.cpp b/src/xrpld/rpc/handlers/admin/UnlList.cpp index c3835c7ae0..61b5e4c640 100644 --- a/src/xrpld/rpc/handlers/admin/UnlList.cpp +++ b/src/xrpld/rpc/handlers/admin/UnlList.cpp @@ -12,7 +12,7 @@ namespace xrpl { json::Value -doUnlList(RPC::JsonContext& context) +doUnlList(rpc::JsonContext& context) { json::Value obj(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/admin/data/CanDelete.cpp b/src/xrpld/rpc/handlers/admin/data/CanDelete.cpp index 9ec1157e66..91db16bb4f 100644 --- a/src/xrpld/rpc/handlers/admin/data/CanDelete.cpp +++ b/src/xrpld/rpc/handlers/admin/data/CanDelete.cpp @@ -19,10 +19,10 @@ namespace xrpl { // can_delete [||now|always|never] json::Value -doCanDelete(RPC::JsonContext& context) +doCanDelete(rpc::JsonContext& context) { if (!context.app.getSHAMapStore().advisoryDelete()) - return RPC::makeError(RpcNotEnabled); + return rpc::makeError(RpcNotEnabled); json::Value ret(json::ValueType::Object); @@ -56,20 +56,20 @@ doCanDelete(RPC::JsonContext& context) { canDeleteSeq = context.app.getSHAMapStore().getLastRotated(); if (canDeleteSeq == 0u) - return RPC::makeError(RpcNotReady); + return rpc::makeError(RpcNotReady); } else if (uint256 lh; lh.parseHex(canDeleteStr)) { auto ledger = context.ledgerMaster.getLedgerByHash(lh); if (!ledger) - return RPC::makeError(RpcLgrNotFound, "ledgerNotFound"); + return rpc::makeError(RpcLgrNotFound, "ledgerNotFound"); canDeleteSeq = ledger->header().seq; } else { - return RPC::makeError(RpcInvalidParams); + return rpc::makeError(RpcInvalidParams); } } diff --git a/src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp b/src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp index a62ca44cca..78a2fec410 100644 --- a/src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp +++ b/src/xrpld/rpc/handlers/admin/data/LedgerCleaner.cpp @@ -9,10 +9,10 @@ namespace xrpl { json::Value -doLedgerCleaner(RPC::JsonContext& context) +doLedgerCleaner(rpc::JsonContext& context) { context.app.getLedgerCleaner().clean(context.params); - return RPC::makeObjectValue("Cleaner configured"); + return rpc::makeObjectValue("Cleaner configured"); } } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp b/src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp index de1e4439cf..80a49aea3f 100644 --- a/src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp +++ b/src/xrpld/rpc/handlers/admin/data/LedgerRequest.cpp @@ -13,10 +13,10 @@ namespace xrpl { // ledger_index : // } json::Value -doLedgerRequest(RPC::JsonContext& context) +doLedgerRequest(rpc::JsonContext& context) { - context.loadType = Resource::kFeeHeavyBurdenRpc; - auto res = RPC::getOrAcquireLedger(context); + context.loadType = resource::kFeeHeavyBurdenRpc; + auto res = rpc::getOrAcquireLedger(context); if (!res.has_value()) return res.error(); diff --git a/src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp b/src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp index 0849bad944..5ff3e6727e 100644 --- a/src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp +++ b/src/xrpld/rpc/handlers/admin/keygen/ValidationCreate.cpp @@ -30,7 +30,7 @@ validationSeed(json::Value const& params) // This command requires Role::ADMIN access because it makes // no sense to ask an untrusted server for this. json::Value -doValidationCreate(RPC::JsonContext& context) +doValidationCreate(rpc::JsonContext& context) { json::Value obj(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp b/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp index 4b5f1821e3..62def76f9a 100644 --- a/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp +++ b/src/xrpld/rpc/handlers/admin/keygen/WalletPropose.cpp @@ -52,7 +52,7 @@ estimateEntropy(std::string const& input) // passphrase: // } json::Value -doWalletPropose(RPC::JsonContext& context) +doWalletPropose(rpc::JsonContext& context) { return walletPropose(context.params); } @@ -68,7 +68,7 @@ walletPropose(json::Value const& params) { if (!params[jss::key_type].isString()) { - return RPC::expectedFieldError(jss::key_type, "string"); + return rpc::expectedFieldError(jss::key_type, "string"); } keyType = keyTypeFromString(params[jss::key_type].asString()); @@ -83,11 +83,11 @@ walletPropose(json::Value const& params) { if (params.isMember(jss::passphrase)) { - seed = RPC::parseXrplLibSeed(params[jss::passphrase]); + seed = rpc::parseXrplLibSeed(params[jss::passphrase]); } else if (params.isMember(jss::seed)) { - seed = RPC::parseXrplLibSeed(params[jss::seed]); + seed = rpc::parseXrplLibSeed(params[jss::seed]); } if (seed) @@ -110,7 +110,7 @@ walletPropose(json::Value const& params) { json::Value err; - seed = RPC::getSeedFromRPC(params, err); + seed = rpc::getSeedFromRPC(params, err); if (!seed) return err; diff --git a/src/xrpld/rpc/handlers/admin/log/LogLevel.cpp b/src/xrpld/rpc/handlers/admin/log/LogLevel.cpp index 1ff5aa1a27..4aae350810 100644 --- a/src/xrpld/rpc/handlers/admin/log/LogLevel.cpp +++ b/src/xrpld/rpc/handlers/admin/log/LogLevel.cpp @@ -16,7 +16,7 @@ namespace xrpl { json::Value -doLogLevel(RPC::JsonContext& context) +doLogLevel(rpc::JsonContext& context) { // log_level if (not context.params.isMember(jss::severity)) diff --git a/src/xrpld/rpc/handlers/admin/log/LogRotate.cpp b/src/xrpld/rpc/handlers/admin/log/LogRotate.cpp index 5f5c3e64df..ca935540dc 100644 --- a/src/xrpld/rpc/handlers/admin/log/LogRotate.cpp +++ b/src/xrpld/rpc/handlers/admin/log/LogRotate.cpp @@ -9,10 +9,10 @@ namespace xrpl { json::Value -doLogRotate(RPC::JsonContext& context) +doLogRotate(rpc::JsonContext& context) { context.app.getPerfLog().rotate(); - return RPC::makeObjectValue(context.app.getLogs().rotate()); + return rpc::makeObjectValue(context.app.getLogs().rotate()); } } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/admin/peer/Connect.cpp b/src/xrpld/rpc/handlers/admin/peer/Connect.cpp index 568dcdaa26..b318af06f9 100644 --- a/src/xrpld/rpc/handlers/admin/peer/Connect.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/Connect.cpp @@ -21,15 +21,15 @@ namespace xrpl { // } // XXX Might allow domain for manual connections. json::Value -doConnect(RPC::JsonContext& context) +doConnect(rpc::JsonContext& context) { if (context.app.config().standalone()) { - return RPC::makeError(RpcNotSynced); + return rpc::makeError(RpcNotSynced); } if (!context.params.isMember(jss::ip)) - return RPC::missingFieldError(jss::ip); + return rpc::missingFieldError(jss::ip); if (context.params.isMember(jss::port) && !context.params[jss::port].isConvertibleTo(json::ValueType::Int)) @@ -49,12 +49,12 @@ doConnect(RPC::JsonContext& context) } auto const ipStr = context.params[jss::ip].asString(); - auto ip = beast::IP::Endpoint::fromString(ipStr); + auto ip = beast::ip::Endpoint::fromString(ipStr); if (!isUnspecified(ip)) context.app.getOverlay().connect(ip.atPort(iPort)); - return RPC::makeObjectValue( + return rpc::makeObjectValue( "attempting connection to IP:" + ipStr + " port: " + std::to_string(iPort)); } diff --git a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp index 23b0d094b4..579ad85f41 100644 --- a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsAdd.cpp @@ -15,12 +15,12 @@ namespace xrpl { json::Value -doPeerReservationsAdd(RPC::JsonContext& context) +doPeerReservationsAdd(rpc::JsonContext& context) { auto const& params = context.params; if (!params.isMember(jss::public_key)) - return RPC::missingFieldError(jss::public_key); + return rpc::missingFieldError(jss::public_key); // Returning JSON from every function ruins any attempt to encapsulate // the pattern of "get field F as type T, and diagnose an error if it is @@ -36,7 +36,7 @@ doPeerReservationsAdd(RPC::JsonContext& context) // essentially an optional (the "maybe monad" in Haskell) with a non-unit // type for the failure case to capture more information. if (!params[jss::public_key].isString()) - return RPC::expectedFieldError(jss::public_key, "a string"); + return rpc::expectedFieldError(jss::public_key, "a string"); // Same for the pattern of "if field F is present, make sure it has type T // and get it". @@ -44,7 +44,7 @@ doPeerReservationsAdd(RPC::JsonContext& context) if (params.isMember(jss::description)) { if (!params[jss::description].isString()) - return RPC::expectedFieldError(jss::description, "a string"); + return rpc::expectedFieldError(jss::description, "a string"); desc = params[jss::description].asString(); } diff --git a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp index c2a8319876..e5912a5eca 100644 --- a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsDel.cpp @@ -14,15 +14,15 @@ namespace xrpl { json::Value -doPeerReservationsDel(RPC::JsonContext& context) +doPeerReservationsDel(rpc::JsonContext& context) { auto const& params = context.params; // We repeat much of the parameter parsing from `doPeerReservationsAdd`. if (!params.isMember(jss::public_key)) - return RPC::missingFieldError(jss::public_key); + return rpc::missingFieldError(jss::public_key); if (!params[jss::public_key].isString()) - return RPC::expectedFieldError(jss::public_key, "a string"); + return rpc::expectedFieldError(jss::public_key, "a string"); std::optional optPk = parseBase58(TokenType::NodePublic, params[jss::public_key].asString()); diff --git a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp index e0204159fd..30e19a5c0b 100644 --- a/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/PeerReservationsList.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doPeerReservationsList(RPC::JsonContext& context) +doPeerReservationsList(rpc::JsonContext& context) { auto const& reservations = context.app.getPeerReservations().list(); // Enumerate the reservations in context.app.getPeerReservations() diff --git a/src/xrpld/rpc/handlers/admin/peer/Peers.cpp b/src/xrpld/rpc/handlers/admin/peer/Peers.cpp index ab14325f0e..99f069e27e 100644 --- a/src/xrpld/rpc/handlers/admin/peer/Peers.cpp +++ b/src/xrpld/rpc/handlers/admin/peer/Peers.cpp @@ -17,7 +17,7 @@ namespace xrpl { json::Value -doPeers(RPC::JsonContext& context) +doPeers(rpc::JsonContext& context) { json::Value jvResult(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp b/src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp index ce06a6e480..00a259bb52 100644 --- a/src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp +++ b/src/xrpld/rpc/handlers/admin/server_control/LedgerAccept.cpp @@ -12,7 +12,7 @@ namespace xrpl { json::Value -doLedgerAccept(RPC::JsonContext& context) +doLedgerAccept(rpc::JsonContext& context) { json::Value jvResult; diff --git a/src/xrpld/rpc/handlers/admin/server_control/Stop.cpp b/src/xrpld/rpc/handlers/admin/server_control/Stop.cpp index 3e86bd4632..949eccf1e1 100644 --- a/src/xrpld/rpc/handlers/admin/server_control/Stop.cpp +++ b/src/xrpld/rpc/handlers/admin/server_control/Stop.cpp @@ -6,15 +6,15 @@ namespace xrpl { -namespace RPC { +namespace rpc { struct JsonContext; -} // namespace RPC +} // namespace rpc json::Value -doStop(RPC::JsonContext& context) +doStop(rpc::JsonContext& context) { context.app.signalStop("RPC"); - return RPC::makeObjectValue(systemName() + " server stopping"); + return rpc::makeObjectValue(systemName() + " server stopping"); } } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp b/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp index be3ce13d45..d97ce9dac4 100644 --- a/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp +++ b/src/xrpld/rpc/handlers/admin/signing/ChannelAuthorize.cpp @@ -30,34 +30,34 @@ namespace xrpl { // drops: 64-bit uint (as string) // } json::Value -doChannelAuthorize(RPC::JsonContext& context) +doChannelAuthorize(rpc::JsonContext& context) { if (context.role != Role::ADMIN && !context.app.config().canSign()) { - return RPC::makeError(RpcNotSupported, "Signing is not supported by this server."); + return rpc::makeError(RpcNotSupported, "Signing is not supported by this server."); } auto const& params(context.params); for (auto const& p : {jss::channel_id, jss::amount}) { if (!params.isMember(p)) - return RPC::missingFieldError(p); + return rpc::missingFieldError(p); } // Compatibility if a key type isn't specified. If it is, the // keypairForSignature code will validate parameters and return // the appropriate error. if (!params.isMember(jss::key_type) && !params.isMember(jss::secret)) - return RPC::missingFieldError(jss::secret); + return rpc::missingFieldError(jss::secret); json::Value result; std::optional> const keyPair = - RPC::keypairForSignature(params, result, context.apiVersion); + rpc::keypairForSignature(params, result, context.apiVersion); XRPL_ASSERT( - keyPair || RPC::containsError(result), + keyPair || rpc::containsError(result), "xrpl::doChannelAuthorize : valid keyPair or an error"); - if (!keyPair || RPC::containsError(result)) + if (!keyPair || rpc::containsError(result)) return result; PublicKey const& pk = keyPair->first; @@ -86,7 +86,7 @@ doChannelAuthorize(RPC::JsonContext& context) catch (std::exception const& ex) { // LCOV_EXCL_START - result = RPC::makeError( + result = rpc::makeError( RpcInternal, "Exception occurred during signing: " + std::string(ex.what())); // LCOV_EXCL_STOP } diff --git a/src/xrpld/rpc/handlers/admin/signing/Sign.cpp b/src/xrpld/rpc/handlers/admin/signing/Sign.cpp index 781e160f54..6aac058a56 100644 --- a/src/xrpld/rpc/handlers/admin/signing/Sign.cpp +++ b/src/xrpld/rpc/handlers/admin/signing/Sign.cpp @@ -15,18 +15,18 @@ namespace xrpl { // secret: // } json::Value -doSign(RPC::JsonContext& context) +doSign(rpc::JsonContext& context) { if (context.role != Role::ADMIN && !context.app.config().canSign()) { - return RPC::makeError(RpcNotSupported, "Signing is not supported by this server."); + return rpc::makeError(RpcNotSupported, "Signing is not supported by this server."); } - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; NetworkOPs::FailHard const failType = NetworkOPs::doFailHard( context.params.isMember(jss::fail_hard) && context.params[jss::fail_hard].asBool()); - auto ret = RPC::transactionSign( + auto ret = rpc::transactionSign( context.params, context.apiVersion, failType, diff --git a/src/xrpld/rpc/handlers/admin/signing/SignFor.cpp b/src/xrpld/rpc/handlers/admin/signing/SignFor.cpp index 35274d51f4..2b9c830647 100644 --- a/src/xrpld/rpc/handlers/admin/signing/SignFor.cpp +++ b/src/xrpld/rpc/handlers/admin/signing/SignFor.cpp @@ -16,18 +16,18 @@ namespace xrpl { // secret: // } json::Value -doSignFor(RPC::JsonContext& context) +doSignFor(rpc::JsonContext& context) { if (context.role != Role::ADMIN && !context.app.config().canSign()) { - return RPC::makeError(RpcNotSupported, "Signing is not supported by this server."); + return rpc::makeError(RpcNotSupported, "Signing is not supported by this server."); } - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; auto const failHard = context.params[jss::fail_hard].asBool(); auto const failType = NetworkOPs::doFailHard(failHard); - auto ret = RPC::transactionSignFor( + auto ret = rpc::transactionSignFor( context.params, context.apiVersion, failType, diff --git a/src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp b/src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp index 341980ba6d..8017e7058b 100644 --- a/src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp +++ b/src/xrpld/rpc/handlers/admin/status/ConsensusInfo.cpp @@ -7,7 +7,7 @@ namespace xrpl { json::Value -doConsensusInfo(RPC::JsonContext& context) +doConsensusInfo(rpc::JsonContext& context) { json::Value ret(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp b/src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp index 16e4789025..ca9bff31f5 100644 --- a/src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp +++ b/src/xrpld/rpc/handlers/admin/status/FetchInfo.cpp @@ -7,7 +7,7 @@ namespace xrpl { json::Value -doFetchInfo(RPC::JsonContext& context) +doFetchInfo(rpc::JsonContext& context) { json::Value ret(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/admin/status/GetCounts.cpp b/src/xrpld/rpc/handlers/admin/status/GetCounts.cpp index 789c6dcf17..421f23d237 100644 --- a/src/xrpld/rpc/handlers/admin/status/GetCounts.cpp +++ b/src/xrpld/rpc/handlers/admin/status/GetCounts.cpp @@ -111,7 +111,7 @@ getCountsJson(Application& app, int minObjectCount) // min_count: // optional, defaults to 10 // } json::Value -doGetCounts(RPC::JsonContext& context) +doGetCounts(rpc::JsonContext& context) { int minCount = 10; diff --git a/src/xrpld/rpc/handlers/admin/status/Print.cpp b/src/xrpld/rpc/handlers/admin/status/Print.cpp index 99fd01c9f4..1e1f7f0662 100644 --- a/src/xrpld/rpc/handlers/admin/status/Print.cpp +++ b/src/xrpld/rpc/handlers/admin/status/Print.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doPrint(RPC::JsonContext& context) +doPrint(rpc::JsonContext& context) { JsonPropertyStream stream; if (context.params.isObject() && context.params[jss::params].isArray() && diff --git a/src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp b/src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp index efe1529ccb..705e03c1a0 100644 --- a/src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp +++ b/src/xrpld/rpc/handlers/admin/status/ValidatorInfo.cpp @@ -12,12 +12,12 @@ namespace xrpl { json::Value -doValidatorInfo(RPC::JsonContext& context) +doValidatorInfo(rpc::JsonContext& context) { // return error if not configured as validator auto const validationPK = context.app.getValidationPublicKey(); if (!validationPK) - return RPC::notValidatorError(); + return rpc::notValidatorError(); json::Value ret; diff --git a/src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp b/src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp index 7497105c50..9bc8b6bcda 100644 --- a/src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp +++ b/src/xrpld/rpc/handlers/admin/status/ValidatorListSites.cpp @@ -7,7 +7,7 @@ namespace xrpl { json::Value -doValidatorListSites(RPC::JsonContext& context) +doValidatorListSites(rpc::JsonContext& context) { return context.app.getValidatorSites().getJson(); } diff --git a/src/xrpld/rpc/handlers/admin/status/Validators.cpp b/src/xrpld/rpc/handlers/admin/status/Validators.cpp index 48e4466861..d605a38f1b 100644 --- a/src/xrpld/rpc/handlers/admin/status/Validators.cpp +++ b/src/xrpld/rpc/handlers/admin/status/Validators.cpp @@ -7,7 +7,7 @@ namespace xrpl { json::Value -doValidators(RPC::JsonContext& context) +doValidators(rpc::JsonContext& context) { return context.app.getValidators().getJson(); } diff --git a/src/xrpld/rpc/handlers/ledger/Ledger.cpp b/src/xrpld/rpc/handlers/ledger/Ledger.cpp index 23a97a5026..51f5bdf348 100644 --- a/src/xrpld/rpc/handlers/ledger/Ledger.cpp +++ b/src/xrpld/rpc/handlers/ledger/Ledger.cpp @@ -34,7 +34,7 @@ #include namespace xrpl { -namespace RPC { +namespace rpc { LedgerHandler::LedgerHandler(JsonContext& context) : context_(context) { @@ -107,7 +107,7 @@ LedgerHandler::check() { return RpcTooBusy; } - context_.loadType = binary ? Resource::kFeeMediumBurdenRpc : Resource::kFeeHeavyBurdenRpc; + context_.loadType = binary ? resource::kFeeMediumBurdenRpc : resource::kFeeHeavyBurdenRpc; } if (*queue) @@ -162,10 +162,10 @@ LedgerHandler::writeResult(json::Value& value) value[jss::warnings] = std::move(warnings); } -} // namespace RPC +} // namespace rpc std::pair -doLedgerGrpc(RPC::GRPCContext& context) +doLedgerGrpc(rpc::GRPCContext& context) { auto begin = std::chrono::system_clock::now(); org::xrpl::rpc::v1::GetLedgerRequest const& request = context.params; @@ -173,7 +173,7 @@ doLedgerGrpc(RPC::GRPCContext& context) grpc::Status const status = grpc::Status::OK; std::shared_ptr ledger; - if (auto status = RPC::ledgerFromRequest(ledger, context)) + if (auto status = rpc::ledgerFromRequest(ledger, context)) { grpc::Status errorStatus; if (status.toErrorCode() == RpcInvalidParams) diff --git a/src/xrpld/rpc/handlers/ledger/Ledger.h b/src/xrpld/rpc/handlers/ledger/Ledger.h index 59b64832f7..07d24b497d 100644 --- a/src/xrpld/rpc/handlers/ledger/Ledger.h +++ b/src/xrpld/rpc/handlers/ledger/Ledger.h @@ -18,7 +18,7 @@ namespace json { class Object; } // namespace json -namespace xrpl::RPC { +namespace xrpl::rpc { struct JsonContext; @@ -42,9 +42,9 @@ public: // NOLINTBEGIN(readability-identifier-naming) static constexpr char name[] = "ledger"; - static constexpr unsigned minApiVer = RPC::kApiMinimumSupportedVersion; + static constexpr unsigned minApiVer = rpc::kApiMinimumSupportedVersion; - static constexpr unsigned maxApiVer = RPC::kApiMaximumValidVersion; + static constexpr unsigned maxApiVer = rpc::kApiMaximumValidVersion; static constexpr Role role = Role::USER; @@ -59,4 +59,4 @@ private: int options_ = 0; }; -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp b/src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp index 7ea314292f..def0a73cd3 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerClosed.cpp @@ -10,7 +10,7 @@ namespace xrpl { json::Value -doLedgerClosed(RPC::JsonContext& context) +doLedgerClosed(rpc::JsonContext& context) { auto ledger = context.ledgerMaster.getClosedLedger(); XRPL_ASSERT(ledger, "xrpl::doLedgerClosed : non-null closed ledger"); diff --git a/src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp b/src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp index 1d05774163..ac04084848 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerCurrent.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doLedgerCurrent(RPC::JsonContext& context) +doLedgerCurrent(rpc::JsonContext& context) { json::Value jvResult; jvResult[jss::ledger_current_index] = context.ledgerMaster.getCurrentLedgerIndex(); diff --git a/src/xrpld/rpc/handlers/ledger/LedgerData.cpp b/src/xrpld/rpc/handlers/ledger/LedgerData.cpp index 64ab30374b..697d8e52b8 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerData.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerData.cpp @@ -36,12 +36,12 @@ namespace xrpl { // state: array of state nodes // marker: resume point, if any json::Value -doLedgerData(RPC::JsonContext& context) +doLedgerData(rpc::JsonContext& context) { std::shared_ptr lpLedger; auto const& params = context.params; - auto jvResult = RPC::lookupLedger(lpLedger, context); + auto jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; @@ -51,14 +51,14 @@ doLedgerData(RPC::JsonContext& context) { json::Value const& jMarker = params[jss::marker]; if (!(jMarker.isString() && key.parseHex(jMarker.asString()))) - return RPC::expectedFieldError(jss::marker, "valid"); + return rpc::expectedFieldError(jss::marker, "valid"); } bool isBinary = false; if (params.isMember(jss::binary)) { if (!params[jss::binary].isBool()) - return RPC::expectedFieldError(jss::binary, "boolean"); + return rpc::expectedFieldError(jss::binary, "boolean"); isBinary = params[jss::binary].asBool(); } @@ -67,12 +67,12 @@ doLedgerData(RPC::JsonContext& context) { json::Value const& jLimit = params[jss::limit]; if (!jLimit.isIntegral()) - return RPC::expectedFieldError(jss::limit, "integer"); + return rpc::expectedFieldError(jss::limit, "integer"); limit = jLimit.asInt(); } - auto maxLimit = RPC::Tuning::pageLength(isBinary); + auto maxLimit = rpc::tuning::pageLength(isBinary); if ((limit < 0) || ((limit > maxLimit) && (!isUnlimited(context.role)))) limit = maxLimit; @@ -86,7 +86,7 @@ doLedgerData(RPC::JsonContext& context) *lpLedger, &context, isBinary ? static_cast(LedgerFill::Options::Binary) : 0)); } - auto [rpcStatus, type] = RPC::chooseLedgerEntryType(params); + auto [rpcStatus, type] = rpc::chooseLedgerEntryType(params); if (rpcStatus) { jvResult.clear(); @@ -131,14 +131,14 @@ doLedgerData(RPC::JsonContext& context) } std::pair -doLedgerDataGrpc(RPC::GRPCContext& context) +doLedgerDataGrpc(rpc::GRPCContext& context) { org::xrpl::rpc::v1::GetLedgerDataRequest const& request = context.params; org::xrpl::rpc::v1::GetLedgerDataResponse response; grpc::Status const status = grpc::Status::OK; std::shared_ptr ledger; - if (auto status = RPC::ledgerFromRequest(ledger, context)) + if (auto status = rpc::ledgerFromRequest(ledger, context)) { grpc::Status errorStatus; if (status.toErrorCode() == RpcInvalidParams) @@ -177,7 +177,7 @@ doLedgerDataGrpc(RPC::GRPCContext& con e = ledger->sles.upperBound(*key); } - int maxLimit = RPC::Tuning::pageLength(true); + int maxLimit = rpc::tuning::pageLength(true); for (auto i = ledger->sles.upperBound(startKey); i != e; ++i) { diff --git a/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp b/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp index f1a9253de2..5e83bedf08 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp @@ -15,7 +15,7 @@ namespace xrpl { std::pair -doLedgerDiffGrpc(RPC::GRPCContext& context) +doLedgerDiffGrpc(rpc::GRPCContext& context) { org::xrpl::rpc::v1::GetLedgerDiffRequest const& request = context.params; org::xrpl::rpc::v1::GetLedgerDiffResponse response; @@ -24,13 +24,13 @@ doLedgerDiffGrpc(RPC::GRPCContext& con std::shared_ptr baseLedgerRv; std::shared_ptr desiredLedgerRv; - if (RPC::ledgerFromSpecifier(baseLedgerRv, request.base_ledger(), context)) + if (rpc::ledgerFromSpecifier(baseLedgerRv, request.base_ledger(), context)) { grpc::Status const errorStatus{grpc::StatusCode::NOT_FOUND, "base ledger not found"}; return {response, errorStatus}; } - if (RPC::ledgerFromSpecifier(desiredLedgerRv, request.desired_ledger(), context)) + if (rpc::ledgerFromSpecifier(desiredLedgerRv, request.desired_ledger(), context)) { grpc::Status const errorStatus{grpc::StatusCode::NOT_FOUND, "desired ledger not found"}; return {response, errorStatus}; diff --git a/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp index 784be779bb..0dd52b6776 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerEntry.cpp @@ -66,11 +66,11 @@ parseObjectID( json::StaticString const fieldName, std::string const& expectedType = "hex string or object") { - if (auto const uNodeIndex = LedgerEntryHelpers::parse(params)) + if (auto const uNodeIndex = ledger_entry_helpers::parse(params)) { return *uNodeIndex; } - return LedgerEntryHelpers::invalidFieldError("malformedRequest", fieldName, expectedType); + return ledger_entry_helpers::invalidFieldError("malformedRequest", fieldName, expectedType); } static std::expected @@ -101,12 +101,12 @@ parseAccountRoot( json::StaticString const fieldName, [[maybe_unused]] unsigned const apiVersion) { - if (auto const account = LedgerEntryHelpers::parse(params)) + if (auto const account = ledger_entry_helpers::parse(params)) { return keylet::account(*account).key; } - return LedgerEntryHelpers::invalidFieldError("malformedAddress", fieldName, "AccountID"); + return ledger_entry_helpers::invalidFieldError("malformedAddress", fieldName, "AccountID"); } auto const parseAmendments = fixed(keylet::amendments()); @@ -122,17 +122,18 @@ parseAMM( return parseObjectID(params, fieldName); } - if (auto const value = LedgerEntryHelpers::hasRequired(params, {jss::asset, jss::asset2}); + if (auto const value = ledger_entry_helpers::hasRequired(params, {jss::asset, jss::asset2}); !value) { return std::unexpected(value.error()); } - auto const asset = LedgerEntryHelpers::requiredAsset(params, jss::asset, "malformedRequest"); + auto const asset = ledger_entry_helpers::requiredAsset(params, jss::asset, "malformedRequest"); if (!asset) return std::unexpected(asset.error()); - auto const asset2 = LedgerEntryHelpers::requiredAsset(params, jss::asset2, "malformedRequest"); + auto const asset2 = + ledger_entry_helpers::requiredAsset(params, jss::asset2, "malformedRequest"); if (!asset2) return std::unexpected(asset2.error()); @@ -147,7 +148,7 @@ parseBridge( { if (!params.isMember(jss::bridge)) { - return std::unexpected(LedgerEntryHelpers::missingFieldError(jss::bridge)); + return std::unexpected(ledger_entry_helpers::missingFieldError(jss::bridge)); } if (params[jss::bridge].isString()) @@ -155,11 +156,11 @@ parseBridge( return parseObjectID(params, fieldName); } - auto const bridge = LedgerEntryHelpers::parseBridgeFields(params[jss::bridge]); + auto const bridge = ledger_entry_helpers::parseBridgeFields(params[jss::bridge]); if (!bridge) return std::unexpected(bridge.error()); - auto const account = LedgerEntryHelpers::requiredAccountID( + auto const account = ledger_entry_helpers::requiredAccountID( params, jss::bridge_account, "malformedBridgeAccount"); if (!account) return std::unexpected(account.error()); @@ -167,7 +168,7 @@ parseBridge( STXChainBridge::ChainType const chainType = STXChainBridge::srcChain(account.value() == bridge->lockingChainDoor()); if (account.value() != bridge->door(chainType)) - return LedgerEntryHelpers::malformedError("malformedRequest", ""); + return ledger_entry_helpers::malformedError("malformedRequest", ""); return keylet::bridge(*bridge, chainType).key; } @@ -193,16 +194,16 @@ parseCredential( } auto const subject = - LedgerEntryHelpers::requiredAccountID(cred, jss::subject, "malformedRequest"); + ledger_entry_helpers::requiredAccountID(cred, jss::subject, "malformedRequest"); if (!subject) return std::unexpected(subject.error()); auto const issuer = - LedgerEntryHelpers::requiredAccountID(cred, jss::issuer, "malformedRequest"); + ledger_entry_helpers::requiredAccountID(cred, jss::issuer, "malformedRequest"); if (!issuer) return std::unexpected(issuer.error()); - auto const credType = LedgerEntryHelpers::requiredHexBlob( + auto const credType = ledger_entry_helpers::requiredHexBlob( cred, jss::credential_type, kMaxCredentialTypeLength, "malformedRequest"); if (!credType) return std::unexpected(credType.error()); @@ -222,12 +223,12 @@ parseDelegate( } auto const account = - LedgerEntryHelpers::requiredAccountID(params, jss::account, "malformedAddress"); + ledger_entry_helpers::requiredAccountID(params, jss::account, "malformedAddress"); if (!account) return std::unexpected(account.error()); auto const authorize = - LedgerEntryHelpers::requiredAccountID(params, jss::authorize, "malformedAddress"); + ledger_entry_helpers::requiredAccountID(params, jss::authorize, "malformedAddress"); if (!authorize) return std::unexpected(authorize.error()); @@ -239,7 +240,7 @@ parseAuthorizeCredentials(json::Value const& jv) { if (!jv.isArray()) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAuthorizedCredentials", jss::authorized_credentials, "array"); } @@ -247,7 +248,7 @@ parseAuthorizeCredentials(json::Value const& jv) if (n > kMaxCredentialsArraySize) { return std::unexpected( - LedgerEntryHelpers::malformedError( + ledger_entry_helpers::malformedError( "malformedAuthorizedCredentials", "Invalid field '" + std::string(jss::authorized_credentials) + "', array too long.")); @@ -256,7 +257,7 @@ parseAuthorizeCredentials(json::Value const& jv) if (n == 0) { return std::unexpected( - LedgerEntryHelpers::malformedError( + ledger_entry_helpers::malformedError( "malformedAuthorizedCredentials", "Invalid field '" + std::string(jss::authorized_credentials) + "', array empty.")); } @@ -266,23 +267,23 @@ parseAuthorizeCredentials(json::Value const& jv) { if (!jo.isObject()) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAuthorizedCredentials", jss::authorized_credentials, "array of objects"); } - if (auto const value = LedgerEntryHelpers::hasRequired( + if (auto const value = ledger_entry_helpers::hasRequired( jo, {jss::issuer, jss::credential_type}, "malformedAuthorizedCredentials"); !value) { return std::unexpected(value.error()); } - auto const issuer = LedgerEntryHelpers::requiredAccountID( + auto const issuer = ledger_entry_helpers::requiredAccountID( jo, jss::issuer, "malformedAuthorizedCredentials"); if (!issuer) return std::unexpected(issuer.error()); - auto const credentialType = LedgerEntryHelpers::requiredHexBlob( + auto const credentialType = ledger_entry_helpers::requiredHexBlob( jo, jss::credential_type, kMaxCredentialTypeLength, "malformedAuthorizedCredentials"); if (!credentialType) return std::unexpected(credentialType.error()); @@ -309,13 +310,13 @@ parseDepositPreauth( if ((dp.isMember(jss::authorized) == dp.isMember(jss::authorized_credentials))) { - return LedgerEntryHelpers::malformedError( + return ledger_entry_helpers::malformedError( "malformedRequest", "Must have exactly one of `authorized` and " "`authorized_credentials`."); } - auto const owner = LedgerEntryHelpers::requiredAccountID(dp, jss::owner, "malformedOwner"); + auto const owner = ledger_entry_helpers::requiredAccountID(dp, jss::owner, "malformedOwner"); if (!owner) { return std::unexpected(owner.error()); @@ -323,11 +324,11 @@ parseDepositPreauth( if (dp.isMember(jss::authorized)) { - if (auto const authorized = LedgerEntryHelpers::parse(dp[jss::authorized])) + if (auto const authorized = ledger_entry_helpers::parse(dp[jss::authorized])) { return keylet::depositPreauth(*owner, *authorized).key; } - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAuthorized", jss::authorized, "AccountID"); } @@ -340,7 +341,7 @@ parseDepositPreauth( if (sorted.empty()) { // TODO: this error message is bad/inaccurate - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAuthorizedCredentials", jss::authorized_credentials, "array"); } @@ -353,10 +354,10 @@ parseDID( json::StaticString const fieldName, [[maybe_unused]] unsigned const apiVersion) { - auto const account = LedgerEntryHelpers::parse(params); + auto const account = ledger_entry_helpers::parse(params); if (!account) { - return LedgerEntryHelpers::invalidFieldError("malformedAddress", fieldName, "AccountID"); + return ledger_entry_helpers::invalidFieldError("malformedAddress", fieldName, "AccountID"); } return keylet::did(*account).key; @@ -377,12 +378,13 @@ parseDirectoryNode( (!params[jss::sub_index].isConvertibleTo(json::ValueType::UInt) || params[jss::sub_index].isBool())) { - return LedgerEntryHelpers::invalidFieldError("malformedRequest", jss::sub_index, "number"); + return ledger_entry_helpers::invalidFieldError( + "malformedRequest", jss::sub_index, "number"); } if (params.isMember(jss::owner) == params.isMember(jss::dir_root)) { - return LedgerEntryHelpers::malformedError( + return ledger_entry_helpers::malformedError( "malformedRequest", "Must have exactly one of `owner` and `dir_root` fields."); } @@ -390,27 +392,27 @@ parseDirectoryNode( if (params.isMember(jss::dir_root)) { - if (auto const uDirRoot = LedgerEntryHelpers::parse(params[jss::dir_root])) + if (auto const uDirRoot = ledger_entry_helpers::parse(params[jss::dir_root])) { return keylet::page(*uDirRoot, uSubIndex).key; } - return LedgerEntryHelpers::invalidFieldError("malformedDirRoot", jss::dir_root, "hash"); + return ledger_entry_helpers::invalidFieldError("malformedDirRoot", jss::dir_root, "hash"); } if (params.isMember(jss::owner)) { - auto const ownerID = LedgerEntryHelpers::parse(params[jss::owner]); + auto const ownerID = ledger_entry_helpers::parse(params[jss::owner]); if (!ownerID) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAddress", jss::owner, "AccountID"); } return keylet::page(keylet::ownerDir(*ownerID), uSubIndex).key; } - return LedgerEntryHelpers::malformedError("malformedRequest", ""); + return ledger_entry_helpers::malformedError("malformedRequest", ""); } static std::expected @@ -424,10 +426,10 @@ parseEscrow( return parseObjectID(params, fieldName); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::owner, "malformedOwner"); + auto const id = ledger_entry_helpers::requiredAccountID(params, jss::owner, "malformedOwner"); if (!id) return std::unexpected(id.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(params, jss::seq, "malformedSeq"); + auto const seq = ledger_entry_helpers::requiredUInt32(params, jss::seq, "malformedSeq"); if (!seq) return std::unexpected(seq.error()); @@ -449,7 +451,7 @@ parseFixed( } if (!params.asBool()) { - return LedgerEntryHelpers::invalidFieldError("invalidParams", fieldName, "true"); + return ledger_entry_helpers::invalidFieldError("invalidParams", fieldName, "true"); } return keylet.key; @@ -486,10 +488,10 @@ parseLoanBroker( return parseObjectID(params, fieldName, "hex string"); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::owner, "malformedOwner"); + auto const id = ledger_entry_helpers::requiredAccountID(params, jss::owner, "malformedOwner"); if (!id) return std::unexpected(id.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(params, jss::seq, "malformedSeq"); + auto const seq = ledger_entry_helpers::requiredUInt32(params, jss::seq, "malformedSeq"); if (!seq) return std::unexpected(seq.error()); @@ -508,10 +510,10 @@ parseLoan( } auto const id = - LedgerEntryHelpers::requiredUInt256(params, jss::loan_broker_id, "malformedBroker"); + ledger_entry_helpers::requiredUInt256(params, jss::loan_broker_id, "malformedBroker"); if (!id) return std::unexpected(id.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(params, jss::loan_seq, "malformedSeq"); + auto const seq = ledger_entry_helpers::requiredUInt32(params, jss::loan_seq, "malformedSeq"); if (!seq) return std::unexpected(seq.error()); @@ -529,13 +531,13 @@ parseMPToken( return parseObjectID(params, fieldName); } - auto const mptIssuanceID = - LedgerEntryHelpers::requiredUInt192(params, jss::mpt_issuance_id, "malformedMPTIssuanceID"); + auto const mptIssuanceID = ledger_entry_helpers::requiredUInt192( + params, jss::mpt_issuance_id, "malformedMPTIssuanceID"); if (!mptIssuanceID) return std::unexpected(mptIssuanceID.error()); auto const account = - LedgerEntryHelpers::requiredAccountID(params, jss::account, "malformedAccount"); + ledger_entry_helpers::requiredAccountID(params, jss::account, "malformedAccount"); if (!account) return std::unexpected(account.error()); @@ -548,10 +550,10 @@ parseMPTokenIssuance( json::StaticString const fieldName, [[maybe_unused]] unsigned const apiVersion) { - auto const mptIssuanceID = LedgerEntryHelpers::parse(params); + auto const mptIssuanceID = ledger_entry_helpers::parse(params); if (!mptIssuanceID) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedMPTokenIssuance", fieldName, "Hash192"); } @@ -589,11 +591,12 @@ parseOffer( return parseObjectID(params, fieldName); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::account, "malformedAddress"); + auto const id = + ledger_entry_helpers::requiredAccountID(params, jss::account, "malformedAddress"); if (!id) return std::unexpected(id.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(params, jss::seq, "malformedRequest"); + auto const seq = ledger_entry_helpers::requiredUInt32(params, jss::seq, "malformedRequest"); if (!seq) return std::unexpected(seq.error()); @@ -611,12 +614,13 @@ parseOracle( return parseObjectID(params, fieldName); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::account, "malformedAccount"); + auto const id = + ledger_entry_helpers::requiredAccountID(params, jss::account, "malformedAccount"); if (!id) return std::unexpected(id.error()); - auto const seq = - LedgerEntryHelpers::requiredUInt32(params, jss::oracle_document_id, "malformedDocumentID"); + auto const seq = ledger_entry_helpers::requiredUInt32( + params, jss::oracle_document_id, "malformedDocumentID"); if (!seq) return std::unexpected(seq.error()); @@ -645,16 +649,16 @@ parsePermissionedDomain( if (!pd.isObject()) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedRequest", fieldName, "hex string or object"); } auto const account = - LedgerEntryHelpers::requiredAccountID(pd, jss::account, "malformedAddress"); + ledger_entry_helpers::requiredAccountID(pd, jss::account, "malformedAddress"); if (!account) return std::unexpected(account.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(pd, jss::seq, "malformedRequest"); + auto const seq = ledger_entry_helpers::requiredUInt32(pd, jss::seq, "malformedRequest"); if (!seq) return std::unexpected(seq.error()); @@ -675,7 +679,7 @@ parseRippleState( } if (auto const value = - LedgerEntryHelpers::hasRequired(jvRippleState, {jss::currency, jss::accounts}); + ledger_entry_helpers::hasRequired(jvRippleState, {jss::currency, jss::accounts}); !value) { return std::unexpected(value.error()); @@ -683,27 +687,27 @@ parseRippleState( if (!jvRippleState[jss::accounts].isArray() || jvRippleState[jss::accounts].size() != 2) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedRequest", jss::accounts, "length-2 array of Accounts"); } - auto const id1 = LedgerEntryHelpers::parse(jvRippleState[jss::accounts][0u]); - auto const id2 = LedgerEntryHelpers::parse(jvRippleState[jss::accounts][1u]); + auto const id1 = ledger_entry_helpers::parse(jvRippleState[jss::accounts][0u]); + auto const id2 = ledger_entry_helpers::parse(jvRippleState[jss::accounts][1u]); if (!id1 || !id2) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedAddress", jss::accounts, "array of Accounts"); } if (id1 == id2) { - return LedgerEntryHelpers::malformedError( + return ledger_entry_helpers::malformedError( "malformedRequest", "Cannot have a trustline to self."); } if (!jvRippleState[jss::currency].isString() || jvRippleState[jss::currency] == "" || !toCurrency(uCurrency, jvRippleState[jss::currency].asString())) { - return LedgerEntryHelpers::invalidFieldError( + return ledger_entry_helpers::invalidFieldError( "malformedCurrency", jss::currency, "Currency"); } @@ -729,12 +733,12 @@ parseSponsorship( return parseObjectID(params, fieldName); auto const sponsorID = - LedgerEntryHelpers::requiredAccountID(params, jss::sponsor, "malformedSponsor"); + ledger_entry_helpers::requiredAccountID(params, jss::sponsor, "malformedSponsor"); if (!sponsorID) return std::unexpected(sponsorID.error()); auto const sponseeID = - LedgerEntryHelpers::requiredAccountID(params, jss::sponsee, "malformedSponsee"); + ledger_entry_helpers::requiredAccountID(params, jss::sponsee, "malformedSponsee"); if (!sponseeID) return std::unexpected(sponseeID.error()); @@ -752,12 +756,13 @@ parseTicket( return parseObjectID(params, fieldName); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::account, "malformedAddress"); + auto const id = + ledger_entry_helpers::requiredAccountID(params, jss::account, "malformedAddress"); if (!id) return std::unexpected(id.error()); auto const seq = - LedgerEntryHelpers::requiredUInt32(params, jss::ticket_seq, "malformedRequest"); + ledger_entry_helpers::requiredUInt32(params, jss::ticket_seq, "malformedRequest"); if (!seq) return std::unexpected(seq.error()); @@ -775,11 +780,11 @@ parseVault( return parseObjectID(params, fieldName); } - auto const id = LedgerEntryHelpers::requiredAccountID(params, jss::owner, "malformedOwner"); + auto const id = ledger_entry_helpers::requiredAccountID(params, jss::owner, "malformedOwner"); if (!id) return std::unexpected(id.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32(params, jss::seq, "malformedRequest"); + auto const seq = ledger_entry_helpers::requiredUInt32(params, jss::seq, "malformedRequest"); if (!seq) return std::unexpected(seq.error()); @@ -797,11 +802,11 @@ parseXChainOwnedClaimID( return parseObjectID(claimId, fieldName); } - auto const bridgeSpec = LedgerEntryHelpers::parseBridgeFields(claimId); + auto const bridgeSpec = ledger_entry_helpers::parseBridgeFields(claimId); if (!bridgeSpec) return std::unexpected(bridgeSpec.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32( + auto const seq = ledger_entry_helpers::requiredUInt32( claimId, jss::xchain_owned_claim_id, "malformedXChainOwnedClaimID"); if (!seq) { @@ -823,11 +828,11 @@ parseXChainOwnedCreateAccountClaimID( return parseObjectID(claimId, fieldName); } - auto const bridgeSpec = LedgerEntryHelpers::parseBridgeFields(claimId); + auto const bridgeSpec = ledger_entry_helpers::parseBridgeFields(claimId); if (!bridgeSpec) return std::unexpected(bridgeSpec.error()); - auto const seq = LedgerEntryHelpers::requiredUInt32( + auto const seq = ledger_entry_helpers::requiredUInt32( claimId, jss::xchain_owned_create_account_claim_id, "malformedXChainOwnedCreateAccountClaimID"); @@ -853,7 +858,7 @@ struct LedgerEntry // ... // } json::Value -doLedgerEntry(RPC::JsonContext& context) +doLedgerEntry(rpc::JsonContext& context) { static auto kLedgerEntryParsers = std::to_array({ #pragma push_macro("LEDGER_ENTRY") @@ -892,11 +897,11 @@ doLedgerEntry(RPC::JsonContext& context) if (hasMoreThanOneMember) { - return RPC::makeParamError("Too many fields provided."); + return rpc::makeParamError("Too many fields provided."); } std::shared_ptr lpLedger; - auto jvResult = RPC::lookupLedger(lpLedger, context); + auto jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; @@ -936,7 +941,7 @@ doLedgerEntry(RPC::JsonContext& context) jvResult[jss::error] = "unknownOption"; return jvResult; } - return RPC::makeParamError("No ledger_entry params provided."); + return rpc::makeParamError("No ledger_entry params provided."); } } catch (json::Error const& e) @@ -945,7 +950,7 @@ doLedgerEntry(RPC::JsonContext& context) { // For apiVersion 2 onwards, any parsing failures that throw // this exception return an invalidParam error. - return RPC::makeError(RpcInvalidParams); + return rpc::makeError(RpcInvalidParams); } throw; @@ -956,7 +961,7 @@ doLedgerEntry(RPC::JsonContext& context) if (uNodeIndex.isZero()) { - RPC::injectError(RpcEntryNotFound, jvResult); + rpc::injectError(RpcEntryNotFound, jvResult); return jvResult; } @@ -969,13 +974,13 @@ doLedgerEntry(RPC::JsonContext& context) if (!sleNode) { // Not found. - RPC::injectError(RpcEntryNotFound, jvResult); + rpc::injectError(RpcEntryNotFound, jvResult); return jvResult; } if ((expectedType != ltANY) && (expectedType != sleNode->getType())) { - RPC::injectError(RpcUnexpectedLedgerType, jvResult); + rpc::injectError(RpcUnexpectedLedgerType, jvResult); return jvResult; } @@ -996,14 +1001,14 @@ doLedgerEntry(RPC::JsonContext& context) } std::pair -doLedgerEntryGrpc(RPC::GRPCContext& context) +doLedgerEntryGrpc(rpc::GRPCContext& context) { org::xrpl::rpc::v1::GetLedgerEntryRequest const& request = context.params; org::xrpl::rpc::v1::GetLedgerEntryResponse response; grpc::Status const status = grpc::Status::OK; std::shared_ptr ledger; - if (auto status = RPC::ledgerFromRequest(ledger, context)) + if (auto status = rpc::ledgerFromRequest(ledger, context)) { grpc::Status errorStatus; if (status.toErrorCode() == RpcInvalidParams) diff --git a/src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h b/src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h index 57c4e58242..1b119db04e 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h +++ b/src/xrpld/rpc/handlers/ledger/LedgerEntryHelpers.h @@ -22,7 +22,7 @@ #include #include -namespace xrpl::LedgerEntryHelpers { +namespace xrpl::ledger_entry_helpers { inline std::unexpected missingFieldError(json::StaticString const field, std::optional err = std::nullopt) @@ -30,7 +30,7 @@ missingFieldError(json::StaticString const field, std::optional err json::Value json = json::ValueType::Object; json[jss::error] = err.value_or("malformedRequest"); json[jss::error_code] = RpcInvalidParams; - json[jss::error_message] = RPC::missingFieldMessage(std::string(field.cStr())); + json[jss::error_message] = rpc::missingFieldMessage(std::string(field.cStr())); return std::unexpected(json); } @@ -40,7 +40,7 @@ invalidFieldError(std::string const& err, json::StaticString const field, std::s json::Value json = json::ValueType::Object; json[jss::error] = err; json[jss::error_code] = RpcInvalidParams; - json[jss::error_message] = RPC::expectedFieldMessage(field, type); + json[jss::error_message] = rpc::expectedFieldMessage(field, type); return std::unexpected(json); } @@ -291,4 +291,4 @@ parseBridgeFields(json::Value const& params) *lockingChainDoor, lockingChainIssue, *issuingChainDoor, issuingChainIssue); } -} // namespace xrpl::LedgerEntryHelpers +} // namespace xrpl::ledger_entry_helpers diff --git a/src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp b/src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp index e2cb80615b..ec3c9fe602 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerHeader.cpp @@ -18,10 +18,10 @@ namespace xrpl { // ledger_index : // } json::Value -doLedgerHeader(RPC::JsonContext& context) +doLedgerHeader(rpc::JsonContext& context) { std::shared_ptr lpLedger; - auto jvResult = RPC::lookupLedger(lpLedger, context); + auto jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; diff --git a/src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp b/src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp index 7f54f81423..e95c51c483 100644 --- a/src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp +++ b/src/xrpld/rpc/handlers/orderbook/AMMInfo.cpp @@ -61,13 +61,13 @@ toIso8601(NetClock::time_point tp) } json::Value -doAMMInfo(RPC::JsonContext& context) +doAMMInfo(rpc::JsonContext& context) { auto const& params(context.params); json::Value result; std::shared_ptr ledger; - result = RPC::lookupLedger(ledger, context); + result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -174,7 +174,7 @@ doAMMInfo(RPC::JsonContext& context) auto const r = getValuesFromContextParams(); if (!r) { - RPC::injectError(r.error(), result); + rpc::injectError(r.error(), result); return result; } diff --git a/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp b/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp index abad196246..0f796df3a4 100644 --- a/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp +++ b/src/xrpld/rpc/handlers/orderbook/BookChanges.cpp @@ -11,15 +11,15 @@ namespace xrpl { json::Value -doBookChanges(RPC::JsonContext& context) +doBookChanges(rpc::JsonContext& context) { std::shared_ptr ledger; - json::Value result = RPC::lookupLedger(ledger, context); + json::Value result = rpc::lookupLedger(ledger, context); if (ledger == nullptr) return result; - return RPC::computeBookChanges(ledger); + return rpc::computeBookChanges(ledger); } } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp b/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp index 63dee76f1b..ae539a59f3 100644 --- a/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp +++ b/src/xrpld/rpc/handlers/orderbook/BookOffers.cpp @@ -32,19 +32,19 @@ validateTakerJSON(json::Value const& taker, json::StaticString const& name) { if (!taker.isMember(jss::currency) && !taker.isMember(jss::mpt_issuance_id)) { - return RPC::missingFieldError((boost::format("%s.currency") % name.cStr()).str()); + return rpc::missingFieldError((boost::format("%s.currency") % name.cStr()).str()); } if (taker.isMember(jss::mpt_issuance_id) && (taker.isMember(jss::currency) || taker.isMember(jss::issuer))) { - return RPC::invalidFieldError(name.cStr()); + return rpc::invalidFieldError(name.cStr()); } if ((taker.isMember(jss::currency) && !taker[jss::currency].isString()) || (taker.isMember(jss::mpt_issuance_id) && !taker[jss::mpt_issuance_id].isString())) { - return RPC::expectedFieldError( + return rpc::expectedFieldError( (boost::format("%s.currency") % name.cStr()).str(), "string"); } @@ -71,7 +71,7 @@ parseTakerAssetJSON( if (!toCurrency(issue.currency, taker[jss::currency].asString())) { JLOG(j.info()) << boost::format("Bad %s currency.") % name.cStr(); - return RPC::makeError( + return rpc::makeError( assetError, (boost::format("Invalid field '%s.currency', bad currency.") % name.cStr()).str()); } @@ -82,7 +82,7 @@ parseTakerAssetJSON( MPTID mptid; if (!mptid.parseHex(taker[jss::mpt_issuance_id].asString())) { - return RPC::makeError( + return rpc::makeError( assetError, (boost::format("Invalid field '%s.mpt_issuance_id'") % name.cStr()).str()); } @@ -113,20 +113,20 @@ parseTakerIssuerJSON( { if (!taker[jss::issuer].isString()) { - return RPC::expectedFieldError( + return rpc::expectedFieldError( (boost::format("%s.issuer") % name.cStr()).str(), "string"); } if (!toIssuer(issue.account, taker[jss::issuer].asString())) { - return RPC::makeError( + return rpc::makeError( issuerError, (boost::format("Invalid field '%s.issuer', bad issuer.") % name.cStr()).str()); } if (issue.account == noAccount()) { - return RPC::makeError( + return rpc::makeError( issuerError, (boost::format("Invalid field '%s.issuer', bad issuer account one.") % name.cStr()) @@ -140,7 +140,7 @@ parseTakerIssuerJSON( if (isXRP(issue.currency) && !isXRP(issue.account)) { - return RPC::makeError( + return rpc::makeError( issuerError, (boost::format( "Unneeded field '%s.issuer' for XRP currency " @@ -151,7 +151,7 @@ parseTakerIssuerJSON( if (!isXRP(issue.currency) && isXRP(issue.account)) { - return RPC::makeError( + return rpc::makeError( issuerError, (boost::format("Invalid field '%s.issuer', expected non-XRP issuer.") % name.cStr()) .str()); @@ -162,7 +162,7 @@ parseTakerIssuerJSON( } json::Value -doBookOffers(RPC::JsonContext& context) +doBookOffers(rpc::JsonContext& context) { // VFALCO TODO Here is a terrible place for this kind of business // logic. It needs to be moved elsewhere and documented, @@ -171,25 +171,25 @@ doBookOffers(RPC::JsonContext& context) return rpcError(RpcTooBusy); std::shared_ptr lpLedger; - auto jvResult = RPC::lookupLedger(lpLedger, context); + auto jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; if (!context.params.isMember(jss::taker_pays)) - return RPC::missingFieldError(jss::taker_pays); + return rpc::missingFieldError(jss::taker_pays); if (!context.params.isMember(jss::taker_gets)) - return RPC::missingFieldError(jss::taker_gets); + return rpc::missingFieldError(jss::taker_gets); json::Value const& takerPays = context.params[jss::taker_pays]; json::Value const& takerGets = context.params[jss::taker_gets]; if (!takerPays.isObjectOrNull()) - return RPC::objectFieldError(jss::taker_pays); + return rpc::objectFieldError(jss::taker_pays); if (!takerGets.isObjectOrNull()) - return RPC::objectFieldError(jss::taker_gets); + return rpc::objectFieldError(jss::taker_gets); if (auto const err = validateTakerJSON(takerPays, jss::taker_pays)) return *err; @@ -215,11 +215,11 @@ doBookOffers(RPC::JsonContext& context) if (context.params.isMember(jss::taker)) { if (!context.params[jss::taker].isString()) - return RPC::expectedFieldError(jss::taker, "string"); + return rpc::expectedFieldError(jss::taker, "string"); takerID = parseBase58(context.params[jss::taker].asString()); if (!takerID) - return RPC::invalidFieldError(jss::taker); + return rpc::invalidFieldError(jss::taker); } std::optional domain; @@ -229,7 +229,7 @@ doBookOffers(RPC::JsonContext& context) if (!context.params[jss::domain].isString() || !num.parseHex(context.params[jss::domain].asString())) { - return RPC::makeError(RpcDomainMalformed, "Unable to parse domain."); + return rpc::makeError(RpcDomainMalformed, "Unable to parse domain."); } domain = num; @@ -238,11 +238,11 @@ doBookOffers(RPC::JsonContext& context) if (book.in == book.out) { JLOG(context.j.info()) << "taker_gets same as taker_pays."; - return RPC::makeError(RpcBadMarket); + return rpc::makeError(RpcBadMarket); } unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kBookOffers, context)) + if (auto err = readLimitField(limit, rpc::tuning::kBookOffers, context)) return *err; bool const bProof(context.params.isMember(jss::proof)); @@ -260,7 +260,7 @@ doBookOffers(RPC::JsonContext& context) jvMarker, jvResult); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return jvResult; } diff --git a/src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp b/src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp index 343d539277..9d109fe16f 100644 --- a/src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp +++ b/src/xrpld/rpc/handlers/orderbook/DepositAuthorized.cpp @@ -32,17 +32,17 @@ namespace xrpl { // } json::Value -doDepositAuthorized(RPC::JsonContext& context) +doDepositAuthorized(rpc::JsonContext& context) { json::Value const& params = context.params; // Validate source_account. if (!params.isMember(jss::source_account)) - return RPC::missingFieldError(jss::source_account); + return rpc::missingFieldError(jss::source_account); if (!params[jss::source_account].isString()) { - return RPC::makeError( - RpcInvalidParams, RPC::expectedFieldMessage(jss::source_account, "a string")); + return rpc::makeError( + RpcInvalidParams, rpc::expectedFieldMessage(jss::source_account, "a string")); } auto srcID = parseBase58(params[jss::source_account].asString()); @@ -52,11 +52,11 @@ doDepositAuthorized(RPC::JsonContext& context) // Validate destination_account. if (!params.isMember(jss::destination_account)) - return RPC::missingFieldError(jss::destination_account); + return rpc::missingFieldError(jss::destination_account); if (!params[jss::destination_account].isString()) { - return RPC::makeError( - RpcInvalidParams, RPC::expectedFieldMessage(jss::destination_account, "a string")); + return rpc::makeError( + RpcInvalidParams, rpc::expectedFieldMessage(jss::destination_account, "a string")); } auto dstID = parseBase58(params[jss::destination_account].asString()); @@ -66,7 +66,7 @@ doDepositAuthorized(RPC::JsonContext& context) // Validate ledger. std::shared_ptr ledger; - json::Value result = RPC::lookupLedger(ledger, context); + json::Value result = rpc::lookupLedger(ledger, context); if (!ledger) return result; @@ -74,7 +74,7 @@ doDepositAuthorized(RPC::JsonContext& context) // If source account is not in the ledger it can't be authorized. if (!ledger->exists(keylet::account(srcAcct))) { - RPC::injectError(RpcSrcActNotFound, result); + rpc::injectError(RpcSrcActNotFound, result); return result; } @@ -82,7 +82,7 @@ doDepositAuthorized(RPC::JsonContext& context) auto const sleDest = ledger->read(keylet::account(dstAcct)); if (!sleDest) { - RPC::injectError(RpcDstActNotFound, result); + rpc::injectError(RpcDstActNotFound, result); return result; } @@ -96,15 +96,15 @@ doDepositAuthorized(RPC::JsonContext& context) auto const& creds(params[jss::credentials]); if (!creds.isArray() || !creds) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, - RPC::expectedFieldMessage( + rpc::expectedFieldMessage( jss::credentials, "is non-empty array of CredentialID(hash256)")); } if (creds.size() > kMaxCredentialsArraySize) { - return RPC::makeError( - RpcInvalidParams, RPC::expectedFieldMessage(jss::credentials, "array too long")); + return rpc::makeError( + RpcInvalidParams, rpc::expectedFieldMessage(jss::credentials, "array too long")); } lifeExtender.reserve(creds.size()); @@ -112,9 +112,9 @@ doDepositAuthorized(RPC::JsonContext& context) { if (!jo.isString()) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, - RPC::expectedFieldMessage( + rpc::expectedFieldMessage( jss::credentials, "an array of CredentialID(hash256)")); } @@ -122,34 +122,34 @@ doDepositAuthorized(RPC::JsonContext& context) auto const credS = jo.asString(); if (!credH.parseHex(credS)) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, - RPC::expectedFieldMessage( + rpc::expectedFieldMessage( jss::credentials, "an array of CredentialID(hash256)")); } SLE::const_pointer sleCred = ledger->read(keylet::credential(credH)); if (!sleCred) { - RPC::injectError(RpcBadCredentials, "credentials don't exist", result); + rpc::injectError(RpcBadCredentials, "credentials don't exist", result); return result; } if (!sleCred->isFlag(lsfAccepted)) { - RPC::injectError(RpcBadCredentials, "credentials aren't accepted", result); + rpc::injectError(RpcBadCredentials, "credentials aren't accepted", result); return result; } if (credentials::checkExpired(*sleCred, ledger->header().parentCloseTime)) { - RPC::injectError(RpcBadCredentials, "credentials are expired", result); + rpc::injectError(RpcBadCredentials, "credentials are expired", result); return result; } if ((*sleCred)[sfSubject] != srcAcct) { - RPC::injectError( + rpc::injectError( RpcBadCredentials, "credentials doesn't belong to the root account", result); return result; } @@ -157,7 +157,7 @@ doDepositAuthorized(RPC::JsonContext& context) auto [it, ins] = sorted.emplace((*sleCred)[sfIssuer], (*sleCred)[sfCredentialType]); if (!ins) { - RPC::injectError(RpcBadCredentials, "duplicates in credentials", result); + rpc::injectError(RpcBadCredentials, "duplicates in credentials", result); return result; } lifeExtender.push_back(std::move(sleCred)); diff --git a/src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp b/src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp index 632456a3fa..f493000d0b 100644 --- a/src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp +++ b/src/xrpld/rpc/handlers/orderbook/GetAggregatePrice.cpp @@ -48,7 +48,7 @@ using Prices = bimap>, multiset_of const& f) { @@ -149,26 +149,26 @@ getStats(Prices::right_const_iterator const& begin, Prices::right_const_iterator * range - {most recent, most recent - time_threshold} [optional] */ json::Value -doGetAggregatePrice(RPC::JsonContext& context) +doGetAggregatePrice(rpc::JsonContext& context) { json::Value result; auto const& params(context.params); static constexpr std::uint16_t kMaxOracles = 200; if (!params.isMember(jss::oracles)) - return RPC::missingFieldError(jss::oracles); + return rpc::missingFieldError(jss::oracles); if (!params[jss::oracles].isArray() || params[jss::oracles].size() == 0 || params[jss::oracles].size() > kMaxOracles) { - RPC::injectError(RpcOracleMalformed, result); + rpc::injectError(RpcOracleMalformed, result); return result; } if (!params.isMember(jss::base_asset)) - return RPC::missingFieldError(jss::base_asset); + return rpc::missingFieldError(jss::base_asset); if (!params.isMember(jss::quote_asset)) - return RPC::missingFieldError(jss::quote_asset); + return rpc::missingFieldError(jss::quote_asset); // Lambda to validate uint type // support positive int, uint, and a number represented as a string @@ -213,38 +213,38 @@ doGetAggregatePrice(RPC::JsonContext& context) auto const trim = getField(jss::trim); if (std::holds_alternative(trim)) { - RPC::injectError(std::get(trim), result); + rpc::injectError(std::get(trim), result); return result; } if (params.isMember(jss::trim) && (std::get(trim) == 0 || std::get(trim) > kMaxTrim)) { - RPC::injectError(RpcInvalidParams, result); + rpc::injectError(RpcInvalidParams, result); return result; } auto const timeThreshold = getField(jss::time_threshold, 0); if (std::holds_alternative(timeThreshold)) { - RPC::injectError(std::get(timeThreshold), result); + rpc::injectError(std::get(timeThreshold), result); return result; } auto const baseAsset = getCurrency(sfBaseAsset, jss::base_asset); if (std::holds_alternative(baseAsset)) { - RPC::injectError(std::get(baseAsset), result); + rpc::injectError(std::get(baseAsset), result); return result; } auto const quoteAsset = getCurrency(sfQuoteAsset, jss::quote_asset); if (std::holds_alternative(quoteAsset)) { - RPC::injectError(std::get(quoteAsset), result); + rpc::injectError(std::get(quoteAsset), result); return result; } std::shared_ptr ledger; - result = RPC::lookupLedger(ledger, context); + result = rpc::lookupLedger(ledger, context); if (!ledger) return result; // LCOV_EXCL_LINE @@ -255,7 +255,7 @@ doGetAggregatePrice(RPC::JsonContext& context) { if (!oracle.isMember(jss::oracle_document_id) || !oracle.isMember(jss::account)) { - RPC::injectError(RpcOracleMalformed, result); + rpc::injectError(RpcOracleMalformed, result); return result; } auto const documentID = validUInt(oracle, jss::oracle_document_id) @@ -264,7 +264,7 @@ doGetAggregatePrice(RPC::JsonContext& context) auto const account = parseBase58(oracle[jss::account].asString()); if (!account || account->isZero() || !documentID) { - RPC::injectError(RpcInvalidParams, result); + rpc::injectError(RpcInvalidParams, result); return result; } @@ -298,7 +298,7 @@ doGetAggregatePrice(RPC::JsonContext& context) if (prices.empty()) { - RPC::injectError(RpcObjectNotFound, result); + rpc::injectError(RpcObjectNotFound, result); return result; } @@ -321,7 +321,7 @@ doGetAggregatePrice(RPC::JsonContext& context) if (prices.empty()) { // LCOV_EXCL_START - RPC::injectError(RpcInternal, result); + rpc::injectError(RpcInternal, result); return result; // LCOV_EXCL_STOP } diff --git a/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp b/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp index 88e4392dad..60b48ac5a6 100644 --- a/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp +++ b/src/xrpld/rpc/handlers/orderbook/NFTBuyOffers.cpp @@ -10,15 +10,15 @@ namespace xrpl { json::Value -doNFTBuyOffers(RPC::JsonContext& context) +doNFTBuyOffers(rpc::JsonContext& context) { if (!context.params.isMember(jss::nft_id)) - return RPC::missingFieldError(jss::nft_id); + return rpc::missingFieldError(jss::nft_id); uint256 nftId; if (!nftId.parseHex(context.params[jss::nft_id].asString())) - return RPC::invalidFieldError(jss::nft_id); + return rpc::invalidFieldError(jss::nft_id); return enumerateNFTOffers(context, nftId, keylet::nftBuys(nftId)); } diff --git a/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h b/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h index 70bc258d77..e03830ae0d 100644 --- a/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h +++ b/src/xrpld/rpc/handlers/orderbook/NFTOffersHelpers.h @@ -52,15 +52,15 @@ appendNftOfferJson(Application const& app, SLE::const_ref offer, json::Value& of // marker: opaque // optional, resume previous query // } inline json::Value -enumerateNFTOffers(RPC::JsonContext& context, uint256 const& nftId, Keylet const& directory) +enumerateNFTOffers(rpc::JsonContext& context, uint256 const& nftId, Keylet const& directory) { unsigned int limit = 0; - if (auto err = readLimitField(limit, RPC::Tuning::kNftOffers, context)) + if (auto err = readLimitField(limit, rpc::tuning::kNftOffers, context)) return *err; std::shared_ptr ledger; - if (auto result = RPC::lookupLedger(ledger, context); !ledger) + if (auto result = rpc::lookupLedger(ledger, context); !ledger) return result; if (!ledger->exists(directory)) @@ -83,7 +83,7 @@ enumerateNFTOffers(RPC::JsonContext& context, uint256 const& nftId, Keylet const json::Value const& marker(context.params[jss::marker]); if (!marker.isString()) - return RPC::expectedFieldError(jss::marker, "string"); + return rpc::expectedFieldError(jss::marker, "string"); if (!startAfter.parseHex(marker.asString())) return rpcError(RpcInvalidParams); @@ -127,7 +127,7 @@ enumerateNFTOffers(RPC::JsonContext& context, uint256 const& nftId, Keylet const for (auto const& offer : offers) appendNftOfferJson(context.app, offer, jsonOffers); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; return result; } diff --git a/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp b/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp index 309df93605..8b09b42a34 100644 --- a/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp +++ b/src/xrpld/rpc/handlers/orderbook/NFTSellOffers.cpp @@ -10,15 +10,15 @@ namespace xrpl { json::Value -doNFTSellOffers(RPC::JsonContext& context) +doNFTSellOffers(rpc::JsonContext& context) { if (!context.params.isMember(jss::nft_id)) - return RPC::missingFieldError(jss::nft_id); + return rpc::missingFieldError(jss::nft_id); uint256 nftId; if (!nftId.parseHex(context.params[jss::nft_id].asString())) - return RPC::invalidFieldError(jss::nft_id); + return rpc::invalidFieldError(jss::nft_id); return enumerateNFTOffers(context, nftId, keylet::nftSells(nftId)); } diff --git a/src/xrpld/rpc/handlers/orderbook/PathFind.cpp b/src/xrpld/rpc/handlers/orderbook/PathFind.cpp index 3a6b52ee98..c46238a5a5 100644 --- a/src/xrpld/rpc/handlers/orderbook/PathFind.cpp +++ b/src/xrpld/rpc/handlers/orderbook/PathFind.cpp @@ -13,7 +13,7 @@ namespace xrpl { json::Value -doPathFind(RPC::JsonContext& context) +doPathFind(rpc::JsonContext& context) { if (context.app.config().pathSearchMax == 0) return rpcError(RpcNotSupported); @@ -34,7 +34,7 @@ doPathFind(RPC::JsonContext& context) if (sSubCommand == "create") { - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; context.infoSub->clearRequest(); return context.app.getPathRequestManager().makePathRequest( context.infoSub, lpLedger, context.params); diff --git a/src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp b/src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp index b7edfb6dbe..923cb0f7f5 100644 --- a/src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp +++ b/src/xrpld/rpc/handlers/orderbook/RipplePathFind.cpp @@ -21,12 +21,12 @@ namespace xrpl { // This interface is deprecated. json::Value -doRipplePathFind(RPC::JsonContext& context) +doRipplePathFind(rpc::JsonContext& context) { if (context.app.config().pathSearchMax == 0) return rpcError(RpcNotSupported); - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; std::shared_ptr lpLedger; json::Value jvResult; @@ -37,7 +37,7 @@ doRipplePathFind(RPC::JsonContext& context) // No ledger specified, use pathfinding defaults // and dispatch to pathfinding engine if (context.app.getLedgerMaster().getValidatedLedgerAge() > - RPC::Tuning::kMaxValidatedLedgerAge) + rpc::tuning::kMaxValidatedLedgerAge) { if (context.apiVersion == 1) return rpcError(RpcNoNetwork); @@ -146,11 +146,11 @@ doRipplePathFind(RPC::JsonContext& context) } // The caller specified a ledger - jvResult = RPC::lookupLedger(lpLedger, context); + jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; - RPC::LegacyPathFind const lpf(isUnlimited(context.role), context.app); + rpc::LegacyPathFind const lpf(isUnlimited(context.role), context.app); if (!lpf.isOk()) return rpcError(RpcTooBusy); diff --git a/src/xrpld/rpc/handlers/server_info/Feature.cpp b/src/xrpld/rpc/handlers/server_info/Feature.cpp index bd7198b61c..1906658106 100644 --- a/src/xrpld/rpc/handlers/server_info/Feature.cpp +++ b/src/xrpld/rpc/handlers/server_info/Feature.cpp @@ -18,7 +18,7 @@ namespace xrpl { // vetoed : true/false // } json::Value -doFeature(RPC::JsonContext& context) +doFeature(rpc::JsonContext& context) { if (context.params.isMember(jss::feature)) { diff --git a/src/xrpld/rpc/handlers/server_info/Fee.cpp b/src/xrpld/rpc/handlers/server_info/Fee.cpp index 1fe5476d50..2e4147fc1e 100644 --- a/src/xrpld/rpc/handlers/server_info/Fee.cpp +++ b/src/xrpld/rpc/handlers/server_info/Fee.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doFee(RPC::JsonContext& context) +doFee(rpc::JsonContext& context) { auto result = context.app.getTxQ().doRPC(context.app); if (result.type() == json::ValueType::Object) @@ -16,7 +16,7 @@ doFee(RPC::JsonContext& context) // LCOV_EXCL_START UNREACHABLE("xrpl::doFee : invalid result type"); - RPC::injectError(RpcInternal, context.params); + rpc::injectError(RpcInternal, context.params); return context.params; // LCOV_EXCL_STOP } diff --git a/src/xrpld/rpc/handlers/server_info/Manifest.cpp b/src/xrpld/rpc/handlers/server_info/Manifest.cpp index cb1771750b..c0b29d8275 100644 --- a/src/xrpld/rpc/handlers/server_info/Manifest.cpp +++ b/src/xrpld/rpc/handlers/server_info/Manifest.cpp @@ -12,12 +12,12 @@ namespace xrpl { json::Value -doManifest(RPC::JsonContext& context) +doManifest(rpc::JsonContext& context) { auto& params = context.params; if (!params.isMember(jss::public_key)) - return RPC::missingFieldError(jss::public_key); + return rpc::missingFieldError(jss::public_key); auto const requested = params[jss::public_key].asString(); @@ -27,7 +27,7 @@ doManifest(RPC::JsonContext& context) auto const pk = parseBase58(TokenType::NodePublic, requested); if (!pk) { - RPC::injectError(RpcInvalidParams, ret); + rpc::injectError(RpcInvalidParams, ret); return ret; } diff --git a/src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp b/src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp index cce1b3e07f..b561ce6d38 100644 --- a/src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp +++ b/src/xrpld/rpc/handlers/server_info/ServerDefinitions.cpp @@ -382,7 +382,7 @@ getServerDefinitionsJson() } json::Value -doServerDefinitions(RPC::JsonContext& context) +doServerDefinitions(rpc::JsonContext& context) { auto& params = context.params; @@ -390,7 +390,7 @@ doServerDefinitions(RPC::JsonContext& context) if (params.isMember(jss::hash)) { if (!params[jss::hash].isString() || !hash.parseHex(params[jss::hash].asString())) - return RPC::invalidFieldError(jss::hash); + return rpc::invalidFieldError(jss::hash); } auto const& defs = detail::getDefinitions(); diff --git a/src/xrpld/rpc/handlers/server_info/ServerInfo.cpp b/src/xrpld/rpc/handlers/server_info/ServerInfo.cpp index aaad9d2b02..fd6e2f717f 100644 --- a/src/xrpld/rpc/handlers/server_info/ServerInfo.cpp +++ b/src/xrpld/rpc/handlers/server_info/ServerInfo.cpp @@ -9,7 +9,7 @@ namespace xrpl { json::Value -doServerInfo(RPC::JsonContext& context) +doServerInfo(rpc::JsonContext& context) { json::Value ret(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/server_info/ServerState.cpp b/src/xrpld/rpc/handlers/server_info/ServerState.cpp index acf4e9eb43..e0d43d4053 100644 --- a/src/xrpld/rpc/handlers/server_info/ServerState.cpp +++ b/src/xrpld/rpc/handlers/server_info/ServerState.cpp @@ -8,7 +8,7 @@ namespace xrpl { json::Value -doServerState(RPC::JsonContext& context) +doServerState(rpc::JsonContext& context) { json::Value ret(json::ValueType::Object); diff --git a/src/xrpld/rpc/handlers/server_info/Version.h b/src/xrpld/rpc/handlers/server_info/Version.h index f25d8679ba..40ad4e5e71 100644 --- a/src/xrpld/rpc/handlers/server_info/Version.h +++ b/src/xrpld/rpc/handlers/server_info/Version.h @@ -9,7 +9,7 @@ #include #include -namespace xrpl::RPC { +namespace xrpl::rpc { class VersionHandler { @@ -34,9 +34,9 @@ public: // NOLINTBEGIN(readability-identifier-naming) static constexpr char const* name = "version"; - static constexpr unsigned minApiVer = RPC::kApiMinimumSupportedVersion; + static constexpr unsigned minApiVer = rpc::kApiMinimumSupportedVersion; - static constexpr unsigned maxApiVer = RPC::kApiMaximumValidVersion; + static constexpr unsigned maxApiVer = rpc::kApiMaximumValidVersion; static constexpr Role role = Role::USER; @@ -48,4 +48,4 @@ private: bool betaEnabled_; }; -} // namespace xrpl::RPC +} // namespace xrpl::rpc diff --git a/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp b/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp index 93840bb6d6..7ce432c49e 100644 --- a/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp +++ b/src/xrpld/rpc/handlers/subscribe/Subscribe.cpp @@ -27,7 +27,7 @@ namespace xrpl { json::Value -doSubscribe(RPC::JsonContext& context) +doSubscribe(rpc::JsonContext& context) { InfoSub::pointer ispSub; json::Value jvResult(json::ValueType::Object); @@ -79,7 +79,7 @@ doSubscribe(RPC::JsonContext& context) } catch (std::runtime_error const& ex) { - return RPC::makeParamError(ex.what()); + return rpc::makeParamError(ex.what()); } } else @@ -174,7 +174,7 @@ doSubscribe(RPC::JsonContext& context) if (!context.params[accountsProposed].isArray()) return rpcError(RpcInvalidParams); - auto ids = RPC::parseAccountIds(context.params[accountsProposed]); + auto ids = rpc::parseAccountIds(context.params[accountsProposed]); if (ids.empty()) return rpcError(RpcActMalformed); context.netOps.subAccount(ispSub, ids, true); @@ -185,7 +185,7 @@ doSubscribe(RPC::JsonContext& context) if (!context.params[jss::accounts].isArray()) return rpcError(RpcInvalidParams); - auto ids = RPC::parseAccountIds(context.params[jss::accounts]); + auto ids = rpc::parseAccountIds(context.params[jss::accounts]); if (ids.empty()) return rpcError(RpcActMalformed); context.netOps.subAccount(ispSub, ids, false); @@ -197,7 +197,7 @@ doSubscribe(RPC::JsonContext& context) if (!context.app.config().useTxTables()) return rpcError(RpcNotEnabled); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; auto const& req = context.params[jss::account_history_tx_stream]; if (!req.isMember(jss::account) || !req[jss::account].isString()) return rpcError(RpcInvalidParams); @@ -230,11 +230,11 @@ doSubscribe(RPC::JsonContext& context) Book book; - if (auto const err = RPC::parseSubUnsubJson(book.in, j, jss::taker_pays, context.j); + if (auto const err = rpc::parseSubUnsubJson(book.in, j, jss::taker_pays, context.j); err != RpcSuccess) return rpcError(err); - if (auto const err = RPC::parseSubUnsubJson(book.out, j, jss::taker_gets, context.j); + if (auto const err = rpc::parseSubUnsubJson(book.out, j, jss::taker_gets, context.j); err != RpcSuccess) return rpcError(err); @@ -285,7 +285,7 @@ doSubscribe(RPC::JsonContext& context) if ((j.isMember(jss::snapshot) && j[jss::snapshot].asBool()) || (j.isMember(jss::state_now) && j[jss::state_now].asBool())) { - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; std::shared_ptr lpLedger = context.app.getLedgerMaster().getPublishedLedger(); if (lpLedger) @@ -299,7 +299,7 @@ doSubscribe(RPC::JsonContext& context) field == jss::asks ? reversed(book) : book, takerID ? *takerID : noAccount(), false, - RPC::Tuning::kBookOffers.rDefault, + rpc::tuning::kBookOffers.rDefault, jvMarker, jvOffers); diff --git a/src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp b/src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp index af42af2a55..33c785a9bb 100644 --- a/src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp +++ b/src/xrpld/rpc/handlers/subscribe/Unsubscribe.cpp @@ -18,7 +18,7 @@ namespace xrpl { json::Value -doUnsubscribe(RPC::JsonContext& context) +doUnsubscribe(rpc::JsonContext& context) { InfoSub::pointer ispSub; json::Value jvResult(json::ValueType::Object); @@ -106,7 +106,7 @@ doUnsubscribe(RPC::JsonContext& context) if (!context.params[accountsProposed].isArray()) return rpcError(RpcInvalidParams); - auto ids = RPC::parseAccountIds(context.params[accountsProposed]); + auto ids = rpc::parseAccountIds(context.params[accountsProposed]); if (ids.empty()) return rpcError(RpcActMalformed); context.netOps.unsubAccount(ispSub, ids, true); @@ -117,7 +117,7 @@ doUnsubscribe(RPC::JsonContext& context) if (!context.params[jss::accounts].isArray()) return rpcError(RpcInvalidParams); - auto ids = RPC::parseAccountIds(context.params[jss::accounts]); + auto ids = rpc::parseAccountIds(context.params[jss::accounts]); if (ids.empty()) return rpcError(RpcActMalformed); context.netOps.unsubAccount(ispSub, ids, false); @@ -161,11 +161,11 @@ doUnsubscribe(RPC::JsonContext& context) Book book; - if (auto const err = RPC::parseSubUnsubJson(book.in, jv, jss::taker_pays, context.j); + if (auto const err = rpc::parseSubUnsubJson(book.in, jv, jss::taker_pays, context.j); err != RpcSuccess) return rpcError(err); - if (auto const err = RPC::parseSubUnsubJson(book.out, jv, jss::taker_gets, context.j); + if (auto const err = rpc::parseSubUnsubJson(book.out, jv, jss::taker_gets, context.j); err != RpcSuccess) return rpcError(err); diff --git a/src/xrpld/rpc/handlers/transaction/Simulate.cpp b/src/xrpld/rpc/handlers/transaction/Simulate.cpp index 0f163c7356..8441add08b 100644 --- a/src/xrpld/rpc/handlers/transaction/Simulate.cpp +++ b/src/xrpld/rpc/handlers/transaction/Simulate.cpp @@ -44,7 +44,7 @@ namespace xrpl { static std::expected -getAutofillSequence(json::Value const& txJson, RPC::JsonContext& context) +getAutofillSequence(json::Value const& txJson, rpc::JsonContext& context) { // autofill Sequence bool const hasTicketSeq = txJson.isMember(sfTicketSequence.jsonName); @@ -53,14 +53,14 @@ getAutofillSequence(json::Value const& txJson, RPC::JsonContext& context) { // sanity check, should fail earlier // LCOV_EXCL_START - return std::unexpected(RPC::invalidFieldError("tx.Account")); + return std::unexpected(rpc::invalidFieldError("tx.Account")); // LCOV_EXCL_STOP } auto const srcAddressID = parseBase58(accountStr.asString()); if (!srcAddressID.has_value()) { return std::unexpected( - RPC::makeError(RpcSrcActMalformed, RPC::invalidFieldMessage("tx.Account"))); + rpc::makeError(RpcSrcActMalformed, rpc::invalidFieldMessage("tx.Account"))); } SLE::const_pointer const sle = context.app.getOpenLedger().current()->read(keylet::account(*srcAddressID)); @@ -88,7 +88,7 @@ autofillSignature(json::Value& sigObject, std::string const& fieldPrefix = "tx") if (sigObject.isMember(jss::Signers)) { if (!sigObject[jss::Signers].isArray()) - return RPC::invalidFieldError(fieldPrefix + ".Signers"); + return rpc::invalidFieldError(fieldPrefix + ".Signers"); // check multisigned signers for (unsigned index = 0; index < sigObject[jss::Signers].size(); index++) { @@ -96,7 +96,7 @@ autofillSignature(json::Value& sigObject, std::string const& fieldPrefix = "tx") if (!signer.isObject() || !signer.isMember(jss::Signer) || !signer[jss::Signer].isObject()) { - return RPC::invalidFieldError( + return rpc::invalidFieldError( fieldPrefix + ".Signers[" + std::to_string(index) + "]"); } @@ -133,7 +133,7 @@ autofillSignature(json::Value& sigObject, std::string const& fieldPrefix = "tx") } static std::optional -autofillTx(json::Value& txJson, RPC::JsonContext& context) +autofillTx(json::Value& txJson, rpc::JsonContext& context) { if (auto error = autofillSignature(txJson)) return error; @@ -142,7 +142,7 @@ autofillTx(json::Value& txJson, RPC::JsonContext& context) { auto& sponsorSignature = txJson[sfSponsorSignature.jsonName]; if (!sponsorSignature.isObject()) - return RPC::objectFieldError(sfSponsorSignature.jsonName); + return rpc::objectFieldError(sfSponsorSignature.jsonName); if (auto const error = autofillSignature(sponsorSignature, "tx.SponsorSignature")) return error; @@ -167,7 +167,7 @@ autofillTx(json::Value& txJson, RPC::JsonContext& context) { // Autofill Fee after normalizing nested signer fields so the fee // estimator sees the full transaction shape. - auto feeOrError = RPC::getCurrentNetworkFee( + auto feeOrError = rpc::getCurrentNetworkFee( context.role, context.app.config(), context.app.getFeeTrack(), @@ -191,18 +191,18 @@ getTxJsonFromParams(json::Value const& params) { if (params.isMember(jss::tx_json)) { - return RPC::makeParamError("Can only include one of `tx_blob` and `tx_json`."); + return rpc::makeParamError("Can only include one of `tx_blob` and `tx_json`."); } auto const txBlob = params[jss::tx_blob]; if (!txBlob.isString()) { - return RPC::invalidFieldError(jss::tx_blob); + return rpc::invalidFieldError(jss::tx_blob); } auto unHexed = strUnHex(txBlob.asString()); if (!unHexed || unHexed->empty()) - return RPC::invalidFieldError(jss::tx_blob); + return rpc::invalidFieldError(jss::tx_blob); try { @@ -211,7 +211,7 @@ getTxJsonFromParams(json::Value const& params) } catch (std::runtime_error const&) { - return RPC::invalidFieldError(jss::tx_blob); + return rpc::invalidFieldError(jss::tx_blob); } } else if (params.isMember(jss::tx_json)) @@ -219,30 +219,30 @@ getTxJsonFromParams(json::Value const& params) txJson = params[jss::tx_json]; if (!txJson.isObject()) { - return RPC::objectFieldError(jss::tx_json); + return rpc::objectFieldError(jss::tx_json); } } else { - return RPC::makeParamError("Neither `tx_blob` nor `tx_json` included."); + return rpc::makeParamError("Neither `tx_blob` nor `tx_json` included."); } // basic sanity checks for transaction shape if (!txJson.isMember(jss::TransactionType)) { - return RPC::missingFieldError("tx.TransactionType"); + return rpc::missingFieldError("tx.TransactionType"); } if (!txJson.isMember(jss::Account)) { - return RPC::missingFieldError("tx.Account"); + return rpc::missingFieldError("tx.Account"); } return txJson; } static json::Value -simulateTxn(RPC::JsonContext& context, std::shared_ptr transaction) +simulateTxn(rpc::JsonContext& context, std::shared_ptr transaction) { json::Value jvResult; // Process the transaction @@ -290,11 +290,11 @@ simulateTxn(RPC::JsonContext& context, std::shared_ptr transaction) else { jvResult[jss::meta] = result.metadata->getJson(JsonOptions::Values::None); - RPC::insertDeliveredAmount( + rpc::insertDeliveredAmount( jvResult[jss::meta], view, transaction->getSTransaction(), *result.metadata); - RPC::insertNFTSyntheticInJson( + rpc::insertNFTSyntheticInJson( jvResult, transaction->getSTransaction(), *result.metadata); - RPC::insertMPTokenIssuanceID( + rpc::insertMPTokenIssuanceID( jvResult[jss::meta], transaction->getSTransaction(), *result.metadata); } } @@ -317,23 +317,23 @@ simulateTxn(RPC::JsonContext& context, std::shared_ptr transaction) // binary: // } json::Value -doSimulate(RPC::JsonContext& context) +doSimulate(rpc::JsonContext& context) { - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; json::Value txJson; // the tx as a JSON // check validity of `binary` param if (context.params.isMember(jss::binary) && !context.params[jss::binary].isBool()) { - return RPC::invalidFieldError(jss::binary); + return rpc::invalidFieldError(jss::binary); } for (auto const field : {jss::secret, jss::seed, jss::seed_hex, jss::passphrase}) { if (context.params.isMember(field)) { - return RPC::invalidFieldError(field); + return rpc::invalidFieldError(field); } } @@ -365,13 +365,13 @@ doSimulate(RPC::JsonContext& context) if (stTx->getTxnType() == ttBATCH) { - return RPC::makeError(RpcNotImpl); + return rpc::makeError(RpcNotImpl); } // Reject transactions with the tfInnerBatchTxn flag. if (stTx->isFlag(tfInnerBatchTxn)) { - return RPC::makeError( + return rpc::makeError( RpcInvalidParams, "tfInnerBatchTxn flag is not allowed on top-level transactions."); } diff --git a/src/xrpld/rpc/handlers/transaction/Submit.cpp b/src/xrpld/rpc/handlers/transaction/Submit.cpp index 79f3680684..05a1552221 100644 --- a/src/xrpld/rpc/handlers/transaction/Submit.cpp +++ b/src/xrpld/rpc/handlers/transaction/Submit.cpp @@ -27,11 +27,11 @@ namespace xrpl { static std::expected -getFailHard(RPC::JsonContext const& context) +getFailHard(rpc::JsonContext const& context) { if (context.params.isMember(jss::fail_hard) && !context.params[jss::fail_hard].isBool()) { - return std::unexpected(RPC::expectedFieldError(jss::fail_hard, "boolean")); + return std::unexpected(rpc::expectedFieldError(jss::fail_hard, "boolean")); } return NetworkOPs::doFailHard( context.params.isMember(jss::fail_hard) && context.params[jss::fail_hard].asBool()); @@ -42,9 +42,9 @@ getFailHard(RPC::JsonContext const& context) // secret: // } json::Value -doSubmit(RPC::JsonContext& context) +doSubmit(rpc::JsonContext& context) { - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; if (!context.params.isMember(jss::tx_blob)) { @@ -53,16 +53,16 @@ doSubmit(RPC::JsonContext& context) return failType.error(); if (context.role != Role::ADMIN && !context.app.config().canSign()) - return RPC::makeError(RpcNotSupported, "Signing is not supported by this server."); + return rpc::makeError(RpcNotSupported, "Signing is not supported by this server."); - auto ret = RPC::transactionSubmit( + auto ret = rpc::transactionSubmit( context.params, context.apiVersion, *failType, context.role, context.ledgerMaster.getValidatedLedgerAge(), context.app, - RPC::getProcessTxnFn(context.netOps)); + rpc::getProcessTxnFn(context.netOps)); ret[jss::deprecated] = "Signing support in the 'submit' command has been " diff --git a/src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp b/src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp index cc04ed073e..09301ca8a6 100644 --- a/src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp +++ b/src/xrpld/rpc/handlers/transaction/SubmitMultiSigned.cpp @@ -13,20 +13,20 @@ namespace xrpl { // tx_json: , // } json::Value -doSubmitMultiSigned(RPC::JsonContext& context) +doSubmitMultiSigned(rpc::JsonContext& context) { - context.loadType = Resource::kFeeHeavyBurdenRpc; + context.loadType = resource::kFeeHeavyBurdenRpc; auto const failHard = context.params[jss::fail_hard].asBool(); auto const failType = NetworkOPs::doFailHard(failHard); - return RPC::transactionSubmitMultiSigned( + return rpc::transactionSubmitMultiSigned( context.params, context.apiVersion, failType, context.role, context.ledgerMaster.getValidatedLedgerAge(), context.app, - RPC::getProcessTxnFn(context.netOps)); + rpc::getProcessTxnFn(context.netOps)); } } // namespace xrpl diff --git a/src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp b/src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp index bb68226334..2bd97e852f 100644 --- a/src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp +++ b/src/xrpld/rpc/handlers/transaction/TransactionEntry.cpp @@ -21,10 +21,10 @@ namespace xrpl { // XXX In this case, not specify either ledger does not mean ledger current. It // means any ledger. json::Value -doTransactionEntry(RPC::JsonContext& context) +doTransactionEntry(rpc::JsonContext& context) { std::shared_ptr lpLedger; - json::Value jvResult = RPC::lookupLedger(lpLedger, context); + json::Value jvResult = rpc::lookupLedger(lpLedger, context); if (!lpLedger) return jvResult; @@ -84,7 +84,7 @@ doTransactionEntry(RPC::JsonContext& context) jvResult[jss::tx_json] = sttx->getJson(JsonOptions::Values::None); } - RPC::insertDeliverMax(jvResult[jss::tx_json], sttx->getTxnType(), context.apiVersion); + rpc::insertDeliverMax(jvResult[jss::tx_json], sttx->getTxnType(), context.apiVersion); auto const jsonMeta = (context.apiVersion > 1 ? jss::meta : jss::metadata); if (stobj) diff --git a/src/xrpld/rpc/handlers/transaction/Tx.cpp b/src/xrpld/rpc/handlers/transaction/Tx.cpp index c065bc268e..ee7110bf6b 100644 --- a/src/xrpld/rpc/handlers/transaction/Tx.cpp +++ b/src/xrpld/rpc/handlers/transaction/Tx.cpp @@ -68,8 +68,8 @@ struct TxArgs std::optional> ledgerRange; }; -std::pair -doTxHelp(RPC::Context& context, TxArgs args) +std::pair +doTxHelp(rpc::Context& context, TxArgs args) { TxResult result; @@ -169,7 +169,7 @@ doTxHelp(RPC::Context& context, TxArgs args) uint32_t const netID = context.app.getNetworkIDService().getNetworkID(); if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL) - result.ctid = RPC::encodeCTID(lgrSeq, txnIdx, netID); + result.ctid = rpc::encodeCTID(lgrSeq, txnIdx, netID); } } @@ -178,12 +178,12 @@ doTxHelp(RPC::Context& context, TxArgs args) json::Value populateJsonResponse( - std::pair const& res, + std::pair const& res, TxArgs const& args, - RPC::JsonContext const& context) + rpc::JsonContext const& context) { json::Value response; - RPC::Status const& error = res.second; + rpc::Status const& error = res.second; TxResult const& result = res.first; // handle errors if (error.toErrorCode() != RpcSuccess) @@ -215,7 +215,7 @@ populateJsonResponse( else { response[jss::tx_json] = result.txn->getJson(kOptionsJson); - RPC::insertDeliverMax( + rpc::insertDeliverMax( response[jss::tx_json], sttx->getTxnType(), context.apiVersion); } @@ -236,7 +236,7 @@ populateJsonResponse( { response = result.txn->getJson(JsonOptions::Values::IncludeDate, args.binary); if (!args.binary) - RPC::insertDeliverMax(response, sttx->getTxnType(), context.apiVersion); + rpc::insertDeliverMax(response, sttx->getTxnType(), context.apiVersion); } // populate binary metadata @@ -254,8 +254,8 @@ populateJsonResponse( { response[jss::meta] = meta->getJson(JsonOptions::Values::None); insertDeliveredAmount(response[jss::meta], context, result.txn, *meta); - RPC::insertNFTSyntheticInJson(response, sttx, *meta); - RPC::insertMPTokenIssuanceID(response[jss::meta], sttx, *meta); + rpc::insertNFTSyntheticInJson(response, sttx, *meta); + rpc::insertMPTokenIssuanceID(response[jss::meta], sttx, *meta); } } response[jss::validated] = result.validated; @@ -267,7 +267,7 @@ populateJsonResponse( } json::Value -doTxJson(RPC::JsonContext& context) +doTxJson(rpc::JsonContext& context) { if (!context.app.config().useTxTables()) return rpcError(RpcNotEnabled); @@ -291,7 +291,7 @@ doTxJson(RPC::JsonContext& context) } else if (context.params.isMember(jss::ctid)) { - auto ctid = RPC::decodeCTID(context.params[jss::ctid].asString()); + auto ctid = rpc::decodeCTID(context.params[jss::ctid].asString()); if (!ctid) return rpcError(RpcInvalidParams); @@ -302,7 +302,7 @@ doTxJson(RPC::JsonContext& context) out << "Wrong network. You should submit this request to a node " "running on NetworkID: " << net_id; - return RPC::makeError(RpcWrongNetwork, out.str()); + return rpc::makeError(RpcWrongNetwork, out.str()); } args.ctid = {lgr_seq, txn_idx}; } @@ -327,7 +327,7 @@ doTxJson(RPC::JsonContext& context) } } - std::pair const res = doTxHelp(context, args); + std::pair const res = doTxHelp(context, args); return populateJsonResponse(res, args, context); } diff --git a/src/xrpld/rpc/handlers/transaction/TxHistory.cpp b/src/xrpld/rpc/handlers/transaction/TxHistory.cpp index a45046773c..2d5ad8cbe5 100644 --- a/src/xrpld/rpc/handlers/transaction/TxHistory.cpp +++ b/src/xrpld/rpc/handlers/transaction/TxHistory.cpp @@ -16,12 +16,12 @@ namespace xrpl { // start: // } json::Value -doTxHistory(RPC::JsonContext& context) +doTxHistory(rpc::JsonContext& context) { if (!context.app.config().useTxTables()) return rpcError(RpcNotEnabled); - context.loadType = Resource::kFeeMediumBurdenRpc; + context.loadType = resource::kFeeMediumBurdenRpc; if (!context.params.isMember(jss::start)) return rpcError(RpcInvalidParams); @@ -40,7 +40,7 @@ doTxHistory(RPC::JsonContext& context) for (auto const& t : trans) { json::Value txJson = t->getJson(JsonOptions::Values::None); - RPC::insertDeliverMax(txJson, t->getSTransaction()->getTxnType(), context.apiVersion); + rpc::insertDeliverMax(txJson, t->getSTransaction()->getTxnType(), context.apiVersion); txs.append(txJson); } diff --git a/src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp b/src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp index edc4eff057..8956603012 100644 --- a/src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp +++ b/src/xrpld/rpc/handlers/transaction/TxReduceRelay.cpp @@ -7,7 +7,7 @@ namespace xrpl { json::Value -doTxReduceRelay(RPC::JsonContext& context) +doTxReduceRelay(rpc::JsonContext& context) { return context.app.getOverlay().txMetrics(); } diff --git a/src/xrpld/rpc/handlers/utility/Ping.cpp b/src/xrpld/rpc/handlers/utility/Ping.cpp index 0d34b9e0fc..68fb06456e 100644 --- a/src/xrpld/rpc/handlers/utility/Ping.cpp +++ b/src/xrpld/rpc/handlers/utility/Ping.cpp @@ -6,12 +6,12 @@ namespace xrpl { -namespace RPC { +namespace rpc { struct JsonContext; -} // namespace RPC +} // namespace rpc json::Value -doPing(RPC::JsonContext& context) +doPing(rpc::JsonContext& context) { json::Value ret(json::ValueType::Object); switch (context.role) diff --git a/src/xrpld/rpc/handlers/utility/Random.cpp b/src/xrpld/rpc/handlers/utility/Random.cpp index 56df442cf1..d3428ee6e9 100644 --- a/src/xrpld/rpc/handlers/utility/Random.cpp +++ b/src/xrpld/rpc/handlers/utility/Random.cpp @@ -10,16 +10,16 @@ namespace xrpl { -namespace RPC { +namespace rpc { struct JsonContext; -} // namespace RPC +} // namespace rpc // Result: // { // random: // } json::Value -doRandom(RPC::JsonContext& context) +doRandom(rpc::JsonContext& context) { // TODO(tom): the try/catch is almost certainly redundant, we catch at the // top level too. diff --git a/tests/conan/src/example.cpp b/tests/conan/src/example.cpp index acfb253a7d..4720af4384 100644 --- a/tests/conan/src/example.cpp +++ b/tests/conan/src/example.cpp @@ -5,6 +5,6 @@ int main(int argc, char const** argv) { - std::printf("%s\n", xrpl::BuildInfo::getVersionString().c_str()); + std::printf("%s\n", xrpl::build_info::getVersionString().c_str()); return 0; }