From d3c89fe00e2dd2d62ff5b61c8788055bebfea86a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 27 Jul 2026 17:33:31 -0400 Subject: [PATCH 1/3] fix: Assorted clang-tidy fixes --- .../detail/aged_unordered_container.h | 40 +++++++++---------- include/xrpl/beast/rfc2616.h | 4 +- include/xrpl/core/HashRouter.h | 26 +++++------- include/xrpl/protocol/MultiApiJson.h | 1 + include/xrpl/rdb/RelationalDatabase.h | 2 +- include/xrpl/server/detail/BaseHTTPPeer.h | 6 +-- include/xrpl/server/detail/BaseWSPeer.h | 4 +- include/xrpl/server/detail/PlainWSPeer.h | 2 +- include/xrpl/server/detail/SSLHTTPPeer.h | 2 +- include/xrpl/server/detail/SSLWSPeer.h | 4 +- include/xrpl/server/detail/ServerImpl.h | 6 +-- include/xrpl/server/detail/io_list.h | 2 +- src/xrpld/app/consensus/RCLCxPeerPos.h | 14 +++---- src/xrpld/app/misc/NegativeUNLVote.h | 4 +- src/xrpld/app/misc/NetworkOPs.cpp | 18 ++++----- src/xrpld/app/misc/Transaction.h | 22 +++++----- src/xrpld/app/misc/ValidatorList.h | 10 ++--- src/xrpld/rpc/ServerHandler.h | 2 +- 18 files changed, 81 insertions(+), 88 deletions(-) diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index c4287b1ca12..a3645d10414 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -126,7 +126,7 @@ class AgedUnorderedContainer { } - value_type value; + value_type value{}; time_point when; }; @@ -415,31 +415,31 @@ class AgedUnorderedContainer bucket_type, typename std::allocator_traits::template rebind_alloc>; - Buckets() : maxLoadFactor_(1.f), vec_() + Buckets() : maxLoadFactor_(1.f), vec() { - vec_.resize(cont_type::suggested_upper_bucket_count(0)); + vec.resize(cont_type::suggested_upper_bucket_count(0)); } - Buckets(Allocator const& alloc) : maxLoadFactor_(1.f), vec_(alloc) + Buckets(Allocator const& alloc) : maxLoadFactor_(1.f), vec(alloc) { - vec_.resize(cont_type::suggested_upper_bucket_count(0)); + vec.resize(cont_type::suggested_upper_bucket_count(0)); } operator bucket_traits() { - return bucket_traits(&vec_[0], vec_.size()); + return bucket_traits(&vec[0], vec.size()); } void clear() { - vec_.clear(); + vec.clear(); } [[nodiscard]] size_type maxBucketCount() const { - return vec_.max_size(); + return vec.max_size(); } float& @@ -459,17 +459,17 @@ class AgedUnorderedContainer void rehash(size_type count, Container& c) { - size_type const size(vec_.size()); + size_type const size(vec.size()); if (count == size) return; - if (count > vec_.capacity()) + if (count > vec.capacity()) { // Need two vectors otherwise we // will destroy non-empty buckets. - vec_type vec(vec_.get_allocator()); - std::swap(vec_, vec); - vec_.resize(count); - c.rehash(bucket_traits(&vec_[0], vec_.size())); + vec_type tmp(vec.get_allocator()); + std::swap(tmp, vec); + vec.resize(count); + c.rehash(bucket_traits(&vec[0], vec.size())); return; } // Rehash in place. @@ -477,14 +477,14 @@ class AgedUnorderedContainer { // This should not reallocate since // we checked capacity earlier. - vec_.resize(count); - c.rehash(bucket_traits(&vec_[0], count)); + vec.resize(count); + c.rehash(bucket_traits(&vec[0], count)); return; } // Resize must happen after rehash otherwise // we might destroy non-empty buckets. - c.rehash(bucket_traits(&vec_[0], count)); - vec_.resize(count); + c.rehash(bucket_traits(&vec[0], count)); + vec.resize(count); } // Resize the buckets to accommodate at least n items. @@ -498,7 +498,7 @@ class AgedUnorderedContainer private: float maxLoadFactor_; - vec_type vec_; + vec_type vec{}; }; template @@ -1455,7 +1455,7 @@ class AgedUnorderedContainer private: ConfigT config_; Buckets buck_; - cont_type mutable cont_; + cont_type mutable cont_{}; }; //------------------------------------------------------------------------------ diff --git a/include/xrpl/beast/rfc2616.h b/include/xrpl/beast/rfc2616.h index 1986568553e..8739d481702 100644 --- a/include/xrpl/beast/rfc2616.h +++ b/include/xrpl/beast/rfc2616.h @@ -206,8 +206,8 @@ class ListIterator { using iter_type = boost::string_ref::const_iterator; - iter_type it_; - iter_type end_; + iter_type it_{}; + iter_type end_{}; boost::string_ref value_; public: diff --git a/include/xrpl/core/HashRouter.h b/include/xrpl/core/HashRouter.h index 20aafecc5f7..b50d6cd23e0 100644 --- a/include/xrpl/core/HashRouter.h +++ b/include/xrpl/core/HashRouter.h @@ -40,9 +40,8 @@ enum class HashRouterFlags : std::uint16_t { constexpr HashRouterFlags operator|(HashRouterFlags lhs, HashRouterFlags rhs) { - return static_cast( - static_cast>(lhs) | - static_cast>(rhs)); + using U = std::underlying_type_t; + return static_cast(static_cast(lhs) | static_cast(rhs)); } constexpr HashRouterFlags& @@ -55,9 +54,8 @@ operator|=(HashRouterFlags& lhs, HashRouterFlags rhs) constexpr HashRouterFlags operator&(HashRouterFlags lhs, HashRouterFlags rhs) { - return static_cast( - static_cast>(lhs) & - static_cast>(rhs)); + using U = std::underlying_type_t; + return static_cast(static_cast(lhs) & static_cast(rhs)); } constexpr HashRouterFlags& @@ -130,7 +128,7 @@ class HashRouter addPeer(PeerShortID peer) { if (peer != 0) - peers_.insert(peer); + peers.insert(peer); } [[nodiscard]] HashRouterFlags @@ -151,7 +149,7 @@ class HashRouter std::set releasePeerSet() { - return std::move(peers_); + return std::move(peers); } /** @@ -173,24 +171,18 @@ class HashRouter bool shouldRelay(Stopwatch::time_point const& now, std::chrono::seconds relayTime) { - if (relayed_ && *relayed_ + relayTime > now) - return false; - relayed_.emplace(now); - return true; + return !relayed_ && *relayed_ + relayTime > now; } bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval) { - if (processed_ && ((*processed_ + interval) > now)) - return false; - processed_.emplace(now); - return true; + return !processed_ && ((*processed_ + interval) > now); } private: HashRouterFlags flags_ = HashRouterFlags::UNDEFINED; - std::set peers_; + std::set peers{}; // This could be generalized to a map, if more // than one flag needs to expire independently. std::optional relayed_; diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 9a4882ec558..6c3b67fb870 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -14,6 +14,7 @@ namespace xrpl { namespace detail { + template constexpr bool kIsIntegralConstant = false; template diff --git a/include/xrpl/rdb/RelationalDatabase.h b/include/xrpl/rdb/RelationalDatabase.h index e5784c74180..01a2c9b2133 100644 --- a/include/xrpl/rdb/RelationalDatabase.h +++ b/include/xrpl/rdb/RelationalDatabase.h @@ -123,7 +123,7 @@ class RelationalDatabase struct AccountTxResult { - std::variant transactions; + std::variant transactions{}; LedgerRange ledgerRange{}; uint32_t limit = 0; std::optional marker; diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index c7553c1da3d..c1376edb652 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -58,7 +58,7 @@ class BaseHTTPPeer : public IOList::Work, public Session memcpy(data.get(), ptr, len); } - std::unique_ptr data; + std::unique_ptr data{}; std::size_t bytes; std::size_t used{0}; }; @@ -75,8 +75,8 @@ class BaseHTTPPeer : public IOList::Work, public Session boost::asio::streambuf readBuf_; http_request_type message_; - std::vector wq_; - std::vector wq2_; + std::vector wq_{}; + std::vector wq2_{}; std::mutex mutex_; bool graceful_ = false; bool complete_ = false; diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 59a866ab8c1..3e1a1e956ee 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -49,7 +49,7 @@ class BaseWSPeer : public BasePeer, public WSSession http_request_type request_; boost::beast::multi_buffer rb_; boost::beast::multi_buffer wb_; - std::list> wq_; + std::list> wq_{}; /** * The socket has been closed, or will close after the next write * finishes. Do not do any more writes, and don't try to close @@ -60,7 +60,7 @@ class BaseWSPeer : public BasePeer, public WSSession waitable_timer timer_; bool closeOnTimer_ = false; bool pingActive_ = false; - boost::beast::websocket::ping_data payload_; + boost::beast::websocket::ping_data payload_{}; error_code ec_; std::function controlCallback_; diff --git a/include/xrpl/server/detail/PlainWSPeer.h b/include/xrpl/server/detail/PlainWSPeer.h index 279e256f515..4b9ebcc2a19 100644 --- a/include/xrpl/server/detail/PlainWSPeer.h +++ b/include/xrpl/server/detail/PlainWSPeer.h @@ -25,7 +25,7 @@ class PlainWSPeer : public BaseWSPeer>, using waitable_timer = boost::asio::basic_waitable_timer; using socket_type = boost::beast::tcp_stream; - boost::beast::websocket::stream ws_; + boost::beast::websocket::stream ws_{}; public: template diff --git a/include/xrpl/server/detail/SSLHTTPPeer.h b/include/xrpl/server/detail/SSLHTTPPeer.h index 7fe21ed6b5f..766bc177ce1 100644 --- a/include/xrpl/server/detail/SSLHTTPPeer.h +++ b/include/xrpl/server/detail/SSLHTTPPeer.h @@ -31,7 +31,7 @@ class SSLHTTPPeer : public BaseHTTPPeer>, using yield_context = boost::asio::yield_context; using error_code = boost::system::error_code; - std::unique_ptr streamPtr_; + std::unique_ptr streamPtr_{}; stream_type& stream_; socket_type& socket_; diff --git a/include/xrpl/server/detail/SSLWSPeer.h b/include/xrpl/server/detail/SSLWSPeer.h index fe522e3c9ac..475c98b6e05 100644 --- a/include/xrpl/server/detail/SSLWSPeer.h +++ b/include/xrpl/server/detail/SSLWSPeer.h @@ -33,8 +33,8 @@ class SSLWSPeer : public BaseWSPeer>, using stream_type = boost::beast::ssl_stream; using waitable_timer = boost::asio::basic_waitable_timer; - std::unique_ptr streamPtr_; - boost::beast::websocket::stream ws_; + std::unique_ptr streamPtr_{}; + boost::beast::websocket::stream ws_{}; public: template diff --git a/include/xrpl/server/detail/ServerImpl.h b/include/xrpl/server/detail/ServerImpl.h index c2e411cf9b1..1d20f70209f 100644 --- a/include/xrpl/server/detail/ServerImpl.h +++ b/include/xrpl/server/detail/ServerImpl.h @@ -81,11 +81,11 @@ class ServerImpl : public Server beast::Journal const j_; boost::asio::io_context& ioContext_; boost::asio::strand strand_; - std::optional> work_; + std::optional> work_{}; std::mutex m_; - std::vector ports_; - std::vector>> list_; + std::vector ports_{}; + std::vector>> list_{}; int high_ = 0; std::array hist_{}; diff --git a/include/xrpl/server/detail/io_list.h b/include/xrpl/server/detail/io_list.h index 7ffa85b898d..2ce14819600 100644 --- a/include/xrpl/server/detail/io_list.h +++ b/include/xrpl/server/detail/io_list.h @@ -59,7 +59,7 @@ class IOList final std::size_t n_ = 0; bool closed_ = false; std::condition_variable cv_; - boost::container::flat_map> map_; + boost::container::flat_map> map_{}; std::function f_; public: diff --git a/src/xrpld/app/consensus/RCLCxPeerPos.h b/src/xrpld/app/consensus/RCLCxPeerPos.h index 078556dea81..7ea1734211e 100644 --- a/src/xrpld/app/consensus/RCLCxPeerPos.h +++ b/src/xrpld/app/consensus/RCLCxPeerPos.h @@ -49,13 +49,13 @@ class RCLCxPeerPos /** * Verify the signing hash of the proposal */ - bool + [[nodiscard]] bool checkSign() const; /** * Signature of the proposal (not necessarily verified) */ - Slice + [[nodiscard]] Slice signature() const { return {signature_.data(), signature_.size()}; @@ -64,7 +64,7 @@ class RCLCxPeerPos /** * Public key of peer that sent the proposal */ - PublicKey const& + [[nodiscard]] PublicKey const& publicKey() const { return publicKey_; @@ -73,13 +73,13 @@ class RCLCxPeerPos /** * Unique id used by hash router to suppress duplicates */ - uint256 const& + [[nodiscard]] uint256 const& suppressionID() const { return suppression_; } - Proposal const& + [[nodiscard]] Proposal const& proposal() const { return proposal_; @@ -88,10 +88,10 @@ class RCLCxPeerPos /** * JSON representation of proposal */ - json::Value + [[nodiscard]] json::Value getJson() const; - std::string + [[nodiscard]] std::string render() const { return proposal_.render(); diff --git a/src/xrpld/app/misc/NegativeUNLVote.h b/src/xrpld/app/misc/NegativeUNLVote.h index a01bf04dcf6..55ecb156be6 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.h +++ b/src/xrpld/app/misc/NegativeUNLVote.h @@ -118,8 +118,8 @@ class NegativeUNLVote final */ struct Candidates { - std::vector toDisableCandidates; - std::vector toReEnableCandidates; + std::vector toDisableCandidates{}; + std::vector toReEnableCandidates{}; }; /** diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 47cbebb9015..26146424707 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -816,7 +816,7 @@ class NetworkOPsImp final : public NetworkOPs std::reference_wrapper registry_; beast::Journal journal_; - std::unique_ptr localTX_; + std::unique_ptr localTX_{}; std::recursive_mutex subLock_; @@ -852,13 +852,13 @@ class NetworkOPsImp final : public NetworkOPs */ using SubBookMapType = hash_map; - SubInfoMapType subAccount_; - SubInfoMapType subRTAccount_; - SubBookMapType subBook_; ///< Guarded by subLock_. + SubInfoMapType subAccount_{}; + SubInfoMapType subRTAccount_{}; + SubBookMapType subBook_{}; ///< Guarded by subLock_. - subRpcMapType rpcSubMap_; + subRpcMapType rpcSubMap_{}; - SubAccountHistoryMapType subAccountHistory_; + SubAccountHistoryMapType subAccountHistory_{}; // Used as array indices; converting to enum class would require casts at ~40 call sites. // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) @@ -875,7 +875,7 @@ class NetworkOPsImp final : public NetworkOPs SLastEntry // Any new entry must be ADDED ABOVE this one }; - std::array streamMaps_; + std::array streamMaps_{}; ServerFeeSummary lastFeeSummary_; @@ -891,11 +891,11 @@ class NetworkOPsImp final : public NetworkOPs std::condition_variable cond_; std::mutex mutex_; DispatchState dispatchState_ = DispatchState::None; - std::vector transactions_; + std::vector transactions_{}; StateAccounting accounting_; - std::set pendingValidations_; + std::set pendingValidations_{}; std::mutex validationsMutex_; private: diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index b6b6d1a8d56..9a9ef394341 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -75,25 +75,25 @@ class Transaction : public std::enable_shared_from_this, return transaction_; } - uint256 const& + [[nodiscard]] uint256 const& getID() const { return transactionID_; } - LedgerIndex + [[nodiscard]] LedgerIndex getLedger() const { return ledgerIndex_; } - bool + [[nodiscard]] bool isValidated() const { return ledgerIndex_ != 0; } - TransStatus + [[nodiscard]] TransStatus getStatus() const { return status_; @@ -146,7 +146,7 @@ class Transaction : public std::enable_shared_from_this, * * @return Whether transaction is being applied within a batch. */ - bool + [[nodiscard]] bool getApplying() const { // Note that all access to applying_ are made by NetworkOPsImp, and must @@ -199,7 +199,7 @@ class Transaction : public std::enable_shared_from_this, * @brief getSubmitResult Return submit result * @return SubmitResult struct */ - SubmitResult + [[nodiscard]] SubmitResult getSubmitResult() const { return submitResult_; @@ -276,7 +276,7 @@ class Transaction : public std::enable_shared_from_this, * @brief getCurrentLedgerState Get current ledger state of transaction * @return Current ledger state */ - std::optional + [[nodiscard]] std::optional getCurrentLedgerState() const { return currentLedgerState_; @@ -299,7 +299,7 @@ class Transaction : public std::enable_shared_from_this, currentLedgerState_.emplace(validatedLedger, fee, accountSeq, availableSeq); } - json::Value + [[nodiscard]] json::Value getJson(JsonOptions options, bool binary = false) const; // Information used to locate a transaction. @@ -308,7 +308,7 @@ class Transaction : public std::enable_shared_from_this, // at the time of search. struct Locator { - std::variant, ClosedInterval> locator; + std::variant, ClosedInterval> locator{}; /** * @return true if transaction was found, false otherwise @@ -329,7 +329,7 @@ class Transaction : public std::enable_shared_from_this, * @throws if isFound() returns false */ uint256 const& - getNodestoreHash() + getNodestoreHash() const { return std::get>(locator).first; } @@ -340,7 +340,7 @@ class Transaction : public std::enable_shared_from_this, * @throws if isFound() returns false */ uint32_t - getLedgerSequence() + getLedgerSequence() const { return std::get>(locator).second; } diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index 3f9039eab86..7dfb88f044e 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -120,8 +120,8 @@ struct TrustChanges { explicit TrustChanges() = default; - hash_set added; - hash_set removed; + hash_set added{}; + hash_set removed{}; }; /** @@ -189,8 +189,8 @@ class ValidatorList { explicit PublisherList() = default; - std::vector list; - std::vector manifests; + std::vector list{}; + std::vector manifests{}; std::size_t sequence{}; TimeKeeper::time_point validFrom; TimeKeeper::time_point validUntil; @@ -318,7 +318,7 @@ class ValidatorList // Tracks the dispositions of each processed list and how many times it // occurred - std::map dispositions; + std::map dispositions{}; std::optional publisherKey; PublisherStatus status = PublisherStatus::Unavailable; std::size_t sequence = 0; diff --git a/src/xrpld/rpc/ServerHandler.h b/src/xrpld/rpc/ServerHandler.h index 054bec9b5b2..31ec4898e9a 100644 --- a/src/xrpld/rpc/ServerHandler.h +++ b/src/xrpld/rpc/ServerHandler.h @@ -49,7 +49,7 @@ class ServerHandler { explicit Setup() = default; - std::vector ports; + std::vector ports{}; // Memberspace struct ClientT From eb2017c3953f84c98fc844113cafc18265ed9552 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 27 Jul 2026 17:43:46 -0400 Subject: [PATCH 2/3] apply ctidy diff --- .../detail/aged_unordered_container.h | 36 +++++++++---------- include/xrpl/core/HashRouter.h | 6 ++-- include/xrpl/rdb/RelationalDatabase.h | 2 +- include/xrpl/server/detail/BaseHTTPPeer.h | 2 +- include/xrpl/server/detail/BaseWSPeer.h | 4 +-- include/xrpl/server/detail/PlainWSPeer.h | 2 +- include/xrpl/server/detail/SSLHTTPPeer.h | 2 +- include/xrpl/server/detail/SSLWSPeer.h | 4 +-- include/xrpl/server/detail/ServerImpl.h | 4 +-- include/xrpl/server/detail/io_list.h | 2 +- src/xrpld/app/misc/NegativeUNLVote.h | 4 +-- src/xrpld/app/misc/NetworkOPs.cpp | 16 ++++----- src/xrpld/app/misc/Transaction.h | 6 ++-- src/xrpld/app/misc/ValidatorList.h | 10 +++--- src/xrpld/rpc/ServerHandler.h | 2 +- 15 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index a3645d10414..8392efb665e 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -415,31 +415,31 @@ class AgedUnorderedContainer bucket_type, typename std::allocator_traits::template rebind_alloc>; - Buckets() : maxLoadFactor_(1.f), vec() + Buckets() : maxLoadFactor_(1.f), vec_() { - vec.resize(cont_type::suggested_upper_bucket_count(0)); + vec_.resize(cont_type::suggested_upper_bucket_count(0)); } - Buckets(Allocator const& alloc) : maxLoadFactor_(1.f), vec(alloc) + Buckets(Allocator const& alloc) : maxLoadFactor_(1.f), vec_(alloc) { - vec.resize(cont_type::suggested_upper_bucket_count(0)); + vec_.resize(cont_type::suggested_upper_bucket_count(0)); } operator bucket_traits() { - return bucket_traits(&vec[0], vec.size()); + return bucket_traits(&vec_[0], vec_.size()); } void clear() { - vec.clear(); + vec_.clear(); } [[nodiscard]] size_type maxBucketCount() const { - return vec.max_size(); + return vec_.max_size(); } float& @@ -459,17 +459,17 @@ class AgedUnorderedContainer void rehash(size_type count, Container& c) { - size_type const size(vec.size()); + size_type const size(vec_.size()); if (count == size) return; - if (count > vec.capacity()) + if (count > vec_.capacity()) { // Need two vectors otherwise we // will destroy non-empty buckets. - vec_type tmp(vec.get_allocator()); - std::swap(tmp, vec); - vec.resize(count); - c.rehash(bucket_traits(&vec[0], vec.size())); + vec_type tmp(vec_.get_allocator()); + std::swap(tmp, vec_); + vec_.resize(count); + c.rehash(bucket_traits(&vec_[0], vec_.size())); return; } // Rehash in place. @@ -477,14 +477,14 @@ class AgedUnorderedContainer { // This should not reallocate since // we checked capacity earlier. - vec.resize(count); - c.rehash(bucket_traits(&vec[0], count)); + vec_.resize(count); + c.rehash(bucket_traits(&vec_[0], count)); return; } // Resize must happen after rehash otherwise // we might destroy non-empty buckets. - c.rehash(bucket_traits(&vec[0], count)); - vec.resize(count); + c.rehash(bucket_traits(&vec_[0], count)); + vec_.resize(count); } // Resize the buckets to accommodate at least n items. @@ -498,7 +498,7 @@ class AgedUnorderedContainer private: float maxLoadFactor_; - vec_type vec{}; + vec_type vec_{}; }; template diff --git a/include/xrpl/core/HashRouter.h b/include/xrpl/core/HashRouter.h index b50d6cd23e0..bfb60fd177e 100644 --- a/include/xrpl/core/HashRouter.h +++ b/include/xrpl/core/HashRouter.h @@ -128,7 +128,7 @@ class HashRouter addPeer(PeerShortID peer) { if (peer != 0) - peers.insert(peer); + peers_.insert(peer); } [[nodiscard]] HashRouterFlags @@ -149,7 +149,7 @@ class HashRouter std::set releasePeerSet() { - return std::move(peers); + return std::move(peers_); } /** @@ -182,7 +182,7 @@ class HashRouter private: HashRouterFlags flags_ = HashRouterFlags::UNDEFINED; - std::set peers{}; + std::set peers_; // This could be generalized to a map, if more // than one flag needs to expire independently. std::optional relayed_; diff --git a/include/xrpl/rdb/RelationalDatabase.h b/include/xrpl/rdb/RelationalDatabase.h index 01a2c9b2133..e5784c74180 100644 --- a/include/xrpl/rdb/RelationalDatabase.h +++ b/include/xrpl/rdb/RelationalDatabase.h @@ -123,7 +123,7 @@ class RelationalDatabase struct AccountTxResult { - std::variant transactions{}; + std::variant transactions; LedgerRange ledgerRange{}; uint32_t limit = 0; std::optional marker; diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index c1376edb652..d0d58661775 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -58,7 +58,7 @@ class BaseHTTPPeer : public IOList::Work, public Session memcpy(data.get(), ptr, len); } - std::unique_ptr data{}; + std::unique_ptr data; std::size_t bytes; std::size_t used{0}; }; diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 3e1a1e956ee..59a866ab8c1 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -49,7 +49,7 @@ class BaseWSPeer : public BasePeer, public WSSession http_request_type request_; boost::beast::multi_buffer rb_; boost::beast::multi_buffer wb_; - std::list> wq_{}; + std::list> wq_; /** * The socket has been closed, or will close after the next write * finishes. Do not do any more writes, and don't try to close @@ -60,7 +60,7 @@ class BaseWSPeer : public BasePeer, public WSSession waitable_timer timer_; bool closeOnTimer_ = false; bool pingActive_ = false; - boost::beast::websocket::ping_data payload_{}; + boost::beast::websocket::ping_data payload_; error_code ec_; std::function controlCallback_; diff --git a/include/xrpl/server/detail/PlainWSPeer.h b/include/xrpl/server/detail/PlainWSPeer.h index 4b9ebcc2a19..279e256f515 100644 --- a/include/xrpl/server/detail/PlainWSPeer.h +++ b/include/xrpl/server/detail/PlainWSPeer.h @@ -25,7 +25,7 @@ class PlainWSPeer : public BaseWSPeer>, using waitable_timer = boost::asio::basic_waitable_timer; using socket_type = boost::beast::tcp_stream; - boost::beast::websocket::stream ws_{}; + boost::beast::websocket::stream ws_; public: template diff --git a/include/xrpl/server/detail/SSLHTTPPeer.h b/include/xrpl/server/detail/SSLHTTPPeer.h index 766bc177ce1..7fe21ed6b5f 100644 --- a/include/xrpl/server/detail/SSLHTTPPeer.h +++ b/include/xrpl/server/detail/SSLHTTPPeer.h @@ -31,7 +31,7 @@ class SSLHTTPPeer : public BaseHTTPPeer>, using yield_context = boost::asio::yield_context; using error_code = boost::system::error_code; - std::unique_ptr streamPtr_{}; + std::unique_ptr streamPtr_; stream_type& stream_; socket_type& socket_; diff --git a/include/xrpl/server/detail/SSLWSPeer.h b/include/xrpl/server/detail/SSLWSPeer.h index 475c98b6e05..fe522e3c9ac 100644 --- a/include/xrpl/server/detail/SSLWSPeer.h +++ b/include/xrpl/server/detail/SSLWSPeer.h @@ -33,8 +33,8 @@ class SSLWSPeer : public BaseWSPeer>, using stream_type = boost::beast::ssl_stream; using waitable_timer = boost::asio::basic_waitable_timer; - std::unique_ptr streamPtr_{}; - boost::beast::websocket::stream ws_{}; + std::unique_ptr streamPtr_; + boost::beast::websocket::stream ws_; public: template diff --git a/include/xrpl/server/detail/ServerImpl.h b/include/xrpl/server/detail/ServerImpl.h index 1d20f70209f..8f753cb4b2a 100644 --- a/include/xrpl/server/detail/ServerImpl.h +++ b/include/xrpl/server/detail/ServerImpl.h @@ -81,10 +81,10 @@ class ServerImpl : public Server beast::Journal const j_; boost::asio::io_context& ioContext_; boost::asio::strand strand_; - std::optional> work_{}; + std::optional> work_; std::mutex m_; - std::vector ports_{}; + std::vector ports_; std::vector>> list_{}; int high_ = 0; std::array hist_{}; diff --git a/include/xrpl/server/detail/io_list.h b/include/xrpl/server/detail/io_list.h index 2ce14819600..7ffa85b898d 100644 --- a/include/xrpl/server/detail/io_list.h +++ b/include/xrpl/server/detail/io_list.h @@ -59,7 +59,7 @@ class IOList final std::size_t n_ = 0; bool closed_ = false; std::condition_variable cv_; - boost::container::flat_map> map_{}; + boost::container::flat_map> map_; std::function f_; public: diff --git a/src/xrpld/app/misc/NegativeUNLVote.h b/src/xrpld/app/misc/NegativeUNLVote.h index 55ecb156be6..a01bf04dcf6 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.h +++ b/src/xrpld/app/misc/NegativeUNLVote.h @@ -118,8 +118,8 @@ class NegativeUNLVote final */ struct Candidates { - std::vector toDisableCandidates{}; - std::vector toReEnableCandidates{}; + std::vector toDisableCandidates; + std::vector toReEnableCandidates; }; /** diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 26146424707..60d4d6c15e1 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -816,7 +816,7 @@ class NetworkOPsImp final : public NetworkOPs std::reference_wrapper registry_; beast::Journal journal_; - std::unique_ptr localTX_{}; + std::unique_ptr localTX_; std::recursive_mutex subLock_; @@ -852,13 +852,13 @@ class NetworkOPsImp final : public NetworkOPs */ using SubBookMapType = hash_map; - SubInfoMapType subAccount_{}; - SubInfoMapType subRTAccount_{}; - SubBookMapType subBook_{}; ///< Guarded by subLock_. + SubInfoMapType subAccount_; + SubInfoMapType subRTAccount_; + SubBookMapType subBook_; ///< Guarded by subLock_. - subRpcMapType rpcSubMap_{}; + subRpcMapType rpcSubMap_; - SubAccountHistoryMapType subAccountHistory_{}; + SubAccountHistoryMapType subAccountHistory_; // Used as array indices; converting to enum class would require casts at ~40 call sites. // NOLINTNEXTLINE(cppcoreguidelines-use-enum-class) @@ -891,11 +891,11 @@ class NetworkOPsImp final : public NetworkOPs std::condition_variable cond_; std::mutex mutex_; DispatchState dispatchState_ = DispatchState::None; - std::vector transactions_{}; + std::vector transactions_; StateAccounting accounting_; - std::set pendingValidations_{}; + std::set pendingValidations_; std::mutex validationsMutex_; private: diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index 9a9ef394341..003eec649de 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -308,7 +308,7 @@ class Transaction : public std::enable_shared_from_this, // at the time of search. struct Locator { - std::variant, ClosedInterval> locator{}; + std::variant, ClosedInterval> locator; /** * @return true if transaction was found, false otherwise @@ -328,7 +328,7 @@ class Transaction : public std::enable_shared_from_this, * * @throws if isFound() returns false */ - uint256 const& + [[nodiscard]] uint256 const& getNodestoreHash() const { return std::get>(locator).first; @@ -339,7 +339,7 @@ class Transaction : public std::enable_shared_from_this, * * @throws if isFound() returns false */ - uint32_t + [[nodiscard]] uint32_t getLedgerSequence() const { return std::get>(locator).second; diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index 7dfb88f044e..3f9039eab86 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -120,8 +120,8 @@ struct TrustChanges { explicit TrustChanges() = default; - hash_set added{}; - hash_set removed{}; + hash_set added; + hash_set removed; }; /** @@ -189,8 +189,8 @@ class ValidatorList { explicit PublisherList() = default; - std::vector list{}; - std::vector manifests{}; + std::vector list; + std::vector manifests; std::size_t sequence{}; TimeKeeper::time_point validFrom; TimeKeeper::time_point validUntil; @@ -318,7 +318,7 @@ class ValidatorList // Tracks the dispositions of each processed list and how many times it // occurred - std::map dispositions{}; + std::map dispositions; std::optional publisherKey; PublisherStatus status = PublisherStatus::Unavailable; std::size_t sequence = 0; diff --git a/src/xrpld/rpc/ServerHandler.h b/src/xrpld/rpc/ServerHandler.h index 31ec4898e9a..054bec9b5b2 100644 --- a/src/xrpld/rpc/ServerHandler.h +++ b/src/xrpld/rpc/ServerHandler.h @@ -49,7 +49,7 @@ class ServerHandler { explicit Setup() = default; - std::vector ports{}; + std::vector ports; // Memberspace struct ClientT From ddbe7db5cfb416e7f4761974f32833cf87edefc5 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 28 Jul 2026 11:04:57 -0400 Subject: [PATCH 3/3] fix HashRouter --- include/xrpl/core/HashRouter.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/xrpl/core/HashRouter.h b/include/xrpl/core/HashRouter.h index bfb60fd177e..20aafecc5f7 100644 --- a/include/xrpl/core/HashRouter.h +++ b/include/xrpl/core/HashRouter.h @@ -40,8 +40,9 @@ enum class HashRouterFlags : std::uint16_t { constexpr HashRouterFlags operator|(HashRouterFlags lhs, HashRouterFlags rhs) { - using U = std::underlying_type_t; - return static_cast(static_cast(lhs) | static_cast(rhs)); + return static_cast( + static_cast>(lhs) | + static_cast>(rhs)); } constexpr HashRouterFlags& @@ -54,8 +55,9 @@ operator|=(HashRouterFlags& lhs, HashRouterFlags rhs) constexpr HashRouterFlags operator&(HashRouterFlags lhs, HashRouterFlags rhs) { - using U = std::underlying_type_t; - return static_cast(static_cast(lhs) & static_cast(rhs)); + return static_cast( + static_cast>(lhs) & + static_cast>(rhs)); } constexpr HashRouterFlags& @@ -171,13 +173,19 @@ class HashRouter bool shouldRelay(Stopwatch::time_point const& now, std::chrono::seconds relayTime) { - return !relayed_ && *relayed_ + relayTime > now; + if (relayed_ && *relayed_ + relayTime > now) + return false; + relayed_.emplace(now); + return true; } bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval) { - return !processed_ && ((*processed_ + interval) > now); + if (processed_ && ((*processed_ + interval) > now)) + return false; + processed_.emplace(now); + return true; } private: