From 1696896277d4182861e64bf27714044286922d50 Mon Sep 17 00:00:00 2001 From: Vito Tumas <5780819+Tapanito@users.noreply.github.com> Date: Thu, 8 May 2025 13:00:42 +0200 Subject: [PATCH] refactor: use east const convention (#5409) This change refactors the codebase to use the "east const convention", and adds a clang-format rule to follow this convention. --- .clang-format | 1 + hook/genesis/build_xahau_h.sh | 8 +- include/xrpl/basics/BasicConfig.h | 2 +- include/xrpl/basics/CompressionAlgorithms.h | 4 +- include/xrpl/basics/Expected.h | 4 +- include/xrpl/basics/TaggedCache.h | 16 +-- include/xrpl/basics/TaggedCache.ipp | 12 +- include/xrpl/basics/base_uint.h | 18 +-- include/xrpl/basics/comparators.h | 4 +- .../xrpl/basics/partitioned_unordered_map.h | 2 +- include/xrpl/basics/tagged_integer.h | 8 +- include/xrpl/beast/utility/EnhancedLogging.h | 16 +-- include/xrpl/beast/utility/Journal.h | 12 +- include/xrpl/beast/utility/temp_dir.h | 4 +- include/xrpl/hook/Enum.h | 14 +-- include/xrpl/hook/Guard.h | 6 +- include/xrpl/hook/Misc.h | 2 +- include/xrpl/hook/guard_checker.cpp | 2 +- include/xrpl/hook/xahau.h | 4 +- include/xrpl/json/json_reader.h | 6 +- include/xrpl/json/json_value.h | 114 +++++++++--------- include/xrpl/json/json_writer.h | 26 ++-- include/xrpl/json/to_string.h | 2 +- include/xrpl/protocol/FeeUnits.h | 2 +- include/xrpl/protocol/Import.h | 14 +-- include/xrpl/protocol/MultiApiJson.h | 4 +- include/xrpl/protocol/Permissions.h | 6 +- include/xrpl/protocol/Quality.h | 4 +- include/xrpl/protocol/SField.h | 16 +-- include/xrpl/protocol/STAccount.h | 2 +- include/xrpl/protocol/STAmount.h | 26 ++-- include/xrpl/protocol/STArray.h | 12 +- include/xrpl/protocol/STBase.h | 10 +- include/xrpl/protocol/STBitString.h | 14 +-- include/xrpl/protocol/STBlob.h | 2 +- include/xrpl/protocol/STCurrency.h | 2 +- include/xrpl/protocol/STInteger.h | 6 +- include/xrpl/protocol/STIssue.h | 2 +- include/xrpl/protocol/STLedgerEntry.h | 2 +- include/xrpl/protocol/STObject.h | 44 +++---- include/xrpl/protocol/STPathSet.h | 14 +-- include/xrpl/protocol/STVector256.h | 6 +- include/xrpl/protocol/STXChainBridge.h | 2 +- include/xrpl/protocol/Serializer.h | 16 +-- include/xrpl/protocol/UintTypes.h | 2 +- include/xrpl/protocol/XRPAmount.h | 2 +- include/xrpl/protocol/detail/token_errors.h | 4 +- include/xrpl/protocol/json_get_or_throw.h | 4 +- include/xrpl/server/detail/UDPDoor.h | 10 +- src/libxrpl/basics/Archive.cpp | 2 +- src/libxrpl/basics/FileUtilities.cpp | 2 +- src/libxrpl/basics/Log.cpp | 8 +- src/libxrpl/basics/Number.cpp | 2 +- src/libxrpl/basics/StringUtilities.cpp | 6 +- src/libxrpl/basics/UptimeClock.cpp | 2 +- .../beast/utility/beast_EnhancedLogging.cpp | 14 +-- src/libxrpl/beast/utility/beast_Journal.cpp | 2 +- src/libxrpl/json/Writer.cpp | 16 +-- src/libxrpl/json/json_reader.cpp | 12 +- src/libxrpl/json/json_value.cpp | 66 +++++----- src/libxrpl/json/json_valueiterator.cpp | 28 ++--- src/libxrpl/json/json_writer.cpp | 40 +++--- src/libxrpl/protocol/BuildInfo.cpp | 2 +- src/libxrpl/protocol/Feature.cpp | 20 +-- src/libxrpl/protocol/Indexes.cpp | 4 +- src/libxrpl/protocol/LedgerFormats.cpp | 2 +- src/libxrpl/protocol/Quality.cpp | 2 +- src/libxrpl/protocol/SField.cpp | 2 +- src/libxrpl/protocol/STAccount.cpp | 2 +- src/libxrpl/protocol/STAmount.cpp | 14 +-- src/libxrpl/protocol/STArray.cpp | 6 +- src/libxrpl/protocol/STBase.cpp | 10 +- src/libxrpl/protocol/STBlob.cpp | 4 +- src/libxrpl/protocol/STCurrency.cpp | 4 +- src/libxrpl/protocol/STIssue.cpp | 4 +- src/libxrpl/protocol/STObject.cpp | 26 ++-- src/libxrpl/protocol/STParsedJSON.cpp | 5 +- src/libxrpl/protocol/STPathSet.cpp | 4 +- src/libxrpl/protocol/STVector256.cpp | 4 +- src/libxrpl/protocol/STXChainBridge.cpp | 4 +- src/libxrpl/protocol/Serializer.cpp | 8 +- src/libxrpl/protocol/TxFormats.cpp | 2 +- src/test/app/AMMExtended_test.cpp | 2 +- src/test/app/AMM_test.cpp | 22 ++-- src/test/app/AccountDelete_test.cpp | 6 +- src/test/app/Credentials_test.cpp | 22 ++-- src/test/app/DID_test.cpp | 2 +- src/test/app/DepositAuth_test.cpp | 12 +- src/test/app/Escrow_test.cpp | 4 +- src/test/app/FeeVote_test.cpp | 2 +- src/test/app/HookAPI_test.cpp | 4 +- src/test/app/Import_test.cpp | 10 +- src/test/app/LedgerReplay_test.cpp | 6 +- src/test/app/MPToken_test.cpp | 4 +- src/test/app/PayChan_test.cpp | 2 +- src/test/app/PermissionedDomains_test.cpp | 2 +- src/test/app/SHAMapStore_test.cpp | 24 ++-- src/test/app/SetHookTSH_test.cpp | 12 +- src/test/app/SetHook_test.cpp | 34 +++--- src/test/app/SetTrust_test.cpp | 2 +- src/test/app/TxQ_test.cpp | 8 +- src/test/app/URIToken_test.cpp | 16 +-- src/test/app/ValidatorKeys_test.cpp | 10 +- src/test/app/ValidatorList_test.cpp | 8 +- src/test/app/ValidatorSite_test.cpp | 2 +- src/test/app/XChain_test.cpp | 20 +-- src/test/app/XahauGenesis_test.cpp | 4 +- src/test/app/tx/apply_test.cpp | 2 +- src/test/basics/FileUtilities_test.cpp | 2 +- src/test/basics/PerfLog_test.cpp | 2 +- src/test/basics/mulDiv_test.cpp | 4 +- .../consensus/ByzantineFailureSim_test.cpp | 4 +- src/test/core/SociDB_test.cpp | 2 +- src/test/csf/Peer.h | 6 +- src/test/csf/Tx.h | 2 +- src/test/csf/collectors.h | 2 +- src/test/csf/ledgers.h | 2 +- src/test/jtx/Env.h | 2 +- src/test/jtx/TrustedPublisherServer.h | 12 +- src/test/jtx/deposit.h | 2 +- src/test/jtx/envconfig.h | 2 +- src/test/jtx/genesis.h | 4 +- src/test/jtx/hook.h | 2 +- src/test/jtx/impl/amount.cpp | 2 +- src/test/jtx/impl/mpt.cpp | 4 +- src/test/jtx/xchain_bridge.h | 10 +- src/test/overlay/reduce_relay_test.cpp | 15 +-- src/test/overlay/tx_reduce_relay_test.cpp | 4 +- src/test/protocol/MultiApiJson_test.cpp | 8 +- src/test/protocol/STAccount_test.cpp | 2 +- src/test/protocol/STAmount_test.cpp | 2 +- src/test/protocol/TER_test.cpp | 4 +- src/test/rdb/RelationalDatabase_test.cpp | 2 +- src/test/rpc/Catalogue_test.cpp | 6 +- src/test/rpc/DepositAuthorized_test.cpp | 6 +- src/test/rpc/Feature_test.cpp | 4 +- src/test/rpc/Handler_test.cpp | 4 +- src/test/rpc/LedgerEntry_test.cpp | 6 +- src/test/rpc/LedgerRPC_test.cpp | 8 +- src/test/rpc/RPCCall_test.cpp | 4 +- src/test/rpc/Simulate_test.cpp | 4 +- src/test/rpc/Subscribe_test.cpp | 2 +- src/test/rpc/Transaction_test.cpp | 24 ++-- src/test/rpc/ValidatorInfo_test.cpp | 2 +- src/test/unit_test/multi_runner.h | 4 +- src/xrpld/app/consensus/RCLConsensus.cpp | 18 +-- src/xrpld/app/consensus/RCLConsensus.h | 4 +- src/xrpld/app/hook/HookAPI.h | 4 +- src/xrpld/app/hook/applyHook.h | 16 +-- src/xrpld/app/hook/detail/HookAPI.cpp | 16 +-- src/xrpld/app/hook/detail/applyHook.cpp | 52 ++++---- src/xrpld/app/ledger/BuildLedger.h | 2 +- src/xrpld/app/ledger/Ledger.cpp | 2 +- src/xrpld/app/ledger/LedgerHistory.cpp | 60 ++++----- src/xrpld/app/ledger/LedgerMaster.h | 4 +- src/xrpld/app/ledger/OrderBookDB.cpp | 2 +- src/xrpld/app/ledger/OrderBookDB.h | 2 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 4 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 4 +- src/xrpld/app/ledger/detail/LedgerToJson.cpp | 2 +- .../app/ledger/detail/TimeoutCounter.cpp | 4 +- src/xrpld/app/main/Application.cpp | 2 +- src/xrpld/app/main/Application.h | 2 +- src/xrpld/app/main/GRPCServer.cpp | 4 +- src/xrpld/app/main/GRPCServer.h | 16 +-- src/xrpld/app/main/Main.cpp | 2 +- src/xrpld/app/misc/DatagramMonitor.h | 34 +++--- src/xrpld/app/misc/FeeVoteImpl.cpp | 4 +- src/xrpld/app/misc/HashRouter.cpp | 2 +- src/xrpld/app/misc/NetworkOPs.cpp | 30 ++--- src/xrpld/app/misc/Transaction.h | 2 +- src/xrpld/app/misc/TxQ.h | 4 +- src/xrpld/app/misc/ValidatorList.h | 2 +- src/xrpld/app/misc/ValidatorSite.h | 4 +- src/xrpld/app/misc/detail/AMMUtils.cpp | 6 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 4 +- src/xrpld/app/misc/detail/TxQ.cpp | 16 +-- src/xrpld/app/misc/detail/ValidatorList.cpp | 2 +- src/xrpld/app/paths/AMMLiquidity.h | 2 +- src/xrpld/app/paths/Flow.cpp | 4 +- src/xrpld/app/paths/PathRequest.cpp | 2 +- src/xrpld/app/paths/PathRequest.h | 4 +- src/xrpld/app/paths/Pathfinder.cpp | 9 +- src/xrpld/app/paths/detail/BookStep.cpp | 3 +- src/xrpld/app/paths/detail/DirectStep.cpp | 3 +- .../app/paths/detail/XRPEndpointStep.cpp | 3 +- src/xrpld/app/rdb/RelationalDatabase.h | 4 +- src/xrpld/app/rdb/backend/RWDBDatabase.h | 50 ++++---- src/xrpld/app/rdb/backend/detail/Node.cpp | 8 +- .../app/rdb/detail/RelationalDatabase.cpp | 2 +- src/xrpld/app/tx/detail/CancelOffer.cpp | 4 +- src/xrpld/app/tx/detail/Change.cpp | 6 +- src/xrpld/app/tx/detail/Import.cpp | 14 +-- src/xrpld/app/tx/detail/SetHook.cpp | 16 +-- src/xrpld/app/tx/detail/SetHook.h | 2 +- src/xrpld/app/tx/detail/Transactor.cpp | 6 +- src/xrpld/conditions/detail/error.cpp | 2 +- src/xrpld/conditions/detail/utils.h | 4 +- src/xrpld/consensus/Consensus.h | 20 +-- src/xrpld/consensus/DisputedTx.h | 3 +- src/xrpld/core/Job.h | 8 +- src/xrpld/core/detail/Config.cpp | 4 +- src/xrpld/core/detail/Job.cpp | 8 +- src/xrpld/core/detail/SociDB.cpp | 2 +- src/xrpld/ledger/ReadView.h | 2 +- src/xrpld/ledger/View.h | 12 +- src/xrpld/ledger/detail/ApplyStateTable.cpp | 2 +- src/xrpld/ledger/detail/RawStateTable.h | 2 +- src/xrpld/ledger/detail/View.cpp | 26 ++-- src/xrpld/net/AutoSocket.h | 14 +-- src/xrpld/net/HTTPClient.h | 12 +- src/xrpld/net/HTTPClientSSLContext.h | 2 +- src/xrpld/net/InfoSub.h | 4 +- src/xrpld/net/RPCCall.h | 6 +- src/xrpld/net/detail/HTTPClient.cpp | 40 +++--- src/xrpld/net/detail/InfoSub.cpp | 4 +- src/xrpld/net/detail/RPCCall.cpp | 16 +-- src/xrpld/net/detail/RPCSub.cpp | 2 +- src/xrpld/net/detail/RegisterSSLCerts.cpp | 2 +- src/xrpld/nodestore/backend/RWDBFactory.cpp | 6 +- src/xrpld/nodestore/detail/DummyScheduler.cpp | 4 +- src/xrpld/overlay/PeerSet.h | 2 +- src/xrpld/overlay/Slot.h | 2 +- src/xrpld/overlay/detail/PeerImp.cpp | 18 +-- src/xrpld/overlay/detail/PeerImp.h | 2 +- src/xrpld/overlay/detail/PeerSet.cpp | 6 +- src/xrpld/overlay/detail/TrafficCount.h | 2 +- src/xrpld/overlay/detail/ZeroCopyStream.h | 4 +- src/xrpld/peerfinder/detail/Logic.h | 6 +- src/xrpld/perflog/PerfLog.h | 4 +- src/xrpld/rpc/CTID.h | 4 +- src/xrpld/rpc/detail/Handler.cpp | 2 +- src/xrpld/rpc/detail/Handler.h | 2 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 2 +- src/xrpld/rpc/detail/RPCHelpers.h | 2 +- src/xrpld/rpc/detail/ServerHandler.cpp | 2 +- src/xrpld/rpc/detail/TransactionSign.cpp | 7 +- src/xrpld/rpc/handlers/Catalogue.cpp | 16 +-- src/xrpld/rpc/handlers/GetAggregatePrice.cpp | 4 +- src/xrpld/rpc/handlers/GetCounts.cpp | 2 +- src/xrpld/rpc/handlers/LedgerEntry.cpp | 2 +- src/xrpld/rpc/handlers/ServerDefinitions.cpp | 38 +++--- src/xrpld/rpc/handlers/Simulate.cpp | 2 +- src/xrpld/rpc/handlers/Subscribe.cpp | 2 +- src/xrpld/shamap/SHAMap.h | 4 +- src/xrpld/shamap/SHAMapLeafNode.h | 4 +- src/xrpld/shamap/detail/SHAMap.cpp | 4 +- src/xrpld/shamap/detail/SHAMapInnerNode.cpp | 2 +- src/xrpld/shamap/detail/SHAMapLeafNode.cpp | 2 +- src/xrpld/shamap/detail/SHAMapSync.cpp | 2 +- src/xrpld/shamap/detail/SHAMapTreeNode.cpp | 2 +- 251 files changed, 1057 insertions(+), 1040 deletions(-) diff --git a/.clang-format b/.clang-format index 910039688..7b0fda27c 100644 --- a/.clang-format +++ b/.clang-format @@ -94,3 +94,4 @@ SpacesInSquareBrackets: false Standard: Cpp11 TabWidth: 8 UseTab: Never +QualifierAlignment: Right \ No newline at end of file diff --git a/hook/genesis/build_xahau_h.sh b/hook/genesis/build_xahau_h.sh index 08e1547fe..530a115a4 100755 --- a/hook/genesis/build_xahau_h.sh +++ b/hook/genesis/build_xahau_h.sh @@ -100,14 +100,14 @@ update_hook_array() { echo -e "${BLUE}==> Updating ${hook_name}...${NC}" # Check if hook already exists - if grep -q "static const std::vector ${hook_name} = {" "${XAHAU_H}"; then + if grep -q "static std::vector const ${hook_name} = {" "${XAHAU_H}"; then echo -e "${YELLOW} Replacing existing ${hook_name}${NC}" # Use awk to replace the array content awk -v hook="${hook_name}" -v hex="${hex_array}" ' BEGIN { in_array=0 } { - if ($0 ~ "static const std::vector " hook " = {") { + if ($0 ~ "static std::vector const " hook " = {") { print $0 print hex in_array=1 @@ -133,7 +133,7 @@ update_hook_array() { { if ($0 ~ /#endif.*XAHAU_GENESIS_HOOKS/) { print "" - print "static const std::vector " hook " = {" + print "static std::vector const " hook " = {" print hex print "};" print "" @@ -178,7 +178,7 @@ echo -e "${GREEN} Formatting completed${NC}" echo -e "${BLUE}==> Verifying changes...${NC}" for hook_entry in "${HOOK_FILES[@]}"; do hook_name="${hook_entry%%:*}" - if grep -q "static const std::vector ${hook_name} = {" "${XAHAU_H}"; then + if grep -q "static std::vector const ${hook_name} = {" "${XAHAU_H}"; then echo -e "${GREEN} ✓ ${hook_name} found in xahau.h${NC}" else echo -e "${RED} ✗ ${hook_name} NOT found in xahau.h${NC}" >&2 diff --git a/include/xrpl/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h index 2e3478644..dcd96e773 100644 --- a/include/xrpl/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -367,7 +367,7 @@ get(Section const& section, } inline std::string -get(Section const& section, std::string const& name, const char* defaultValue) +get(Section const& section, std::string const& name, char const* defaultValue) { try { diff --git a/include/xrpl/basics/CompressionAlgorithms.h b/include/xrpl/basics/CompressionAlgorithms.h index 19db3568d..4d6cf21cd 100644 --- a/include/xrpl/basics/CompressionAlgorithms.h +++ b/include/xrpl/basics/CompressionAlgorithms.h @@ -55,7 +55,7 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf) auto compressed = bf(outCapacity); auto compressedSize = LZ4_compress_default( - reinterpret_cast(in), + reinterpret_cast(in), reinterpret_cast(compressed), inSize, outCapacity); @@ -89,7 +89,7 @@ lz4Decompress( Throw("lz4Decompress: integer overflow (output)"); if (LZ4_decompress_safe( - reinterpret_cast(in), + reinterpret_cast(in), reinterpret_cast(decompressed), inSize, decompressedSize) != decompressedSize) diff --git a/include/xrpl/basics/Expected.h b/include/xrpl/basics/Expected.h index b1575c93b..d08b55e45 100644 --- a/include/xrpl/basics/Expected.h +++ b/include/xrpl/basics/Expected.h @@ -93,7 +93,7 @@ public: { } - constexpr const E& + constexpr E const& value() const& { return val_; @@ -111,7 +111,7 @@ public: return std::move(val_); } - constexpr const E&& + constexpr E const&& value() const&& { return std::move(val_); diff --git a/include/xrpl/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h index 64570ae06..99c91fe39 100644 --- a/include/xrpl/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -115,7 +115,7 @@ public: sweep(); bool - del(const key_type& key, bool valid); + del(key_type const& key, bool valid); public: /** Replace aliased objects with originals. @@ -134,20 +134,20 @@ public: template bool canonicalize( - const key_type& key, + key_type const& key, SharedPointerType& data, R&& replaceCallback); bool canonicalize_replace_cache( - const key_type& key, + key_type const& key, SharedPointerType const& data); bool - canonicalize_replace_client(const key_type& key, SharedPointerType& data); + canonicalize_replace_client(key_type const& key, SharedPointerType& data); SharedPointerType - fetch(const key_type& key); + fetch(key_type const& key); /** Insert the element into the container. If the key already exists, nothing happens. @@ -168,7 +168,7 @@ public: // simply return an iterator. // bool - retrieve(const key_type& key, T& data); + retrieve(key_type const& key, T& data); mutex_type& peekMutex(); @@ -322,10 +322,10 @@ private: std::string m_name; // Desired number of cache entries (0 = ignore) - const int m_target_size; + int const m_target_size; // Desired maximum cache age - const clock_type::duration m_target_age; + clock_type::duration const m_target_age; // Number of items cached int m_cache_count; diff --git a/include/xrpl/basics/TaggedCache.ipp b/include/xrpl/basics/TaggedCache.ipp index 010806168..16a3f7587 100644 --- a/include/xrpl/basics/TaggedCache.ipp +++ b/include/xrpl/basics/TaggedCache.ipp @@ -365,7 +365,7 @@ TaggedCache< SharedPointerType, Hash, KeyEqual, - Mutex>::del(const key_type& key, bool valid) + Mutex>::del(key_type const& key, bool valid) { // Remove from cache, if !valid, remove from map too. Returns true if // removed from cache @@ -414,7 +414,7 @@ TaggedCache< KeyEqual, Mutex>:: canonicalize( - const key_type& key, + key_type const& key, SharedPointerType& data, R&& replaceCallback) { @@ -509,7 +509,7 @@ TaggedCache< KeyEqual, Mutex>:: canonicalize_replace_cache( - const key_type& key, + key_type const& key, SharedPointerType const& data) { return canonicalize( @@ -535,7 +535,7 @@ TaggedCache< Hash, KeyEqual, Mutex>:: - canonicalize_replace_client(const key_type& key, SharedPointerType& data) + canonicalize_replace_client(key_type const& key, SharedPointerType& data) { return canonicalize(key, data, []() { return false; }); } @@ -558,7 +558,7 @@ TaggedCache< SharedPointerType, Hash, KeyEqual, - Mutex>::fetch(const key_type& key) + Mutex>::fetch(key_type const& key) { std::lock_guard l(m_mutex); auto ret = initialFetch(key, l); @@ -656,7 +656,7 @@ TaggedCache< SharedPointerType, Hash, KeyEqual, - Mutex>::retrieve(const key_type& key, T& data) + Mutex>::retrieve(key_type const& key, T& data) { // retrieve the value of the stored data auto entry = fetch(key); diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index 68304f4f4..beb2011db 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -386,7 +386,7 @@ public: } base_uint& - operator^=(const base_uint& b) + operator^=(base_uint const& b) { for (int i = 0; i < WIDTH; i++) data_[i] ^= b.data_[i]; @@ -395,7 +395,7 @@ public: } base_uint& - operator&=(const base_uint& b) + operator&=(base_uint const& b) { for (int i = 0; i < WIDTH; i++) data_[i] &= b.data_[i]; @@ -404,7 +404,7 @@ public: } base_uint& - operator|=(const base_uint& b) + operator|=(base_uint const& b) { for (int i = 0; i < WIDTH; i++) data_[i] |= b.data_[i]; @@ -427,11 +427,11 @@ public: return *this; } - const base_uint + base_uint const operator++(int) { // postfix operator - const base_uint ret = *this; + base_uint const ret = *this; ++(*this); return ret; @@ -453,11 +453,11 @@ public: return *this; } - const base_uint + base_uint const operator--(int) { // postfix operator - const base_uint ret = *this; + base_uint const ret = *this; --(*this); return ret; @@ -478,7 +478,7 @@ public: } base_uint& - operator+=(const base_uint& b) + operator+=(base_uint const& b) { std::uint64_t carry = 0; @@ -523,7 +523,7 @@ public: } [[nodiscard]] constexpr bool - parseHex(const char* str) + parseHex(char const* str) { return parseHex(std::string_view{str}); } diff --git a/include/xrpl/basics/comparators.h b/include/xrpl/basics/comparators.h index ce782dcd3..0e5f11e9e 100644 --- a/include/xrpl/basics/comparators.h +++ b/include/xrpl/basics/comparators.h @@ -43,7 +43,7 @@ struct less using result_type = bool; constexpr bool - operator()(const T& left, const T& right) const + operator()(T const& left, T const& right) const { return std::less()(left, right); } @@ -55,7 +55,7 @@ struct equal_to using result_type = bool; constexpr bool - operator()(const T& left, const T& right) const + operator()(T const& left, T const& right) const { return std::equal_to()(left, right); } diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index a37801152..4e503ad0f 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -52,7 +52,7 @@ template < typename Value, typename Hash, typename Pred = std::equal_to, - typename Alloc = std::allocator>> + typename Alloc = std::allocator>> class partitioned_unordered_map { std::size_t partitions_; diff --git a/include/xrpl/basics/tagged_integer.h b/include/xrpl/basics/tagged_integer.h index b826b87db..471fa8eb1 100644 --- a/include/xrpl/basics/tagged_integer.h +++ b/include/xrpl/basics/tagged_integer.h @@ -76,13 +76,13 @@ public: } bool - operator<(const tagged_integer& rhs) const noexcept + operator<(tagged_integer const& rhs) const noexcept { return m_value < rhs.m_value; } bool - operator==(const tagged_integer& rhs) const noexcept + operator==(tagged_integer const& rhs) const noexcept { return m_value == rhs.m_value; } @@ -144,14 +144,14 @@ public: } tagged_integer& - operator<<=(const tagged_integer& rhs) noexcept + operator<<=(tagged_integer const& rhs) noexcept { m_value <<= rhs.m_value; return *this; } tagged_integer& - operator>>=(const tagged_integer& rhs) noexcept + operator>>=(tagged_integer const& rhs) noexcept { m_value >>= rhs.m_value; return *this; diff --git a/include/xrpl/beast/utility/EnhancedLogging.h b/include/xrpl/beast/utility/EnhancedLogging.h index 3c6301dd4..58426c954 100644 --- a/include/xrpl/beast/utility/EnhancedLogging.h +++ b/include/xrpl/beast/utility/EnhancedLogging.h @@ -32,14 +32,14 @@ should_log_use_colors(); // Get the log highlight color - can be overridden via // LOG_HIGHLIGHT_COLOR -const char* +char const* get_log_highlight_color(); // Strip source root path from __FILE__ at compile time // IMPORTANT: This MUST stay in the header as constexpr for compile-time // evaluation! -constexpr const char* -strip_source_root(const char* file) +constexpr char const* +strip_source_root(char const* file) { // Handle relative paths from build/ directory (common with ccache) // e.g., "../src/ripple/..." -> "ripple/..." @@ -50,15 +50,15 @@ strip_source_root(const char* file) } #ifdef SOURCE_ROOT_PATH - constexpr const char* sourceRoot = SOURCE_ROOT_PATH; - constexpr auto strlen_constexpr = [](const char* s) constexpr { - const char* p = s; + constexpr char const* sourceRoot = SOURCE_ROOT_PATH; + constexpr auto strlen_constexpr = [](char const* s) constexpr { + char const* p = s; while (*p) ++p; return p - s; }; constexpr auto strncmp_constexpr = - [](const char* a, const char* b, size_t n) constexpr { + [](char const* a, char const* b, size_t n) constexpr { for (size_t i = 0; i < n; ++i) { if (a[i] != b[i]) @@ -83,7 +83,7 @@ should_show_location(); // Helper to write location string (no leading/trailing space) void -log_write_location_string(std::ostream& os, const char* file, int line); +log_write_location_string(std::ostream& os, char const* file, int line); } // namespace detail } // namespace beast diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 15d753257..47558d2df 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -157,7 +157,7 @@ public: ScopedStream(Sink& sink, Severity level); #ifdef BEAST_ENHANCED_LOGGING - ScopedStream(Sink& sink, Severity level, const char* file, int line); + ScopedStream(Sink& sink, Severity level, char const* file, int line); #endif template @@ -188,7 +188,7 @@ public: Severity const m_level; std::ostringstream mutable m_ostream; #ifdef BEAST_ENHANCED_LOGGING - const char* file_ = nullptr; + char const* file_ = nullptr; int line_ = 0; #endif }; @@ -216,7 +216,7 @@ public: class StreamWithLocation { public: - StreamWithLocation(Stream const& stream, const char* file, int line) + StreamWithLocation(Stream const& stream, char const* file, int line) : file_(file), line_(line), stream_(stream) { } @@ -230,9 +230,9 @@ public: operator<<(std::ostream& manip(std::ostream&)) const; private: - const char* file_; + char const* file_; int line_; - const Stream& stream_; + Stream const& stream_; }; #endif @@ -306,7 +306,7 @@ public: #ifdef BEAST_ENHANCED_LOGGING /** Create a StreamWithLocation that prepends file:line info */ StreamWithLocation - withLocation(const char* file, int line) const + withLocation(char const* file, int line) const { return StreamWithLocation(*this, file, line); } diff --git a/include/xrpl/beast/utility/temp_dir.h b/include/xrpl/beast/utility/temp_dir.h index bbb7afc7b..074b7461a 100644 --- a/include/xrpl/beast/utility/temp_dir.h +++ b/include/xrpl/beast/utility/temp_dir.h @@ -37,9 +37,9 @@ class temp_dir public: #if !GENERATING_DOCS - temp_dir(const temp_dir&) = delete; + temp_dir(temp_dir const&) = delete; temp_dir& - operator=(const temp_dir&) = delete; + operator=(temp_dir const&) = delete; #endif /// Construct a temporary directory. diff --git a/include/xrpl/hook/Enum.h b/include/xrpl/hook/Enum.h index 29f7ed16b..6c5f3cc06 100644 --- a/include/xrpl/hook/Enum.h +++ b/include/xrpl/hook/Enum.h @@ -20,7 +20,7 @@ namespace hook_api { struct Rules { constexpr bool - enabled(const uint256& feature) const + enabled(uint256 const& feature) const { return true; } @@ -393,12 +393,12 @@ enum ExitType : uint8_t { ACCEPT = 3, }; -const uint16_t max_state_modifications = 256; -const uint8_t max_slots = 255; -const uint8_t max_nonce = 255; -const uint8_t max_emit = 255; -const uint8_t max_params = 16; -const double fee_base_multiplier = 1.1f; +uint16_t const max_state_modifications = 256; +uint8_t const max_slots = 255; +uint8_t const max_nonce = 255; +uint8_t const max_emit = 255; +uint8_t const max_params = 16; +double const fee_base_multiplier = 1.1f; using APIWhitelist = std::map>; diff --git a/include/xrpl/hook/Guard.h b/include/xrpl/hook/Guard.h index 8c5eee25c..f22d94e51 100644 --- a/include/xrpl/hook/Guard.h +++ b/include/xrpl/hook/Guard.h @@ -205,7 +205,7 @@ struct WasmBlkInf } // compute worst case execution time inline uint64_t -compute_wce(const WasmBlkInf* blk, int level, bool* recursion_limit_reached) +compute_wce(WasmBlkInf const* blk, int level, bool* recursion_limit_reached) { if (level > 16) { @@ -972,7 +972,7 @@ validateGuards( } if (std::string_view( - (const char*)(wasm.data() + i), (size_t)mod_length) != + (char const*)(wasm.data() + i), (size_t)mod_length) != "env") { GUARDLOG(hook::log::IMPORT_MODULE_ENV) @@ -1000,7 +1000,7 @@ validateGuards( } std::string import_name{ - (const char*)(wasm.data() + i), (size_t)name_length}; + (char const*)(wasm.data() + i), (size_t)name_length}; i += name_length; CHECK_SHORT_HOOK(); diff --git a/include/xrpl/hook/Misc.h b/include/xrpl/hook/Misc.h index e28a780f6..046c0e0b9 100644 --- a/include/xrpl/hook/Misc.h +++ b/include/xrpl/hook/Misc.h @@ -6,7 +6,7 @@ namespace ripple { // RH TODO: there's definitely a mucher nicer way to do this, but it involves // modifying the base_uint class and we don't want to do that yet. -static const std::array UINT256_BIT = { +static std::array const UINT256_BIT = { ripple::uint256( "0000000000000000000000000000000000000000000000000000000000000001"), ripple::uint256( diff --git a/include/xrpl/hook/guard_checker.cpp b/include/xrpl/hook/guard_checker.cpp index 06e294886..0a424c2ab 100644 --- a/include/xrpl/hook/guard_checker.cpp +++ b/include/xrpl/hook/guard_checker.cpp @@ -16,7 +16,7 @@ int main(int argc, char** argv) { - const char* fin = 0; + char const* fin = 0; if (argc > 2) return fprintf( diff --git a/include/xrpl/hook/xahau.h b/include/xrpl/hook/xahau.h index 0ac449db4..9ae84433e 100644 --- a/include/xrpl/hook/xahau.h +++ b/include/xrpl/hook/xahau.h @@ -2,7 +2,7 @@ #define XAHAU_GENESIS_HOOKS #include -static const std::vector GovernanceHook = { +static std::vector const GovernanceHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x42U, 0x09U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, @@ -819,7 +819,7 @@ static const std::vector GovernanceHook = { 0x20U, 0x6CU, 0x6FU, 0x67U, 0x69U, 0x63U, 0x20U, 0x65U, 0x72U, 0x72U, 0x6FU, 0x72U, 0x2EU}; -static const std::vector RewardHook = { +static std::vector const RewardHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x61U, 0x0EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x00U, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, diff --git a/include/xrpl/json/json_reader.h b/include/xrpl/json/json_reader.h index 27d608f85..81866819a 100644 --- a/include/xrpl/json/json_reader.h +++ b/include/xrpl/json/json_reader.h @@ -39,7 +39,7 @@ class Reader { public: using Char = char; - using Location = const Char*; + using Location = Char const*; /** \brief Constructs a Reader allowing all features * for parsing. @@ -64,7 +64,7 @@ public: * error occurred. */ bool - parse(const char* beginDoc, const char* endDoc, Value& root); + parse(char const* beginDoc, char const* endDoc, Value& root); /// \brief Parse from input stream. /// \see Json::operator>>(std::istream&, Json::Value&). @@ -133,7 +133,7 @@ private: using Errors = std::deque; bool - expectToken(TokenType type, Token& token, const char* message); + expectToken(TokenType type, Token& token, char const* message); bool readToken(Token& token); void diff --git a/include/xrpl/json/json_value.h b/include/xrpl/json/json_value.h index 91d29c28d..3431ab774 100644 --- a/include/xrpl/json/json_value.h +++ b/include/xrpl/json/json_value.h @@ -61,24 +61,24 @@ enum ValueType { class StaticString { public: - constexpr explicit StaticString(const char* czstring) : str_(czstring) + constexpr explicit StaticString(char const* czstring) : str_(czstring) { } constexpr - operator const char*() const + operator char const*() const { return str_; } - constexpr const char* + constexpr char const* c_str() const { return str_; } private: - const char* str_; + char const* str_; }; inline bool @@ -156,10 +156,10 @@ public: using Int = Json::Int; using ArrayIndex = UInt; - static const Value null; - static const Int minInt; - static const Int maxInt; - static const UInt maxUInt; + static Value const null; + static Int const minInt; + static Int const maxInt; + static UInt const maxUInt; private: class CZString @@ -171,24 +171,24 @@ private: duplicateOnCopy }; CZString(int index); - CZString(const char* cstr, DuplicationPolicy allocate); - CZString(const CZString& other); + CZString(char const* cstr, DuplicationPolicy allocate); + CZString(CZString const& other); ~CZString(); CZString& - operator=(const CZString& other) = delete; + operator=(CZString const& other) = delete; bool - operator<(const CZString& other) const; + operator<(CZString const& other) const; bool - operator==(const CZString& other) const; + operator==(CZString const& other) const; int index() const; - const char* + char const* c_str() const; bool isStaticString() const; private: - const char* cstr_; + char const* cstr_; int index_; }; @@ -215,7 +215,7 @@ public: Value(Int value); Value(UInt value); Value(double value); - Value(const char* value); + Value(char const* value); /** \brief Constructs a value from a static string. * Like other value string constructor but do not duplicate the string for @@ -227,10 +227,10 @@ public: * Json::Value aValue( StaticString("some text") ); * \endcode */ - Value(const StaticString& value); + Value(StaticString const& value); Value(std::string const& value); Value(bool value); - Value(const Value& other); + Value(Value const& other); ~Value(); Value& @@ -247,7 +247,7 @@ public: ValueType type() const; - const char* + char const* asCString() const; /** Returns the unquoted string value. */ std::string @@ -317,12 +317,12 @@ public: /// Access an array element (zero based index ) /// (You may need to say 'value[0u]' to get your compiler to distinguish /// this from the operator[] which takes a string.) - const Value& + Value const& operator[](UInt index) const; /// If the array contains at least index+1 elements, returns the element /// value, otherwise returns defaultValue. Value - get(UInt index, const Value& defaultValue) const; + get(UInt index, Value const& defaultValue) const; /// Return true if index < size(). bool isValidIndex(UInt index) const; @@ -330,25 +330,25 @@ public: /// /// Equivalent to jsonvalue[jsonvalue.size()] = value; Value& - append(const Value& value); + append(Value const& value); Value& append(Value&& value); /// Access an object value by name, create a null member if it does not /// exist. Value& - operator[](const char* key); + operator[](char const* key); /// Access an object value by name, returns null if there is no member with /// that name. - const Value& - operator[](const char* key) const; + Value const& + operator[](char const* key) const; /// Access an object value by name, create a null member if it does not /// exist. Value& operator[](std::string const& key); /// Access an object value by name, returns null if there is no member with /// that name. - const Value& + Value const& operator[](std::string const& key) const; /** \brief Access an object value by name, create a null member if it does not exist. @@ -364,14 +364,14 @@ public: * \endcode */ Value& - operator[](const StaticString& key); + operator[](StaticString const& key); /// Return the member named key if it exist, defaultValue otherwise. Value - get(const char* key, const Value& defaultValue) const; + get(char const* key, Value const& defaultValue) const; /// Return the member named key if it exist, defaultValue otherwise. Value - get(std::string const& key, const Value& defaultValue) const; + get(std::string const& key, Value const& defaultValue) const; /// \brief Remove and return the named member. /// @@ -380,14 +380,14 @@ public: /// \pre type() is objectValue or nullValue /// \post type() is unchanged Value - removeMember(const char* key); + removeMember(char const* key); /// Same as removeMember(const char*) Value removeMember(std::string const& key); /// Return true if the object has a member named key. bool - isMember(const char* key) const; + isMember(char const* key) const; /// Return true if the object has a member named key. bool isMember(std::string const& key) const; @@ -414,13 +414,13 @@ public: end(); friend bool - operator==(const Value&, const Value&); + operator==(Value const&, Value const&); friend bool - operator<(const Value&, const Value&); + operator<(Value const&, Value const&); private: Value& - resolveReference(const char* key, bool isStatic); + resolveReference(char const* key, bool isStatic); private: union ValueHolder @@ -437,31 +437,31 @@ private: }; bool -operator==(const Value&, const Value&); +operator==(Value const&, Value const&); inline bool -operator!=(const Value& x, const Value& y) +operator!=(Value const& x, Value const& y) { return !(x == y); } bool -operator<(const Value&, const Value&); +operator<(Value const&, Value const&); inline bool -operator<=(const Value& x, const Value& y) +operator<=(Value const& x, Value const& y) { return !(y < x); } inline bool -operator>(const Value& x, const Value& y) +operator>(Value const& x, Value const& y) { return y < x; } inline bool -operator>=(const Value& x, const Value& y) +operator>=(Value const& x, Value const& y) { return !(x < y); } @@ -482,11 +482,11 @@ public: virtual ~ValueAllocator() = default; virtual char* - makeMemberName(const char* memberName) = 0; + makeMemberName(char const* memberName) = 0; virtual void releaseMemberName(char* memberName) = 0; virtual char* - duplicateStringValue(const char* value, unsigned int length = unknown) = 0; + duplicateStringValue(char const* value, unsigned int length = unknown) = 0; virtual void releaseStringValue(char* value) = 0; }; @@ -503,16 +503,16 @@ public: ValueIteratorBase(); - explicit ValueIteratorBase(const Value::ObjectValues::iterator& current); + explicit ValueIteratorBase(Value::ObjectValues::iterator const& current); bool - operator==(const SelfType& other) const + operator==(SelfType const& other) const { return isEqual(other); } bool - operator!=(const SelfType& other) const + operator!=(SelfType const& other) const { return !isEqual(other); } @@ -528,7 +528,7 @@ public: /// Return the member name of the referenced Value. "" if it is not an /// objectValue. - const char* + char const* memberName() const; protected: @@ -542,13 +542,13 @@ protected: decrement(); difference_type - computeDistance(const SelfType& other) const; + computeDistance(SelfType const& other) const; bool - isEqual(const SelfType& other) const; + isEqual(SelfType const& other) const; void - copy(const SelfType& other); + copy(SelfType const& other); private: Value::ObjectValues::iterator current_; @@ -566,8 +566,8 @@ class ValueConstIterator : public ValueIteratorBase public: using size_t = unsigned int; using difference_type = int; - using reference = const Value&; - using pointer = const Value*; + using reference = Value const&; + using pointer = Value const*; using SelfType = ValueConstIterator; ValueConstIterator() = default; @@ -575,11 +575,11 @@ public: private: /*! \internal Use by Value to create an iterator. */ - explicit ValueConstIterator(const Value::ObjectValues::iterator& current); + explicit ValueConstIterator(Value::ObjectValues::iterator const& current); public: SelfType& - operator=(const ValueIteratorBase& other); + operator=(ValueIteratorBase const& other); SelfType operator++(int) @@ -632,17 +632,17 @@ public: using SelfType = ValueIterator; ValueIterator() = default; - ValueIterator(const ValueConstIterator& other); - ValueIterator(const ValueIterator& other); + ValueIterator(ValueConstIterator const& other); + ValueIterator(ValueIterator const& other); private: /*! \internal Use by Value to create an iterator. */ - explicit ValueIterator(const Value::ObjectValues::iterator& current); + explicit ValueIterator(Value::ObjectValues::iterator const& current); public: SelfType& - operator=(const SelfType& other); + operator=(SelfType const& other); SelfType operator++(int) diff --git a/include/xrpl/json/json_writer.h b/include/xrpl/json/json_writer.h index 1b4ff1550..7e21e766e 100644 --- a/include/xrpl/json/json_writer.h +++ b/include/xrpl/json/json_writer.h @@ -39,7 +39,7 @@ public: { } virtual std::string - write(const Value& root) = 0; + write(Value const& root) = 0; }; /** \brief Outputs a Value in JSON format @@ -60,11 +60,11 @@ public: public: // overridden from Writer std::string - write(const Value& root) override; + write(Value const& root) override; private: void - writeValue(const Value& value); + writeValue(Value const& value); std::string document_; }; @@ -101,15 +101,15 @@ public: // overridden from Writer * JSON document that represents the root value. */ std::string - write(const Value& root) override; + write(Value const& root) override; private: void - writeValue(const Value& value); + writeValue(Value const& value); void - writeArrayValue(const Value& value); + writeArrayValue(Value const& value); bool - isMultineArray(const Value& value); + isMultineArray(Value const& value); void pushValue(std::string const& value); void @@ -168,15 +168,15 @@ public: * return a value. */ void - write(std::ostream& out, const Value& root); + write(std::ostream& out, Value const& root); private: void - writeValue(const Value& value); + writeValue(Value const& value); void - writeArrayValue(const Value& value); + writeArrayValue(Value const& value); bool - isMultineArray(const Value& value); + isMultineArray(Value const& value); void pushValue(std::string const& value); void @@ -207,12 +207,12 @@ valueToString(double value); std::string valueToString(bool value); std::string -valueToQuotedString(const char* value); +valueToQuotedString(char const* value); /// \brief Output using the StyledStreamWriter. /// \see Json::operator>>() std::ostream& -operator<<(std::ostream&, const Value& root); +operator<<(std::ostream&, Value const& root); //------------------------------------------------------------------------------ diff --git a/include/xrpl/json/to_string.h b/include/xrpl/json/to_string.h index 5f692a415..5b20293f0 100644 --- a/include/xrpl/json/to_string.h +++ b/include/xrpl/json/to_string.h @@ -37,7 +37,7 @@ pretty(Value const&); /** Output using the StyledStreamWriter. @see Json::operator>>(). */ std::ostream& -operator<<(std::ostream&, const Value& root); +operator<<(std::ostream&, Value const& root); } // namespace Json diff --git a/include/xrpl/protocol/FeeUnits.h b/include/xrpl/protocol/FeeUnits.h index 0cbf1b608..c6949a434 100644 --- a/include/xrpl/protocol/FeeUnits.h +++ b/include/xrpl/protocol/FeeUnits.h @@ -336,7 +336,7 @@ public: // Output Fees as just their numeric value. template std::basic_ostream& -operator<<(std::basic_ostream& os, const TaggedFee& q) +operator<<(std::basic_ostream& os, TaggedFee const& q) { return os << q.value(); } diff --git a/include/xrpl/protocol/Import.h b/include/xrpl/protocol/Import.h index 7dbdb96ef..1ab45bf98 100644 --- a/include/xrpl/protocol/Import.h +++ b/include/xrpl/protocol/Import.h @@ -87,7 +87,7 @@ syntaxCheckProof( << "XPOP.transaction.proof list should be exactly 16 entries"; return false; } - for (const auto& entry : proof) + for (auto const& entry : proof) { if (entry.isString()) { @@ -132,7 +132,7 @@ syntaxCheckProof( return syntaxCheckProof(proof["children"], j, depth + 1); } - for (const auto& branch : proof.getMemberNames()) + for (auto const& branch : proof.getMemberNames()) { if (branch.size() != 1 || !isHex(branch)) { @@ -142,7 +142,7 @@ syntaxCheckProof( return false; } - const auto& node = proof[branch]; + auto const& node = proof[branch]; if (!node.isObject() || !node["hash"].isString() || node["hash"].asString().size() != 64 || !node["key"].isString() || @@ -336,9 +336,9 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j) return {}; } - for (const auto& key : xpop["validation"]["data"].getMemberNames()) + for (auto const& key : xpop["validation"]["data"].getMemberNames()) { - const auto& value = xpop["validation"]["data"][key]; + auto const& value = xpop["validation"]["data"][key]; if (!isBase58(key) || !value.isString() || !isHex(value.asString())) { JLOG(j.warn()) << "XPOP.validation.data entry has wrong format " @@ -349,9 +349,9 @@ syntaxCheckXPOP(Blob const& blob, beast::Journal const& j) } uint32_t found = 0; - for (const auto& key : xpop["validation"]["unl"].getMemberNames()) + for (auto const& key : xpop["validation"]["unl"].getMemberNames()) { - const auto& value = xpop["validation"]["unl"][key]; + auto const& value = xpop["validation"]["unl"][key]; if (key == "public_key") { if (!value.isString() || !isHex(value.asString())) diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 15743e856..1e35bdbda 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -80,7 +80,7 @@ struct MultiApiJson } void - set(const char* key, auto const& v) + set(char const* key, auto const& v) requires std::constructible_from { for (auto& a : this->val) @@ -91,7 +91,7 @@ struct MultiApiJson enum IsMemberResult : int { none = 0, some, all }; [[nodiscard]] IsMemberResult - isMember(const char* key) const + isMember(char const* key) const { int count = 0; for (auto& a : this->val) diff --git a/include/xrpl/protocol/Permissions.h b/include/xrpl/protocol/Permissions.h index eb2c73331..8ba53d94d 100644 --- a/include/xrpl/protocol/Permissions.h +++ b/include/xrpl/protocol/Permissions.h @@ -67,9 +67,9 @@ public: static Permission const& getInstance(); - Permission(const Permission&) = delete; + Permission(Permission const&) = delete; Permission& - operator=(const Permission&) = delete; + operator=(Permission const&) = delete; std::optional getGranularValue(std::string const& name) const; @@ -85,7 +85,7 @@ public: // for tx level permission, permission value is equal to tx type plus one uint32_t - txToPermissionType(const TxType& type) const; + txToPermissionType(TxType const& type) const; // tx type value is permission value minus one TxType diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 6783fbf6d..f1a3a5822 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -113,8 +113,8 @@ public: // have lower unsigned integer representations. using value_type = std::uint64_t; - static const int minTickSize = 3; - static const int maxTickSize = 16; + static int const minTickSize = 3; + static int const maxTickSize = 16; private: // This has the same representation as STAmount, see the comment on the diff --git a/include/xrpl/protocol/SField.h b/include/xrpl/protocol/SField.h index 298bf6596..deb344630 100644 --- a/include/xrpl/protocol/SField.h +++ b/include/xrpl/protocol/SField.h @@ -183,22 +183,22 @@ public: private_access_tag_t, SerializedTypeID tid, int fv, - const char* fn, + char const* fn, int meta = sMD_Default, IsSigning signing = IsSigning::yes); explicit SField(private_access_tag_t, int fc); - static const SField& + static SField const& getField(int fieldCode); - static const SField& + static SField const& getField(std::string const& fieldName); - static const SField& + static SField const& getField(int type, int value) { return getField(field_code(type, value)); } - static const SField& + static SField const& getField(SerializedTypeID type, int value) { return getField(field_code(type, value)); @@ -285,19 +285,19 @@ public: } bool - operator==(const SField& f) const + operator==(SField const& f) const { return fieldCode == f.fieldCode; } bool - operator!=(const SField& f) const + operator!=(SField const& f) const { return fieldCode != f.fieldCode; } static int - compare(const SField& f1, const SField& f2); + compare(SField const& f1, SField const& f2); static std::map knownCodeToField; diff --git a/include/xrpl/protocol/STAccount.h b/include/xrpl/protocol/STAccount.h index 537a336e5..422a01def 100644 --- a/include/xrpl/protocol/STAccount.h +++ b/include/xrpl/protocol/STAccount.h @@ -58,7 +58,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index b9fd34bbc..c71dcb108 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -62,20 +62,20 @@ private: public: using value_type = STAmount; - static const int cMinOffset = -96; - static const int cMaxOffset = 80; + static int const cMinOffset = -96; + static int const cMaxOffset = 80; // Maximum native value supported by the code - static const std::uint64_t cMinValue = 1000000000000000ull; - static const std::uint64_t cMaxValue = 9999999999999999ull; - static const std::uint64_t cMaxNative = 9000000000000000000ull; + static std::uint64_t const cMinValue = 1000000000000000ull; + static std::uint64_t const cMaxValue = 9999999999999999ull; + static std::uint64_t const cMaxNative = 9000000000000000000ull; // Max native value on network. - static const std::uint64_t cMaxNativeN = 100000000000000000ull; - static const std::uint64_t cIssuedCurrency = 0x8000000000000000ull; - static const std::uint64_t cPositive = 0x4000000000000000ull; - static const std::uint64_t cMPToken = 0x2000000000000000ull; - static const std::uint64_t cValueMask = ~(cPositive | cMPToken); + static std::uint64_t const cMaxNativeN = 100000000000000000ull; + static std::uint64_t const cIssuedCurrency = 0x8000000000000000ull; + static std::uint64_t const cPositive = 0x4000000000000000ull; + static std::uint64_t const cMPToken = 0x2000000000000000ull; + static std::uint64_t const cValueMask = ~(cPositive | cMPToken); static std::uint64_t const uRateOne; @@ -274,7 +274,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; @@ -716,8 +716,8 @@ isAddable(STAmount const& amt1, STAmount const& amt2) return (finalAmt >= A && finalAmt >= B); } - static const STAmount one{IOUAmount{1, 0}, noIssue()}; - static const STAmount maxLoss{IOUAmount{1, -4}, noIssue()}; + static STAmount const one{IOUAmount{1, 0}, noIssue()}; + static STAmount const maxLoss{IOUAmount{1, -4}, noIssue()}; STAmount A = amt1; STAmount B = amt2; diff --git a/include/xrpl/protocol/STArray.h b/include/xrpl/protocol/STArray.h index 987e61326..51293ca4d 100644 --- a/include/xrpl/protocol/STArray.h +++ b/include/xrpl/protocol/STArray.h @@ -131,13 +131,13 @@ public: add(Serializer& s) const override; void - sort(bool (*compare)(const STObject& o1, const STObject& o2)); + sort(bool (*compare)(STObject const& o1, STObject const& o2)); bool - operator==(const STArray& s) const; + operator==(STArray const& s) const; bool - operator!=(const STArray& s) const; + operator!=(STArray const& s) const; iterator erase(iterator pos); @@ -155,7 +155,7 @@ public: getSType() const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; @@ -278,13 +278,13 @@ STArray::swap(STArray& a) noexcept } inline bool -STArray::operator==(const STArray& s) const +STArray::operator==(STArray const& s) const { return v_ == s.v_; } inline bool -STArray::operator!=(const STArray& s) const +STArray::operator!=(STArray const& s) const { return v_ != s.v_; } diff --git a/include/xrpl/protocol/STBase.h b/include/xrpl/protocol/STBase.h index e0f28e03d..8d0aaabe4 100644 --- a/include/xrpl/protocol/STBase.h +++ b/include/xrpl/protocol/STBase.h @@ -129,16 +129,16 @@ class STBase public: virtual ~STBase() = default; STBase(); - STBase(const STBase&) = default; + STBase(STBase const&) = default; STBase& - operator=(const STBase& t); + operator=(STBase const& t); explicit STBase(SField const& n); bool - operator==(const STBase& t) const; + operator==(STBase const& t) const; bool - operator!=(const STBase& t) const; + operator!=(STBase const& t) const; template D& @@ -197,7 +197,7 @@ private: //------------------------------------------------------------------------------ std::ostream& -operator<<(std::ostream& out, const STBase& t); +operator<<(std::ostream& out, STBase const& t); template D& diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index bf4ce84a3..7d41637c8 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -45,8 +45,8 @@ public: STBitString() = default; STBitString(SField const& n); - STBitString(const value_type& v); - STBitString(SField const& n, const value_type& v); + STBitString(value_type const& v); + STBitString(SField const& n, value_type const& v); STBitString(SerialIter& sit, SField const& name); SerializedTypeID @@ -56,7 +56,7 @@ public: getText() const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; void add(Serializer& s) const override; @@ -93,12 +93,12 @@ inline STBitString::STBitString(SField const& n) : STBase(n) } template -inline STBitString::STBitString(const value_type& v) : value_(v) +inline STBitString::STBitString(value_type const& v) : value_(v) { } template -inline STBitString::STBitString(SField const& n, const value_type& v) +inline STBitString::STBitString(SField const& n, value_type const& v) : STBase(n), value_(v) { } @@ -160,9 +160,9 @@ STBitString::getText() const template bool -STBitString::isEquivalent(const STBase& t) const +STBitString::isEquivalent(STBase const& t) const { - const STBitString* v = dynamic_cast(&t); + STBitString const* v = dynamic_cast(&t); return v && (value_ == v->value_); } diff --git a/include/xrpl/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h index cfe4ab5af..80832b268 100644 --- a/include/xrpl/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -63,7 +63,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; diff --git a/include/xrpl/protocol/STCurrency.h b/include/xrpl/protocol/STCurrency.h index 3383137fb..90a658904 100644 --- a/include/xrpl/protocol/STCurrency.h +++ b/include/xrpl/protocol/STCurrency.h @@ -65,7 +65,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 68e25be1c..b25963877 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -54,7 +54,7 @@ public: isDefault() const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; STInteger& operator=(value_type const& v); @@ -127,9 +127,9 @@ STInteger::isDefault() const template inline bool -STInteger::isEquivalent(const STBase& t) const +STInteger::isEquivalent(STBase const& t) const { - const STInteger* v = dynamic_cast(&t); + STInteger const* v = dynamic_cast(&t); return v && (value_ == v->value_); } diff --git a/include/xrpl/protocol/STIssue.h b/include/xrpl/protocol/STIssue.h index 08812c15a..c729854e1 100644 --- a/include/xrpl/protocol/STIssue.h +++ b/include/xrpl/protocol/STIssue.h @@ -71,7 +71,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; diff --git a/include/xrpl/protocol/STLedgerEntry.h b/include/xrpl/protocol/STLedgerEntry.h index 96b37af0b..3609a04d4 100644 --- a/include/xrpl/protocol/STLedgerEntry.h +++ b/include/xrpl/protocol/STLedgerEntry.h @@ -35,7 +35,7 @@ class STLedgerEntry final : public STObject, public CountedObject public: using pointer = std::shared_ptr; - using ref = const std::shared_ptr&; + using ref = std::shared_ptr const&; /** Create an empty object with the given key and type. */ explicit STLedgerEntry(Keylet const& k); diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index b89a415eb..2efa82826 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -99,8 +99,8 @@ public: STObject& operator=(STObject&& other); - STObject(const SOTemplate& type, SField const& name); - STObject(const SOTemplate& type, SerialIter& sit, SField const& name); + STObject(SOTemplate const& type, SField const& name); + STObject(SOTemplate const& type, SerialIter& sit, SField const& name); STObject(SerialIter& sit, SField const& name, int depth = 0); STObject(SerialIter&& sit, SField const& name); explicit STObject(SField const& name); @@ -121,7 +121,7 @@ public: reserve(std::size_t n); void - applyTemplate(const SOTemplate& type); + applyTemplate(SOTemplate const& type); void applyTemplateFromSField(SField const&); @@ -130,7 +130,7 @@ public: isFree() const; void - set(const SOTemplate&); + set(SOTemplate const&); bool set(SerialIter& u, int depth = 0); @@ -139,7 +139,7 @@ public: getSType() const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; @@ -183,13 +183,13 @@ public: uint256 getSigningHash(HashPrefix prefix) const; - const STBase& + STBase const& peekAtIndex(int offset) const; STBase& getIndex(int offset); - const STBase* + STBase const* peekAtPIndex(int offset) const; STBase* @@ -201,13 +201,13 @@ public: SField const& getFieldSType(int index) const; - const STBase& + STBase const& peekAtField(SField const& field) const; STBase& getField(SField const& field); - const STBase* + STBase const* peekAtPField(SField const& field) const; STBase* @@ -241,11 +241,11 @@ public: getFieldAmount(SField const& field) const; STPathSet const& getFieldPathSet(SField const& field) const; - const STVector256& + STVector256 const& getFieldV256(SField const& field) const; - const STArray& + STArray const& getFieldArray(SField const& field) const; - const STCurrency& + STCurrency const& getFieldCurrency(SField const& field) const; STNumber const& getFieldNumber(SField const& field) const; @@ -409,12 +409,12 @@ public: delField(int index); bool - hasMatchingEntry(const STBase&); + hasMatchingEntry(STBase const&); bool - operator==(const STObject& o) const; + operator==(STObject const& o) const; bool - operator!=(const STObject& o) const; + operator!=(STObject const& o) const; class FieldErr; @@ -970,7 +970,7 @@ STObject::getCount() const return v_.size(); } -inline const STBase& +inline STBase const& STObject::peekAtIndex(int offset) const { return v_[offset].get(); @@ -982,7 +982,7 @@ STObject::getIndex(int offset) return v_[offset].get(); } -inline const STBase* +inline STBase const* STObject::peekAtPIndex(int offset) const { return &v_[offset].get(); @@ -1117,7 +1117,7 @@ STObject::setFieldH160(SField const& field, base_uint<160, Tag> const& v) } inline bool -STObject::operator!=(const STObject& o) const +STObject::operator!=(STObject const& o) const { return !(*this == o); } @@ -1126,7 +1126,7 @@ template V STObject::getFieldByValue(SField const& field) const { - const STBase* rf = peekAtPField(field); + STBase const* rf = peekAtPField(field); if (!rf) throwFieldNotFound(field); @@ -1136,7 +1136,7 @@ STObject::getFieldByValue(SField const& field) const if (id == STI_NOTPRESENT) return V(); // optional field not present - const T* cf = dynamic_cast(rf); + T const* cf = dynamic_cast(rf); if (!cf) Throw("Wrong field type"); @@ -1153,7 +1153,7 @@ template V const& STObject::getFieldByConstRef(SField const& field, V const& empty) const { - const STBase* rf = peekAtPField(field); + STBase const* rf = peekAtPField(field); if (!rf) throwFieldNotFound(field); @@ -1163,7 +1163,7 @@ STObject::getFieldByConstRef(SField const& field, V const& empty) const if (id == STI_NOTPRESENT) return empty; // optional field not present - const T* cf = dynamic_cast(rf); + T const* cf = dynamic_cast(rf); if (!cf) Throw("Wrong field type"); diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index 7605a2283..c56dd43e7 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -106,10 +106,10 @@ public: getIssuerID() const; bool - operator==(const STPathElement& t) const; + operator==(STPathElement const& t) const; bool - operator!=(const STPathElement& t) const; + operator!=(STPathElement const& t) const; private: static std::size_t @@ -164,7 +164,7 @@ public: STPathElement& operator[](int i); - const STPathElement& + STPathElement const& operator[](int i) const; void @@ -196,7 +196,7 @@ public: assembleAdd(STPath const& base, STPathElement const& tail); bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; @@ -375,7 +375,7 @@ STPathElement::getIssuerID() const } inline bool -STPathElement::operator==(const STPathElement& t) const +STPathElement::operator==(STPathElement const& t) const { return (mType & typeAccount) == (t.mType & typeAccount) && hash_value_ == t.hash_value_ && mAccountID == t.mAccountID && @@ -383,7 +383,7 @@ STPathElement::operator==(const STPathElement& t) const } inline bool -STPathElement::operator!=(const STPathElement& t) const +STPathElement::operator!=(STPathElement const& t) const { return !operator==(t); } @@ -455,7 +455,7 @@ STPath::operator[](int i) return mPath[i]; } -inline const STPathElement& +inline STPathElement const& STPath::operator[](int i) const { return mPath[i]; diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index d81ddf977..bc22ebdc7 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -50,7 +50,7 @@ public: Json::Value getJson(JsonOptions) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; @@ -62,7 +62,7 @@ public: operator=(std::vector&& v); void - setValue(const STVector256& v); + setValue(STVector256 const& v); /** Retrieve a copy of the vector we contain */ explicit @@ -153,7 +153,7 @@ STVector256::operator=(std::vector&& v) } inline void -STVector256::setValue(const STVector256& v) +STVector256::setValue(STVector256 const& v) { mValue = v.mValue; } diff --git a/include/xrpl/protocol/STXChainBridge.h b/include/xrpl/protocol/STXChainBridge.h index 813bcc444..4435857a5 100644 --- a/include/xrpl/protocol/STXChainBridge.h +++ b/include/xrpl/protocol/STXChainBridge.h @@ -107,7 +107,7 @@ public: add(Serializer& s) const override; bool - isEquivalent(const STBase& t) const override; + isEquivalent(STBase const& t) const override; bool isDefault() const override; diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index 5724a19f5..9c77aa411 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -139,9 +139,9 @@ public: int addRaw(Slice slice); int - addRaw(const void* ptr, int len); + addRaw(void const* ptr, int len); int - addRaw(const Serializer& s); + addRaw(Serializer const& s); int addVL(Blob const& vector); @@ -151,7 +151,7 @@ public: int addVL(Iter begin, Iter end, int len); int - addVL(const void* ptr, int len); + addVL(void const* ptr, int len); // disassemble functions bool @@ -161,7 +161,7 @@ public: bool getInteger(Integer& number, int offset) { - static const auto bytes = sizeof(Integer); + static auto const bytes = sizeof(Integer); if ((offset + bytes) > mData.size()) return false; number = 0; @@ -220,7 +220,7 @@ public: { return mData.size(); } - const void* + void const* getDataPtr() const { return mData.data(); @@ -238,7 +238,7 @@ public: std::string getString() const { - return std::string(static_cast(getDataPtr()), size()); + return std::string(static_cast(getDataPtr()), size()); } void erase() @@ -296,12 +296,12 @@ public: return v != mData; } bool - operator==(const Serializer& v) const + operator==(Serializer const& v) const { return v.mData == mData; } bool - operator!=(const Serializer& v) const + operator!=(Serializer const& v) const { return v.mData != mData; } diff --git a/include/xrpl/protocol/UintTypes.h b/include/xrpl/protocol/UintTypes.h index 32f4465e9..561bfbcc0 100644 --- a/include/xrpl/protocol/UintTypes.h +++ b/include/xrpl/protocol/UintTypes.h @@ -85,7 +85,7 @@ isXRP(Currency const& c) inline bool isBadCurrency(Currency const& c) { - static const std::set badCurrencies{ + static std::set const badCurrencies{ Currency(0x7861680000000000), // xah Currency(0x7861480000000000), // xaH Currency(0x7841680000000000), // xAh diff --git a/include/xrpl/protocol/XRPAmount.h b/include/xrpl/protocol/XRPAmount.h index 1d6cae9ec..332735dc6 100644 --- a/include/xrpl/protocol/XRPAmount.h +++ b/include/xrpl/protocol/XRPAmount.h @@ -267,7 +267,7 @@ XRPAmount::decimalXRP() const // Output XRPAmount as just the drops value. template std::basic_ostream& -operator<<(std::basic_ostream& os, const XRPAmount& q) +operator<<(std::basic_ostream& os, XRPAmount const& q) { return os << q.drops(); } diff --git a/include/xrpl/protocol/detail/token_errors.h b/include/xrpl/protocol/detail/token_errors.h index 23a46bd1c..0ae272802 100644 --- a/include/xrpl/protocol/detail/token_errors.h +++ b/include/xrpl/protocol/detail/token_errors.h @@ -50,7 +50,7 @@ class TokenCodecErrcCategory : public std::error_category { public: // Return a short descriptive name for the category - virtual const char* + virtual char const* name() const noexcept override final { return "TokenCodecError"; @@ -86,7 +86,7 @@ public: }; } // namespace detail -inline const ripple::detail::TokenCodecErrcCategory& +inline ripple::detail::TokenCodecErrcCategory const& TokenCodecErrcCategory() { static ripple::detail::TokenCodecErrcCategory c; diff --git a/include/xrpl/protocol/json_get_or_throw.h b/include/xrpl/protocol/json_get_or_throw.h index 5277ee864..c59b5a71a 100644 --- a/include/xrpl/protocol/json_get_or_throw.h +++ b/include/xrpl/protocol/json_get_or_throw.h @@ -20,7 +20,7 @@ struct JsonMissingKeyError : std::exception JsonMissingKeyError(Json::StaticString const& k) : key{k.c_str()} { } - const char* + char const* what() const noexcept override { if (msg.empty()) @@ -40,7 +40,7 @@ struct JsonTypeMismatchError : std::exception : key{k.c_str()}, expectedType{std::move(et)} { } - const char* + char const* what() const noexcept override { if (msg.empty()) diff --git a/include/xrpl/server/detail/UDPDoor.h b/include/xrpl/server/detail/UDPDoor.h index 9f7f73b77..ea5114617 100644 --- a/include/xrpl/server/detail/UDPDoor.h +++ b/include/xrpl/server/detail/UDPDoor.h @@ -187,10 +187,10 @@ private: return; } - const size_t HEADER_SIZE = 16; - const size_t MAX_DATAGRAM_SIZE = + size_t const HEADER_SIZE = 16; + size_t const MAX_DATAGRAM_SIZE = 65487; // Allow for ipv6 header 40 bytes + 8 bytes of udp header - const size_t MAX_PAYLOAD_SIZE = MAX_DATAGRAM_SIZE - HEADER_SIZE; + size_t const MAX_PAYLOAD_SIZE = MAX_DATAGRAM_SIZE - HEADER_SIZE; // Convert TCP endpoint back to UDP for sending boost::asio::ip::udp::endpoint udp_endpoint( @@ -216,8 +216,8 @@ private: } // Calculate number of packets needed - const size_t payload_size = MAX_PAYLOAD_SIZE; - const uint16_t total_packets = + size_t const payload_size = MAX_PAYLOAD_SIZE; + uint16_t const total_packets = (response.length() + payload_size - 1) / payload_size; // Get current timestamp in microseconds diff --git a/src/libxrpl/basics/Archive.cpp b/src/libxrpl/basics/Archive.cpp index 2ddbc8200..e60b2f12c 100644 --- a/src/libxrpl/basics/Archive.cpp +++ b/src/libxrpl/basics/Archive.cpp @@ -94,7 +94,7 @@ extractTarLz4( if (archive_entry_size(entry) > 0) { - const void* buf; + void const* buf; size_t sz; la_int64_t offset; while (true) diff --git a/src/libxrpl/basics/FileUtilities.cpp b/src/libxrpl/basics/FileUtilities.cpp index 5f58f1354..ffb979261 100644 --- a/src/libxrpl/basics/FileUtilities.cpp +++ b/src/libxrpl/basics/FileUtilities.cpp @@ -64,7 +64,7 @@ getFileContents( return {}; } - const std::string result{ + std::string const result{ std::istreambuf_iterator{fileStream}, std::istreambuf_iterator{}}; diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 606638cb8..a6f29f513 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -348,14 +348,14 @@ Logs::format( // 1. Logging starts before config parsing (needed to debug config issues) // 2. This is a developer feature - devs can easily set env vars // 3. Allows per-run overrides without editing config files - static const char* fmt = []() { - const char* env = std::getenv("LOG_DATE_FORMAT"); + static char const* fmt = []() { + char const* env = std::getenv("LOG_DATE_FORMAT"); return env ? env : "%Y-%b-%d %T %Z"; // Default format }(); // Check if we should use local time - static const bool useLocalTime = []() { - const char* env = std::getenv("LOG_DATE_LOCAL"); + static bool const useLocalTime = []() { + char const* env = std::getenv("LOG_DATE_LOCAL"); return env && std::strcmp(env, "1") == 0; }(); diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 186a363b4..f43288b57 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -469,7 +469,7 @@ Number::operator/=(Number const& y) } // Shift by 10^17 gives greatest precision while not overflowing uint128_t // or the cast back to int64_t - const uint128_t f = 100'000'000'000'000'000; + uint128_t const f = 100'000'000'000'000'000; mantissa_ = static_cast(uint128_t(nm) * f / uint128_t(dm)); exponent_ = ne - de - 17; mantissa_ *= np * dp; diff --git a/src/libxrpl/basics/StringUtilities.cpp b/src/libxrpl/basics/StringUtilities.cpp index 500873071..3cf3df209 100644 --- a/src/libxrpl/basics/StringUtilities.cpp +++ b/src/libxrpl/basics/StringUtilities.cpp @@ -89,13 +89,13 @@ parseUrl(parsedURL& pUrl, std::string const& strUrl) boost::algorithm::to_lower(pUrl.scheme); pUrl.username = smMatch[2]; pUrl.password = smMatch[3]; - const std::string domain = smMatch[4]; + std::string const domain = smMatch[4]; // We need to use Endpoint to parse the domain to // strip surrounding brackets from IPv6 addresses, // e.g. [::1] => ::1. - const auto result = beast::IP::Endpoint::from_string_checked(domain); + auto const result = beast::IP::Endpoint::from_string_checked(domain); pUrl.domain = result ? result->address().to_string() : domain; - const std::string port = smMatch[5]; + std::string const port = smMatch[5]; if (!port.empty()) { pUrl.port = beast::lexicalCast(port); diff --git a/src/libxrpl/basics/UptimeClock.cpp b/src/libxrpl/basics/UptimeClock.cpp index 42ba479fa..7b61a5397 100644 --- a/src/libxrpl/basics/UptimeClock.cpp +++ b/src/libxrpl/basics/UptimeClock.cpp @@ -67,7 +67,7 @@ UptimeClock::time_point UptimeClock::now() { // start the update thread on first use - static const auto init = start_clock(); + static auto const init = start_clock(); // Return the number of seconds since rippled start return time_point{duration{now_}}; diff --git a/src/libxrpl/beast/utility/beast_EnhancedLogging.cpp b/src/libxrpl/beast/utility/beast_EnhancedLogging.cpp index 08a173950..49ac4e98d 100644 --- a/src/libxrpl/beast/utility/beast_EnhancedLogging.cpp +++ b/src/libxrpl/beast/utility/beast_EnhancedLogging.cpp @@ -34,7 +34,7 @@ namespace detail { bool should_log_use_colors() { - static const bool use_colors = []() { + static bool const use_colors = []() { // Honor NO_COLOR environment variable (standard) if (std::getenv("NO_COLOR")) return false; @@ -51,11 +51,11 @@ should_log_use_colors() // Get the log highlight color - can be overridden via // LOG_HIGHLIGHT_COLOR -const char* +char const* get_log_highlight_color() { - static const char* escape = []() { - const char* env = std::getenv("LOG_HIGHLIGHT_COLOR"); + static char const* escape = []() { + char const* env = std::getenv("LOG_HIGHLIGHT_COLOR"); if (!env) return "\033[36m"; // Default: cyan @@ -91,8 +91,8 @@ get_log_highlight_color() bool should_show_location() { - static const bool show = []() { - const char* env = std::getenv("LOG_DISABLE"); + static bool const show = []() { + char const* env = std::getenv("LOG_DISABLE"); // Show location by default, hide if LOG_DISABLE=1 return !env || std::strcmp(env, "1") != 0; }(); @@ -101,7 +101,7 @@ should_show_location() // Helper to write location string (no leading/trailing space) void -log_write_location_string(std::ostream& os, const char* file, int line) +log_write_location_string(std::ostream& os, char const* file, int line) { if (detail::should_log_use_colors()) { diff --git a/src/libxrpl/beast/utility/beast_Journal.cpp b/src/libxrpl/beast/utility/beast_Journal.cpp index b9349dbae..4d4238d29 100644 --- a/src/libxrpl/beast/utility/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/beast_Journal.cpp @@ -154,7 +154,7 @@ Journal::ScopedStream::ScopedStream( Journal::ScopedStream::ScopedStream( Sink& sink, Severity level, - const char* file, + char const* file, int line) : m_sink(sink), m_level(level), file_(file), line_(line) { diff --git a/src/libxrpl/json/Writer.cpp b/src/libxrpl/json/Writer.cpp index 94c734478..369763da0 100644 --- a/src/libxrpl/json/Writer.cpp +++ b/src/libxrpl/json/Writer.cpp @@ -34,7 +34,7 @@ namespace Json { namespace { -std::map jsonSpecialCharacterEscape = { +std::map jsonSpecialCharacterEscape = { {'"', "\\\""}, {'\\', "\\\\"}, {'/', "\\/"}, @@ -47,13 +47,13 @@ std::map jsonSpecialCharacterEscape = { static size_t const jsonEscapeLength = 2; // All other JSON punctuation. -const char closeBrace = '}'; -const char closeBracket = ']'; -const char colon = ':'; -const char comma = ','; -const char openBrace = '{'; -const char openBracket = '['; -const char quote = '"'; +char const closeBrace = '}'; +char const closeBracket = ']'; +char const colon = ':'; +char const comma = ','; +char const openBrace = '{'; +char const openBracket = '['; +char const quote = '"'; static auto const integralFloatsBecomeInts = false; diff --git a/src/libxrpl/json/json_reader.cpp b/src/libxrpl/json/json_reader.cpp index 6818d73de..9bad898be 100644 --- a/src/libxrpl/json/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -78,8 +78,8 @@ bool Reader::parse(std::string const& document, Value& root) { document_ = document; - const char* begin = document_.c_str(); - const char* end = begin + document_.length(); + char const* begin = document_.c_str(); + char const* end = begin + document_.length(); return parse(begin, end, root); } @@ -99,7 +99,7 @@ Reader::parse(std::istream& sin, Value& root) } bool -Reader::parse(const char* beginDoc, const char* endDoc, Value& root) +Reader::parse(char const* beginDoc, char const* endDoc, Value& root) { begin_ = beginDoc; end_ = endDoc; @@ -193,7 +193,7 @@ Reader::skipCommentTokens(Token& token) } bool -Reader::expectToken(TokenType type, Token& token, const char* message) +Reader::expectToken(TokenType type, Token& token, char const* message) { readToken(token); @@ -629,7 +629,7 @@ bool Reader::decodeDouble(Token& token) { double value = 0; - const int bufferSize = 32; + int const bufferSize = 32; int count; int length = int(token.end_ - token.start_); // Sanity check to avoid buffer overflow exploits. @@ -939,7 +939,7 @@ Reader::getFormatedErrorMessages() const itError != errors_.end(); ++itError) { - const ErrorInfo& error = *itError; + ErrorInfo const& error = *itError; formattedMessage += "* " + getLocationLineAndColumn(error.token_.start_) + "\n"; formattedMessage += " " + error.message_ + "\n"; diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index 709b425d6..86a8ed5ae 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -31,10 +31,10 @@ namespace Json { -const Value Value::null; -const Int Value::minInt = Int(~(UInt(-1) / 2)); -const Int Value::maxInt = Int(UInt(-1) / 2); -const UInt Value::maxUInt = UInt(-1); +Value const Value::null; +Int const Value::minInt = Int(~(UInt(-1) / 2)); +Int const Value::maxInt = Int(UInt(-1) / 2); +UInt const Value::maxUInt = UInt(-1); class DefaultValueAllocator : public ValueAllocator { @@ -42,7 +42,7 @@ public: virtual ~DefaultValueAllocator() = default; char* - makeMemberName(const char* memberName) override + makeMemberName(char const* memberName) override { return duplicateStringValue(memberName); } @@ -54,7 +54,7 @@ public: } char* - duplicateStringValue(const char* value, unsigned int length = unknown) + duplicateStringValue(char const* value, unsigned int length = unknown) override { //@todo investigate this old optimization @@ -110,14 +110,14 @@ Value::CZString::CZString(int index) : cstr_(0), index_(index) { } -Value::CZString::CZString(const char* cstr, DuplicationPolicy allocate) +Value::CZString::CZString(char const* cstr, DuplicationPolicy allocate) : cstr_( allocate == duplicate ? valueAllocator()->makeMemberName(cstr) : cstr) , index_(allocate) { } -Value::CZString::CZString(const CZString& other) +Value::CZString::CZString(CZString const& other) : cstr_( other.index_ != noDuplication && other.cstr_ != 0 ? valueAllocator()->makeMemberName(other.cstr_) @@ -136,7 +136,7 @@ Value::CZString::~CZString() } bool -Value::CZString::operator<(const CZString& other) const +Value::CZString::operator<(CZString const& other) const { if (cstr_ && other.cstr_) return strcmp(cstr_, other.cstr_) < 0; @@ -145,7 +145,7 @@ Value::CZString::operator<(const CZString& other) const } bool -Value::CZString::operator==(const CZString& other) const +Value::CZString::operator==(CZString const& other) const { if (cstr_ && other.cstr_) return strcmp(cstr_, other.cstr_) == 0; @@ -159,7 +159,7 @@ Value::CZString::index() const return index_; } -const char* +char const* Value::CZString::c_str() const { return cstr_; @@ -232,7 +232,7 @@ Value::Value(double value) : type_(realValue) value_.real_ = value; } -Value::Value(const char* value) : type_(stringValue), allocated_(true) +Value::Value(char const* value) : type_(stringValue), allocated_(true) { value_.string_ = valueAllocator()->duplicateStringValue(value); } @@ -243,7 +243,7 @@ Value::Value(std::string const& value) : type_(stringValue), allocated_(true) value.c_str(), (unsigned int)value.length()); } -Value::Value(const StaticString& value) : type_(stringValue), allocated_(false) +Value::Value(StaticString const& value) : type_(stringValue), allocated_(false) { value_.string_ = const_cast(value.c_str()); } @@ -253,7 +253,7 @@ Value::Value(bool value) : type_(booleanValue) value_.bool_ = value; } -Value::Value(const Value& other) : type_(other.type_) +Value::Value(Value const& other) : type_(other.type_) { switch (type_) { @@ -370,7 +370,7 @@ integerCmp(Int i, UInt ui) } bool -operator<(const Value& x, const Value& y) +operator<(Value const& x, Value const& y) { if (auto signum = x.type_ - y.type_) { @@ -419,7 +419,7 @@ operator<(const Value& x, const Value& y) } bool -operator==(const Value& x, const Value& y) +operator==(Value const& x, Value const& y) { if (x.type_ != y.type_) { @@ -464,7 +464,7 @@ operator==(const Value& x, const Value& y) return 0; // unreachable } -const char* +char const* Value::asCString() const { XRPL_ASSERT(type_ == stringValue, "Json::Value::asCString : valid type"); @@ -795,7 +795,7 @@ Value::operator[](UInt index) return (*it).second; } -const Value& +Value const& Value::operator[](UInt index) const { XRPL_ASSERT( @@ -815,13 +815,13 @@ Value::operator[](UInt index) const } Value& -Value::operator[](const char* key) +Value::operator[](char const* key) { return resolveReference(key, false); } Value& -Value::resolveReference(const char* key, bool isStatic) +Value::resolveReference(char const* key, bool isStatic) { XRPL_ASSERT( type_ == nullValue || type_ == objectValue, @@ -844,9 +844,9 @@ Value::resolveReference(const char* key, bool isStatic) } Value -Value::get(UInt index, const Value& defaultValue) const +Value::get(UInt index, Value const& defaultValue) const { - const Value* value = &((*this)[index]); + Value const* value = &((*this)[index]); return value == &null ? defaultValue : *value; } @@ -856,8 +856,8 @@ Value::isValidIndex(UInt index) const return index < size(); } -const Value& -Value::operator[](const char* key) const +Value const& +Value::operator[](char const* key) const { XRPL_ASSERT( type_ == nullValue || type_ == objectValue, @@ -881,20 +881,20 @@ Value::operator[](std::string const& key) return (*this)[key.c_str()]; } -const Value& +Value const& Value::operator[](std::string const& key) const { return (*this)[key.c_str()]; } Value& -Value::operator[](const StaticString& key) +Value::operator[](StaticString const& key) { return resolveReference(key, true); } Value& -Value::append(const Value& value) +Value::append(Value const& value) { return (*this)[size()] = value; } @@ -906,20 +906,20 @@ Value::append(Value&& value) } Value -Value::get(const char* key, const Value& defaultValue) const +Value::get(char const* key, Value const& defaultValue) const { - const Value* value = &((*this)[key]); + Value const* value = &((*this)[key]); return value == &null ? defaultValue : *value; } Value -Value::get(std::string const& key, const Value& defaultValue) const +Value::get(std::string const& key, Value const& defaultValue) const { return get(key.c_str(), defaultValue); } Value -Value::removeMember(const char* key) +Value::removeMember(char const* key) { XRPL_ASSERT( type_ == nullValue || type_ == objectValue, @@ -946,12 +946,12 @@ Value::removeMember(std::string const& key) } bool -Value::isMember(const char* key) const +Value::isMember(char const* key) const { if (type_ != objectValue) return false; - const Value* value = &((*this)[key]); + Value const* value = &((*this)[key]); return value != &null; } diff --git a/src/libxrpl/json/json_valueiterator.cpp b/src/libxrpl/json/json_valueiterator.cpp index 20dedf2bb..9f65a48a0 100644 --- a/src/libxrpl/json/json_valueiterator.cpp +++ b/src/libxrpl/json/json_valueiterator.cpp @@ -37,7 +37,7 @@ ValueIteratorBase::ValueIteratorBase() : current_(), isNull_(true) } ValueIteratorBase::ValueIteratorBase( - const Value::ObjectValues::iterator& current) + Value::ObjectValues::iterator const& current) : current_(current), isNull_(false) { } @@ -61,7 +61,7 @@ ValueIteratorBase::decrement() } ValueIteratorBase::difference_type -ValueIteratorBase::computeDistance(const SelfType& other) const +ValueIteratorBase::computeDistance(SelfType const& other) const { // Iterator for null value are initialized using the default // constructor, which initialize current_ to the default @@ -89,7 +89,7 @@ ValueIteratorBase::computeDistance(const SelfType& other) const } bool -ValueIteratorBase::isEqual(const SelfType& other) const +ValueIteratorBase::isEqual(SelfType const& other) const { if (isNull_) { @@ -100,7 +100,7 @@ ValueIteratorBase::isEqual(const SelfType& other) const } void -ValueIteratorBase::copy(const SelfType& other) +ValueIteratorBase::copy(SelfType const& other) { current_ = other.current_; } @@ -108,7 +108,7 @@ ValueIteratorBase::copy(const SelfType& other) Value ValueIteratorBase::key() const { - const Value::CZString czstring = (*current_).first; + Value::CZString const czstring = (*current_).first; if (czstring.c_str()) { @@ -124,7 +124,7 @@ ValueIteratorBase::key() const UInt ValueIteratorBase::index() const { - const Value::CZString czstring = (*current_).first; + Value::CZString const czstring = (*current_).first; if (!czstring.c_str()) return czstring.index(); @@ -132,10 +132,10 @@ ValueIteratorBase::index() const return Value::UInt(-1); } -const char* +char const* ValueIteratorBase::memberName() const { - const char* name = (*current_).first.c_str(); + char const* name = (*current_).first.c_str(); return name ? name : ""; } @@ -148,13 +148,13 @@ ValueIteratorBase::memberName() const // ////////////////////////////////////////////////////////////////// ValueConstIterator::ValueConstIterator( - const Value::ObjectValues::iterator& current) + Value::ObjectValues::iterator const& current) : ValueIteratorBase(current) { } ValueConstIterator& -ValueConstIterator::operator=(const ValueIteratorBase& other) +ValueConstIterator::operator=(ValueIteratorBase const& other) { copy(other); return *this; @@ -168,23 +168,23 @@ ValueConstIterator::operator=(const ValueIteratorBase& other) // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// -ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current) +ValueIterator::ValueIterator(Value::ObjectValues::iterator const& current) : ValueIteratorBase(current) { } -ValueIterator::ValueIterator(const ValueConstIterator& other) +ValueIterator::ValueIterator(ValueConstIterator const& other) : ValueIteratorBase(other) { } -ValueIterator::ValueIterator(const ValueIterator& other) +ValueIterator::ValueIterator(ValueIterator const& other) : ValueIteratorBase(other) { } ValueIterator& -ValueIterator::operator=(const SelfType& other) +ValueIterator::operator=(SelfType const& other) { copy(other); return *this; diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index a830f2855..fabc69735 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -40,7 +40,7 @@ isControlCharacter(char ch) } static bool -containsControlCharacter(const char* str) +containsControlCharacter(char const* str) { while (*str) { @@ -117,7 +117,7 @@ valueToString(bool value) } std::string -valueToQuotedString(const char* value) +valueToQuotedString(char const* value) { // Not sure how to handle unicode... if (strpbrk(value, "\"\\\b\f\n\r\t") == nullptr && @@ -132,7 +132,7 @@ valueToQuotedString(const char* value) result.reserve(maxsize); // to avoid lots of mallocs result += "\""; - for (const char* c = value; *c != 0; ++c) + for (char const* c = value; *c != 0; ++c) { switch (*c) { @@ -197,7 +197,7 @@ valueToQuotedString(const char* value) // ////////////////////////////////////////////////////////////////// std::string -FastWriter::write(const Value& root) +FastWriter::write(Value const& root) { document_ = ""; writeValue(root); @@ -205,7 +205,7 @@ FastWriter::write(const Value& root) } void -FastWriter::writeValue(const Value& value) +FastWriter::writeValue(Value const& value) { switch (value.type()) { @@ -281,7 +281,7 @@ StyledWriter::StyledWriter() : rightMargin_(74), indentSize_(3) } std::string -StyledWriter::write(const Value& root) +StyledWriter::write(Value const& root) { document_ = ""; addChildValues_ = false; @@ -292,7 +292,7 @@ StyledWriter::write(const Value& root) } void -StyledWriter::writeValue(const Value& value) +StyledWriter::writeValue(Value const& value) { switch (value.type()) { @@ -338,7 +338,7 @@ StyledWriter::writeValue(const Value& value) while (true) { std::string const& name = *it; - const Value& childValue = value[name]; + Value const& childValue = value[name]; writeWithIndent(valueToQuotedString(name.c_str())); document_ += " : "; writeValue(childValue); @@ -358,7 +358,7 @@ StyledWriter::writeValue(const Value& value) } void -StyledWriter::writeArrayValue(const Value& value) +StyledWriter::writeArrayValue(Value const& value) { unsigned size = value.size(); @@ -377,7 +377,7 @@ StyledWriter::writeArrayValue(const Value& value) while (true) { - const Value& childValue = value[index]; + Value const& childValue = value[index]; if (hasChildValue) writeWithIndent(childValues_[index]); @@ -417,7 +417,7 @@ StyledWriter::writeArrayValue(const Value& value) } bool -StyledWriter::isMultineArray(const Value& value) +StyledWriter::isMultineArray(Value const& value) { int size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; @@ -425,7 +425,7 @@ StyledWriter::isMultineArray(const Value& value) for (int index = 0; index < size && !isMultiLine; ++index) { - const Value& childValue = value[index]; + Value const& childValue = value[index]; isMultiLine = isMultiLine || ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); @@ -507,7 +507,7 @@ StyledStreamWriter::StyledStreamWriter(std::string indentation) } void -StyledStreamWriter::write(std::ostream& out, const Value& root) +StyledStreamWriter::write(std::ostream& out, Value const& root) { document_ = &out; addChildValues_ = false; @@ -518,7 +518,7 @@ StyledStreamWriter::write(std::ostream& out, const Value& root) } void -StyledStreamWriter::writeValue(const Value& value) +StyledStreamWriter::writeValue(Value const& value) { switch (value.type()) { @@ -564,7 +564,7 @@ StyledStreamWriter::writeValue(const Value& value) while (true) { std::string const& name = *it; - const Value& childValue = value[name]; + Value const& childValue = value[name]; writeWithIndent(valueToQuotedString(name.c_str())); *document_ << " : "; writeValue(childValue); @@ -584,7 +584,7 @@ StyledStreamWriter::writeValue(const Value& value) } void -StyledStreamWriter::writeArrayValue(const Value& value) +StyledStreamWriter::writeArrayValue(Value const& value) { unsigned size = value.size(); @@ -603,7 +603,7 @@ StyledStreamWriter::writeArrayValue(const Value& value) while (true) { - const Value& childValue = value[index]; + Value const& childValue = value[index]; if (hasChildValue) writeWithIndent(childValues_[index]); @@ -643,7 +643,7 @@ StyledStreamWriter::writeArrayValue(const Value& value) } bool -StyledStreamWriter::isMultineArray(const Value& value) +StyledStreamWriter::isMultineArray(Value const& value) { int size = value.size(); bool isMultiLine = size * 3 >= rightMargin_; @@ -651,7 +651,7 @@ StyledStreamWriter::isMultineArray(const Value& value) for (int index = 0; index < size && !isMultiLine; ++index) { - const Value& childValue = value[index]; + Value const& childValue = value[index]; isMultiLine = isMultiLine || ((childValue.isArray() || childValue.isObject()) && childValue.size() > 0); @@ -726,7 +726,7 @@ StyledStreamWriter::unindent() } std::ostream& -operator<<(std::ostream& sout, const Value& root) +operator<<(std::ostream& sout, Value const& root) { Json::StyledStreamWriter writer; writer.write(sout, root); diff --git a/src/libxrpl/protocol/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp index 477e792b4..89d07d161 100644 --- a/src/libxrpl/protocol/BuildInfo.cpp +++ b/src/libxrpl/protocol/BuildInfo.cpp @@ -206,7 +206,7 @@ encodeSoftwareVersion(char const* versionStr) // extract and append build number as the final two bytes auto extractBuildNumber = - [](const std::string& str) noexcept -> std::optional { + [](std::string const& str) noexcept -> std::optional { size_t plusPos = str.find('+'); if (plusPos == std::string::npos || plusPos == str.length() - 1) return std::nullopt; diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 3065bdf41..eeeee1c18 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -139,27 +139,27 @@ class FeatureCollections { if (i >= features.size()) LogicError("Invalid FeatureBitset index"); - const auto& sequence = features.get(); + auto const& sequence = features.get(); return sequence[i]; } size_t getIndex(Feature const& feature) const { - const auto& sequence = features.get(); + auto const& sequence = features.get(); auto const it_to = sequence.iterator_to(feature); return it_to - sequence.begin(); } Feature const* getByFeature(uint256 const& feature) const { - const auto& feature_index = features.get(); + auto const& feature_index = features.get(); auto const feature_it = feature_index.find(feature); return feature_it == feature_index.end() ? nullptr : &*feature_it; } Feature const* getByName(std::string const& name) const { - const auto& name_index = features.get(); + auto const& name_index = features.get(); auto const name_it = name_index.find(name); return name_it == name_index.end() ? nullptr : &*name_it; } @@ -240,7 +240,7 @@ FeatureCollections::getRegisteredFeature(std::string const& name) const } void -check(bool condition, const char* logicErrorMessage) +check(bool condition, char const* logicErrorMessage) { if (!condition) LogicError(logicErrorMessage); @@ -437,9 +437,13 @@ featureToName(uint256 const& f) uint256 const feature##name = registerFeature(#name, supported, vote); #define XRPL_FIX(name, supported, vote) \ uint256 const fix##name = registerFeature("fix" #name, supported, vote); -#define XRPL_RETIRE(name) \ - [[deprecated("The referenced amendment has been retired"), maybe_unused]] \ + +// clang-format off +#define XRPL_RETIRE(name) \ + [[deprecated("The referenced amendment has been retired")]] \ + [[maybe_unused]] \ uint256 const retired##name = retireFeature(#name); +// clang-format on #include @@ -455,7 +459,7 @@ featureToName(uint256 const& f) // // Use initialization of one final static variable to set // featureCollections::readOnly. -[[maybe_unused]] static const bool readOnlySet = +[[maybe_unused]] static bool const readOnlySet = featureCollections.registrationIsDone(); } // namespace ripple diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 67b933e37..e4e9ebcbe 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -534,7 +534,7 @@ uritoken(AccountID const& issuer, Blob const& uri) Keylet cron(uint32_t timestamp, std::optional const& id) { - static const uint256 ns = indexHash(LedgerNameSpace::CRON); + static uint256 const ns = indexHash(LedgerNameSpace::CRON); uint8_t h[32]; @@ -554,7 +554,7 @@ cron(uint32_t timestamp, std::optional const& id) return {ltCRON, uint256::fromVoid(h)}; } - const uint256 accHash = indexHash(LedgerNameSpace::CRON, timestamp, *id); + uint256 const accHash = indexHash(LedgerNameSpace::CRON, timestamp, *id); // final 20 bytes are account ID std::memcpy(h + 12, accHash.cdata(), 20); diff --git a/src/libxrpl/protocol/LedgerFormats.cpp b/src/libxrpl/protocol/LedgerFormats.cpp index 6a6983490..d66a79e2a 100644 --- a/src/libxrpl/protocol/LedgerFormats.cpp +++ b/src/libxrpl/protocol/LedgerFormats.cpp @@ -29,7 +29,7 @@ namespace ripple { LedgerFormats::LedgerFormats() { // Fields shared by all ledger formats: - static const std::initializer_list commonFields{ + static std::initializer_list const commonFields{ {sfLedgerIndex, soeOPTIONAL}, {sfLedgerEntryType, soeREQUIRED}, {sfFlags, soeREQUIRED}, diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index f7a970a3b..18649db56 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -183,7 +183,7 @@ Quality Quality::round(int digits) const { // Modulus for mantissa - static const std::uint64_t mod[17] = { + static std::uint64_t const mod[17] = { /* 0 */ 10000000000000000, /* 1 */ 1000000000000000, /* 2 */ 100000000000000, diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index b59e2a2b6..1ffce099b 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -87,7 +87,7 @@ SField::SField( private_access_tag_t, SerializedTypeID tid, int fv, - const char* fn, + char const* fn, int meta, IsSigning signing) : fieldCode(field_code(tid, fv)) diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index ba9a2d191..7229c8524 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -106,7 +106,7 @@ STAccount::add(Serializer& s) const } bool -STAccount::isEquivalent(const STBase& t) const +STAccount::isEquivalent(STBase const& t) const { auto const* const tPtr = dynamic_cast(&t); return tPtr && (default_ == tPtr->default_) && (value_ == tPtr->value_); diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index e0815fbef..f02042bc2 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -90,13 +90,13 @@ setSTAmountCanonicalizeSwitchover(bool v) *getStaticSTAmountCanonicalizeSwitchover() = v; } -static const std::uint64_t tenTo14 = 100000000000000ull; -static const std::uint64_t tenTo14m1 = tenTo14 - 1; -static const std::uint64_t tenTo17 = tenTo14 * 1000; +static std::uint64_t const tenTo14 = 100000000000000ull; +static std::uint64_t const tenTo14m1 = tenTo14 - 1; +static std::uint64_t const tenTo17 = tenTo14 * 1000; //------------------------------------------------------------------------------ static std::int64_t -getInt64Value(STAmount const& amount, bool valid, const char* error) +getInt64Value(STAmount const& amount, bool valid, char const* error) { if (!valid) Throw(error); @@ -680,9 +680,9 @@ STAmount::add(Serializer& s) const } bool -STAmount::isEquivalent(const STBase& t) const +STAmount::isEquivalent(STBase const& t) const { - const STAmount* v = dynamic_cast(&t); + STAmount const* v = dynamic_cast(&t); return v && (*v == *this); } @@ -1065,7 +1065,7 @@ amountFromJsonNoThrow(STAmount& result, Json::Value const& jvSource) result = amountFromJson(sfGeneric, jvSource); return true; } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(debugLog().warn()) << "amountFromJsonNoThrow: caught: " << e.what(); diff --git a/src/libxrpl/protocol/STArray.cpp b/src/libxrpl/protocol/STArray.cpp index 1afb986c1..0644163c8 100644 --- a/src/libxrpl/protocol/STArray.cpp +++ b/src/libxrpl/protocol/STArray.cpp @@ -198,9 +198,9 @@ STArray::getSType() const } bool -STArray::isEquivalent(const STBase& t) const +STArray::isEquivalent(STBase const& t) const { - auto v = dynamic_cast(&t); + auto v = dynamic_cast(&t); return v != nullptr && v_ == v->v_; } @@ -211,7 +211,7 @@ STArray::isDefault() const } void -STArray::sort(bool (*compare)(const STObject&, const STObject&)) +STArray::sort(bool (*compare)(STObject const&, STObject const&)) { std::sort(v_.begin(), v_.end(), compare); } diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index 86e52a1f7..417b7e230 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -40,7 +40,7 @@ STBase::STBase(SField const& n) : fName(&n) } STBase& -STBase::operator=(const STBase& t) +STBase::operator=(STBase const& t) { if (!fName->isUseful()) fName = t.fName; @@ -48,13 +48,13 @@ STBase::operator=(const STBase& t) } bool -STBase::operator==(const STBase& t) const +STBase::operator==(STBase const& t) const { return (getSType() == t.getSType()) && isEquivalent(t); } bool -STBase::operator!=(const STBase& t) const +STBase::operator!=(STBase const& t) const { return (getSType() != t.getSType()) || !isEquivalent(t); } @@ -116,7 +116,7 @@ STBase::add(Serializer& s) const } bool -STBase::isEquivalent(const STBase& t) const +STBase::isEquivalent(STBase const& t) const { XRPL_ASSERT( getSType() == STI_NOTPRESENT, @@ -154,7 +154,7 @@ STBase::addFieldID(Serializer& s) const //------------------------------------------------------------------------------ std::ostream& -operator<<(std::ostream& out, const STBase& t) +operator<<(std::ostream& out, STBase const& t) { return out << t.getFullText(); } diff --git a/src/libxrpl/protocol/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp index 33245a1e1..3d62cb5ee 100644 --- a/src/libxrpl/protocol/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -71,9 +71,9 @@ STBlob::add(Serializer& s) const } bool -STBlob::isEquivalent(const STBase& t) const +STBlob::isEquivalent(STBase const& t) const { - const STBlob* v = dynamic_cast(&t); + STBlob const* v = dynamic_cast(&t); return v && (value_ == v->value_); } diff --git a/src/libxrpl/protocol/STCurrency.cpp b/src/libxrpl/protocol/STCurrency.cpp index a17ed2e0d..68186bbfd 100644 --- a/src/libxrpl/protocol/STCurrency.cpp +++ b/src/libxrpl/protocol/STCurrency.cpp @@ -72,9 +72,9 @@ STCurrency::add(Serializer& s) const } bool -STCurrency::isEquivalent(const STBase& t) const +STCurrency::isEquivalent(STBase const& t) const { - const STCurrency* v = dynamic_cast(&t); + STCurrency const* v = dynamic_cast(&t); return v && (*v == *this); } diff --git a/src/libxrpl/protocol/STIssue.cpp b/src/libxrpl/protocol/STIssue.cpp index 8483b8cfe..821e17f6a 100644 --- a/src/libxrpl/protocol/STIssue.cpp +++ b/src/libxrpl/protocol/STIssue.cpp @@ -128,9 +128,9 @@ STIssue::add(Serializer& s) const } bool -STIssue::isEquivalent(const STBase& t) const +STIssue::isEquivalent(STBase const& t) const { - const STIssue* v = dynamic_cast(&t); + STIssue const* v = dynamic_cast(&t); return v && (*v == *this); } diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index 63273c2a8..f04c696ce 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -150,7 +150,7 @@ STObject::operator=(STObject&& other) } void -STObject::set(const SOTemplate& type) +STObject::set(SOTemplate const& type) { v_.clear(); v_.reserve(type.size()); @@ -166,7 +166,7 @@ STObject::set(const SOTemplate& type) } void -STObject::applyTemplate(const SOTemplate& type) +STObject::applyTemplate(SOTemplate const& type) { auto throwFieldErr = [](std::string const& field, char const* description) { std::stringstream ss; @@ -309,9 +309,9 @@ STObject::set(SerialIter& sit, int depth) } bool -STObject::hasMatchingEntry(const STBase& t) +STObject::hasMatchingEntry(STBase const& t) { - const STBase* o = peekAtPField(t.getFName()); + STBase const* o = peekAtPField(t.getFName()); if (!o) return false; @@ -370,9 +370,9 @@ STObject::getText() const } bool -STObject::isEquivalent(const STBase& t) const +STObject::isEquivalent(STBase const& t) const { - const STObject* v = dynamic_cast(&t); + STObject const* v = dynamic_cast(&t); if (!v) return false; @@ -438,7 +438,7 @@ STObject::getFieldIndex(SField const& field) const return -1; } -const STBase& +STBase const& STObject::peekAtField(SField const& field) const { int index = getFieldIndex(field); @@ -466,7 +466,7 @@ STObject::getFieldSType(int index) const return v_[index]->getFName(); } -const STBase* +STBase const* STObject::peekAtPField(SField const& field) const { int index = getFieldIndex(field); @@ -549,7 +549,7 @@ STObject::isFlag(std::uint32_t f) const std::uint32_t STObject::getFlags(void) const { - const STUInt32* t = dynamic_cast(peekAtPField(sfFlags)); + STUInt32 const* t = dynamic_cast(peekAtPField(sfFlags)); if (!t) return 0; @@ -587,7 +587,7 @@ STObject::makeFieldAbsent(SField const& field) if (index == -1) throwFieldNotFound(field); - const STBase& f = peekAtIndex(index); + STBase const& f = peekAtIndex(index); if (f.getSType() == STI_NOTPRESENT) return; @@ -688,14 +688,14 @@ STObject::getFieldPathSet(SField const& field) const return getFieldByConstRef(field, empty); } -const STVector256& +STVector256 const& STObject::getFieldV256(SField const& field) const { static STVector256 const empty{}; return getFieldByConstRef(field, empty); } -const STArray& +STArray const& STObject::getFieldArray(SField const& field) const { static STArray const empty{}; @@ -848,7 +848,7 @@ STObject::getJson(JsonOptions options) const } bool -STObject::operator==(const STObject& obj) const +STObject::operator==(STObject const& obj) const { // This is not particularly efficient, and only compares data elements // with binary representations diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index e7568c681..1437ed922 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -851,7 +851,7 @@ parseLeaf( return ret; } -static const int maxDepth = 64; +static int const maxDepth = 64; // Forward declaration since parseObject() and parseArray() call each other. static std::optional @@ -1037,7 +1037,8 @@ parseArray( Json::Value const objectFields(json[i][objectName]); std::stringstream ss; - ss << json_name << "." << "[" << i << "]." << objectName; + ss << json_name << "." + << "[" << i << "]." << objectName; auto ret = parseObject( ss.str(), objectFields, nameField, depth + 1, error); diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index d2bd20cfe..1252ca7c6 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -145,9 +145,9 @@ STPathSet::assembleAdd(STPath const& base, STPathElement const& tail) } bool -STPathSet::isEquivalent(const STBase& t) const +STPathSet::isEquivalent(STBase const& t) const { - const STPathSet* v = dynamic_cast(&t); + STPathSet const* v = dynamic_cast(&t); return v && (value == v->value); } diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index 50b022d29..3612b0cc4 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -86,9 +86,9 @@ STVector256::add(Serializer& s) const } bool -STVector256::isEquivalent(const STBase& t) const +STVector256::isEquivalent(STBase const& t) const { - const STVector256* v = dynamic_cast(&t); + STVector256 const* v = dynamic_cast(&t); return v && (mValue == v->mValue); } diff --git a/src/libxrpl/protocol/STXChainBridge.cpp b/src/libxrpl/protocol/STXChainBridge.cpp index 1499d790c..fb192d82d 100644 --- a/src/libxrpl/protocol/STXChainBridge.cpp +++ b/src/libxrpl/protocol/STXChainBridge.cpp @@ -197,9 +197,9 @@ STXChainBridge::getSType() const } bool -STXChainBridge::isEquivalent(const STBase& t) const +STXChainBridge::isEquivalent(STBase const& t) const { - const STXChainBridge* v = dynamic_cast(&t); + STXChainBridge const* v = dynamic_cast(&t); return v && (*v == *this); } diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index 339e25db1..b8a68d28b 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -101,7 +101,7 @@ Serializer::addRaw(Slice slice) } int -Serializer::addRaw(const Serializer& s) +Serializer::addRaw(Serializer const& s) { int ret = mData.size(); mData.insert(mData.end(), s.begin(), s.end()); @@ -109,10 +109,10 @@ Serializer::addRaw(const Serializer& s) } int -Serializer::addRaw(const void* ptr, int len) +Serializer::addRaw(void const* ptr, int len) { int ret = mData.size(); - mData.insert(mData.end(), (const char*)ptr, ((const char*)ptr) + len); + mData.insert(mData.end(), (char const*)ptr, ((char const*)ptr) + len); return ret; } @@ -208,7 +208,7 @@ Serializer::addVL(Slice const& slice) } int -Serializer::addVL(const void* ptr, int len) +Serializer::addVL(void const* ptr, int len) { int ret = addEncoded(len); diff --git a/src/libxrpl/protocol/TxFormats.cpp b/src/libxrpl/protocol/TxFormats.cpp index 6c986261a..27fb0f99f 100644 --- a/src/libxrpl/protocol/TxFormats.cpp +++ b/src/libxrpl/protocol/TxFormats.cpp @@ -29,7 +29,7 @@ namespace ripple { TxFormats::TxFormats() { // Fields shared by all txFormats: - static const std::initializer_list commonFields{ + static std::initializer_list const commonFields{ {sfTransactionType, soeREQUIRED}, {sfFlags, soeOPTIONAL}, {sfSourceTag, soeOPTIONAL}, diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index ae94c929f..cdf9d8a56 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -3589,7 +3589,7 @@ private: int const signerListOwners{features[featureMultiSignReserve] ? 2 : 5}; env.require(owners(alice, signerListOwners + 0)); - const msig ms{becky, bogie}; + msig const ms{becky, bogie}; // Multisign all AMM transactions AMM ammAlice( diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 6268e33b4..2cd5e2632 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -1372,14 +1372,14 @@ private: // equal asset deposit: unit test to exercise the rounding-down of // LPTokens in the AMMHelpers.cpp: adjustLPTokens calculations // The LPTokens need to have 16 significant digits and a fractional part - for (const Number deltaLPTokens : + for (Number const deltaLPTokens : {Number{UINT64_C(100000'0000000009), -10}, Number{UINT64_C(100000'0000000001), -10}}) { testAMM([&](AMM& ammAlice, Env& env) { // initial LPToken balance IOUAmount const initLPToken = ammAlice.getLPTokensBalance(); - const IOUAmount newLPTokens{ + IOUAmount const newLPTokens{ deltaLPTokens.mantissa(), deltaLPTokens.exponent()}; // carol performs a two-asset deposit @@ -1398,17 +1398,17 @@ private: // fraction of newLPTokens/(existing LPToken balance). The // existing LPToken balance is 1e7 - const Number fr = deltaLPTokens / 1e7; + Number const fr = deltaLPTokens / 1e7; // The below equations are based on Equation 1, 2 from XLS-30d // specification, Section: 2.3.1.2 - const Number deltaXRP = fr * 1e10; - const Number deltaUSD = fr * 1e4; + Number const deltaXRP = fr * 1e10; + Number const deltaUSD = fr * 1e4; - const STAmount depositUSD = + STAmount const depositUSD = STAmount{USD, deltaUSD.mantissa(), deltaUSD.exponent()}; - const STAmount depositXRP = + STAmount const depositXRP = STAmount{XRP, deltaXRP.mantissa(), deltaXRP.exponent()}; // initial LPTokens (1e7) + newLPTokens @@ -6281,11 +6281,11 @@ private: testcase("swapRounding"); using namespace jtx; - const STAmount xrpPool{XRP, UINT64_C(51600'000981)}; - const STAmount iouPool{USD, UINT64_C(803040'9987141784), -10}; + STAmount const xrpPool{XRP, UINT64_C(51600'000981)}; + STAmount const iouPool{USD, UINT64_C(803040'9987141784), -10}; - const STAmount xrpBob{XRP, UINT64_C(1092'878933)}; - const STAmount iouBob{ + STAmount const xrpBob{XRP, UINT64_C(1092'878933)}; + STAmount const iouBob{ USD, UINT64_C(3'988035892323031), -28}; // 3.9...e-13 testAMM( diff --git a/src/test/app/AccountDelete_test.cpp b/src/test/app/AccountDelete_test.cpp index 9b537fa68..91cb9cb26 100644 --- a/src/test/app/AccountDelete_test.cpp +++ b/src/test/app/AccountDelete_test.cpp @@ -927,7 +927,7 @@ public: Account const carol{"carol"}; Account const daria{"daria"}; - const char credType[] = "abcd"; + char const credType[] = "abcd"; Env env{*this, features}; env.fund(XRP(100000), alice, becky, carol, daria); @@ -1193,7 +1193,7 @@ public: Account const becky{"becky"}; Account const carol{"carol"}; - const char credType[] = "abcd"; + char const credType[] = "abcd"; Env env{*this, features}; env.fund(XRP(100000), alice, becky, carol); @@ -1237,7 +1237,7 @@ public: Account const becky{"becky"}; Account const carol{"carol"}; - const char credType[] = "abcd"; + char const credType[] = "abcd"; Env env{*this, features}; env.fund(XRP(100000), alice, becky, carol); diff --git a/src/test/app/Credentials_test.cpp b/src/test/app/Credentials_test.cpp index 76fb50111..99f8dfb03 100644 --- a/src/test/app/Credentials_test.cpp +++ b/src/test/app/Credentials_test.cpp @@ -60,8 +60,8 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; - const char uri[] = "uri"; + char const credType[] = "abcde"; + char const uri[] = "uri"; Account const issuer{"issuer"}; Account const subject{"subject"}; @@ -209,7 +209,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; @@ -458,7 +458,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; @@ -616,7 +616,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; Account const other{"other"}; @@ -726,7 +726,7 @@ struct Credentials_test : public beast::unit_test::suite } { - const char credType2[] = "efghi"; + char const credType2[] = "efghi"; testcase("CredentialsAccept fail, expired credentials."); auto jv = credentials::create(subject, issuer, credType2); @@ -797,7 +797,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; Account const other{"other"}; @@ -842,7 +842,7 @@ struct Credentials_test : public beast::unit_test::suite } { - const char credType2[] = "fghij"; + char const credType2[] = "fghij"; env(credentials::create(subject, issuer, credType2)); env.close(); @@ -944,7 +944,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; @@ -972,7 +972,7 @@ struct Credentials_test : public beast::unit_test::suite { using namespace test::jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; @@ -1066,7 +1066,7 @@ struct Credentials_test : public beast::unit_test::suite testcase("Test flags"); - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const subject{"subject"}; diff --git a/src/test/app/DID_test.cpp b/src/test/app/DID_test.cpp index 345d7f95a..385be5322 100644 --- a/src/test/app/DID_test.cpp +++ b/src/test/app/DID_test.cpp @@ -149,7 +149,7 @@ struct DID_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); // uri is too long - const std::string longString(257, 'a'); + std::string const longString(257, 'a'); env(did::set(alice), did::uri(longString), ter(temMALFORMED)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 0); diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index 30440051c..1e7c26207 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -665,7 +665,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { // becky setup depositpreauth with credentials - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const carol{"carol"}; env.fund(XRP(5000), carol); env.close(); @@ -821,7 +821,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { using namespace jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const alice{"alice"}; Account const bob{"bob"}; @@ -994,7 +994,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { // create another valid credential - const char credType2[] = "fghij"; + char const credType2[] = "fghij"; env(credentials::create(alice, issuer, credType2)); env.close(); env(credentials::accept(alice, issuer, credType2)); @@ -1026,7 +1026,7 @@ struct DepositPreauth_test : public beast::unit_test::suite { using namespace jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const issuer{"issuer"}; Account const alice{"alice"}; Account const bob{"bob"}; @@ -1197,8 +1197,8 @@ struct DepositPreauth_test : public beast::unit_test::suite testExpiredCreds(FeatureBitset features) { using namespace jtx; - const char credType[] = "abcde"; - const char credType2[] = "fghijkl"; + char const credType[] = "abcde"; + char const credType2[] = "fghijkl"; Account const issuer{"issuer"}; Account const alice{"alice"}; Account const bob{"bob"}; diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 2fe53ecc6..ff2d53276 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -4589,7 +4589,7 @@ struct Escrow_test : public beast::unit_test::suite Account const dillon{"dillon "}; Account const zelda{"zelda"}; - const char credType[] = "abcde"; + char const credType[] = "abcde"; { // Credentials amendment not enabled @@ -4691,7 +4691,7 @@ struct Escrow_test : public beast::unit_test::suite env.close(); { - const char credType2[] = "fghijk"; + char const credType2[] = "fghijk"; env(credentials::create(bob, zelda, credType2)); env.close(); diff --git a/src/test/app/FeeVote_test.cpp b/src/test/app/FeeVote_test.cpp index bf293a93f..1cf2e67f8 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -76,7 +76,7 @@ class FeeVote_test : public beast::unit_test::suite setup.owner_reserve == static_cast(-1234)); } { - const auto big64 = std::to_string( + auto const big64 = std::to_string( static_cast( std::numeric_limits::max()) + 1); diff --git a/src/test/app/HookAPI_test.cpp b/src/test/app/HookAPI_test.cpp index 5022da81a..d60336ee6 100644 --- a/src/test/app/HookAPI_test.cpp +++ b/src/test/app/HookAPI_test.cpp @@ -3166,7 +3166,7 @@ public: StubHookContext stubCtx{}; stubCtx.slot[3] = { .storage = - std::reinterpret_pointer_cast(storage), + std::reinterpret_pointer_cast(storage), .entry = &(*storage)}; auto hookCtx = makeStubHookContext(applyCtx, alice.id(), alice.id(), stubCtx); @@ -3320,7 +3320,7 @@ public: StubHookContext stubCtx{}; stubCtx.slot[1] = { .storage = - std::reinterpret_pointer_cast(storage), + std::reinterpret_pointer_cast(storage), .entry = &(*storage)}; auto hookCtx = makeStubHookContext(applyCtx, alice.id(), alice.id(), stubCtx); diff --git a/src/test/app/Import_test.cpp b/src/test/app/Import_test.cpp index fe6a3374f..a56c2c34b 100644 --- a/src/test/app/Import_test.cpp +++ b/src/test/app/Import_test.cpp @@ -2759,7 +2759,7 @@ class Import_test : public beast::unit_test::suite // Set Regular Key Json::Value jv; jv[jss::Account] = alice.human(); - const AccountID ACCOUNT_ZERO(0); + AccountID const ACCOUNT_ZERO(0); jv["RegularKey"] = to_string(ACCOUNT_ZERO); jv[jss::TransactionType] = jss::SetRegularKey; env(jv); @@ -2791,7 +2791,7 @@ class Import_test : public beast::unit_test::suite // Set Regular Key Json::Value jv; jv[jss::Account] = alice.human(); - const AccountID ACCOUNT_ONE(1); + AccountID const ACCOUNT_ONE(1); jv["RegularKey"] = to_string(ACCOUNT_ONE); jv[jss::TransactionType] = jss::SetRegularKey; env(jv); @@ -2823,7 +2823,7 @@ class Import_test : public beast::unit_test::suite // Set Regular Key Json::Value jv; jv[jss::Account] = alice.human(); - const AccountID ACCOUNT_TWO(2); + AccountID const ACCOUNT_TWO(2); jv["RegularKey"] = to_string(ACCOUNT_TWO); jv[jss::TransactionType] = jss::SetRegularKey; env(jv); @@ -2855,7 +2855,7 @@ class Import_test : public beast::unit_test::suite // Set Regular Key Json::Value jv; jv[jss::Account] = alice.human(); - const AccountID ACCOUNT_ZERO(0); + AccountID const ACCOUNT_ZERO(0); jv["RegularKey"] = to_string(ACCOUNT_ZERO); jv[jss::TransactionType] = jss::SetRegularKey; env(jv); @@ -6219,7 +6219,7 @@ class Import_test : public beast::unit_test::suite // Set Regular Key Json::Value jv; jv[jss::Account] = acct.human(); - const AccountID ACCOUNT_ZERO(0); + AccountID const ACCOUNT_ZERO(0); jv["RegularKey"] = to_string(ACCOUNT_ZERO); jv[jss::TransactionType] = jss::SetRegularKey; env(jv); diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 05391673d..f26852e41 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -318,11 +318,11 @@ public: { } void - addTxQueue(const uint256&) override + addTxQueue(uint256 const&) override { } void - removeTxQueue(const uint256&) override + removeTxQueue(uint256 const&) override { } bool @@ -420,7 +420,7 @@ struct TestPeerSet : public PeerSet } } - const std::set& + std::set const& getPeerIds() const override { static std::set emptyPeers; diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index 8f65c230d..4cf3aaf05 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -1328,7 +1328,7 @@ class MPToken_test : public beast::unit_test::suite Account const diana("diana"); Account const dpIssuer("dpIssuer"); // holder - const char credType[] = "abcde"; + char const credType[] = "abcde"; { Env env(*this, features); @@ -1887,7 +1887,7 @@ class MPToken_test : public beast::unit_test::suite test(jv, sfClaimCurrency.jsonName.c_str()); } } - for (const auto& str : txWithAmounts) + for (auto const& str : txWithAmounts) printf("%s\n", str.c_str()); BEAST_EXPECT(txWithAmounts.empty()); } diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index 29d0c29c2..cd35ccb28 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -966,7 +966,7 @@ struct PayChan_test : public beast::unit_test::suite using namespace jtx; using namespace std::literals::chrono_literals; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const alice("alice"); Account const bob("bob"); diff --git a/src/test/app/PermissionedDomains_test.cpp b/src/test/app/PermissionedDomains_test.cpp index 50f8fe466..d4164e729 100644 --- a/src/test/app/PermissionedDomains_test.cpp +++ b/src/test/app/PermissionedDomains_test.cpp @@ -285,7 +285,7 @@ class PermissionedDomains_test : public beast::unit_test::suite Env env(*this, withFeature_); env.set_parse_failure_expected(true); - const int accNum = 12; + int const accNum = 12; Account const alice[accNum] = { "alice", "alice2", diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index cd9fd45c8..085017930 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -96,21 +96,21 @@ class SHAMapStore_test : public beast::unit_test::suite env.app().getRelationalDatabase().getLedgerInfoByIndex(seq); if (!oinfo) return false; - const LedgerInfo& info = oinfo.value(); + LedgerInfo const& info = oinfo.value(); - const std::string outHash = to_string(info.hash); - const LedgerIndex outSeq = info.seq; - const std::string outParentHash = to_string(info.parentHash); - const std::string outDrops = to_string(info.drops); - const std::uint64_t outCloseTime = + std::string const outHash = to_string(info.hash); + LedgerIndex const outSeq = info.seq; + std::string const outParentHash = to_string(info.parentHash); + std::string const outDrops = to_string(info.drops); + std::uint64_t const outCloseTime = info.closeTime.time_since_epoch().count(); - const std::uint64_t outParentCloseTime = + std::uint64_t const outParentCloseTime = info.parentCloseTime.time_since_epoch().count(); - const std::uint64_t outCloseTimeResolution = + std::uint64_t const outCloseTimeResolution = info.closeTimeResolution.count(); - const std::uint64_t outCloseFlags = info.closeFlags; - const std::string outAccountHash = to_string(info.accountHash); - const std::string outTxHash = to_string(info.txHash); + std::uint64_t const outCloseFlags = info.closeFlags; + std::string const outAccountHash = to_string(info.accountHash); + std::string const outTxHash = to_string(info.txHash); auto const& ledger = json[jss::result][jss::ledger]; return outHash == ledger[jss::ledger_hash].asString() && @@ -148,7 +148,7 @@ class SHAMapStore_test : public beast::unit_test::suite void ledgerCheck(jtx::Env& env, int const rows, int const first) { - const auto [actualRows, actualFirst, actualLast] = + auto const [actualRows, actualFirst, actualLast] = dynamic_cast(&env.app().getRelationalDatabase()) ->getLedgerCountMinMax(); diff --git a/src/test/app/SetHookTSH_test.cpp b/src/test/app/SetHookTSH_test.cpp index a0a4c447d..37a3327cc 100644 --- a/src/test/app/SetHookTSH_test.cpp +++ b/src/test/app/SetHookTSH_test.cpp @@ -50,9 +50,9 @@ namespace test { struct SetHookTSH0_test : public beast::unit_test::suite { private: - const uint64_t tshSTRONG = 0; - const uint64_t tshWEAK = 1; - const uint64_t tshNONE = 2; + uint64_t const tshSTRONG = 0; + uint64_t const tshWEAK = 1; + uint64_t const tshNONE = 2; // helper void static overrideFlag(Json::Value& jv) @@ -64,7 +64,7 @@ private: jv[jss::Flags] = hsfOVERRIDE | hsfCOLLECT; } - const std::vector CallbackHook = { + std::vector const CallbackHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x35U, 0x08U, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x05U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x02U, 0x7FU, @@ -308,7 +308,7 @@ private: 0x00U, 0x73U, 0x21U, 0x00U, 0x41U, 0x9BU, 0x0AU, 0x0BU, 0x02U, 0x81U, 0x14U, 0x00U, 0x41U, 0xB1U, 0x0AU, 0x0BU, 0x02U, 0x83U, 0x14U}; - const std::vector EmitTenHook = { + std::vector const EmitTenHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x35U, 0x08U, 0x60U, 0x05U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, @@ -517,7 +517,7 @@ private: 0x02U, 0x81U, 0x14U, 0x00U, 0x41U, 0xC1U, 0x0CU, 0x0BU, 0x02U, 0x83U, 0x14U}; - const std::vector TshHook = { + std::vector const TshHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x28U, 0x06U, 0x60U, 0x05U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x00U, diff --git a/src/test/app/SetHook_test.cpp b/src/test/app/SetHook_test.cpp index 7d1ee82ec..1ac576f53 100644 --- a/src/test/app/SetHook_test.cpp +++ b/src/test/app/SetHook_test.cpp @@ -44,7 +44,7 @@ class JSSHasher { public: size_t - operator()(const Json::StaticString& n) const + operator()(Json::StaticString const& n) const { return std::hash{}(n.c_str()); } @@ -54,7 +54,7 @@ class JSSEq { public: bool - operator()(const Json::StaticString& a, const Json::StaticString& b) const + operator()(Json::StaticString const& a, Json::StaticString const& b) const { return a == b; } @@ -1142,7 +1142,7 @@ public: testcase("Checks partial nsdelete operation"); using namespace jtx; - static const std::vector hook = { + static std::vector const hook = { 0x00U, 0x61U, 0x73U, 0x6dU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x21U, 0x05U, 0x60U, 0x02U, 0x7fU, 0x7fU, 0x01U, 0x7fU, 0x60U, 0x02U, 0x7fU, 0x7fU, 0x01U, 0x7eU, 0x60U, 0x03U, 0x7fU, 0x7fU, @@ -2166,21 +2166,21 @@ public: BEAST_EXPECT(hooks[0].getFieldH256(sfHookNamespace) == ns); BEAST_REQUIRE(hooks[0].isFieldPresent(sfHookParameters)); - const auto& p = hooks[0].getFieldArray(sfHookParameters); + auto const& p = hooks[0].getFieldArray(sfHookParameters); BEAST_REQUIRE(p.size() == 1); BEAST_REQUIRE(p[0].isFieldPresent(sfHookParameterName)); BEAST_REQUIRE(p[0].isFieldPresent(sfHookParameterValue)); - const auto pn = p[0].getFieldVL(sfHookParameterName); + auto const pn = p[0].getFieldVL(sfHookParameterName); BEAST_REQUIRE(pn.size() == 2); BEAST_REQUIRE(pn[0] == 0xCAU && pn[1] == 0xFEU); - const auto pv = p[0].getFieldVL(sfHookParameterValue); + auto const pv = p[0].getFieldVL(sfHookParameterValue); BEAST_REQUIRE(pv.size() == 2); BEAST_REQUIRE(pv[0] == 0xBAU && pv[1] == 0xBEU); BEAST_REQUIRE(hooks[0].isFieldPresent(sfHookGrants)); - const auto& g = hooks[0].getFieldArray(sfHookGrants); + auto const& g = hooks[0].getFieldArray(sfHookGrants); BEAST_REQUIRE(g.size() == 1); BEAST_REQUIRE(g[0].isFieldPresent(sfHookHash)); BEAST_REQUIRE(g[0].getFieldH256(sfHookHash) == accept_hash); @@ -2271,15 +2271,15 @@ public: // check all the previous parameters plus the new ones BEAST_REQUIRE(hooks[0].isFieldPresent(sfHookParameters)); - const auto& p = hooks[0].getFieldArray(sfHookParameters); + auto const& p = hooks[0].getFieldArray(sfHookParameters); BEAST_REQUIRE(p.size() == params.size()); std::set already; for (uint8_t i = 0; i < params.size(); ++i) { - const auto pn = p[i].getFieldVL(sfHookParameterName); - const auto pv = p[i].getFieldVL(sfHookParameterValue); + auto const pn = p[i].getFieldVL(sfHookParameterName); + auto const pv = p[i].getFieldVL(sfHookParameterValue); // make sure it's not a duplicate entry BEAST_EXPECT(already.find(pn) == already.end()); @@ -2323,7 +2323,7 @@ public: // check there right number of parameters exist BEAST_REQUIRE(hooks[0].isFieldPresent(sfHookParameters)); - const auto& p = hooks[0].getFieldArray(sfHookParameters); + auto const& p = hooks[0].getFieldArray(sfHookParameters); BEAST_REQUIRE(p.size() == params.size()); // and that they still have the expected values and that there are @@ -2331,8 +2331,8 @@ public: std::set already; for (uint8_t i = 0; i < params.size(); ++i) { - const auto pn = p[i].getFieldVL(sfHookParameterName); - const auto pv = p[i].getFieldVL(sfHookParameterValue); + auto const pn = p[i].getFieldVL(sfHookParameterName); + auto const pv = p[i].getFieldVL(sfHookParameterValue); // make sure it's not a duplicate entry BEAST_EXPECT(already.find(pn) == already.end()); @@ -2379,7 +2379,7 @@ public: // check there right number of parameters exist BEAST_REQUIRE(hooks[0].isFieldPresent(sfHookParameters)); - const auto& p = hooks[0].getFieldArray(sfHookParameters); + auto const& p = hooks[0].getFieldArray(sfHookParameters); BEAST_REQUIRE(p.size() == params.size()); // and that they still have the expected values and that there are @@ -2387,8 +2387,8 @@ public: std::set already; for (uint8_t i = 0; i < params.size(); ++i) { - const auto pn = p[i].getFieldVL(sfHookParameterName); - const auto pv = p[i].getFieldVL(sfHookParameterValue); + auto const pn = p[i].getFieldVL(sfHookParameterName); + auto const pv = p[i].getFieldVL(sfHookParameterValue); // make sure it's not a duplicate entry BEAST_EXPECT(already.find(pn) == already.end()); @@ -9584,7 +9584,7 @@ public: testcase("Test state_foreign_set max"); using namespace jtx; - static const std::vector ns_maxHook_wasm = { + static std::vector const ns_maxHook_wasm = { 0x00U, 0x61U, 0x73U, 0x6dU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x36U, 0x07U, 0x60U, 0x02U, 0x7fU, 0x7fU, 0x01U, 0x7fU, 0x60U, 0x02U, 0x7fU, 0x7fU, 0x01U, 0x7eU, 0x60U, 0x03U, 0x7fU, 0x7fU, diff --git a/src/test/app/SetTrust_test.cpp b/src/test/app/SetTrust_test.cpp index c99a1dafa..9b4048bf9 100644 --- a/src/test/app/SetTrust_test.cpp +++ b/src/test/app/SetTrust_test.cpp @@ -469,7 +469,7 @@ public: auto& tx1 = createQuality ? txWithQuality : txWithoutQuality; auto& tx2 = createQuality ? txWithoutQuality : txWithQuality; - auto check_quality = [&](const bool exists) { + auto check_quality = [&](bool const exists) { Json::Value jv; jv["account"] = toAcct.human(); auto const lines = env.rpc("json", "account_lines", to_string(jv)); diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index e88d883bb..274d54561 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -179,7 +179,7 @@ class TxQPosNegFlows_test : public beast::unit_test::suite auto calcMedFeeLevel(FeeLevel64 const feeLevel1, FeeLevel64 const feeLevel2) { - const FeeLevel64 expectedMedFeeLevel = + FeeLevel64 const expectedMedFeeLevel = (feeLevel1 + feeLevel2 + FeeLevel64{1}) / 2; return std::max(expectedMedFeeLevel, minEscalationFeeLevel).fee(); @@ -388,7 +388,7 @@ public: ////////////////////////////////////////////////////////////// constexpr auto largeFeeMultiplier = 700; - const auto largeFee = baseFee * largeFeeMultiplier; + auto const largeFee = baseFee * largeFeeMultiplier; // Stuff the ledger and queue so we can verify that // stuff gets kicked out. @@ -893,7 +893,7 @@ public: env(noop(alice), json(R"({"LastLedgerSequence":8})"), queued); constexpr auto largeFeeMultiplier = 700; - const auto largeFee = baseFee * largeFeeMultiplier; + auto const largeFee = baseFee * largeFeeMultiplier; // Queue items with higher fees to force the previous // txn to wait. @@ -943,7 +943,7 @@ public: BEAST_EXPECT(env.seq(alice) == 3); constexpr auto anotherLargeFeeMultiplier = 800; - const auto anotherLargeFee = baseFee * anotherLargeFeeMultiplier; + auto const anotherLargeFee = baseFee * anotherLargeFeeMultiplier; // Keep alice's transaction waiting. // clang-format off env(noop(bob), fee(anotherLargeFee), queued); diff --git a/src/test/app/URIToken_test.cpp b/src/test/app/URIToken_test.cpp index b537c257c..4ba83c57a 100644 --- a/src/test/app/URIToken_test.cpp +++ b/src/test/app/URIToken_test.cpp @@ -1005,7 +1005,7 @@ struct URIToken_test : public beast::unit_test::suite // bob can buy with XRP { // alice mints - const auto delta = XRP(10); + auto const delta = XRP(10); auto preAlice = env.balance(alice); auto preBob = env.balance(bob); env(uritoken::mint(alice, uri)); @@ -1043,7 +1043,7 @@ struct URIToken_test : public beast::unit_test::suite // bob can buy with USD { // alice mints - const auto delta = USD(10); + auto const delta = USD(10); auto preAlice = env.balance(alice, USD.issue()); auto preAliceXrp = env.balance(alice); auto preBob = env.balance(bob, USD.issue()); @@ -1115,7 +1115,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can sell with XRP { // alice mints - const auto delta = XRP(10); + auto const delta = XRP(10); auto preAlice = env.balance(alice); auto preBob = env.balance(bob); env(uritoken::mint(alice, uri)); @@ -1161,7 +1161,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can sell with XRP and dest { // alice mints - const auto delta = XRP(10); + auto const delta = XRP(10); auto preAlice = env.balance(alice); auto preBob = env.balance(bob); env(uritoken::mint(alice, uri)); @@ -1205,7 +1205,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can sell with USD { // alice mints - const auto delta = USD(10); + auto const delta = USD(10); auto preAlice = env.balance(alice, USD.issue()); auto preAliceXrp = env.balance(alice); auto preBob = env.balance(bob, USD.issue()); @@ -1255,7 +1255,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can sell with USD and dest { // alice mints - const auto delta = USD(10); + auto const delta = USD(10); auto preAlice = env.balance(alice, USD.issue()); auto preAliceXrp = env.balance(alice); auto preBob = env.balance(bob, USD.issue()); @@ -1333,7 +1333,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can clear / reset XRP amount { // alice mints - const auto delta = XRP(10); + auto const delta = XRP(10); auto preAlice = env.balance(alice); env(uritoken::mint(alice, uri)); env.close(); @@ -1367,7 +1367,7 @@ struct URIToken_test : public beast::unit_test::suite // alice can clear / reset USD amount { // alice mints - const auto delta = USD(10); + auto const delta = USD(10); env(uritoken::mint(alice, uri)); env.close(); BEAST_EXPECT(inOwnerDir(*env.current(), alice, tid)); diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index 7c8584698..427ada132 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -35,13 +35,13 @@ namespace test { class ValidatorKeys_test : public beast::unit_test::suite { // Used with [validation_seed] - const std::string seed = "shUwVw52ofnCUX5m7kPTKzJdr4HEH"; + std::string const seed = "shUwVw52ofnCUX5m7kPTKzJdr4HEH"; // Used with [validation_token] - const std::string tokenSecretStr = + std::string const tokenSecretStr = "paQmjZ37pKKPMrgadBLsuf9ab7Y7EUNzh27LQrZqoexpAs31nJi"; - const std::vector tokenBlob = { + std::vector const tokenBlob = { " " "eyJ2YWxpZGF0aW9uX3NlY3JldF9rZXkiOiI5ZWQ0NWY4NjYyNDFjYzE4YTI3NDdiNT\n", " \tQzODdjMDYyNTkwNzk3MmY0ZTcxOTAyMzFmYWE5Mzc0NTdmYTlkYWY2IiwibWFuaWZl " @@ -56,7 +56,7 @@ class ValidatorKeys_test : public beast::unit_test::suite "NmluOEhBU1FLUHVnQkQ2N2tNYVJGR3ZtcEFUSGxHS0pkdkRGbFdQWXk1QXFEZWRGdj\n", "VUSmEydzBpMjFlcTNNWXl3TFZKWm5GT3I3QzBrdzJBaVR6U0NqSXpkaXRROD0ifQ==\n"}; - const std::string tokenManifest = + std::string const tokenManifest = "JAAAAAFxIe1FtwmimvGtH2iCcMJqC9gVFKilGfw1/vCxHXXLplc2GnMhAkE1agqXxBwD" "wDbID6OMSYuM0FDAlpAgNk8SKFn7MO2fdkcwRQIhAOngu9sAKqXYouJ+l2V0W+sAOkVB" "+ZRS6PShlJAfUsXfAiBsVJGesaadOJc/aAZokS1vymGmVrlHPKWX3Yywu6in8HASQKPu" @@ -64,7 +64,7 @@ class ValidatorKeys_test : public beast::unit_test::suite "2AiTzSCjIzditQ8="; // Manifest does not match private key - const std::vector invalidTokenBlob = { + std::vector const invalidTokenBlob = { "eyJtYW5pZmVzdCI6IkpBQUFBQVZ4SWUyOVVBdzViZFJudHJ1elVkREk4aDNGV1JWZl\n", "k3SXVIaUlKQUhJd3MxdzZzM01oQWtsa1VXQWR2RnFRVGRlSEpvS1pNY0hlS0RzOExo\n", "b3d3bDlHOEdkVGNJbmFka1l3UkFJZ0h2Q01lQU1aSzlqQnV2aFhlaFRLRzVDQ3BBR1\n", diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index 819340bfa..a3b62bd4f 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -551,7 +551,7 @@ private: auto const version, std::vector> const& expected) { - const auto available = trustedKeys->getAvailable(hexPublic); + auto const available = trustedKeys->getAvailable(hexPublic); BEAST_EXPECT(!version || available); if (available) @@ -621,7 +621,7 @@ private: auto const publisherSecret = randomSecretKey(); auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - const auto hexPublic = + auto const hexPublic = strHex(publisherPublic.begin(), publisherPublic.end()); auto const pubSigningKeys1 = randomKeyPair(KeyType::secp256k1); auto const manifest1 = base64_encode(makeManifestString( @@ -1005,7 +1005,7 @@ private: auto const publisherSecret = randomSecretKey(); auto const publisherPublic = derivePublicKey(KeyType::ed25519, publisherSecret); - const auto hexPublic = + auto const hexPublic = strHex(publisherPublic.begin(), publisherPublic.end()); auto const pubSigningKeys1 = randomKeyPair(KeyType::secp256k1); auto const manifest = base64_encode(makeManifestString( @@ -1057,7 +1057,7 @@ private: // unknown public key auto const badSecret = randomSecretKey(); auto const badPublic = derivePublicKey(KeyType::ed25519, badSecret); - const auto hexBad = strHex(badPublic.begin(), badPublic.end()); + auto const hexBad = strHex(badPublic.begin(), badPublic.end()); auto const available = trustedKeys->getAvailable(hexBad, 1); BEAST_EXPECT(!available); diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index 27848d0e7..2364fece9 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -39,7 +39,7 @@ namespace ripple { namespace test { namespace detail { -constexpr const char* +constexpr char const* realValidatorContents() { return R"vl({ diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index e2f15fdee..f6c7ed922 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -316,7 +316,7 @@ struct BalanceTransfer return std::all_of( reward_accounts.begin(), reward_accounts.end(), - [&](const balance& b) { return b.diff() == reward; }); + [&](balance const& b) { return b.diff() == reward; }); } bool @@ -4582,8 +4582,8 @@ private: { public: SmBase( - const std::shared_ptr& chainstate, - const BridgeDef& bridge) + std::shared_ptr const& chainstate, + BridgeDef const& bridge) : bridge_(bridge), st_(chainstate) { } @@ -4613,7 +4613,7 @@ private: } protected: - const BridgeDef& bridge_; + BridgeDef const& bridge_; std::shared_ptr st_; }; @@ -4624,8 +4624,8 @@ private: using Base = SmBase; SmCreateAccount( - const std::shared_ptr& chainstate, - const BridgeDef& bridge, + std::shared_ptr const& chainstate, + BridgeDef const& bridge, AccountCreate create) : Base(chainstate, bridge) , sm_state(st_initial) @@ -4756,8 +4756,8 @@ private: using Base = SmBase; SmTransfer( - const std::shared_ptr& chainstate, - const BridgeDef& bridge, + std::shared_ptr const& chainstate, + BridgeDef const& bridge, Transfer xfer) : Base(chainstate, bridge) , xfer(std::move(xfer)) @@ -4926,7 +4926,7 @@ private: void xfer( uint64_t time, - const std::shared_ptr& chainstate, + std::shared_ptr const& chainstate, BridgeDef const& bridge, Transfer transfer) { @@ -4936,7 +4936,7 @@ private: void ac(uint64_t time, - const std::shared_ptr& chainstate, + std::shared_ptr const& chainstate, BridgeDef const& bridge, AccountCreate ac) { diff --git a/src/test/app/XahauGenesis_test.cpp b/src/test/app/XahauGenesis_test.cpp index 1c15a26c3..15612be4c 100644 --- a/src/test/app/XahauGenesis_test.cpp +++ b/src/test/app/XahauGenesis_test.cpp @@ -327,7 +327,7 @@ struct XahauGenesis_test : public beast::unit_test::suite { for (auto const& [rn, x] : ngdist) { - const char first = rn.c_str()[0]; + char const first = rn.c_str()[0]; BEAST_EXPECT( (first == 'r' && !!parseBase58(rn)) || first == 'n' && @@ -363,7 +363,7 @@ struct XahauGenesis_test : public beast::unit_test::suite params = XahauGenesis::GovernanceParameters; for (auto const& [rn, x] : l1membership) { - const char first = rn.c_str()[0]; + char const first = rn.c_str()[0]; BEAST_EXPECT( (first == 'r' && !!parseBase58(rn)) || first == 'n' && diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index 63fecde65..44a2c10b4 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -40,7 +40,7 @@ public: testFullyCanonicalSigs() { // Construct a payments w/out a fully-canonical tx - const std::string non_fully_canonical_tx = + std::string const non_fully_canonical_tx = "12000022000000002400000001201B00497D9C6140000000000F6950684000000" "00000000C732103767C7B2C13AD90050A4263745E4BAB2B975417FA22E87780E1" "506DDAF21139BE74483046022100E95670988A34C4DB0FA73A8BFD6383872AF43" diff --git a/src/test/basics/FileUtilities_test.cpp b/src/test/basics/FileUtilities_test.cpp index 1b07e240c..b6755cb50 100644 --- a/src/test/basics/FileUtilities_test.cpp +++ b/src/test/basics/FileUtilities_test.cpp @@ -36,7 +36,7 @@ public: using namespace ripple::test::detail; using namespace boost::system; - constexpr const char* expectedContents = + constexpr char const* expectedContents = "This file is very short. That's all we need."; FileDirGuard file( diff --git a/src/test/basics/PerfLog_test.cpp b/src/test/basics/PerfLog_test.cpp index 7ec62a170..05678e699 100644 --- a/src/test/basics/PerfLog_test.cpp +++ b/src/test/basics/PerfLog_test.cpp @@ -776,7 +776,7 @@ public: // Verify values in jss::total are what we expect. Json::Value const& total{jobQueue[jss::total]}; - const int finished = jobs.size() * 2; + int const finished = jobs.size() * 2; BEAST_EXPECT(jsonToUint64(total[jss::queued]) == jobs.size()); BEAST_EXPECT(jsonToUint64(total[jss::started]) == finished); BEAST_EXPECT(jsonToUint64(total[jss::finished]) == finished); diff --git a/src/test/basics/mulDiv_test.cpp b/src/test/basics/mulDiv_test.cpp index 47332fd45..61521577d 100644 --- a/src/test/basics/mulDiv_test.cpp +++ b/src/test/basics/mulDiv_test.cpp @@ -28,8 +28,8 @@ struct mulDiv_test : beast::unit_test::suite void run() override { - const auto max = std::numeric_limits::max(); - const std::uint64_t max32 = std::numeric_limits::max(); + auto const max = std::numeric_limits::max(); + std::uint64_t const max32 = std::numeric_limits::max(); auto result = mulDiv(85, 20, 5); BEAST_EXPECT(result && *result == 340); diff --git a/src/test/consensus/ByzantineFailureSim_test.cpp b/src/test/consensus/ByzantineFailureSim_test.cpp index b97994347..887a060a5 100644 --- a/src/test/consensus/ByzantineFailureSim_test.cpp +++ b/src/test/consensus/ByzantineFailureSim_test.cpp @@ -68,8 +68,8 @@ class ByzantineFailureSim_test : public beast::unit_test::suite for (TrustGraph::ForkInfo const& fi : sim.trustGraph.forkablePairs(0.8)) { - std::cout << "Can fork " << PeerGroup{fi.unlA} << " " << " " - << PeerGroup{fi.unlB} << " overlap " << fi.overlap + std::cout << "Can fork " << PeerGroup{fi.unlA} << " " + << " " << PeerGroup{fi.unlB} << " overlap " << fi.overlap << " required " << fi.required << "\n"; }; diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index 8f2a3c664..9a3666f07 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -320,7 +320,7 @@ public: { soci::session s; sc.open(s); - const char* dbInit[] = { + char const* dbInit[] = { "BEGIN TRANSACTION;", "CREATE TABLE Ledgers ( \ LedgerHash CHARACTER(64) PRIMARY KEY, \ diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index 678924112..1cb2d03cc 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -553,11 +553,11 @@ struct Peer ConsensusCloseTimes const& rawCloseTimes, ConsensusMode const& mode, Json::Value&& consensusJson, - const bool validating) + bool const validating) { schedule(delays.ledgerAccept, [=, this]() { - const bool proposing = mode == ConsensusMode::proposing; - const bool consensusFail = result.state == ConsensusState::MovedOn; + bool const proposing = mode == ConsensusMode::proposing; + bool const consensusFail = result.state == ConsensusState::MovedOn; TxSet const acceptedTxs = injectTxs(prevLedger, result.txns); Ledger const newLedger = oracle.accept( diff --git a/src/test/csf/Tx.h b/src/test/csf/Tx.h index 066aee226..7f37d60d7 100644 --- a/src/test/csf/Tx.h +++ b/src/test/csf/Tx.h @@ -188,7 +188,7 @@ private: // Helper functions for debug printing inline std::ostream& -operator<<(std::ostream& o, const Tx& t) +operator<<(std::ostream& o, Tx const& t) { return o << t.id(); } diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 0494178ae..7b91863cb 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -720,4 +720,4 @@ struct JumpCollector } // namespace test } // namespace ripple -#endif +#endif \ No newline at end of file diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index a02adb9c8..45e255ffd 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -151,7 +151,7 @@ private: }; // Single common genesis instance - static const Instance genesis; + static Instance const genesis; Ledger(ID id, Instance const* i) : id_{id}, instance_{i} { diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index a26879dea..b0b70467b 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -72,7 +72,7 @@ noripple(Account const& account, Args const&... args) inline FeatureBitset supported_amendments() { - static const FeatureBitset ids = [] { + static FeatureBitset const ids = [] { auto const& sa = ripple::detail::supportedAmendments(); std::vector feats; feats.reserve(sa.size()); diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index 27b186415..7f1102164 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -221,8 +221,9 @@ public: getList_ = [blob = blob, sig, manifest, version](int interval) { // Build the contents of a version 1 format UNL file std::stringstream l; - l << "{\"blob\":\"" << blob << "\"" << ",\"signature\":\"" << sig - << "\"" << ",\"manifest\":\"" << manifest << "\"" + l << "{\"blob\":\"" << blob << "\"" + << ",\"signature\":\"" << sig << "\"" + << ",\"manifest\":\"" << manifest << "\"" << ",\"refresh_interval\": " << interval << ",\"version\":" << version << '}'; return l.str(); @@ -257,14 +258,15 @@ public: std::stringstream l; for (auto const& info : blobInfo) { - l << "{\"blob\":\"" << info.blob << "\"" << ",\"signature\":\"" - << info.signature << "\"},"; + l << "{\"blob\":\"" << info.blob << "\"" + << ",\"signature\":\"" << info.signature << "\"},"; } std::string blobs = l.str(); blobs.pop_back(); l.str(std::string()); l << "{\"blobs_v2\": [ " << blobs << "],\"manifest\":\"" << manifest - << "\"" << ",\"refresh_interval\": " << interval + << "\"" + << ",\"refresh_interval\": " << interval << ",\"version\":" << (version + 1) << '}'; return l.str(); }; diff --git a/src/test/jtx/deposit.h b/src/test/jtx/deposit.h index 9bd73d383..a09979b7a 100644 --- a/src/test/jtx/deposit.h +++ b/src/test/jtx/deposit.h @@ -44,7 +44,7 @@ struct AuthorizeCredentials std::string credType; auto - operator<=>(const AuthorizeCredentials&) const = default; + operator<=>(AuthorizeCredentials const&) const = default; Json::Value toJson() const diff --git a/src/test/jtx/envconfig.h b/src/test/jtx/envconfig.h index d437a7468..fcd8a1fda 100644 --- a/src/test/jtx/envconfig.h +++ b/src/test/jtx/envconfig.h @@ -32,7 +32,7 @@ namespace test { extern std::atomic envUseIPv4; -inline const char* +inline char const* getEnvLocalhostAddr() { return envUseIPv4 ? "127.0.0.1" : "::1"; diff --git a/src/test/jtx/genesis.h b/src/test/jtx/genesis.h index d44d40d8b..6efa46df6 100644 --- a/src/test/jtx/genesis.h +++ b/src/test/jtx/genesis.h @@ -30,7 +30,7 @@ namespace jtx { /** Genesis operations. */ namespace genesis { -static const std::vector MintTestHook = { +static std::vector const MintTestHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x35U, 0x08U, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7FU, @@ -127,7 +127,7 @@ static const std::vector MintTestHook = { 0x20U, 0x74U, 0x78U, 0x6EU, 0x20U, 0x73U, 0x75U, 0x63U, 0x63U, 0x65U, 0x73U, 0x73U, 0x66U, 0x75U, 0x6CU, 0x6CU, 0x79U, 0x2EU}; -static const std::vector AcceptHook = { +static std::vector const AcceptHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U, 0x03U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, 0x17U, 0x02U, 0x03U, diff --git a/src/test/jtx/hook.h b/src/test/jtx/hook.h index 5e3b15ce7..5e88b4f00 100644 --- a/src/test/jtx/hook.h +++ b/src/test/jtx/hook.h @@ -100,7 +100,7 @@ struct StubHookContext std::map guard_map{}; StubHookResult result = {}; std::optional emitFailure = std::nullopt; - const hook::HookExecutor* module = 0; + hook::HookExecutor const* module = 0; }; // Overload that takes external stateMap to avoid dangling reference diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 9134122da..a1dbd2565 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -54,7 +54,7 @@ PrettyAmount::operator AnyAmount() const template static std::string -to_places(const T d, std::uint8_t places) +to_places(T const d, std::uint8_t places) { assert(places <= std::numeric_limits::digits10); diff --git a/src/test/jtx/impl/mpt.cpp b/src/test/jtx/impl/mpt.cpp index 51490ad21..c8ff16722 100644 --- a/src/test/jtx/impl/mpt.cpp +++ b/src/test/jtx/impl/mpt.cpp @@ -83,7 +83,7 @@ MPTTester::MPTTester(Env& env, Account const& issuer, MPTInit const& arg) } void -MPTTester::create(const MPTCreate& arg) +MPTTester::create(MPTCreate const& arg) { if (id_) Throw("MPT can't be reused"); @@ -413,7 +413,7 @@ MPTTester::getFlags(std::optional const& holder) const } MPT -MPTTester::operator[](const std::string& name) +MPTTester::operator[](std::string const& name) { return MPT(name, issuanceID()); } diff --git a/src/test/jtx/xchain_bridge.h b/src/test/jtx/xchain_bridge.h index 8ff19bd50..1b3841358 100644 --- a/src/test/jtx/xchain_bridge.h +++ b/src/test/jtx/xchain_bridge.h @@ -196,12 +196,12 @@ struct XChainBridgeObjects STAmount const split_reward_quorum; // 250,000 drops STAmount const split_reward_everyone; // 200,000 drops - const STAmount tiny_reward; // 37 drops - const STAmount tiny_reward_split; // 9 drops - const STAmount tiny_reward_remainder; // 1 drops + STAmount const tiny_reward; // 37 drops + STAmount const tiny_reward_split; // 9 drops + STAmount const tiny_reward_remainder; // 1 drops - const STAmount one_xrp; - const STAmount xrp_dust; + STAmount const one_xrp; + STAmount const xrp_dust; static constexpr int drop_per_xrp = 1000000; diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 9fc105262..18aebbe19 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -179,11 +179,11 @@ public: { } void - addTxQueue(const uint256&) override + addTxQueue(uint256 const&) override { } void - removeTxQueue(const uint256&) override + removeTxQueue(uint256 const&) override { } }; @@ -196,7 +196,7 @@ public: typedef std::milli period; typedef std::chrono::duration duration; typedef std::chrono::time_point time_point; - inline static const bool is_steady = false; + inline static bool const is_steady = false; static void advance(duration d) noexcept @@ -890,11 +890,12 @@ class reduce_relay_test : public beast::unit_test::suite protected: void - printPeers(const std::string& msg, std::uint16_t validator = 0) + printPeers(std::string const& msg, std::uint16_t validator = 0) { auto peers = network_.overlay().getPeers(network_.validator(validator)); - std::cout << msg << " " << "num peers " - << (int)network_.overlay().getNumPeers() << std::endl; + std::cout << msg << " " + << "num peers " << (int)network_.overlay().getNumPeers() + << std::endl; for (auto& [k, v] : peers) std::cout << k << ":" << (int)std::get(v) << " "; @@ -1125,7 +1126,7 @@ protected: } void - doTest(const std::string& msg, bool log, std::function f) + doTest(std::string const& msg, bool log, std::function f) { testcase(msg); f(log); diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 07ff2bb14..7a6b36ecd 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -41,7 +41,7 @@ public: private: void - doTest(const std::string& msg, bool log, std::function f) + doTest(std::string const& msg, bool log, std::function f) { testcase(msg); f(log); @@ -131,7 +131,7 @@ private: sendTx_++; } void - addTxQueue(const uint256& hash) override + addTxQueue(uint256 const& hash) override { queueTx_++; } diff --git a/src/test/protocol/MultiApiJson_test.cpp b/src/test/protocol/MultiApiJson_test.cpp index a5c37d257..9105607ba 100644 --- a/src/test/protocol/MultiApiJson_test.cpp +++ b/src/test/protocol/MultiApiJson_test.cpp @@ -45,7 +45,7 @@ Overload(Ts...) -> Overload; struct MultiApiJson_test : beast::unit_test::suite { static auto - makeJson(const char* key, int val) + makeJson(char const* key, int val) { Json::Value obj1(Json::objectValue); obj1[key] = val; @@ -80,7 +80,7 @@ struct MultiApiJson_test : beast::unit_test::suite testcase("forApiVersions, forAllApiVersions"); // Some static data for test inputs - static const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, + static int const primes[] = {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(primes) > RPC::apiMaximumValidVersion); @@ -205,7 +205,7 @@ struct MultiApiJson_test : beast::unit_test::suite return !requires { forAllApiVersions( std::forward(v).visit(), // - [](auto, auto, const char*) {}, + [](auto, auto, char const*) {}, 1); // parameter type mismatch }; }(std::as_const(s1))); @@ -256,7 +256,7 @@ struct MultiApiJson_test : beast::unit_test::suite Json::Value const&, std::integral_constant, int, - const char*) {}, + char const*) {}, 0, ""); }; diff --git a/src/test/protocol/STAccount_test.cpp b/src/test/protocol/STAccount_test.cpp index 034e0e9e0..9476a47c5 100644 --- a/src/test/protocol/STAccount_test.cpp +++ b/src/test/protocol/STAccount_test.cpp @@ -91,7 +91,7 @@ struct STAccount_test : public beast::unit_test::suite { // Construct from a VL that is not exactly 160 bits. Serializer s; - const std::uint8_t bits128[]{ + std::uint8_t const bits128[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; s.addVL(bits128, sizeof(bits128)); SerialIter sit(s.slice()); diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index 67b39d121..12706a779 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -300,7 +300,7 @@ public: unexpected(!to_currency(c, "USD"), "create USD currency"); unexpected(to_string(c) != "USD", "check USD currency"); - const std::string cur = "015841551A748AD2C1F76FF6ECB0CCCD00000000"; + std::string const cur = "015841551A748AD2C1F76FF6ECB0CCCD00000000"; unexpected(!to_currency(c, cur), "create custom currency"); unexpected(to_string(c) != cur, "check custom currency"); } diff --git a/src/test/protocol/TER_test.cpp b/src/test/protocol/TER_test.cpp index a43fd8758..0107f1c7d 100644 --- a/src/test/protocol/TER_test.cpp +++ b/src/test/protocol/TER_test.cpp @@ -149,7 +149,7 @@ struct TER_test : public beast::unit_test::suite terRETRY, tesSUCCESS, tecCLAIM); - static const int hiIndex{ + static int const hiIndex{ std::tuple_size::value - 1}; // Verify that enums cannot be converted to other enum types. @@ -277,7 +277,7 @@ struct TER_test : public beast::unit_test::suite tecCLAIM, NotTEC{telLOCAL_ERROR}, TER{tecCLAIM}); - static const int hiIndex{std::tuple_size::value - 1}; + static int const hiIndex{std::tuple_size::value - 1}; // Verify that all types in the ters tuple can be compared with all // the other types in ters. diff --git a/src/test/rdb/RelationalDatabase_test.cpp b/src/test/rdb/RelationalDatabase_test.cpp index 32d71cbbd..dcd75d428 100644 --- a/src/test/rdb/RelationalDatabase_test.cpp +++ b/src/test/rdb/RelationalDatabase_test.cpp @@ -819,7 +819,7 @@ public: std::vector static getBackends(std::string const& unittest_arg) { // Valid backends - static const std::set validBackends = {"sqlite", "rwdb"}; + static std::set const validBackends = {"sqlite", "rwdb"}; // Default to all valid backends if no arg specified if (unittest_arg.empty()) diff --git a/src/test/rpc/Catalogue_test.cpp b/src/test/rpc/Catalogue_test.cpp index bd03e5ffb..ef17a89b4 100644 --- a/src/test/rpc/Catalogue_test.cpp +++ b/src/test/rpc/Catalogue_test.cpp @@ -52,7 +52,7 @@ struct LedgerRetryParams // Poll for ledger availability with retry logic // Returns nullptr if ledger cannot be retrieved within the timeout period std::shared_ptr -getLedgerWithRetry(const LedgerRetryParams& params) +getLedgerWithRetry(LedgerRetryParams const& params) { auto start = std::chrono::steady_clock::now(); @@ -933,7 +933,7 @@ class Catalogue_test : public beast::unit_test::suite file.seekp(offsetof(TestCATLHeader, filesize), std::ios::beg); uint64_t wrongSize = 12345; // Some arbitrary wrong size file.write( - reinterpret_cast(&wrongSize), sizeof(wrongSize)); + reinterpret_cast(&wrongSize), sizeof(wrongSize)); file.close(); // Try to load the modified file @@ -977,7 +977,7 @@ class Catalogue_test : public beast::unit_test::suite }; uint64_t prevSize = 0; - for (const auto& test : compressionTests) + for (auto const& test : compressionTests) { std::string testName = test.first; Json::Value compressionLevel = test.second; diff --git a/src/test/rpc/DepositAuthorized_test.cpp b/src/test/rpc/DepositAuthorized_test.cpp index f75583152..95d6f356a 100644 --- a/src/test/rpc/DepositAuthorized_test.cpp +++ b/src/test/rpc/DepositAuthorized_test.cpp @@ -339,7 +339,7 @@ public: using namespace jtx; - const char credType[] = "abcde"; + char const credType[] = "abcde"; Account const alice{"alice"}; Account const becky{"becky"}; @@ -477,7 +477,7 @@ public: } { - static const std::vector credIds = { + static std::vector const credIds = { "18004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B" "E4", "28004829F915654A81B11C4AB8218D96FED67F209B58328A72314FB6EA288B" @@ -571,7 +571,7 @@ public: testcase("deposit_authorized with expired credentials"); // check expired credentials - const char credType2[] = "fghijk"; + char const credType2[] = "fghijk"; std::uint32_t const x = env.current() ->info() .parentCloseTime.time_since_epoch() diff --git a/src/test/rpc/Feature_test.cpp b/src/test/rpc/Feature_test.cpp index bc789f9a7..40de395a7 100644 --- a/src/test/rpc/Feature_test.cpp +++ b/src/test/rpc/Feature_test.cpp @@ -519,7 +519,7 @@ class Feature_test : public beast::unit_test::suite using namespace test::jtx; Env env{*this, FeatureBitset(featureMultiSignReserve)}; - constexpr const char* featureName = "MultiSignReserve"; + constexpr char const* featureName = "MultiSignReserve"; auto jrr = env.rpc("feature", featureName)[jss::result]; if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status")) @@ -570,7 +570,7 @@ class Feature_test : public beast::unit_test::suite using namespace test::jtx; Env env{*this}; - constexpr const char* featureName = "NonFungibleTokensV1"; + constexpr char const* featureName = "NonFungibleTokensV1"; auto jrr = env.rpc("feature", featureName)[jss::result]; if (!BEAST_EXPECTS(jrr[jss::status] == jss::success, "status")) diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 4883cf664..8eb0c8d01 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -84,7 +84,7 @@ class Handler_test : public beast::unit_test::suite } } - const double mean_squared = (sum * sum) / (j * j); + double const mean_squared = (sum * sum) / (j * j); return std::make_tuple( clock::duration{static_cast(sum / j)}, clock::duration{ @@ -100,7 +100,7 @@ class Handler_test : public beast::unit_test::suite std::random_device dev; std::ranlux48 prng(dev()); - std::vector names = + std::vector names = test::jtx::make_vector(ripple::RPC::getHandlerNames()); std::uniform_int_distribution distr{0, names.size() - 1}; diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index 592f37483..5a45194ab 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -260,7 +260,7 @@ class LedgerEntry_test : public beast::unit_test::suite Account const issuer{"issuer"}; Account const alice{"alice"}; Account const bob{"bob"}; - const char credType[] = "abcde"; + char const credType[] = "abcde"; env.fund(XRP(5000), issuer, alice, bob); env.close(); @@ -782,7 +782,7 @@ class LedgerEntry_test : public beast::unit_test::suite Account const issuer{"issuer"}; Account const alice{"alice"}; Account const bob{"bob"}; - const char credType[] = "abcde"; + char const credType[] = "abcde"; env.fund(XRP(5000), issuer, alice, bob); env.close(); @@ -975,7 +975,7 @@ class LedgerEntry_test : public beast::unit_test::suite { // Failed, authorized_credentials is too long - static const std::string_view credTypes[] = { + static std::string_view const credTypes[] = { "cred1", "cred2", "cred3", diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index 9e009e6cb..2bb4559ae 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -572,11 +572,11 @@ public: env.close(); jrr = env.rpc("json", "ledger", to_string(jv))[jss::result]; - const std::string txid0 = [&]() { + std::string const txid0 = [&]() { auto const& parentHash = env.current()->info().parentHash; if (BEAST_EXPECT(jrr[jss::queue_data].size() == 2)) { - const std::string txid1 = [&]() { + std::string const txid1 = [&]() { auto const& txj = jrr[jss::queue_data][1u]; BEAST_EXPECT(txj[jss::account] == alice.human()); BEAST_EXPECT(txj[jss::fee_level] == "256"); @@ -598,7 +598,7 @@ public: auto const& tx = txj[jss::tx]; BEAST_EXPECT(tx[jss::Account] == alice.human()); BEAST_EXPECT(tx[jss::TransactionType] == jss::OfferCreate); - const auto txid0 = tx[jss::hash].asString(); + auto const txid0 = tx[jss::hash].asString(); uint256 tx0, tx1; BEAST_EXPECT(tx0.parseHex(txid0)); BEAST_EXPECT(tx1.parseHex(txid1)); @@ -674,7 +674,7 @@ public: jv[jss::binary] = false; jrr = env.rpc("json", "ledger", to_string(jv))[jss::result]; - const std::string txid2 = [&]() { + std::string const txid2 = [&]() { if (BEAST_EXPECT(jrr[jss::queue_data].size() == 1)) { auto const& txj = jrr[jss::queue_data][0u]; diff --git a/src/test/rpc/RPCCall_test.cpp b/src/test/rpc/RPCCall_test.cpp index 4b60f65b7..217e0dd9b 100644 --- a/src/test/rpc/RPCCall_test.cpp +++ b/src/test/rpc/RPCCall_test.cpp @@ -5886,7 +5886,7 @@ static RPCCallTestData const rpcCallTestArray[] = { }; std::string -updateAPIVersionString(const char* const req, unsigned apiVersion) +updateAPIVersionString(char const* const req, unsigned apiVersion) { std::string const version_str = std::to_string(apiVersion); static auto const place_holder = "%API_VER%"; @@ -5929,7 +5929,7 @@ public: std::vector const args{ rpcCallTest.args.begin(), rpcCallTest.args.end()}; - const char* const expVersioned = + char const* const expVersioned = (apiVersion - RPC::apiMinimumSupportedVersion) < rpcCallTest.exp.size() ? rpcCallTest.exp[apiVersion - RPC::apiMinimumSupportedVersion] diff --git a/src/test/rpc/Simulate_test.cpp b/src/test/rpc/Simulate_test.cpp index e7c8b1072..9010f187c 100644 --- a/src/test/rpc/Simulate_test.cpp +++ b/src/test/rpc/Simulate_test.cpp @@ -1092,7 +1092,7 @@ class Simulate_test : public beast::unit_test::suite env.close(); { - const std::vector acceptHook = { + std::vector const acceptHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U, 0x03U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, @@ -1137,7 +1137,7 @@ class Simulate_test : public beast::unit_test::suite { testcase("simulate Hook rollback"); - const std::vector rollbackHook = { + std::vector const rollbackHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x13U, 0x03U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU, 0x60U, 0x01U, 0x7FU, diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 8499af209..f9328c18f 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -1303,7 +1303,7 @@ public: } } - const std::vector TshHook = { + std::vector const TshHook = { 0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x28U, 0x06U, 0x60U, 0x05U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x04U, 0x7FU, 0x7FU, 0x7FU, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x00U, diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index 75aa7ccd4..057038595 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -55,11 +55,11 @@ class Transaction_test : public beast::unit_test::suite using namespace test::jtx; using std::to_string; - const char* COMMAND = jss::tx.c_str(); - const char* BINARY = jss::binary.c_str(); - const char* NOT_FOUND = RPC::get_error_info(rpcTXN_NOT_FOUND).token; - const char* INVALID = RPC::get_error_info(rpcINVALID_LGR_RANGE).token; - const char* EXCESSIVE = + char const* COMMAND = jss::tx.c_str(); + char const* BINARY = jss::binary.c_str(); + char const* NOT_FOUND = RPC::get_error_info(rpcTXN_NOT_FOUND).token; + char const* INVALID = RPC::get_error_info(rpcINVALID_LGR_RANGE).token; + char const* EXCESSIVE = RPC::get_error_info(rpcEXCESSIVE_LGR_RANGE).token; Env env{*this, features}; @@ -135,7 +135,7 @@ class Transaction_test : public beast::unit_test::suite BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool()); } - const auto deletedLedger = (startLegSeq + endLegSeq) / 2; + auto const deletedLedger = (startLegSeq + endLegSeq) / 2; { // Remove one of the ledgers from the database directly dynamic_cast(&env.app().getRelationalDatabase()) @@ -305,11 +305,11 @@ class Transaction_test : public beast::unit_test::suite using namespace test::jtx; using std::to_string; - const char* COMMAND = jss::tx.c_str(); - const char* BINARY = jss::binary.c_str(); - const char* NOT_FOUND = RPC::get_error_info(rpcTXN_NOT_FOUND).token; - const char* INVALID = RPC::get_error_info(rpcINVALID_LGR_RANGE).token; - const char* EXCESSIVE = + char const* COMMAND = jss::tx.c_str(); + char const* BINARY = jss::binary.c_str(); + char const* NOT_FOUND = RPC::get_error_info(rpcTXN_NOT_FOUND).token; + char const* INVALID = RPC::get_error_info(rpcINVALID_LGR_RANGE).token; + char const* EXCESSIVE = RPC::get_error_info(rpcEXCESSIVE_LGR_RANGE).token; Env env{*this, makeNetworkConfig(11111)}; @@ -393,7 +393,7 @@ class Transaction_test : public beast::unit_test::suite BEAST_EXPECT(!result[jss::result][jss::searched_all].asBool()); } - const auto deletedLedger = (startLegSeq + endLegSeq) / 2; + auto const deletedLedger = (startLegSeq + endLegSeq) / 2; { // Remove one of the ledgers from the database directly dynamic_cast(&env.app().getRelationalDatabase()) diff --git a/src/test/rpc/ValidatorInfo_test.cpp b/src/test/rpc/ValidatorInfo_test.cpp index 4904923e0..78ff267e5 100644 --- a/src/test/rpc/ValidatorInfo_test.cpp +++ b/src/test/rpc/ValidatorInfo_test.cpp @@ -63,7 +63,7 @@ public: testcase("Lookup"); using namespace jtx; - const std::vector tokenBlob = { + std::vector const tokenBlob = { " " "eyJ2YWxpZGF0aW9uX3NlY3JldF9rZXkiOiI5ZWQ0NWY4NjYyNDFjYzE4YTI3NDdiNT" "\n", diff --git a/src/test/unit_test/multi_runner.h b/src/test/unit_test/multi_runner.h index 653bbead0..08512d188 100644 --- a/src/test/unit_test/multi_runner.h +++ b/src/test/unit_test/multi_runner.h @@ -152,10 +152,10 @@ class multi_runner_base print_results(S& s); }; - static constexpr const char* shared_mem_name_ = "RippledUnitTestSharedMem"; + static constexpr char const* shared_mem_name_ = "RippledUnitTestSharedMem"; // name of the message queue a multi_runner_child will use to communicate // with multi_runner_parent - static constexpr const char* message_queue_name_ = + static constexpr char const* message_queue_name_ = "RippledUnitTestMessageQueue"; // `inner_` will be created in shared memory diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 0e5686ec6..c0492282a 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -320,8 +320,8 @@ RCLConsensus::Adaptor::onClose( NetClock::time_point const& closeTime, ConsensusMode mode) -> Result { - const bool wrongLCL = mode == ConsensusMode::wrongLedger; - const bool proposing = mode == ConsensusMode::proposing; + bool const wrongLCL = mode == ConsensusMode::wrongLedger; + bool const proposing = mode == ConsensusMode::proposing; notify(protocol::neCLOSING_LEDGER, ledger, !wrongLCL); @@ -438,7 +438,7 @@ RCLConsensus::Adaptor::onAccept( ConsensusCloseTimes const& rawCloseTimes, ConsensusMode const& mode, Json::Value&& consensusJson, - const bool validating) + bool const validating) { app_.getJobQueue().addJob( jtACCEPT, @@ -475,9 +475,9 @@ RCLConsensus::Adaptor::doAccept( bool closeTimeCorrect; - const bool proposing = mode == ConsensusMode::proposing; - const bool haveCorrectLCL = mode != ConsensusMode::wrongLedger; - const bool consensusFail = result.state == ConsensusState::MovedOn; + bool const proposing = mode == ConsensusMode::proposing; + bool const haveCorrectLCL = mode != ConsensusMode::wrongLedger; + bool const consensusFail = result.state == ConsensusState::MovedOn; auto consensusCloseTime = result.position.closeTime(); @@ -1020,7 +1020,7 @@ RCLConsensus::Adaptor::preStartRound( } } - const bool synced = app_.getOPs().getOperatingMode() == OperatingMode::FULL; + bool const synced = app_.getOPs().getOperatingMode() == OperatingMode::FULL; if (validating_) { @@ -1105,8 +1105,8 @@ RCLConsensus::startRound( } RclConsensusLogger::RclConsensusLogger( - const char* label, - const bool validating, + char const* label, + bool const validating, beast::Journal j) : j_(j) { diff --git a/src/xrpld/app/consensus/RCLConsensus.h b/src/xrpld/app/consensus/RCLConsensus.h index 735c67fd0..38481d236 100644 --- a/src/xrpld/app/consensus/RCLConsensus.h +++ b/src/xrpld/app/consensus/RCLConsensus.h @@ -328,7 +328,7 @@ class RCLConsensus ConsensusCloseTimes const& rawCloseTimes, ConsensusMode const& mode, Json::Value&& consensusJson, - const bool validating); + bool const validating); /** Process the accepted ledger that was a result of simulation/force accept. @@ -556,7 +556,7 @@ class RclConsensusLogger public: explicit RclConsensusLogger( - const char* label, + char const* label, bool validating, beast::Journal j); ~RclConsensusLogger(); diff --git a/src/xrpld/app/hook/HookAPI.h b/src/xrpld/app/hook/HookAPI.h index 4bae2c3b4..7fa1f9ab5 100644 --- a/src/xrpld/app/hook/HookAPI.h +++ b/src/xrpld/app/hook/HookAPI.h @@ -149,7 +149,7 @@ public: uint32_t otxn_generation() const; - Expected + Expected otxn_field(uint32_t field_id) const; Expected @@ -228,7 +228,7 @@ public: Bytes& data) const; /// slot APIs - Expected + Expected slot(uint32_t slot_no) const; Expected diff --git a/src/xrpld/app/hook/applyHook.h b/src/xrpld/app/hook/applyHook.h index aeddb8be0..4b0ab7bc5 100644 --- a/src/xrpld/app/hook/applyHook.h +++ b/src/xrpld/app/hook/applyHook.h @@ -183,8 +183,8 @@ class HookExecutor; struct SlotEntry { - std::shared_ptr storage; - const ripple::STBase* entry; // raw pointer into the storage, that can be + std::shared_ptr storage; + ripple::STBase const* entry; // raw pointer into the storage, that can be // freely pointed around inside }; @@ -217,7 +217,7 @@ struct HookContext emitFailure; // if this is a callback from a failed // emitted txn then this optional becomes // populated with the SLE - const HookExecutor* module = 0; + HookExecutor const* module = 0; // Lazy-initialized HookAPI member mutable std::unique_ptr api_; @@ -360,7 +360,7 @@ public: if (WasmEdge_ResultOK(res)) return {}; - const char* msg = WasmEdge_ResultGetMessage(res); + char const* msg = WasmEdge_ResultGetMessage(res); return prefix + ": " + (msg ? msg : "unknown error"); } @@ -368,7 +368,7 @@ public: * Validate that a web assembly blob can be loaded by wasmedge */ static std::optional - validateWasm(const void* wasm, size_t len) + validateWasm(void const* wasm, size_t len) { WasmEdgeVM vm; @@ -376,7 +376,7 @@ public: return "Could not create WASMEDGE instance"; WasmEdge_Result res = WasmEdge_VMLoadWasmFromBuffer( - vm.ctx, reinterpret_cast(wasm), len); + vm.ctx, reinterpret_cast(wasm), len); if (auto err = getWasmError("VMLoadWasmFromBuffer failed", res); err) return *err; @@ -397,7 +397,7 @@ public: */ void executeWasm( - const void* wasm, + void const* wasm, size_t len, bool callback, uint32_t wasmParam, @@ -441,7 +441,7 @@ public: res = WasmEdge_VMRunWasmFromBuffer( vm.ctx, - reinterpret_cast(wasm), + reinterpret_cast(wasm), len, callback ? cbakFunctionName : hookFunctionName, params, diff --git a/src/xrpld/app/hook/detail/HookAPI.cpp b/src/xrpld/app/hook/detail/HookAPI.cpp index beda5bbef..6b04d5eb8 100644 --- a/src/xrpld/app/hook/detail/HookAPI.cpp +++ b/src/xrpld/app/hook/detail/HookAPI.cpp @@ -282,7 +282,7 @@ normalize_xfl(T& man, int32_t& exp, bool neg = false) return ret; } -const int64_t float_one_internal = +int64_t const float_one_internal = make_float(1000000000000000ull, -15, false).value(); } // namespace hook_float @@ -1802,7 +1802,7 @@ HookAPI::otxn_generation() const return hookCtx.generation; } -Expected +Expected HookAPI::otxn_field(uint32_t field_id) const { SField const& fieldType = ripple::SField::getField(field_id); @@ -2292,7 +2292,7 @@ HookAPI::state_foreign_set( /// slot APIs -Expected +Expected HookAPI::slot(uint32_t slot_no) const { if (hookCtx.slot.find(slot_no) == hookCtx.slot.end()) @@ -2340,7 +2340,7 @@ HookAPI::slot_set(Bytes const& data, uint32_t slot_no) const if (slot_no == 0 && no_free_slots()) return Unexpected(NO_FREE_SLOTS); - std::optional> slot_value = + std::optional> slot_value = std::nullopt; if (data.size() == 34) @@ -2456,7 +2456,7 @@ HookAPI::slot_subarray( hookCtx.slot[new_slot].entry = &(parent_obj[array_id]); return new_slot; } - catch (const std::bad_cast& e) + catch (std::bad_cast const& e) { if (copied) { @@ -2521,7 +2521,7 @@ HookAPI::slot_subfield( hookCtx.slot[new_slot].entry = &(parent_obj.getField(fieldCode)); return new_slot; } - catch (const std::bad_cast& e) + catch (std::bad_cast const& e) { if (copied) { @@ -2559,7 +2559,7 @@ HookAPI::slot_type(uint32_t slot_no, uint32_t flags) const return Unexpected(INVALID_ARGUMENT); } - catch (const std::bad_cast& e) + catch (std::bad_cast const& e) { return Unexpected(INTERNAL_ERROR); } @@ -2614,7 +2614,7 @@ HookAPI::slot_float(uint32_t slot_no) const return 0; // return 0 in this case return normalized; } - catch (const std::bad_cast& e) + catch (std::bad_cast const& e) { return Unexpected(NOT_AN_AMOUNT); } diff --git a/src/xrpld/app/hook/detail/applyHook.cpp b/src/xrpld/app/hook/detail/applyHook.cpp index b79c9ee30..d00851c3a 100644 --- a/src/xrpld/app/hook/detail/applyHook.cpp +++ b/src/xrpld/app/hook/detail/applyHook.cpp @@ -52,7 +52,7 @@ getTransactionalStakeHolders(STTx const& tx, ReadView const& rv) int upto = 0; auto const ADD_TSH = [&otxnAcc, &tshEntries, &upto]( - const AccountID& acc_r, bool rb) { + AccountID const& acc_r, bool rb) { if (acc_r != *otxnAcc) { if (tshEntries.find(acc_r) != tshEntries.end()) @@ -892,7 +892,7 @@ data_as_int64(void const* ptr_raw, uint32_t len) /* returns true iff every even char is ascii and every odd char is 00 * only a hueristic, may be inaccurate in edgecases */ inline bool -is_UTF16LE(const uint8_t* buffer, size_t len) +is_UTF16LE(uint8_t const* buffer, size_t len) { if (len % 2 != 0 || len == 0) return false; @@ -1281,14 +1281,14 @@ DEFINE_HOOK_FUNCTION( if (read_len > 0) { // skip \0 if present at the end - if (*((const char*)memory + read_ptr + read_len - 1) == '\0') + if (*((char const*)memory + read_ptr + read_len - 1) == '\0') read_len--; if (read_len > 0) { j.trace() << "HookTrace[" << HC_ACC() << "]: " << std::string_view( - (const char*)memory + read_ptr, read_len) + (char const*)memory + read_ptr, read_len) << ": " << number; return 0; @@ -1376,7 +1376,7 @@ DEFINE_HOOK_FUNCTION( if (out_len > 0) { j.trace() << "HookTrace[" << HC_ACC() << "]: " - << std::string_view((const char*)output_storage, out_len); + << std::string_view((char const*)output_storage, out_len); } return 0; @@ -1399,7 +1399,7 @@ std::optional inline make_state_key(std::string_view source) for (; i < pad; ++i) key_buffer[i] = 0; - const char* data = source.data(); + char const* data = source.data(); for (; i < 32; ++i) key_buffer[i] = data[i - pad]; @@ -1502,7 +1502,7 @@ DEFINE_HOOK_FUNCTION( : hookCtx.result.account; auto const key = make_state_key( - std::string_view{(const char*)(memory + kread_ptr), (size_t)kread_len}); + std::string_view{(char const*)(memory + kread_ptr), (size_t)kread_len}); if (view.rules().enabled(fixXahauV1)) { @@ -1534,17 +1534,17 @@ hook::finalizeHookState( uint16_t changeCount = 0; // write all changes to state, if in "apply" mode - for (const auto& accEntry : stateMap) + for (auto const& accEntry : stateMap) { - const auto& acc = accEntry.first; - for (const auto& nsEntry : std::get<3>(accEntry.second)) + auto const& acc = accEntry.first; + for (auto const& nsEntry : std::get<3>(accEntry.second)) { - const auto& ns = nsEntry.first; - for (const auto& cacheEntry : nsEntry.second) + auto const& ns = nsEntry.first; + for (auto const& cacheEntry : nsEntry.second) { bool is_modified = cacheEntry.second.first; - const auto& key = cacheEntry.first; - const auto& blob = cacheEntry.second.second; + auto const& key = cacheEntry.first; + auto const& blob = cacheEntry.second.second; if (is_modified) { changeCount++; @@ -1674,7 +1674,7 @@ hook::finalizeHookResult( applyCtx.app.getHashRouter().setFlags(id, SF_EMITTED); - std::shared_ptr ptr = + std::shared_ptr ptr = tpTrans->getSTransaction(); auto emittedId = keylet::emittedTxn(id); @@ -1866,7 +1866,7 @@ DEFINE_HOOK_FUNCTION( : hookCtx.result.account; auto const key = make_state_key( - std::string_view{(const char*)(memory + kread_ptr), (size_t)kread_len}); + std::string_view{(char const*)(memory + kread_ptr), (size_t)kread_len}); if (!key) return INVALID_ARGUMENT; @@ -2784,7 +2784,7 @@ DEFINE_HOOK_FUNCTION( return OUT_OF_BOUNDS; ripple::Slice txBlob{ - reinterpret_cast(memory + read_ptr), read_len}; + reinterpret_cast(memory + read_ptr), read_len}; auto const res = api.prepare(txBlob); if (!res) @@ -2828,7 +2828,7 @@ DEFINE_HOOK_FUNCTION( // Delegate to decoupled HookAPI for emit logic ripple::Slice txBlob{ - reinterpret_cast(memory + read_ptr), read_len}; + reinterpret_cast(memory + read_ptr), read_len}; auto const res = api.emit(txBlob); @@ -3410,11 +3410,11 @@ DEFINE_HOOK_FUNCTION( return OUT_OF_BOUNDS; ripple::Slice key{ - reinterpret_cast(kread_ptr + memory), kread_len}; + reinterpret_cast(kread_ptr + memory), kread_len}; ripple::Slice data{ - reinterpret_cast(dread_ptr + memory), dread_len}; + reinterpret_cast(dread_ptr + memory), dread_len}; ripple::Slice sig{ - reinterpret_cast(sread_ptr + memory), sread_len}; + reinterpret_cast(sread_ptr + memory), sread_len}; auto const result = api.util_verify(data, sig, key); if (!result) @@ -3447,7 +3447,7 @@ DEFINE_HOOK_FUNCTION( if (NOT_IN_BOUNDS(read_ptr, read_len, memory_length)) return OUT_OF_BOUNDS; ripple::Slice tx{ - reinterpret_cast(read_ptr + memory), read_len}; + reinterpret_cast(read_ptr + memory), read_len}; auto const fee_base = api.etxn_fee_base(tx); if (!fee_base) return fee_base.error(); @@ -3557,7 +3557,7 @@ DEFINE_HOOK_FUNCTION( // omit \0 if present if (read_len > 0 && - *((const char*)memory + read_ptr + read_len - 1) == '\0') + *((char const*)memory + read_ptr + read_len - 1) == '\0') read_len--; if (float1 == 0) @@ -3566,7 +3566,7 @@ DEFINE_HOOK_FUNCTION( << (read_len == 0 ? "" : std::string_view( - (const char*)memory + read_ptr, read_len)) + (char const*)memory + read_ptr, read_len)) << ": Float 0*10^(0) "; return 0; } @@ -3581,7 +3581,7 @@ DEFINE_HOOK_FUNCTION( << (read_len == 0 ? "" : std::string_view( - (const char*)memory + read_ptr, read_len)) + (char const*)memory + read_ptr, read_len)) << ": Float "; return 0; } @@ -3589,7 +3589,7 @@ DEFINE_HOOK_FUNCTION( j.trace() << "HookTrace[" << HC_ACC() << "]:" << (read_len == 0 ? "" : std::string_view( - (const char*)memory + read_ptr, read_len)) + (char const*)memory + read_ptr, read_len)) << ": Float " << (neg ? "-" : "") << man << "*10^(" << exp << ")"; return 0; diff --git a/src/xrpld/app/ledger/BuildLedger.h b/src/xrpld/app/ledger/BuildLedger.h index 0805db6c8..2ec571773 100644 --- a/src/xrpld/app/ledger/BuildLedger.h +++ b/src/xrpld/app/ledger/BuildLedger.h @@ -53,7 +53,7 @@ std::shared_ptr buildLedger( std::shared_ptr const& parent, NetClock::time_point closeTime, - const bool closeTimeCorrect, + bool const closeTimeCorrect, NetClock::duration closeResolution, Application& app, CanonicalTXSet& txns, diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 11412b70c..c33d79b72 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -1152,7 +1152,7 @@ finishLoadByIndexOrHash( std::tuple, std::uint32_t, uint256> getLatestLedger(Application& app) { - const std::optional info = + std::optional const info = app.getRelationalDatabase().getNewestLedgerInfo(); if (!info) return {std::shared_ptr(), {}, {}}; diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 4ce724bba..ee4cdde29 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -65,7 +65,7 @@ LedgerHistory::insert( std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - const bool alreadyHad = m_ledgers_by_hash.canonicalize_replace_cache( + bool const alreadyHad = m_ledgers_by_hash.canonicalize_replace_cache( ledger->info().hash, ledger); if (validated) mLedgersByIndex[ledger->info().seq] = ledger->info().hash; @@ -225,30 +225,30 @@ log_metadata_difference( { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and index!"; - JLOG(j.debug()) - << " Built:" << " Result: " << builtMetaData->getResult() - << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) - << " Valid:" << " Result: " << validMetaData->getResult() - << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) << " Built:" + << " Result: " << builtMetaData->getResult() + << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) << " Valid:" + << " Result: " << validMetaData->getResult() + << " Index: " << validMetaData->getIndex(); } else if (result_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result!"; - JLOG(j.debug()) - << " Built:" << " Result: " << builtMetaData->getResult(); - JLOG(j.debug()) - << " Valid:" << " Result: " << validMetaData->getResult(); + JLOG(j.debug()) << " Built:" + << " Result: " << builtMetaData->getResult(); + JLOG(j.debug()) << " Valid:" + << " Result: " << validMetaData->getResult(); } else if (index_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index!"; - JLOG(j.debug()) - << " Built:" << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) - << " Valid:" << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) << " Built:" + << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) << " Valid:" + << " Index: " << validMetaData->getIndex(); } } else @@ -267,12 +267,12 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and nodes!"; JLOG(j.debug()) - << " Built:" << " Result: " << builtMetaData->getResult() - << " Nodes:\n" + << " Built:" + << " Result: " << builtMetaData->getResult() << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" << " Result: " << validMetaData->getResult() - << " Nodes:\n" + << " Valid:" + << " Result: " << validMetaData->getResult() << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else if (index_diff) @@ -280,21 +280,23 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index and nodes!"; JLOG(j.debug()) - << " Built:" << " Index: " << builtMetaData->getIndex() - << " Nodes:\n" + << " Built:" + << " Index: " << builtMetaData->getIndex() << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" << " Index: " << validMetaData->getIndex() - << " Nodes:\n" + << " Valid:" + << " Index: " << validMetaData->getIndex() << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else // nodes_diff { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different nodes!"; - JLOG(j.debug()) << " Built:" << " Nodes:\n" + JLOG(j.debug()) << " Built:" + << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); - JLOG(j.debug()) << " Valid:" << " Nodes:\n" + JLOG(j.debug()) << " Valid:" + << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } } @@ -351,10 +353,10 @@ LedgerHistory::handleMismatch( if (!builtLedger || !validLedger) { - JLOG(j_.error()) << "MISMATCH cannot be analyzed:" << " builtLedger: " - << to_string(built) << " -> " << builtLedger - << " validLedger: " << to_string(valid) << " -> " - << validLedger; + JLOG(j_.error()) << "MISMATCH cannot be analyzed:" + << " builtLedger: " << to_string(built) << " -> " + << builtLedger << " validLedger: " << to_string(valid) + << " -> " << validLedger; return; } diff --git a/src/xrpld/app/ledger/LedgerMaster.h b/src/xrpld/app/ledger/LedgerMaster.h index e557d429c..070ab4c7c 100644 --- a/src/xrpld/app/ledger/LedgerMaster.h +++ b/src/xrpld/app/ledger/LedgerMaster.h @@ -139,7 +139,7 @@ public: getPinnedLedgersRangeSet(); void - setPinnedLedgersRangeSet(const RangeSet& range_set); + setPinnedLedgersRangeSet(RangeSet const& range_set); /** Apply held transactions to the open ledger This is normally called as we close the ledger. @@ -331,7 +331,7 @@ private: // Returns true if work started. Always called with m_mutex locked. // The passed lock is a reminder to callers. bool - newPFWork(const char* name, std::unique_lock&); + newPFWork(char const* name, std::unique_lock&); Application& app_; beast::Journal m_journal; diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp index 5d3616ce2..b8a7b5400 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -252,7 +252,7 @@ OrderBookDB::getBookListeners(Book const& book) void OrderBookDB::processTxn( std::shared_ptr const& ledger, - const AcceptedLedgerTx& alTx, + AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj) { std::lock_guard sl(mLock); diff --git a/src/xrpld/app/ledger/OrderBookDB.h b/src/xrpld/app/ledger/OrderBookDB.h index d120f43ae..bc36f8a30 100644 --- a/src/xrpld/app/ledger/OrderBookDB.h +++ b/src/xrpld/app/ledger/OrderBookDB.h @@ -65,7 +65,7 @@ public: void processTxn( std::shared_ptr const& ledger, - const AcceptedLedgerTx& alTx, + AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj); private: diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 0f22715b0..d7e52ebec 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -39,7 +39,7 @@ std::shared_ptr buildLedgerImpl( std::shared_ptr const& parent, NetClock::time_point closeTime, - const bool closeTimeCorrect, + bool const closeTimeCorrect, NetClock::duration closeResolution, Application& app, beast::Journal j, @@ -181,7 +181,7 @@ std::shared_ptr buildLedger( std::shared_ptr const& parent, NetClock::time_point closeTime, - const bool closeTimeCorrect, + bool const closeTimeCorrect, NetClock::duration closeResolution, Application& app, CanonicalTXSet& txns, diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 4799a89e4..4dbf0d8f0 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -1668,7 +1668,7 @@ LedgerMaster::newOrderBookDB() */ bool LedgerMaster::newPFWork( - const char* name, + char const* name, std::unique_lock&) { if (!app_.isStopping() && mPathFindThread < 2 && @@ -1758,7 +1758,7 @@ LedgerMaster::getPinnedLedgersRangeSet() } void -LedgerMaster::setPinnedLedgersRangeSet(const RangeSet& range_set) +LedgerMaster::setPinnedLedgersRangeSet(RangeSet const& range_set) { std::scoped_lock lock(mCompleteLock, mPinnedLock); if (!mPinnedLedgers.empty()) diff --git a/src/xrpld/app/ledger/detail/LedgerToJson.cpp b/src/xrpld/app/ledger/detail/LedgerToJson.cpp index 5f1e47e8b..3e4f4b8f0 100644 --- a/src/xrpld/app/ledger/detail/LedgerToJson.cpp +++ b/src/xrpld/app/ledger/detail/LedgerToJson.cpp @@ -168,7 +168,7 @@ fillJsonTx( if (!fill.ledger.open()) txJson[jss::ledger_hash] = to_string(fill.ledger.info().hash); - const bool validated = + bool const validated = fill.context->ledgerMaster.isValidated(fill.ledger); txJson[jss::validated] = validated; if (validated) diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 096148869..e81ec6574 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -100,8 +100,8 @@ TimeoutCounter::invokeOnTimer() if (!progress_) { ++timeouts_; - JLOG(journal_.debug()) - << "Timeout(" << timeouts_ << ") " << " acquiring " << hash_; + JLOG(journal_.debug()) << "Timeout(" << timeouts_ << ") " + << " acquiring " << hash_; onTimer(false, sl); } else diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 0d63fb237..73903a2b3 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -1140,7 +1140,7 @@ public: return maxDisallowedLedger_; } - virtual const std::optional& + virtual std::optional const& trapTxID() const override { return trapTxID_; diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 0af653f99..de0fb63c3 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -272,7 +272,7 @@ public: virtual LedgerIndex getMaxDisallowedLedger() = 0; - virtual const std::optional& + virtual std::optional const& trapTxID() const = 0; }; diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 2ee811dc1..a4bbcda0a 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -447,8 +447,8 @@ GRPCServerImpl::handleRpcs() if (!ok) { - JLOG(journal_.debug()) - << "Request listener cancelled. " << "Destroying object"; + JLOG(journal_.debug()) << "Request listener cancelled. " + << "Destroying object"; erase(ptr); } else diff --git a/src/xrpld/app/main/GRPCServer.h b/src/xrpld/app/main/GRPCServer.h index 2ecbd5e7d..5ed4ba845 100644 --- a/src/xrpld/app/main/GRPCServer.h +++ b/src/xrpld/app/main/GRPCServer.h @@ -44,10 +44,10 @@ public: Processor() = default; - Processor(const Processor&) = delete; + Processor(Processor const&) = delete; Processor& - operator=(const Processor&) = delete; + operator=(Processor const&) = delete; // process a request that has arrived. Can only be called once per instance virtual void @@ -120,10 +120,10 @@ private: public: explicit GRPCServerImpl(Application& app); - GRPCServerImpl(const GRPCServerImpl&) = delete; + GRPCServerImpl(GRPCServerImpl const&) = delete; GRPCServerImpl& - operator=(const GRPCServerImpl&) = delete; + operator=(GRPCServerImpl const&) = delete; void shutdown(); @@ -214,10 +214,10 @@ private: Resource::Charge loadType, std::vector const& secureGatewayIPs); - CallData(const CallData&) = delete; + CallData(CallData const&) = delete; CallData& - operator=(const CallData&) = delete; + operator=(CallData const&) = delete; virtual void process() override; @@ -304,10 +304,10 @@ public: { } - GRPCServer(const GRPCServer&) = delete; + GRPCServer(GRPCServer const&) = delete; GRPCServer& - operator=(const GRPCServer&) = delete; + operator=(GRPCServer const&) = delete; bool start(); diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index 82bac86d8..7ffccd892 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -116,7 +116,7 @@ adjustDescriptorLimit(int needed, beast::Journal j) } void -printHelp(const po::options_description& desc) +printHelp(po::options_description const& desc) { std::cerr << systemName() << "d [options] \n" diff --git a/src/xrpld/app/misc/DatagramMonitor.h b/src/xrpld/app/misc/DatagramMonitor.h index e0e7cb0cd..c98a92a4d 100644 --- a/src/xrpld/app/misc/DatagramMonitor.h +++ b/src/xrpld/app/misc/DatagramMonitor.h @@ -214,12 +214,12 @@ private: double calculateRate( - const SystemMetrics& current, - const std::vector& samples, + SystemMetrics const& current, + std::vector const& samples, size_t current_index, size_t max_samples, bool is_24h_window, - std::function metric_getter) + std::function metric_getter) { // If we don't have at least 2 samples, the rate is 0 if (current_index < 2) @@ -252,7 +252,7 @@ private: size_t oldest_index = (current_index >= max_samples) ? ((current_index + 1) % max_samples) : 0; - const auto& oldest = samples[oldest_index]; + auto const& oldest = samples[oldest_index]; double elapsed = actual_window_micros / 1000000.0; // Convert microseconds to seconds @@ -278,8 +278,8 @@ private: MetricRates calculateMetricRates( - const SystemMetrics& current, - std::function metric_getter) + SystemMetrics const& current, + std::function metric_getter) { MetricRates rates; rates.rate_1m = calculateRate( @@ -295,7 +295,7 @@ private: public: void - addSample(const SystemMetrics& metrics) + addSample(SystemMetrics const& metrics) { auto now = std::chrono::system_clock::now(); @@ -317,19 +317,19 @@ public: } AllRates - getRates(const SystemMetrics& current) + getRates(SystemMetrics const& current) { AllRates rates; rates.network_in = calculateMetricRates( - current, [](const SystemMetrics& m) { return m.network_bytes_in; }); + current, [](SystemMetrics const& m) { return m.network_bytes_in; }); rates.network_out = calculateMetricRates( current, - [](const SystemMetrics& m) { return m.network_bytes_out; }); + [](SystemMetrics const& m) { return m.network_bytes_out; }); rates.disk_read = calculateMetricRates( - current, [](const SystemMetrics& m) { return m.disk_bytes_read; }); + current, [](SystemMetrics const& m) { return m.disk_bytes_read; }); rates.disk_write = calculateMetricRates( current, - [](const SystemMetrics& m) { return m.disk_bytes_written; }); + [](SystemMetrics const& m) { return m.disk_bytes_written; }); return rates; } }; @@ -501,7 +501,7 @@ private: count = physical_ids.size(); } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(app_.journal("DatagramMonitor").error()) << "Error getting CPU count: " << e.what(); @@ -574,7 +574,7 @@ private: metrics.network_bytes_in = total_bytes_in; metrics.network_bytes_out = total_bytes_out; } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(app_.journal("DatagramMonitor").error()) << "Error collecting network stats: " << e.what(); @@ -635,7 +635,7 @@ private: metrics.disk_bytes_read = total_bytes_read; metrics.disk_bytes_written = total_bytes_written; } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(app_.journal("DatagramMonitor").error()) << "Error collecting disk stats: " << e.what(); @@ -671,7 +671,7 @@ private: metrics.network_bytes_out = total_bytes_out; } } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(app_.journal("DatagramMonitor").error()) << "Error collecting network stats: " << e.what(); @@ -983,7 +983,7 @@ private: } std::this_thread::sleep_for(std::chrono::seconds(1)); } - catch (const std::exception& e) + catch (std::exception const& e) { // Log error but continue monitoring JLOG(app_.journal("DatagramMonitor").error()) diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index f9d5fbc58..85b5791d6 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -130,7 +130,7 @@ FeeVoteImpl::doValidation( auto vote = [&v, this]( auto const current, XRPAmount target, - const char* name, + char const* name, auto const& sfield) { if (current != target) { @@ -164,7 +164,7 @@ FeeVoteImpl::doValidation( auto const current, XRPAmount target, auto const& convertCallback, - const char* name, + char const* name, auto const& sfield) { if (current != target) { diff --git a/src/xrpld/app/misc/HashRouter.cpp b/src/xrpld/app/misc/HashRouter.cpp index ac522487f..dc87b2bce 100644 --- a/src/xrpld/app/misc/HashRouter.cpp +++ b/src/xrpld/app/misc/HashRouter.cpp @@ -55,7 +55,7 @@ HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer) } std::pair> -HashRouter::addSuppressionPeerWithStatus(const uint256& key, PeerShortID peer) +HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer) { std::lock_guard lock(mutex_); diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 0015b0869..cb4a8235e 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -304,7 +304,7 @@ public: std::shared_ptr& lpLedger, Book const&, AccountID const& uTakerID, - const bool bProof, + bool const bProof, unsigned int iLimit, Json::Value const& jvMarker, Json::Value& jvResult) override; @@ -328,7 +328,7 @@ private: void switchLastClosedLedger(std::shared_ptr const& newLCL); bool - checkLastClosedLedger(const Overlay::PeerSequence&, uint256& networkClosed); + checkLastClosedLedger(Overlay::PeerSequence const&, uint256& networkClosed); public: bool @@ -882,7 +882,7 @@ NetworkOPsImp::setStateTimer() void NetworkOPsImp::setTimer( boost::asio::steady_timer& timer, - const std::chrono::milliseconds& expiry_time, + std::chrono::milliseconds const& expiry_time, std::function onExpire, std::function onError) { @@ -1025,7 +1025,7 @@ NetworkOPsImp::processHeartbeatTimer() mConsensus.timerEntry(app_.timeKeeper().closeTime(), clog.ss()); CLOG(clog.ss()) << "consensus phase " << to_string(mLastConsensusPhase); - const ConsensusPhase currPhase = mConsensus.phase(); + ConsensusPhase const currPhase = mConsensus.phase(); if (mLastConsensusPhase != currPhase) { reportConsensusStateChange(currPhase); @@ -1833,7 +1833,7 @@ NetworkOPsImp::clearUNLBlocked() bool NetworkOPsImp::checkLastClosedLedger( - const Overlay::PeerSequence& peerList, + Overlay::PeerSequence const& peerList, uint256& networkClosed) { // Returns true if there's an *abnormal* ledger issue, normal changing in @@ -2055,7 +2055,7 @@ NetworkOPsImp::beginConsensus( changes.added, clog); - const ConsensusPhase currPhase = mConsensus.phase(); + ConsensusPhase const currPhase = mConsensus.phase(); if (mLastConsensusPhase != currPhase) { reportConsensusStateChange(currPhase); @@ -3332,7 +3332,7 @@ NetworkOPsImp::transJson( void NetworkOPsImp::pubValidatedTransaction( std::shared_ptr const& ledger, - const AcceptedLedgerTx& transaction, + AcceptedLedgerTx const& transaction, bool last) { auto const& stTxn = transaction.getTxn(); @@ -3477,8 +3477,8 @@ NetworkOPsImp::pubAccountTransaction( } JLOG(m_journal.trace()) - << "pubAccountTransaction: " << "proposed=" << iProposed - << ", accepted=" << iAccepted; + << "pubAccountTransaction: " + << "proposed=" << iProposed << ", accepted=" << iAccepted; if (!notify.empty() || !accountHistoryNotify.empty()) { @@ -3683,7 +3683,7 @@ void NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) { enum DatabaseType { Sqlite, None }; - static const auto databaseType = [&]() -> DatabaseType { + static auto const databaseType = [&]() -> DatabaseType { // Use a dynamic_cast to return DatabaseType::None // on failure. if (dynamic_cast(&app_.getRelationalDatabase())) @@ -3739,7 +3739,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) if (node.isFieldPresent(sfNewFields)) { - if (auto inner = dynamic_cast( + if (auto inner = dynamic_cast( node.peekAtPField(sfNewFields)); inner) { @@ -4075,7 +4075,7 @@ NetworkOPsImp::unsubAccountHistory( void NetworkOPsImp::unsubAccountHistoryInternal( std::uint64_t seq, - const AccountID& account, + AccountID const& account, bool historyOnly) { std::lock_guard sl(mSubLock); @@ -4418,8 +4418,8 @@ NetworkOPsImp::getBookPage( (jvResult[jss::offers] = Json::Value(Json::arrayValue)); std::unordered_map umBalance; - const uint256 uBookBase = getBookBase(book); - const uint256 uBookEnd = getQualityNext(uBookBase); + uint256 const uBookBase = getBookBase(book); + uint256 const uBookEnd = getQualityNext(uBookBase); uint256 uTipIndex = uBookBase; if (auto stream = m_journal.trace()) @@ -4630,7 +4630,7 @@ NetworkOPsImp::getBookPage( auto const rate = transferRate(lesActive, book.out.account); - const bool bGlobalFreeze = lesActive.isGlobalFrozen(book.out.account) || + bool const bGlobalFreeze = lesActive.isGlobalFrozen(book.out.account) || lesActive.isGlobalFrozen(book.in.account); while (iLimit-- > 0 && obIterator.nextOffer()) diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index 817e68817..005ff1699 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -64,7 +64,7 @@ class Transaction : public std::enable_shared_from_this, { public: using pointer = std::shared_ptr; - using ref = const pointer&; + using ref = pointer const&; Transaction( std::shared_ptr const&, diff --git a/src/xrpld/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h index 73b16a9e2..d48e123b3 100644 --- a/src/xrpld/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -663,7 +663,7 @@ private: * */ bool - operator()(const MaybeTx& lhs, const MaybeTx& rhs) const + operator()(MaybeTx const& lhs, MaybeTx const& rhs) const { if (lhs.feeLevel == rhs.feeLevel) return (lhs.txID ^ MaybeTx::parentHashComp) < @@ -703,7 +703,7 @@ private: /// Construct from a transaction explicit TxQAccount(std::shared_ptr const& txn); /// Construct from an account - explicit TxQAccount(const AccountID& account); + explicit TxQAccount(AccountID const& account); /// Return the number of transactions currently queued for this account std::size_t diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index 4e18aa5db..4cb32282d 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -271,7 +271,7 @@ class ValidatorList // collection with more than 5 entries will be considered malformed. static constexpr std::size_t maxSupportedBlobs = 5; // Prefix of the file name used to store cache files. - static const std::string filePrefix_; + static std::string const filePrefix_; public: ValidatorList( diff --git a/src/xrpld/app/misc/ValidatorSite.h b/src/xrpld/app/misc/ValidatorSite.h index 88e30e28a..58f9eaaef 100644 --- a/src/xrpld/app/misc/ValidatorSite.h +++ b/src/xrpld/app/misc/ValidatorSite.h @@ -86,7 +86,7 @@ private: struct Resource { explicit Resource(std::string uri_); - const std::string uri; + std::string const uri; parsedURL pUrl; }; @@ -136,7 +136,7 @@ private: std::vector sites_; // time to allow for requests to complete - const std::chrono::seconds requestTimeout_; + std::chrono::seconds const requestTimeout_; public: ValidatorSite( diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp index d3d7aa5ba..86ee6d664 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -74,7 +74,7 @@ ammHolds( auto const singleIssue = [&issue1, &issue2, &j]( Issue checkIssue, - const char* label) -> std::optional> { + char const* label) -> std::optional> { if (checkIssue == issue1) return std::make_optional(std::make_pair(issue1, issue2)); else if (checkIssue == issue2) @@ -150,8 +150,8 @@ ammLPHolds( } amount.setIssuer(ammAccount); - JLOG(j.trace()) << "ammLPHolds:" << " lpAccount=" - << to_string(lpAccount) + JLOG(j.trace()) << "ammLPHolds:" + << " lpAccount=" << to_string(lpAccount) << " amount=" << amount.getFullText(); } diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index ae41a2aa7..b13e40c3a 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -998,8 +998,8 @@ AmendmentTableImpl::trustChanged(hash_set const& allTrusted) void AmendmentTableImpl::injectJson( Json::Value& v, - const uint256& id, - const AmendmentState& fs, + uint256 const& id, + AmendmentState const& fs, bool isAdmin, std::lock_guard const&) const { diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index a899575af..24445faa6 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -95,7 +95,7 @@ increase(FeeLevel64 level, std::uint32_t increasePercent) void TxQ::debugTxInject(STTx const& txn) { - const std::lock_guard _(debugTxInjectMutex); + std::lock_guard const _(debugTxInjectMutex); debugTxInjectQueue.push_back(txn); } @@ -343,7 +343,7 @@ TxQ::TxQAccount::TxQAccount(std::shared_ptr const& txn) { } -TxQ::TxQAccount::TxQAccount(const AccountID& account_) : account(account_) +TxQ::TxQAccount::TxQAccount(AccountID const& account_) : account(account_) { } @@ -1769,11 +1769,11 @@ TxQ::accept(Application& app, OpenView& view) } else { - JLOG(j_.debug()) - << "Queued transaction " << candidateIter->txID - << " failed with " << transToken(txnResult) - << ". Leave in queue." << " Applied: " << didApply - << ". Flags: " << candidateIter->flags; + JLOG(j_.debug()) << "Queued transaction " << candidateIter->txID + << " failed with " << transToken(txnResult) + << ". Leave in queue." + << " Applied: " << didApply + << ". Flags: " << candidateIter->flags; if (account.retryPenalty && candidateIter->retriesRemaining > 2) candidateIter->retriesRemaining = 1; else @@ -1951,7 +1951,7 @@ TxQ::tryDirectApply( auto const account = (*tx)[sfAccount]; auto const sleAccount = view.read(keylet::account(account)); - const bool isFirstImport = !sleAccount && + bool const isFirstImport = !sleAccount && view.rules().enabled(featureImport) && tx->getTxnType() == ttIMPORT; // Don't attempt to direct apply if the account is not in the ledger. diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index 282c3c9e1..1ddb51c9d 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -115,7 +115,7 @@ ValidatorList::MessageWithHash::MessageWithHash( { } -const std::string ValidatorList::filePrefix_ = "cache."; +std::string const ValidatorList::filePrefix_ = "cache."; ValidatorList::ValidatorList( ManifestCache& validatorManifests, diff --git a/src/xrpld/app/paths/AMMLiquidity.h b/src/xrpld/app/paths/AMMLiquidity.h index ee2c6e34a..1165565db 100644 --- a/src/xrpld/app/paths/AMMLiquidity.h +++ b/src/xrpld/app/paths/AMMLiquidity.h @@ -52,7 +52,7 @@ template class AMMLiquidity { private: - inline static const Number InitialFibSeqPct = Number(5) / 20000; + inline static Number const InitialFibSeqPct = Number(5) / 20000; AMMContext& ammContext_; AccountID const ammAccountID_; std::uint32_t const tradingFee_; diff --git a/src/xrpld/app/paths/Flow.cpp b/src/xrpld/app/paths/Flow.cpp index d4de1e799..1ff69698e 100644 --- a/src/xrpld/app/paths/Flow.cpp +++ b/src/xrpld/app/paths/Flow.cpp @@ -124,8 +124,8 @@ flow( } } - const bool srcIsXRP = isXRP(srcIssue.currency); - const bool dstIsXRP = isXRP(dstIssue.currency); + bool const srcIsXRP = isXRP(srcIssue.currency); + bool const dstIsXRP = isXRP(dstIssue.currency); auto const asDeliver = toAmountSpec(deliver); diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index 0450ed2d3..457113ecf 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -41,7 +41,7 @@ namespace ripple { PathRequest::PathRequest( Application& app, - const std::shared_ptr& subscriber, + std::shared_ptr const& subscriber, int id, PathRequests& owner, beast::Journal journal) diff --git a/src/xrpld/app/paths/PathRequest.h b/src/xrpld/app/paths/PathRequest.h index a334f4c9f..079b3a777 100644 --- a/src/xrpld/app/paths/PathRequest.h +++ b/src/xrpld/app/paths/PathRequest.h @@ -52,8 +52,8 @@ class PathRequest final : public InfoSubRequest, public: using wptr = std::weak_ptr; using pointer = std::shared_ptr; - using ref = const pointer&; - using wref = const wptr&; + using ref = pointer const&; + using wref = wptr const&; public: // path_find semantics diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index de1780550..3f845daca 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -77,7 +77,7 @@ struct AccountCandidate int priority; AccountID account; - static const int highPriority = 10000; + static int const highPriority = 10000; }; bool @@ -236,7 +236,8 @@ Pathfinder::findPaths( mSource = STPathElement(account, mSrcCurrency, issuer); auto issuerString = mSrcIssuer ? to_string(*mSrcIssuer) : std::string("none"); - JLOG(j_.trace()) << "findPaths>" << " mSrcAccount=" << mSrcAccount + JLOG(j_.trace()) << "findPaths>" + << " mSrcAccount=" << mSrcAccount << " mDstAccount=" << mDstAccount << " mDstAmount=" << mDstAmount.getFullText() << " mSrcCurrency=" << mSrcCurrency @@ -582,7 +583,7 @@ Pathfinder::getBestPaths( XRPL_ASSERT( fullLiquidityPath.empty(), "ripple::Pathfinder::getBestPaths : first empty path result"); - const bool issuerIsSender = + bool const issuerIsSender = isXRP(mSrcCurrency) || (srcIssuer == mSrcAccount); std::vector extraPathRanks; @@ -943,7 +944,7 @@ addUniquePath(STPathSet& pathSet, STPath const& path) void Pathfinder::addLink( - const STPath& currentPath, // The path to build from + STPath const& currentPath, // The path to build from STPathSet& incompletePaths, // The set of partial paths we add to int addFlags, std::function const& continueCallback) diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index d83c00b3d..485c948b2 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -190,7 +190,8 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " << "\ninIss: " << book_.in.account + ostr << name << ": " + << "\ninIss: " << book_.in.account << "\noutIss: " << book_.out.account << "\ninCur: " << book_.in.currency << "\noutCur: " << book_.out.currency; diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 644b29e3e..9cd585058 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -205,7 +205,8 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " << "\nSrc: " << src_ << "\nDst: " << dst_; + ostr << name << ": " + << "\nSrc: " << src_ << "\nDst: " << dst_; return ostr.str(); } diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 04b4fe798..f1dedce6d 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -132,7 +132,8 @@ protected: logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " << "\nAcc: " << acc_; + ostr << name << ": " + << "\nAcc: " << acc_; return ostr.str(); } diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index 927b08d38..25b16f04a 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -238,8 +238,8 @@ rangeCheckedCast(C c) /* This should never happen */ UNREACHABLE("ripple::rangeCheckedCast : domain error"); JLOG(debugLog().error()) - << "rangeCheckedCast domain error:" << " value = " << c - << " min = " << std::numeric_limits::lowest() + << "rangeCheckedCast domain error:" + << " value = " << c << " min = " << std::numeric_limits::lowest() << " max: " << std::numeric_limits::max(); } diff --git a/src/xrpld/app/rdb/backend/RWDBDatabase.h b/src/xrpld/app/rdb/backend/RWDBDatabase.h index 75ac7e14a..5ad3dfdd2 100644 --- a/src/xrpld/app/rdb/backend/RWDBDatabase.h +++ b/src/xrpld/app/rdb/backend/RWDBDatabase.h @@ -67,7 +67,7 @@ public: return {}; std::shared_lock lock(mutex_); - for (const auto& [ledgerSeq, ledgerData] : ledgers_) + for (auto const& [ledgerSeq, ledgerData] : ledgers_) { if (!ledgerData.transactions.empty()) return ledgerSeq; @@ -85,7 +85,7 @@ public: if (accountTxMap_.empty()) return std::nullopt; LedgerIndex minSeq = std::numeric_limits::max(); - for (const auto& [_, accountData] : accountTxMap_) + for (auto const& [_, accountData] : accountTxMap_) { if (!accountData.ledgerTxMap.empty()) minSeq = @@ -114,7 +114,7 @@ public: auto it = ledgers_.find(ledgerSeq); if (it != ledgers_.end()) { - for (const auto& [txHash, _] : it->second.transactions) + for (auto const& [txHash, _] : it->second.transactions) { transactionMap_.erase(txHash); } @@ -144,7 +144,7 @@ public: auto it = ledgers_.begin(); while (it != ledgers_.end() && it->first < ledgerSeq) { - for (const auto& [txHash, _] : it->second.transactions) + for (auto const& [txHash, _] : it->second.transactions) { transactionMap_.erase(txHash); } @@ -188,9 +188,9 @@ public: std::shared_lock lock(mutex_); std::size_t count = 0; - for (const auto& [_, accountData] : accountTxMap_) + for (auto const& [_, accountData] : accountTxMap_) { - for (const auto& [_, txVector] : accountData.ledgerTxMap) + for (auto const& [_, txVector] : accountData.ledgerTxMap) { count += txVector.size(); } @@ -414,7 +414,7 @@ public: auto it = transactionMap_.find(id); if (it != transactionMap_.end()) { - const auto& [txn, txMeta] = it->second; + auto const& [txn, txMeta] = it->second; std::uint32_t inLedger = rangeCheckedCast(txMeta->getLgrSeq()); it->second.first->setStatus(COMMITTED); @@ -470,7 +470,7 @@ private: // Add the transaction map nodes inside each ledger (ledger's view of // its transactions) - for (const auto& [_, ledgerData] : ledgers_) + for (auto const& [_, ledgerData] : ledgers_) { size += ledgerData.transactions.size() * (sizeof(uint256) + sizeof(AccountTx) + MAP_NODE_OVERHEAD); @@ -497,7 +497,7 @@ private: (sizeof(uint256) + sizeof(AccountTx) + MAP_NODE_OVERHEAD); // Add actual transaction and metadata data sizes - for (const auto& [_, accountTx] : transactionMap_) + for (auto const& [_, accountTx] : transactionMap_) { if (accountTx.first) size += accountTx.first->getSTransaction() @@ -514,11 +514,11 @@ private: // Count structural overhead of account transaction index // The actual transaction data is already counted above from // transactionMap_ - for (const auto& [accountId, accountData] : accountTxMap_) + for (auto const& [accountId, accountData] : accountTxMap_) { size += sizeof(accountId) + sizeof(AccountTxData) + MAP_NODE_OVERHEAD; - for (const auto& [ledgerSeq, txVector] : accountData.ledgerTxMap) + for (auto const& [ledgerSeq, txVector] : accountData.ledgerTxMap) { // Use capacity() to account for actual allocated memory size += sizeof(ledgerSeq) + MAP_NODE_OVERHEAD; @@ -710,8 +710,8 @@ public: for (auto it = ledgers_.rbegin(); it != ledgers_.rend(); ++it) { - const auto& transactions = it->second.transactions; - for (const auto& [txHash, accountTx] : transactions) + auto const& transactions = it->second.transactions; + for (auto const& [txHash, accountTx] : transactions) { if (skipped < startIndex) { @@ -761,7 +761,7 @@ public: return {}; AccountTxs result; - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound(options.minLedger); auto txEnd = accountData.ledgerTxMap.upper_bound(options.maxLedger); @@ -770,7 +770,7 @@ public: (options.bUnlimited || result.size() < options.limit); ++txIt) { - for (const auto& accountTx : txIt->second) + for (auto const& accountTx : txIt->second) { if (skipped < options.offset) { @@ -802,7 +802,7 @@ public: return {}; AccountTxs result; - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound(options.minLedger); auto txEnd = accountData.ledgerTxMap.upper_bound(options.maxLedger); @@ -846,7 +846,7 @@ public: return {}; MetaTxsList result; - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound(options.minLedger); auto txEnd = accountData.ledgerTxMap.upper_bound(options.maxLedger); @@ -855,14 +855,14 @@ public: (options.bUnlimited || result.size() < options.limit); ++txIt) { - for (const auto& accountTx : txIt->second) + for (auto const& accountTx : txIt->second) { if (skipped < options.offset) { ++skipped; continue; } - const auto& [txn, txMeta] = accountTx; + auto const& [txn, txMeta] = accountTx; result.emplace_back( txn->getSTransaction()->getSerializer().peekData(), txMeta->getAsObject().getSerializer().peekData(), @@ -887,7 +887,7 @@ public: return {}; MetaTxsList result; - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound(options.minLedger); auto txEnd = accountData.ledgerTxMap.upper_bound(options.maxLedger); @@ -906,7 +906,7 @@ public: ++skipped; continue; } - const auto& [txn, txMeta] = *innerRIt; + auto const& [txn, txMeta] = *innerRIt; result.emplace_back( txn->getSTransaction()->getSerializer().peekData(), txMeta->getAsObject().getSerializer().peekData(), @@ -971,7 +971,7 @@ public: if (forward) { // Oldest (forward = true) - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound( findLedger == 0 ? options.minLedger : findLedger); auto txEnd = accountData.ledgerTxMap.upper_bound(options.maxLedger); @@ -979,7 +979,7 @@ public: { std::uint32_t const ledgerSeq = txIt->first; std::uint32_t txnSeq = 0; - for (const auto& accountTx : txIt->second) + for (auto const& accountTx : txIt->second) { if (lookingForMarker) { @@ -1024,7 +1024,7 @@ public: else { // Newest (forward = false) - const auto& accountData = it->second; + auto const& accountData = it->second; auto txIt = accountData.ledgerTxMap.lower_bound(options.minLedger); auto txEnd = accountData.ledgerTxMap.upper_bound( findLedger == 0 ? options.maxLedger : findLedger); @@ -1057,7 +1057,7 @@ public: return {newmarker, total}; } - const auto& accountTx = *innerRIt; + auto const& accountTx = *innerRIt; Blob rawTxn = accountTx.first->getSTransaction() ->getSerializer() .peekData(); diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 8598c4e87..83686289d 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -1106,7 +1106,7 @@ accountTxPage( // SQL's BETWEEN uses a closed interval ([a,b]) - const char* const order = forward ? "ASC" : "DESC"; + char const* const order = forward ? "ASC" : "DESC"; if (findLedger == 0) { @@ -1121,10 +1121,10 @@ accountTxPage( } else { - const char* const compare = forward ? ">=" : "<="; - const std::uint32_t minLedger = + char const* const compare = forward ? ">=" : "<="; + std::uint32_t const minLedger = forward ? findLedger + 1 : options.minLedger; - const std::uint32_t maxLedger = + std::uint32_t const maxLedger = forward ? options.maxLedger : findLedger - 1; auto b58acct = toBase58(options.account); diff --git a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp index acdaeec10..433664d68 100644 --- a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp +++ b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp @@ -36,7 +36,7 @@ RelationalDatabase::init( bool use_sqlite = false; bool use_rwdb = false; - const Section& rdb_section{config.section(SECTION_RELATIONAL_DB)}; + Section const& rdb_section{config.section(SECTION_RELATIONAL_DB)}; if (!rdb_section.empty()) { if (!rdb_section.empty()) diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/xrpld/app/tx/detail/CancelOffer.cpp index 50f772e53..a9bdeabd5 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/xrpld/app/tx/detail/CancelOffer.cpp @@ -35,8 +35,8 @@ CancelOffer::preflight(PreflightContext const& ctx) if (uTxFlags & tfUniversalMask) { - JLOG(ctx.j.trace()) - << "Malformed transaction: " << "Invalid flags set."; + JLOG(ctx.j.trace()) << "Malformed transaction: " + << "Invalid flags set."; return temINVALID_FLAG; } diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index 0753d6d9f..294223798 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -926,8 +926,8 @@ Change::applyAmendment() auto flags = ctx_.tx.getFlags(); - const bool gotMajority = (flags & tfGotMajority) != 0; - const bool lostMajority = (flags & tfLostMajority) != 0; + bool const gotMajority = (flags & tfGotMajority) != 0; + bool const lostMajority = (flags & tfLostMajority) != 0; if (gotMajority && lostMajority) return temINVALID_FLAG; @@ -937,7 +937,7 @@ Change::applyAmendment() bool found = false; if (amendmentObject->isFieldPresent(sfMajorities)) { - const STArray& oldMajorities = + STArray const& oldMajorities = amendmentObject->getFieldArray(sfMajorities); for (auto const& majority : oldMajorities) { diff --git a/src/xrpld/app/tx/detail/Import.cpp b/src/xrpld/app/tx/detail/Import.cpp index 61390fa9c..54daa43db 100644 --- a/src/xrpld/app/tx/detail/Import.cpp +++ b/src/xrpld/app/tx/detail/Import.cpp @@ -337,7 +337,7 @@ Import::preflight(PreflightContext const& ctx) // check inner txns signature // we do this with a custom ruleset which should be kept up to date with // network 0's signing rules - const std::unordered_set> rulesFeatures{ + std::unordered_set> const rulesFeatures{ featureExpandedSignerList}; if (!stpTrans->checkSign( STTx::RequireFullyCanonicalSig::yes, Rules(rulesFeatures))) @@ -534,7 +534,7 @@ Import::preflight(PreflightContext const& ctx) auto hashProof = [](Json::Value const& proof, int depth = 0, auto const& hashProof = nullptr) -> uint256 { - const uint256 nullhash; + uint256 const nullhash; if (depth > 32) return nullhash; @@ -548,7 +548,7 @@ Import::preflight(PreflightContext const& ctx) if (proof.isArray()) { - for (const auto& entry : proof) + for (auto const& entry : proof) { if (entry.isString()) { @@ -717,7 +717,7 @@ Import::preflight(PreflightContext const& ctx) { auto const& data = (*xpop)[jss::validation][jss::data]; std::set used_key; - for (const auto& key : data.getMemberNames()) + for (auto const& key : data.getMemberNames()) { auto nodepub = key; auto const datakey = nodepub; @@ -921,9 +921,9 @@ Import::preclaim(PreclaimContext const& ctx) if (sle->isFieldPresent(sfRegularKey)) { AccountID rk = sle->getAccountID(sfRegularKey); - static const AccountID ACCOUNT_ZERO(0); - static const AccountID ACCOUNT_ONE(1); - static const AccountID ACCOUNT_TWO(2); + static AccountID const ACCOUNT_ZERO(0); + static AccountID const ACCOUNT_ONE(1); + static AccountID const ACCOUNT_TWO(2); if (rk != ACCOUNT_ZERO && rk != ACCOUNT_ONE && rk != ACCOUNT_TWO) diff --git a/src/xrpld/app/tx/detail/SetHook.cpp b/src/xrpld/app/tx/detail/SetHook.cpp index 232ea9f9f..d9a59a02c 100644 --- a/src/xrpld/app/tx/detail/SetHook.cpp +++ b/src/xrpld/app/tx/detail/SetHook.cpp @@ -117,8 +117,8 @@ validateHookGrants(SetHookCtx& ctx, STArray const& hookGrants) bool validateHookParams(SetHookCtx& ctx, STArray const& hookParams) { - const int paramKeyMax = hook::maxHookParameterKeySize(); - const int paramValueMax = hook::maxHookParameterValueSize(); + int const paramKeyMax = hook::maxHookParameterKeySize(); + int const paramValueMax = hook::maxHookParameterValueSize(); int paramCount = (int)(hookParams.size()); if (paramCount > 16) @@ -852,7 +852,7 @@ TER SetHook::destroyNamespace( SetHookCtx& ctx, ApplyView& view, - const AccountID& account, + AccountID const& account, uint256 ns) { JLOG(ctx.j.trace()) << "HookSet(" << hook::log::NSDELETE << ")[" << HS_ACC() @@ -1079,8 +1079,8 @@ updateHookParameters( ripple::STArray const& oldParameters, ripple::STObject& newHook) { - const int paramKeyMax = hook::maxHookParameterKeySize(); - const int paramValueMax = hook::maxHookParameterValueSize(); + int const paramKeyMax = hook::maxHookParameterKeySize(); + int const paramValueMax = hook::maxHookParameterValueSize(); std::map> parameters; @@ -1194,7 +1194,7 @@ updateHookParameters( STArray newParameters{ sfHookParameters, static_cast(parameterCount)}; - for (const auto& [parameterName, parameterValue] : parameters) + for (auto const& [parameterName, parameterValue] : parameters) { if (!parameterValue) { @@ -1251,7 +1251,7 @@ SetHook::computeHookReserve(STObject const& hookObj) struct KeyletComparator { bool - operator()(const Keylet& lhs, const Keylet& rhs) const + operator()(Keylet const& lhs, Keylet const& rhs) const { return lhs.type < rhs.type || (lhs.type == rhs.type && lhs.key < rhs.key); @@ -1277,7 +1277,7 @@ SetHook::setHook() .app = ctx_.app, .rules = ctx_.view().rules()}; - const int blobMax = hook::maxHookWasmSize(); + int const blobMax = hook::maxHookWasmSize(); auto const accountKeylet = keylet::account(account_); auto const hookKeylet = keylet::hook(account_); diff --git a/src/xrpld/app/tx/detail/SetHook.h b/src/xrpld/app/tx/detail/SetHook.h index 4adb9b4b0..1e8a0497c 100644 --- a/src/xrpld/app/tx/detail/SetHook.h +++ b/src/xrpld/app/tx/detail/SetHook.h @@ -104,7 +104,7 @@ private: destroyNamespace( SetHookCtx& ctx, ApplyView& view, - const AccountID& account, + AccountID const& account, uint256 ns); TER diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 94112d06e..3bae14844 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -539,9 +539,9 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) if (balance < feePaid) { - JLOG(ctx.j.trace()) - << "Insufficient balance:" << " balance=" << to_string(balance) - << " paid=" << to_string(feePaid); + JLOG(ctx.j.trace()) << "Insufficient balance:" + << " balance=" << to_string(balance) + << " paid=" << to_string(feePaid); if ((balance > beast::zero) && !ctx.view.open()) { diff --git a/src/xrpld/conditions/detail/error.cpp b/src/xrpld/conditions/detail/error.cpp index 10a3a4392..1ba1a4818 100644 --- a/src/xrpld/conditions/detail/error.cpp +++ b/src/xrpld/conditions/detail/error.cpp @@ -32,7 +32,7 @@ class cryptoconditions_error_category : public std::error_category public: explicit cryptoconditions_error_category() = default; - const char* + char const* name() const noexcept override { return "cryptoconditions"; diff --git a/src/xrpld/conditions/detail/utils.h b/src/xrpld/conditions/detail/utils.h index 28943bd64..93e444a17 100644 --- a/src/xrpld/conditions/detail/utils.h +++ b/src/xrpld/conditions/detail/utils.h @@ -188,9 +188,9 @@ parseInteger(Slice& s, std::size_t count, std::error_code& ec) return v; } - const bool isSigned = std::numeric_limits::is_signed; + bool const isSigned = std::numeric_limits::is_signed; // unsigned types may have a leading zero octet - const size_t maxLength = isSigned ? sizeof(Integer) : sizeof(Integer) + 1; + size_t const maxLength = isSigned ? sizeof(Integer) : sizeof(Integer) + 1; if (count > maxLength) { ec = error::large_size; diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index c8eef4e08..d530e08ac 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -603,7 +603,7 @@ private: Ledger_t previousLedger_; // Transaction Sets, indexed by hash of transaction tree - hash_map acquired_; + hash_map acquired_; std::optional result_; ConsensusCloseTimes rawCloseTimes_; @@ -872,7 +872,7 @@ Consensus::timerEntry( CLOG(clog) << "Set network adjusted time to " << to_string(now) << ". "; // Check we are on the proper ledger (this may change phase_) - const auto phaseOrig = phase_; + auto const phaseOrig = phase_; CLOG(clog) << "Phase " << to_string(phaseOrig) << ". "; checkLedger(clog); if (phaseOrig != phase_) @@ -1121,8 +1121,8 @@ Consensus::checkLedger(std::unique_ptr const& clog) auto netLgr = adaptor_.getPrevLedger(prevLedgerID_, previousLedger_, mode_.get()); - CLOG(clog) << "network ledgerid " << netLgr << ", " << "previous ledger " - << prevLedgerID_ << ". "; + CLOG(clog) << "network ledgerid " << netLgr << ", " + << "previous ledger " << prevLedgerID_ << ". "; if (netLgr != prevLedgerID_) { @@ -1213,7 +1213,8 @@ Consensus::phaseOpen(std::unique_ptr const& clog) adaptor_.parms().ledgerIDLE_INTERVAL, 2 * previousLedger_.closeTimeResolution()); CLOG(clog) << "idle interval set to " << idleInterval.count() - << "ms based on " << "ledgerIDLE_INTERVAL: " + << "ms based on " + << "ledgerIDLE_INTERVAL: " << adaptor_.parms().ledgerIDLE_INTERVAL.count() << ", previous ledger close time resolution: " << previousLedger_.closeTimeResolution().count() << "ms. "; @@ -1261,7 +1262,8 @@ Consensus::shouldPause( << "roundTime: " << result_->roundTime.read().count() << ", " << "max consensus time: " << parms.ledgerMAX_CONSENSUS.count() << ", " << "validators: " << totalValidators << ", " - << "laggards: " << laggards << ", " << "offline: " << offline << ", " + << "laggards: " << laggards << ", " + << "offline: " << offline << ", " << "quorum: " << quorum << ")"; if (!ahead || !laggards || !totalValidators || !adaptor_.validator() || @@ -1447,7 +1449,7 @@ Consensus::closeLedger(std::unique_ptr const& clog) if (acquired_.emplace(result_->txns.id(), result_->txns).second) adaptor_.share(result_->txns); - const auto mode = mode_.get(); + auto const mode = mode_.get(); CLOG(clog) << "closeLedger transitioned to ConsensusPhase::establish, mode: " << to_string(mode) @@ -1622,8 +1624,8 @@ Consensus::updateOurPositions( if (!haveCloseTimeConsensus_) { JLOG(j_.debug()) - << "No CT consensus:" << " Proposers:" - << currPeerPositions_.size() + << "No CT consensus:" + << " Proposers:" << currPeerPositions_.size() << " Mode:" << to_string(mode_.get()) << " Thresh:" << threshConsensus << " Pos:" << consensusCloseTime.time_since_epoch().count(); diff --git a/src/xrpld/consensus/DisputedTx.h b/src/xrpld/consensus/DisputedTx.h index 513f24082..4ed31b77c 100644 --- a/src/xrpld/consensus/DisputedTx.h +++ b/src/xrpld/consensus/DisputedTx.h @@ -149,8 +149,7 @@ public: @return bool Whether the peer changed its vote. (A new vote counts as a change.) */ - [[nodiscard]] - bool + [[nodiscard]] bool setVote(NodeID_t const& peer, bool votesYes); /** Remove a peer's vote diff --git a/src/xrpld/core/Job.h b/src/xrpld/core/Job.h index 66048f4f2..11b0b9b72 100644 --- a/src/xrpld/core/Job.h +++ b/src/xrpld/core/Job.h @@ -132,13 +132,13 @@ public: // These comparison operators make the jobs sort in priority order // in the job set bool - operator<(const Job& j) const; + operator<(Job const& j) const; bool - operator>(const Job& j) const; + operator>(Job const& j) const; bool - operator<=(const Job& j) const; + operator<=(Job const& j) const; bool - operator>=(const Job& j) const; + operator>=(Job const& j) const; private: JobType mType; diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index 44a2d5ce7..b1cc86b4f 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -151,7 +151,7 @@ static_assert( #define SECTION_DEFAULT_NAME "" IniFileSections -parseIniFile(std::string const& strInput, const bool bTrim) +parseIniFile(std::string const& strInput, bool const bTrim) { std::string strData(strInput); std::vector vLines; @@ -485,7 +485,7 @@ Config::loadFromString(std::string const& fileContents) // if the user has specified ip:port then replace : with a space. auto replaceColons = [](std::vector& strVec) { - const static std::regex e(":([0-9]+)$"); + static std::regex const e(":([0-9]+)$"); for (auto& line : strVec) { // skip anything that might be an ipv6 address diff --git a/src/xrpld/core/detail/Job.cpp b/src/xrpld/core/detail/Job.cpp index d62f49ff4..8e9a74b53 100644 --- a/src/xrpld/core/detail/Job.cpp +++ b/src/xrpld/core/detail/Job.cpp @@ -73,7 +73,7 @@ Job::doJob() } bool -Job::operator>(const Job& j) const +Job::operator>(Job const& j) const { if (mType < j.mType) return true; @@ -85,7 +85,7 @@ Job::operator>(const Job& j) const } bool -Job::operator>=(const Job& j) const +Job::operator>=(Job const& j) const { if (mType < j.mType) return true; @@ -97,7 +97,7 @@ Job::operator>=(const Job& j) const } bool -Job::operator<(const Job& j) const +Job::operator<(Job const& j) const { if (mType < j.mType) return false; @@ -109,7 +109,7 @@ Job::operator<(const Job& j) const } bool -Job::operator<=(const Job& j) const +Job::operator<=(Job const& j) const { if (mType < j.mType) return false; diff --git a/src/xrpld/core/detail/SociDB.cpp b/src/xrpld/core/detail/SociDB.cpp index 96b1f9797..5b298dac4 100644 --- a/src/xrpld/core/detail/SociDB.cpp +++ b/src/xrpld/core/detail/SociDB.cpp @@ -311,7 +311,7 @@ protected: sqliteWALHook( void* cpId, sqlite_api::sqlite3* conn, - const char* dbName, + char const* dbName, int walSize) { if (walSize >= checkpointPageCount) diff --git a/src/xrpld/ledger/ReadView.h b/src/xrpld/ledger/ReadView.h index 53e12083f..4c1986be4 100644 --- a/src/xrpld/ledger/ReadView.h +++ b/src/xrpld/ledger/ReadView.h @@ -258,7 +258,7 @@ public: using digest_type = uint256; DigestAwareReadView() = default; - DigestAwareReadView(const DigestAwareReadView&) = default; + DigestAwareReadView(DigestAwareReadView const&) = default; /** Return the digest associated with the key. diff --git a/src/xrpld/ledger/View.h b/src/xrpld/ledger/View.h index 2ce609c48..d330ab30e 100644 --- a/src/xrpld/ledger/View.h +++ b/src/xrpld/ledger/View.h @@ -346,7 +346,7 @@ areCompatible( ReadView const& validLedger, ReadView const& testLedger, beast::Journal::Stream& s, - const char* reason); + char const* reason); [[nodiscard]] bool areCompatible( @@ -354,7 +354,7 @@ areCompatible( LedgerIndex validIndex, ReadView const& testLedger, beast::Journal::Stream& s, - const char* reason); + char const* reason); //------------------------------------------------------------------------------ // @@ -447,14 +447,14 @@ describeOwnerDir(AccountID const& account); [[nodiscard]] TER trustCreate( ApplyView& view, - const bool bSrcHigh, + bool const bSrcHigh, AccountID const& uSrcAccountID, AccountID const& uDstAccountID, uint256 const& uIndex, // --> ripple state entry SLE::ref sleAccount, // --> the account being set. - const bool bAuth, // --> authorize account. - const bool bNoRipple, // --> others cannot ripple through - const bool bFreeze, // --> funds cannot leave + bool const bAuth, // --> authorize account. + bool const bNoRipple, // --> others cannot ripple through + bool const bFreeze, // --> funds cannot leave bool bDeepFreeze, // --> can neither receive nor send funds STAmount const& saBalance, // --> balance of account being set. // Issuer should be noAccount() diff --git a/src/xrpld/ledger/detail/ApplyStateTable.cpp b/src/xrpld/ledger/detail/ApplyStateTable.cpp index ca9bf3af5..fdc8a0c69 100644 --- a/src/xrpld/ledger/detail/ApplyStateTable.cpp +++ b/src/xrpld/ledger/detail/ApplyStateTable.cpp @@ -628,7 +628,7 @@ void ApplyStateTable::threadItem( TxMeta& meta, std::shared_ptr const& sle, - const Rules& rules) + Rules const& rules) { if (rules.enabled(fixProvisionalDoubleThreading)) { diff --git a/src/xrpld/ledger/detail/RawStateTable.h b/src/xrpld/ledger/detail/RawStateTable.h index 2db37d983..37597aa67 100644 --- a/src/xrpld/ledger/detail/RawStateTable.h +++ b/src/xrpld/ledger/detail/RawStateTable.h @@ -126,7 +126,7 @@ private: sleAction, std::less, boost::container::pmr::polymorphic_allocator< - std::pair>>; + std::pair>>; // monotonic_resource_ must outlive `items_`. Make a pointer so it may be // easily moved. std::unique_ptr diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 15e9caa4a..63242b15f 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -391,6 +391,7 @@ accountHolds( { amount.clear(Issue{currency, issuer}); } + JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(account) << " amount=" << amount.getFullText(); @@ -541,7 +542,8 @@ xrpLiquid( STAmount const amount = (balance < reserve) ? STAmount{0} : balance - reserve; - JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(id) + JLOG(j.trace()) << "accountHolds:" + << " account=" << to_string(id) << " amount=" << amount.getFullText() << " fullBalance=" << fullBalance.getFullText() << " balance=" << balance.getFullText() @@ -686,7 +688,7 @@ areCompatible( ReadView const& validLedger, ReadView const& testLedger, beast::Journal::Stream& s, - const char* reason) + char const* reason) { bool ret = true; @@ -750,7 +752,7 @@ areCompatible( LedgerIndex validIndex, ReadView const& testLedger, beast::Journal::Stream& s, - const char* reason) + char const* reason) { bool ret = true; @@ -943,15 +945,15 @@ describeOwnerDir(AccountID const& account) TER trustCreate( ApplyView& view, - const bool bSrcHigh, + bool const bSrcHigh, AccountID const& uSrcAccountID, AccountID const& uDstAccountID, uint256 const& uIndex, // --> ripple state entry SLE::ref sleAccount, // --> the account being set. - const bool bAuth, // --> authorize account. - const bool bNoRipple, // --> others cannot ripple through - const bool bFreeze, // --> funds cannot leave - const bool bDeepFreeze, // --> can neither receive nor send funds + bool const bAuth, // --> authorize account. + bool const bNoRipple, // --> others cannot ripple through + bool const bFreeze, // --> funds cannot leave + bool bDeepFreeze, // --> can neither receive nor send funds STAmount const& saBalance, // --> balance of account being set. // Issuer should be noAccount() STAmount const& saLimit, // --> limit for account being set. @@ -986,8 +988,8 @@ trustCreate( if (!highNode) return tecDIR_FULL; - const bool bSetDst = saLimit.getIssuer() == uDstAccountID; - const bool bSetHigh = bSrcHigh ^ bSetDst; + bool const bSetDst = saLimit.getIssuer() == uDstAccountID; + bool const bSetHigh = bSrcHigh ^ bSetDst; XRPL_ASSERT(sleAccount, "ripple::trustCreate : non-null SLE"); if (!sleAccount) @@ -1123,8 +1125,8 @@ isTrustDefault( uint32_t const acFlags = line->getFieldU32(sfFlags); - const auto fNoRipple{high ? lsfHighNoRipple : lsfLowNoRipple}; - const auto fFreeze{high ? lsfHighFreeze : lsfLowFreeze}; + auto const fNoRipple{high ? lsfHighNoRipple : lsfLowNoRipple}; + auto const fFreeze{high ? lsfHighFreeze : lsfLowFreeze}; if (tlFlags & fFreeze) return false; diff --git a/src/xrpld/net/AutoSocket.h b/src/xrpld/net/AutoSocket.h index 7486d6128..d06787340 100644 --- a/src/xrpld/net/AutoSocket.h +++ b/src/xrpld/net/AutoSocket.h @@ -168,7 +168,7 @@ public: template void - async_read_some(const Seq& buffers, Handler handler) + async_read_some(Seq const& buffers, Handler handler) { if (isSecure()) mSocket->async_read_some(buffers, handler); @@ -178,7 +178,7 @@ public: template void - async_read_until(const Seq& buffers, Condition condition, Handler handler) + async_read_until(Seq const& buffers, Condition condition, Handler handler) { if (isSecure()) boost::asio::async_read_until( @@ -218,7 +218,7 @@ public: template void - async_write(const Buf& buffers, Handler handler) + async_write(Buf const& buffers, Handler handler) { if (isSecure()) boost::asio::async_write(*mSocket, buffers, handler); @@ -240,7 +240,7 @@ public: template void - async_read(const Buf& buffers, Condition cond, Handler handler) + async_read(Buf const& buffers, Condition cond, Handler handler) { if (isSecure()) boost::asio::async_read(*mSocket, buffers, cond, handler); @@ -263,7 +263,7 @@ public: template void - async_read(const Buf& buffers, Handler handler) + async_read(Buf const& buffers, Handler handler) { if (isSecure()) boost::asio::async_read(*mSocket, buffers, handler); @@ -273,7 +273,7 @@ public: template void - async_write_some(const Seq& buffers, Handler handler) + async_write_some(Seq const& buffers, Handler handler) { if (isSecure()) mSocket->async_write_some(buffers, handler); @@ -285,7 +285,7 @@ protected: void handle_autodetect( callback cbFunc, - const error_code& ec, + error_code const& ec, size_t bytesTransferred) { using namespace ripple; diff --git a/src/xrpld/net/HTTPClient.h b/src/xrpld/net/HTTPClient.h index 2a33500aa..a11b88529 100644 --- a/src/xrpld/net/HTTPClient.h +++ b/src/xrpld/net/HTTPClient.h @@ -50,12 +50,12 @@ public: get(bool bSSL, boost::asio::io_service& io_service, std::deque deqSites, - const unsigned short port, + unsigned short const port, std::string const& strPath, std::size_t responseMax, // if no Content-Length header std::chrono::seconds timeout, std::function complete, beast::Journal& j); @@ -64,12 +64,12 @@ public: get(bool bSSL, boost::asio::io_service& io_service, std::string strSite, - const unsigned short port, + unsigned short const port, std::string const& strPath, std::size_t responseMax, // if no Content-Length header std::chrono::seconds timeout, std::function complete, beast::Journal& j); @@ -79,13 +79,13 @@ public: bool bSSL, boost::asio::io_service& io_service, std::string strSite, - const unsigned short port, + unsigned short const port, std::function< void(boost::asio::streambuf& sb, std::string const& strHost)> build, std::size_t responseMax, // if no Content-Length header std::chrono::seconds timeout, std::function complete, beast::Journal& j); diff --git a/src/xrpld/net/HTTPClientSSLContext.h b/src/xrpld/net/HTTPClientSSLContext.h index 2da5ac38d..68f91b18b 100644 --- a/src/xrpld/net/HTTPClientSSLContext.h +++ b/src/xrpld/net/HTTPClientSSLContext.h @@ -191,7 +191,7 @@ public: private: boost::asio::ssl::context ssl_context_; beast::Journal const j_; - const bool verify_; + bool const verify_; }; } // namespace ripple diff --git a/src/xrpld/net/InfoSub.h b/src/xrpld/net/InfoSub.h index c8762c31f..bc6c6e781 100644 --- a/src/xrpld/net/InfoSub.h +++ b/src/xrpld/net/InfoSub.h @@ -57,7 +57,7 @@ public: // aliases. using wptr = std::weak_ptr; - using ref = const std::shared_ptr&; + using ref = std::shared_ptr const&; using Consumer = Resource::Consumer; @@ -224,7 +224,7 @@ public: clearRequest(); void - setRequest(const std::shared_ptr& req); + setRequest(std::shared_ptr const& req); std::shared_ptr const& getRequest(); diff --git a/src/xrpld/net/RPCCall.h b/src/xrpld/net/RPCCall.h index 612d80c66..4c6d25ca5 100644 --- a/src/xrpld/net/RPCCall.h +++ b/src/xrpld/net/RPCCall.h @@ -46,20 +46,20 @@ namespace RPCCall { int fromCommandLine( Config const& config, - const std::vector& vCmd, + std::vector const& vCmd, Logs& logs); void fromNetwork( boost::asio::io_service& io_service, std::string const& strIp, - const std::uint16_t iPort, + std::uint16_t const iPort, std::string const& strUsername, std::string const& strPassword, std::string const& strPath, std::string const& strMethod, Json::Value const& jvParams, - const bool bSSL, + bool const bSSL, bool quiet, Logs& logs, std::function callbackFuncP = diff --git a/src/xrpld/net/detail/HTTPClient.cpp b/src/xrpld/net/detail/HTTPClient.cpp index 0ead4cf0d..901237e1e 100644 --- a/src/xrpld/net/detail/HTTPClient.cpp +++ b/src/xrpld/net/detail/HTTPClient.cpp @@ -53,7 +53,7 @@ class HTTPClientImp : public std::enable_shared_from_this, public: HTTPClientImp( boost::asio::io_service& io_service, - const unsigned short port, + unsigned short const port, std::size_t maxResponseSize, beast::Journal& j) : mSocket(io_service, httpClientSSLContext->context()) @@ -95,7 +95,7 @@ public: void(boost::asio::streambuf& sb, std::string const& strHost)> build, std::chrono::seconds timeout, std::function complete) { @@ -116,7 +116,7 @@ public: std::string const& strPath, std::chrono::seconds timeout, std::function complete) { @@ -179,7 +179,7 @@ public: } void - handleDeadline(const boost::system::error_code& ecResult) + handleDeadline(boost::system::error_code const& ecResult) { if (ecResult == boost::asio::error::operation_aborted) { @@ -218,7 +218,7 @@ public: } void - handleShutdown(const boost::system::error_code& ecResult) + handleShutdown(boost::system::error_code const& ecResult) { if (ecResult) { @@ -229,7 +229,7 @@ public: void handleResolve( - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, boost::asio::ip::tcp::resolver::iterator itrEndpoint) { if (!mShutdown) @@ -261,7 +261,7 @@ public: } void - handleConnect(const boost::system::error_code& ecResult) + handleConnect(boost::system::error_code const& ecResult) { if (!mShutdown) mShutdown = ecResult; @@ -305,7 +305,7 @@ public: } void - handleRequest(const boost::system::error_code& ecResult) + handleRequest(boost::system::error_code const& ecResult) { if (!mShutdown) mShutdown = ecResult; @@ -334,7 +334,7 @@ public: void handleWrite( - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, std::size_t bytes_transferred) { if (!mShutdown) @@ -363,7 +363,7 @@ public: void handleHeader( - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, std::size_t bytes_transferred) { std::string strHeader{ @@ -435,7 +435,7 @@ public: void handleData( - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, std::size_t bytes_transferred) { if (!mShutdown) @@ -467,7 +467,7 @@ public: // Call cancel the deadline timer and invoke the completion routine. void invokeComplete( - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, int iStatus = 0, std::string const& strData = "") { @@ -517,13 +517,13 @@ private: boost::asio::streambuf mHeader; boost::asio::streambuf mResponse; std::string mBody; - const unsigned short mPort; + unsigned short const mPort; std::size_t const maxResponseSize_; int mStatus; std::function mBuild; std::function mComplete; @@ -545,12 +545,12 @@ HTTPClient::get( bool bSSL, boost::asio::io_service& io_service, std::deque deqSites, - const unsigned short port, + unsigned short const port, std::string const& strPath, std::size_t responseMax, std::chrono::seconds timeout, std::function complete, beast::Journal& j) @@ -565,12 +565,12 @@ HTTPClient::get( bool bSSL, boost::asio::io_service& io_service, std::string strSite, - const unsigned short port, + unsigned short const port, std::string const& strPath, std::size_t responseMax, std::chrono::seconds timeout, std::function complete, beast::Journal& j) @@ -587,13 +587,13 @@ HTTPClient::request( bool bSSL, boost::asio::io_service& io_service, std::string strSite, - const unsigned short port, + unsigned short const port, std::function setRequest, std::size_t responseMax, std::chrono::seconds timeout, std::function complete, beast::Journal& j) diff --git a/src/xrpld/net/detail/InfoSub.cpp b/src/xrpld/net/detail/InfoSub.cpp index 7acd7f07a..9f394cf08 100644 --- a/src/xrpld/net/detail/InfoSub.cpp +++ b/src/xrpld/net/detail/InfoSub.cpp @@ -124,12 +124,12 @@ InfoSub::clearRequest() } void -InfoSub::setRequest(const std::shared_ptr& req) +InfoSub::setRequest(std::shared_ptr const& req) { request_ = req; } -const std::shared_ptr& +std::shared_ptr const& InfoSub::getRequest() { return request_; diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index 4a9af9509..21058bb17 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -1257,7 +1257,7 @@ private: if (jvParams.size() >= 3) { - const auto offset = jvParams.size() == 3 ? 0 : 1; + auto const offset = jvParams.size() == 3 ? 0 : 1; jvRequest[jss::min_ledger] = jvParams[1u + offset].asString(); jvRequest[jss::max_ledger] = jvParams[2u + offset].asString(); @@ -1321,7 +1321,7 @@ private: parseGatewayBalances(Json::Value const& jvParams) { unsigned int index = 0; - const unsigned int size = jvParams.size(); + unsigned int const size = jvParams.size(); Json::Value jvRequest{Json::objectValue}; @@ -1405,7 +1405,7 @@ public: struct Command { - const char* name; + char const* name; parseFuncPtr parse; int minParams; int maxParams; @@ -1572,7 +1572,7 @@ struct RPCCallImp static bool onResponse( std::function callbackFuncP, - const boost::system::error_code& ecResult, + boost::system::error_code const& ecResult, int iStatus, std::string const& strData, beast::Journal j) @@ -1835,7 +1835,7 @@ namespace RPCCall { int fromCommandLine( Config const& config, - const std::vector& vCmd, + std::vector const& vCmd, Logs& logs) { auto const result = @@ -1852,14 +1852,14 @@ void fromNetwork( boost::asio::io_service& io_service, std::string const& strIp, - const std::uint16_t iPort, + std::uint16_t const iPort, std::string const& strUsername, std::string const& strPassword, std::string const& strPath, std::string const& strMethod, Json::Value const& jvParams, - const bool bSSL, - const bool quiet, + bool const bSSL, + bool const quiet, Logs& logs, std::function callbackFuncP, std::unordered_map headers) diff --git a/src/xrpld/net/detail/RPCSub.cpp b/src/xrpld/net/detail/RPCSub.cpp index 994292e7b..3f0c923e1 100644 --- a/src/xrpld/net/detail/RPCSub.cpp +++ b/src/xrpld/net/detail/RPCSub.cpp @@ -167,7 +167,7 @@ private: true, logs_); } - catch (const std::exception& e) + catch (std::exception const& e) { JLOG(j_.info()) << "RPCCall::fromNetwork exception: " << e.what(); diff --git a/src/xrpld/net/detail/RegisterSSLCerts.cpp b/src/xrpld/net/detail/RegisterSSLCerts.cpp index 0dbf036e0..5a710323a 100644 --- a/src/xrpld/net/detail/RegisterSSLCerts.cpp +++ b/src/xrpld/net/detail/RegisterSSLCerts.cpp @@ -80,7 +80,7 @@ registerSSLCerts( while ((pContext = CertEnumCertificatesInStore(hStore.get(), pContext)) != NULL) { - const unsigned char* pbCertEncoded = pContext->pbCertEncoded; + unsigned char const* pbCertEncoded = pContext->pbCertEncoded; std::unique_ptr x509{ d2i_X509(NULL, &pbCertEncoded, pContext->cbCertEncoded), X509_free}; if (!x509) diff --git a/src/xrpld/nodestore/backend/RWDBFactory.cpp b/src/xrpld/nodestore/backend/RWDBFactory.cpp index 76f8144bf..eed22cba9 100644 --- a/src/xrpld/nodestore/backend/RWDBFactory.cpp +++ b/src/xrpld/nodestore/backend/RWDBFactory.cpp @@ -143,8 +143,8 @@ public: nodeobject_compress(encoded.getData(), encoded.getSize(), bf); std::vector compressed( - static_cast(result.first), - static_cast(result.first) + result.second); + static_cast(result.first), + static_cast(result.first) + result.second); std::lock_guard lock(mutex_); table_[object->getHash()] = std::move(compressed); @@ -169,7 +169,7 @@ public: return; std::lock_guard lock(mutex_); - for (const auto& entry : table_) + for (auto const& entry : table_) { nudb::detail::buffer bf; auto const result = nodeobject_decompress( diff --git a/src/xrpld/nodestore/detail/DummyScheduler.cpp b/src/xrpld/nodestore/detail/DummyScheduler.cpp index 76cd89610..9df137418 100644 --- a/src/xrpld/nodestore/detail/DummyScheduler.cpp +++ b/src/xrpld/nodestore/detail/DummyScheduler.cpp @@ -30,12 +30,12 @@ DummyScheduler::scheduleTask(Task& task) } void -DummyScheduler::onFetch(const FetchReport& report) +DummyScheduler::onFetch(FetchReport const& report) { } void -DummyScheduler::onBatchWrite(const BatchWriteReport& report) +DummyScheduler::onBatchWrite(BatchWriteReport const& report) { } diff --git a/src/xrpld/overlay/PeerSet.h b/src/xrpld/overlay/PeerSet.h index 6fb4b6564..4ee6b8d7c 100644 --- a/src/xrpld/overlay/PeerSet.h +++ b/src/xrpld/overlay/PeerSet.h @@ -68,7 +68,7 @@ public: std::shared_ptr const& peer) = 0; /** get the set of ids of previously added peers */ - virtual const std::set& + virtual std::set const& getPeerIds() const = 0; }; diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index b2db772f5..6ae3c9a14 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -157,7 +157,7 @@ private: deletePeer(PublicKey const& validator, id_t id, bool erase); /** Get the time of the last peer selection round */ - const time_point& + time_point const& getLastSelected() const { return lastSelected_; diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 8084fb287..88e0b4dcb 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -131,7 +131,7 @@ PeerImp::PeerImp( PeerImp::~PeerImp() { - const bool inCluster{cluster()}; + bool const inCluster{cluster()}; overlay_.deletePeer(id_); overlay_.onPeerDeactivate(id_); @@ -1271,8 +1271,8 @@ PeerImp::handleTransaction( { // If we've never been in synch, there's nothing we can do // with a transaction - JLOG(p_journal_.debug()) - << "Ignoring incoming transaction: " << "Need network ledger"; + JLOG(p_journal_.debug()) << "Ignoring incoming transaction: " + << "Need network ledger"; return; } @@ -2546,7 +2546,7 @@ PeerImp::onMessage(std::shared_ptr const& m) for (int i = 0; i < packet.objects_size(); ++i) { - const protocol::TMIndexedObject& obj = packet.objects(i); + protocol::TMIndexedObject const& obj = packet.objects(i); if (obj.has_hash() && stringIsUint256Sized(obj.hash())) { @@ -2750,7 +2750,7 @@ PeerImp::addLedger( } void -PeerImp::doFetchPack(const std::shared_ptr& packet) +PeerImp::doFetchPack(std::shared_ptr const& packet) { // VFALCO TODO Invert this dependency using an observer and shared state // object. Don't queue fetch pack jobs if we're under load or we already @@ -3460,19 +3460,19 @@ PeerImp::getScore(bool haveItem) const { // Random component of score, used to break ties and avoid // overloading the "best" peer - static const int spRandomMax = 9999; + static int const spRandomMax = 9999; // Score for being very likely to have the thing we are // look for; should be roughly spRandomMax - static const int spHaveItem = 10000; + static int const spHaveItem = 10000; // Score reduction for each millisecond of latency; should // be roughly spRandomMax divided by the maximum reasonable // latency - static const int spLatency = 30; + static int const spLatency = 30; // Penalty for unknown latency; should be roughly spRandomMax - static const int spNoLatency = 8000; + static int const spNoLatency = 8000; int score = rand_int(spRandomMax); diff --git a/src/xrpld/overlay/detail/PeerImp.h b/src/xrpld/overlay/detail/PeerImp.h index 9835f4c6f..8fbafa1ee 100644 --- a/src/xrpld/overlay/detail/PeerImp.h +++ b/src/xrpld/overlay/detail/PeerImp.h @@ -602,7 +602,7 @@ private: std::lock_guard const& lockedRecentLock); void - doFetchPack(const std::shared_ptr& packet); + doFetchPack(std::shared_ptr const& packet); void onValidatorListMessage( diff --git a/src/xrpld/overlay/detail/PeerSet.cpp b/src/xrpld/overlay/detail/PeerSet.cpp index 909b20c30..611728839 100644 --- a/src/xrpld/overlay/detail/PeerSet.cpp +++ b/src/xrpld/overlay/detail/PeerSet.cpp @@ -42,7 +42,7 @@ public: protocol::MessageType type, std::shared_ptr const& peer) override; - const std::set& + std::set const& getPeerIds() const override; private: @@ -117,7 +117,7 @@ PeerSetImpl::sendRequest( } } -const std::set& +std::set const& PeerSetImpl::getPeerIds() const { return peers_; @@ -171,7 +171,7 @@ public: JLOG(j_.error()) << "DummyPeerSet sendRequest should not be called"; } - const std::set& + std::set const& getPeerIds() const override { static std::set emptyPeers; diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index 9d1cce503..e93163683 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -246,7 +246,7 @@ public: static std::string to_string(category cat) { - static const std::unordered_map category_map = { + static std::unordered_map const category_map = { {base, "overhead"}, {cluster, "overhead_cluster"}, {overlay, "overhead_overlay"}, diff --git a/src/xrpld/overlay/detail/ZeroCopyStream.h b/src/xrpld/overlay/detail/ZeroCopyStream.h index 41d94578b..87a5e10bc 100644 --- a/src/xrpld/overlay/detail/ZeroCopyStream.h +++ b/src/xrpld/overlay/detail/ZeroCopyStream.h @@ -49,7 +49,7 @@ public: explicit ZeroCopyInputStream(Buffers const& buffers); bool - Next(const void** data, int* size) override; + Next(void const** data, int* size) override; void BackUp(int count) override; @@ -76,7 +76,7 @@ ZeroCopyInputStream::ZeroCopyInputStream(Buffers const& buffers) template bool -ZeroCopyInputStream::Next(const void** data, int* size) +ZeroCopyInputStream::Next(void const** data, int* size) { *data = boost::asio::buffer_cast(pos_); *size = boost::asio::buffer_size(pos_); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index b3922f63b..e23bbc29e 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -1132,9 +1132,9 @@ public: } else { - JLOG(m_journal.error()) - << beast::leftw(18) << "Logic failed " << "'" << source->name() - << "' fetch, " << results.error.message(); + JLOG(m_journal.error()) << beast::leftw(18) << "Logic failed " + << "'" << source->name() << "' fetch, " + << results.error.message(); } } diff --git a/src/xrpld/perflog/PerfLog.h b/src/xrpld/perflog/PerfLog.h index 58df185e0..5212752ec 100644 --- a/src/xrpld/perflog/PerfLog.h +++ b/src/xrpld/perflog/PerfLog.h @@ -186,9 +186,9 @@ template auto measureDurationAndLog( Func&& func, - const std::string& actionDescription, + std::string const& actionDescription, std::chrono::duration maxDelay, - const beast::Journal& journal) + beast::Journal const& journal) { auto start_time = std::chrono::high_resolution_clock::now(); diff --git a/src/xrpld/rpc/CTID.h b/src/xrpld/rpc/CTID.h index 042b79b52..be531c536 100644 --- a/src/xrpld/rpc/CTID.h +++ b/src/xrpld/rpc/CTID.h @@ -57,12 +57,12 @@ encodeCTID(uint32_t ledgerSeq, uint32_t txnIndex, uint32_t networkID) noexcept template inline std::optional> -decodeCTID(const T ctid) noexcept +decodeCTID(T const ctid) noexcept { uint64_t ctidValue{0}; if constexpr ( std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v) + std::is_same_v || std::is_same_v) { std::string const ctidString(ctid); diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index c81304b92..c1f8e0ae1 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -229,7 +229,7 @@ private: } template - explicit HandlerTable(const Handler (&entries)[N]) + explicit HandlerTable(Handler const (&entries)[N]) { for (auto const& entry : entries) { diff --git a/src/xrpld/rpc/detail/Handler.h b/src/xrpld/rpc/detail/Handler.h index e0fb66f6f..8c263a90a 100644 --- a/src/xrpld/rpc/detail/Handler.h +++ b/src/xrpld/rpc/detail/Handler.h @@ -47,7 +47,7 @@ struct Handler template using Method = std::function; - const char* name_; + char const* name_; Method valueMethod_; Role role_; RPC::Condition condition_; diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 07c1f9728..75b4aa720 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -1085,7 +1085,7 @@ chooseLedgerEntryType(Json::Value const& params) // against the canonical name (case-insensitive) or the RPC name // (case-sensitive). auto const filter = p.asString(); - const auto iter = + auto const iter = std::ranges::find_if(types, [&filter](decltype(types.front())& t) { return boost::iequals(std::get<0>(t), filter) || std::get<1>(t) == filter; diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index f3a6f9be9..1a1810256 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -276,7 +276,7 @@ isAccountObjectsValidType(LedgerEntryType const& type); * @return the api version number */ unsigned int -getAPIVersionNumber(const Json::Value& value, bool betaEnabled); +getAPIVersionNumber(Json::Value const& value, bool betaEnabled); /** Return a ledger based on ledger_hash or ledger_index, or an RPC error */ diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index fbb19d9d1..03e74ff12 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -1222,7 +1222,7 @@ ServerHandler::processRequest( if (auto stream = m_journal.debug()) { - static const int maxSize = 10000; + static int const maxSize = 10000; if (response.size() <= maxSize) stream << "Reply: " << response; else diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 3f388e636..9387aba50 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -746,8 +746,7 @@ transactionFormatResultImpl(Transaction::pointer tpTrans, unsigned apiVersion) //------------------------------------------------------------------------------ -[[nodiscard]] -static XRPAmount +[[nodiscard]] static XRPAmount getTxFee(Application const& app, Config const& config, Json::Value tx) { // autofilling only needed in this function so that the `STParsedJSONObject` @@ -945,7 +944,7 @@ transactionSign( if (!preprocResult.second) return preprocResult.first; - std::shared_ptr ledger = app.openLedger().current(); + std::shared_ptr ledger = app.openLedger().current(); // Make sure the STTx makes a legitimate Transaction. std::pair txn = transactionConstructImpl(preprocResult.second, ledger->rules(), app); @@ -1101,7 +1100,7 @@ transactionSignFor( JLOG(j.debug()) << "transactionSignFor: " << jvRequest; // Verify presence of the signer's account field. - const char accountField[] = "account"; + char const accountField[] = "account"; if (!jvRequest.isMember(accountField)) return RPC::missing_field_error(accountField); diff --git a/src/xrpld/rpc/handlers/Catalogue.cpp b/src/xrpld/rpc/handlers/Catalogue.cpp index 4d61b4d92..f1cc8d19f 100644 --- a/src/xrpld/rpc/handlers/Catalogue.cpp +++ b/src/xrpld/rpc/handlers/Catalogue.cpp @@ -78,7 +78,7 @@ static constexpr uint16_t CATALOGUE_COMPRESS_LEVEL_MASK = std::string formatBytesIEC(uint64_t bytes, int precision = 2) { - static const char* units[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; + static char const* units[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; int unit_index = 0; auto size = static_cast(bytes); @@ -206,7 +206,7 @@ public: template std::streamsize - write(Sink& sink, const char* data, std::streamsize n) + write(Sink& sink, char const* data, std::streamsize n) { std::streamsize result = boost::iostreams::write(sink, data, n); if (result > 0) @@ -605,7 +605,7 @@ doCatalogueCreate(RPC::JsonContext& context) header.network_id = context.app.config().NETWORK_ID; // hash is already zero-initialized - outfile.write(reinterpret_cast(&header), sizeof(CATLHeader)); + outfile.write(reinterpret_cast(&header), sizeof(CATLHeader)); if (outfile.fail()) return rpcError( rpcINTERNAL, @@ -634,8 +634,8 @@ doCatalogueCreate(RPC::JsonContext& context) compStream->push(boost::ref(outfile)); // Process ledgers with local processor implementation - auto writeToFile = [&compStream, &context](const void* data, size_t size) { - compStream->write(reinterpret_cast(data), size); + auto writeToFile = [&compStream, &context](void const* data, size_t size) { + compStream->write(reinterpret_cast(data), size); if (compStream->fail()) { JLOG(context.j.error()) @@ -652,7 +652,7 @@ doCatalogueCreate(RPC::JsonContext& context) auto outputLedger = [&writeToFile, &context, &compStream, &predictor, &byteCounter]( std::shared_ptr ledger, - std::optional> prevStateMap = + std::optional> prevStateMap = std::nullopt) -> bool { try { @@ -797,7 +797,7 @@ doCatalogueCreate(RPC::JsonContext& context) updateFileSizeFile.seekp(0, std::ios::beg); updateFileSizeFile.write( - reinterpret_cast(&header), sizeof(CATLHeader)); + reinterpret_cast(&header), sizeof(CATLHeader)); updateFileSizeFile.close(); // Now compute the hash over the entire file @@ -853,7 +853,7 @@ doCatalogueCreate(RPC::JsonContext& context) updateFile.seekp(offsetof(CATLHeader, hash), std::ios::beg); updateFile.write( - reinterpret_cast(hash_result.data()), hash_result.size()); + reinterpret_cast(hash_result.data()), hash_result.size()); updateFile.close(); // Convert hash to hex string diff --git a/src/xrpld/rpc/handlers/GetAggregatePrice.cpp b/src/xrpld/rpc/handlers/GetAggregatePrice.cpp index 8001071f8..33a88ba78 100644 --- a/src/xrpld/rpc/handlers/GetAggregatePrice.cpp +++ b/src/xrpld/rpc/handlers/GetAggregatePrice.cpp @@ -108,8 +108,8 @@ iteratePriceData( return; oracle = isNew - ? &static_cast(node.peekAtField(sfNewFields)) - : &static_cast( + ? &static_cast(node.peekAtField(sfNewFields)) + : &static_cast( node.peekAtField(sfFinalFields)); break; } diff --git a/src/xrpld/rpc/handlers/GetCounts.cpp b/src/xrpld/rpc/handlers/GetCounts.cpp index 9f57f08a2..3c1d8cccd 100644 --- a/src/xrpld/rpc/handlers/GetCounts.cpp +++ b/src/xrpld/rpc/handlers/GetCounts.cpp @@ -37,7 +37,7 @@ static void textTime( std::string& text, UptimeClock::time_point& seconds, - const char* unitName, + char const* unitName, std::chrono::seconds unitVal) { auto i = seconds.time_since_epoch() / unitVal; diff --git a/src/xrpld/rpc/handlers/LedgerEntry.cpp b/src/xrpld/rpc/handlers/LedgerEntry.cpp index 92800485f..fa74ff570 100644 --- a/src/xrpld/rpc/handlers/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/LedgerEntry.cpp @@ -1182,7 +1182,7 @@ doLedgerEntry(RPC::JsonContext& context) try { bool found = false; - for (const auto& ledgerEntry : ledgerEntryParsers) + for (auto const& ledgerEntry : ledgerEntryParsers) { if (context.params.isMember(ledgerEntry.fieldName)) { diff --git a/src/xrpld/rpc/handlers/ServerDefinitions.cpp b/src/xrpld/rpc/handlers/ServerDefinitions.cpp index 646e833bc..32e06c2e6 100644 --- a/src/xrpld/rpc/handlers/ServerDefinitions.cpp +++ b/src/xrpld/rpc/handlers/ServerDefinitions.cpp @@ -100,7 +100,7 @@ private: { for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; json[jss::TRANSACTION_FLAGS][key][STR(name)] = static_cast(entry.first); } @@ -113,13 +113,13 @@ private: ret[jss::TYPES] = Json::objectValue; auto const translate = [](std::string inp) -> std::string { - auto replace = [&](const char* f, const char* r) -> std::string { + auto replace = [&](char const* f, char const* r) -> std::string { std::string out = inp; boost::replace_all(out, f, r); return out; }; - auto find = [&](const char* s) -> bool { + auto find = [&](char const* s) -> bool { return inp.find(s) != std::string::npos; }; @@ -155,7 +155,7 @@ private: if (inp == "IMPORT_VLSEQ") return "ImportVLSequence"; - static const std::map + static std::map const capitalization_exceptions = { {"NFTOKEN", "NFToken"}, {"UNL", "UNL"}, @@ -198,7 +198,7 @@ private: std::map type_map{{-1, "Done"}}; for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; std::string type_name = translate(name.data() + 4 /* remove STI_ */); int32_t type_value = static_cast(entry.first); @@ -210,7 +210,7 @@ private: ret[jss::LEDGER_ENTRY_TYPES][jss::Invalid] = -1; for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; std::string type_name = translate(name.data() + 2 /* remove lt_ */); int32_t type_value = static_cast(entry.first); ret[jss::LEDGER_ENTRY_TYPES][type_name] = type_value; @@ -357,37 +357,37 @@ private: ret[jss::TRANSACTION_RESULTS] = Json::objectValue; for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_RESULTS][STR(name)] = static_cast(entry.first); } @@ -416,7 +416,7 @@ private: ret[jss::TRANSACTION_TYPES][jss::Invalid] = -1; for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; std::string type_name = translate_tt(translate(name.data() + 2)); int32_t type_value = static_cast(entry.first); ret[jss::TRANSACTION_TYPES][type_name] = type_value; @@ -486,7 +486,7 @@ private: ret[jss::TRANSACTION_FLAGS_INDICES] = Json::objectValue; for (auto const& entry : magic_enum::enum_entries()) { - const auto name = entry.second; + auto const name = entry.second; ret[jss::TRANSACTION_FLAGS_INDICES]["AccountSet"][STR(name)] = static_cast(entry.first); } @@ -495,7 +495,7 @@ private: // generate hash { - const std::string out = Json::FastWriter().write(ret); + std::string const out = Json::FastWriter().write(ret); defsHash = ripple::sha512Half(ripple::Slice{out.data(), out.size()}); } @@ -513,7 +513,7 @@ public: { if (!defsHash) { - static const uint256 fallbackHash( + static uint256 const fallbackHash( "DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0"); return fallbackHash; } @@ -530,7 +530,7 @@ public: Json::Value getStaticServerDefinitions() { - static const Definitions defs{}; + static Definitions const defs{}; Json::Value ret = defs(); ret[jss::hash] = to_string(defs.getHash()); return ret; @@ -576,13 +576,13 @@ doServerDefinitions(RPC::JsonContext& context) lastFeatures = features; { - const std::string out = Json::FastWriter().write(features); + std::string const out = Json::FastWriter().write(features); lastFeatureHash = ripple::sha512Half(ripple::Slice{out.data(), out.size()}); } } - static const Definitions defs{}; + static Definitions const defs{}; // the hash is the xor of the two parts uint256 retHash = lastFeatureHash ^ defs.getHash(); diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/Simulate.cpp index 3c7340ece..5f69c203f 100644 --- a/src/xrpld/rpc/handlers/Simulate.cpp +++ b/src/xrpld/rpc/handlers/Simulate.cpp @@ -233,7 +233,7 @@ simulateTxn(RPC::JsonContext& context, std::shared_ptr transaction) jvResult[jss::applied] = result.applied; jvResult[jss::ledger_index] = view.seq(); - const bool isBinaryOutput = context.params.get(jss::binary, false).asBool(); + bool const isBinaryOutput = context.params.get(jss::binary, false).asBool(); // Convert the TER to human-readable values std::string token; diff --git a/src/xrpld/rpc/handlers/Subscribe.cpp b/src/xrpld/rpc/handlers/Subscribe.cpp index a35e8bd91..af7498f7c 100644 --- a/src/xrpld/rpc/handlers/Subscribe.cpp +++ b/src/xrpld/rpc/handlers/Subscribe.cpp @@ -331,7 +331,7 @@ doSubscribe(RPC::JsonContext& context) context.app.getLedgerMaster().getPublishedLedger(); if (lpLedger) { - const Json::Value jvMarker = Json::Value(Json::nullValue); + Json::Value const jvMarker = Json::Value(Json::nullValue); Json::Value jvOffers(Json::objectValue); auto add = [&](Json::StaticString field) { diff --git a/src/xrpld/shamap/SHAMap.h b/src/xrpld/shamap/SHAMap.h index 8bc5aa6fb..34fc2f3b0 100644 --- a/src/xrpld/shamap/SHAMap.h +++ b/src/xrpld/shamap/SHAMap.h @@ -515,9 +515,9 @@ private: struct MissingNodes { MissingNodes() = delete; - MissingNodes(const MissingNodes&) = delete; + MissingNodes(MissingNodes const&) = delete; MissingNodes& - operator=(const MissingNodes&) = delete; + operator=(MissingNodes const&) = delete; // basic parameters int max_; diff --git a/src/xrpld/shamap/SHAMapLeafNode.h b/src/xrpld/shamap/SHAMapLeafNode.h index c0f9422a3..383da38fd 100644 --- a/src/xrpld/shamap/SHAMapLeafNode.h +++ b/src/xrpld/shamap/SHAMapLeafNode.h @@ -42,9 +42,9 @@ protected: SHAMapHash const& hash); public: - SHAMapLeafNode(const SHAMapLeafNode&) = delete; + SHAMapLeafNode(SHAMapLeafNode const&) = delete; SHAMapLeafNode& - operator=(const SHAMapLeafNode&) = delete; + operator=(SHAMapLeafNode const&) = delete; bool isLeaf() const final override diff --git a/src/xrpld/shamap/detail/SHAMap.cpp b/src/xrpld/shamap/detail/SHAMap.cpp index 8174628a8..c0c8eea4d 100644 --- a/src/xrpld/shamap/detail/SHAMap.cpp +++ b/src/xrpld/shamap/detail/SHAMap.cpp @@ -565,7 +565,7 @@ SHAMap::firstBelow( return belowHelper(node, stack, branch, {init, cmp, incr}); } -static const boost::intrusive_ptr no_item; +static boost::intrusive_ptr const no_item; boost::intrusive_ptr const& SHAMap::onlyBelow(SHAMapTreeNode* node) const @@ -801,7 +801,7 @@ SHAMap::delItem(uint256 const& id) { // we may have made this a node with 1 or 0 children // And, if so, we need to remove this branch - const int bc = node->getBranchCount(); + int const bc = node->getBranchCount(); if (bc == 0) { // no children below this branch diff --git a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp index 8ec581b47..6e9d447cf 100644 --- a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp @@ -266,7 +266,7 @@ SHAMapInnerNode::serializeWithPrefix(Serializer& s) const } std::string -SHAMapInnerNode::getString(const SHAMapNodeID& id) const +SHAMapInnerNode::getString(SHAMapNodeID const& id) const { std::string ret = SHAMapTreeNode::getString(id); auto hashes = hashesAndChildren_.getHashes(); diff --git a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp index cdf0f80a8..10d61ff13 100644 --- a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp @@ -65,7 +65,7 @@ SHAMapLeafNode::setItem(boost::intrusive_ptr item) } std::string -SHAMapLeafNode::getString(const SHAMapNodeID& id) const +SHAMapLeafNode::getString(SHAMapNodeID const& id) const { std::string ret = SHAMapTreeNode::getString(id); diff --git a/src/xrpld/shamap/detail/SHAMapSync.cpp b/src/xrpld/shamap/detail/SHAMapSync.cpp index d43b1ff02..176c9f2a3 100644 --- a/src/xrpld/shamap/detail/SHAMapSync.cpp +++ b/src/xrpld/shamap/detail/SHAMapSync.cpp @@ -577,7 +577,7 @@ SHAMap::addRootNode( SHAMapAddNode SHAMap::addKnownNode( - const SHAMapNodeID& node, + SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncFilter* filter) { diff --git a/src/xrpld/shamap/detail/SHAMapTreeNode.cpp b/src/xrpld/shamap/detail/SHAMapTreeNode.cpp index 6acf3f3bf..d1e74fd6a 100644 --- a/src/xrpld/shamap/detail/SHAMapTreeNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapTreeNode.cpp @@ -179,7 +179,7 @@ SHAMapTreeNode::makeFromPrefix(Slice rawNode, SHAMapHash const& hash) } std::string -SHAMapTreeNode::getString(const SHAMapNodeID& id) const +SHAMapTreeNode::getString(SHAMapNodeID const& id) const { return to_string(id); }