mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
20
.clang-tidy
20
.clang-tidy
@@ -4,6 +4,9 @@ Checks: '-*,
|
||||
bugprone-assert-side-effect,
|
||||
bugprone-bad-signal-to-kill-thread,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-casting-through-void,
|
||||
bugprone-chained-comparison,
|
||||
bugprone-compare-pointer-to-member-virtual-function,
|
||||
bugprone-copy-constructor-init,
|
||||
bugprone-dangling-handle,
|
||||
bugprone-dynamic-static-initializers,
|
||||
@@ -11,6 +14,8 @@ Checks: '-*,
|
||||
bugprone-fold-init-type,
|
||||
bugprone-forward-declaration-namespace,
|
||||
bugprone-inaccurate-erase,
|
||||
bugprone-inc-dec-in-conditions,
|
||||
bugprone-incorrect-enable-if,
|
||||
bugprone-incorrect-roundings,
|
||||
bugprone-infinite-loop,
|
||||
bugprone-integer-division,
|
||||
@@ -21,10 +26,12 @@ Checks: '-*,
|
||||
bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-move-forwarding-reference,
|
||||
bugprone-multi-level-implicit-pointer-conversion,
|
||||
bugprone-multiple-new-in-one-expression,
|
||||
bugprone-multiple-statement-macro,
|
||||
bugprone-no-escape,
|
||||
bugprone-non-zero-enum-to-bool-conversion,
|
||||
bugprone-optional-value-conversion,
|
||||
bugprone-parent-virtual-call,
|
||||
bugprone-posix-return,
|
||||
bugprone-redundant-branch-condition,
|
||||
@@ -59,16 +66,20 @@ Checks: '-*,
|
||||
bugprone-unhandled-self-assignment,
|
||||
bugprone-unique-ptr-array-mismatch,
|
||||
bugprone-unsafe-functions,
|
||||
bugprone-unused-local-non-trivial-variable,
|
||||
bugprone-unused-raii,
|
||||
bugprone-unused-return-value,
|
||||
bugprone-use-after-move,
|
||||
bugprone-virtual-near-miss,
|
||||
cppcoreguidelines-init-variables,
|
||||
cppcoreguidelines-misleading-capture-default-by-value,
|
||||
cppcoreguidelines-no-suspend-with-lock,
|
||||
cppcoreguidelines-pro-type-member-init,
|
||||
cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||
cppcoreguidelines-use-default-member-init,
|
||||
cppcoreguidelines-virtual-class-destructor,
|
||||
hicpp-ignored-remove-result,
|
||||
llvm-namespace-comment,
|
||||
misc-const-correctness,
|
||||
misc-definitions-in-headers,
|
||||
@@ -90,6 +101,8 @@ Checks: '-*,
|
||||
modernize-use-equals-default,
|
||||
modernize-use-equals-delete,
|
||||
modernize-use-override,
|
||||
modernize-use-starts-ends-with,
|
||||
modernize-use-std-numbers,
|
||||
modernize-use-using,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
@@ -99,6 +112,8 @@ Checks: '-*,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-trivially-destructible,
|
||||
readability-avoid-nested-conditional-operator,
|
||||
readability-avoid-return-with-void-value,
|
||||
readability-braces-around-statements,
|
||||
readability-const-return-type,
|
||||
readability-container-contains,
|
||||
@@ -111,9 +126,12 @@ Checks: '-*,
|
||||
readability-make-member-function-const,
|
||||
readability-misleading-indentation,
|
||||
readability-non-const-parameter,
|
||||
readability-redundant-casting,
|
||||
readability-redundant-declaration,
|
||||
readability-redundant-inline-specifier,
|
||||
readability-redundant-member-init,
|
||||
readability-redundant-string-init,
|
||||
readability-reference-to-constructed-temporary,
|
||||
readability-simplify-boolean-expr,
|
||||
readability-static-accessed-through-instance,
|
||||
readability-static-definition-in-anonymous-namespace,
|
||||
@@ -123,7 +141,7 @@ Checks: '-*,
|
||||
CheckOptions:
|
||||
readability-braces-around-statements.ShortStatementLines: 2
|
||||
bugprone-unsafe-functions.ReportMoreUnsafeFunctions: true
|
||||
bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc;::std::expected
|
||||
bugprone-unused-return-value.CheckedReturnTypes: ::std::error_code;::std::error_condition;::std::errc
|
||||
misc-include-cleaner.IgnoreHeaders: '.*/(detail|impl)/.*;.*(expected|unexpected).*'
|
||||
|
||||
HeaderFilterRegex: '^.*/(src|unittests)/.*\.(h|hpp)$'
|
||||
|
||||
@@ -12,12 +12,12 @@ sources="src unittests"
|
||||
formatter="clang-format -i"
|
||||
version=$($formatter --version | grep -o '[0-9\.]*')
|
||||
|
||||
if [[ "17.0.0" > "$version" ]]; then
|
||||
if [[ "18.0.0" > "$version" ]]; then
|
||||
cat <<EOF
|
||||
|
||||
ERROR
|
||||
-----------------------------------------------------------------------------
|
||||
A minimum of version 17 of `which clang-format` is required.
|
||||
A minimum of version 18 of `which clang-format` is required.
|
||||
Your version is $version.
|
||||
Please fix paths and run again.
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
2
.github/workflows/clang-tidy.yml
vendored
2
.github/workflows/clang-tidy.yml
vendored
@@ -60,7 +60,7 @@ jobs:
|
||||
shell: bash
|
||||
id: run_clang_tidy
|
||||
run: |
|
||||
run-clang-tidy-17 -p build -j ${{ steps.number_of_threads.outputs.threads_number }} -fix -quiet 1>output.txt
|
||||
run-clang-tidy-18 -p build -j ${{ steps.number_of_threads.outputs.threads_number }} -fix -quiet 1>output.txt
|
||||
|
||||
- name: Check format
|
||||
if: ${{ steps.run_clang_tidy.outcome != 'success' }}
|
||||
|
||||
@@ -21,7 +21,7 @@ git config --local core.hooksPath .githooks
|
||||
```
|
||||
|
||||
## Git hooks dependencies
|
||||
The pre-commit hook requires `clang-format >= 17.0.0` and `cmake-format` to be installed on your machine.
|
||||
The pre-commit hook requires `clang-format >= 18.0.0` and `cmake-format` to be installed on your machine.
|
||||
`clang-format` can be installed using `brew` on macOS and default package manager on Linux.
|
||||
`cmake-format` can be installed using `pip`.
|
||||
The hook will also attempt to automatically use `doxygen` to verify that everything public in the codebase is covered by doc comments. If `doxygen` is not installed, the hook will raise a warning suggesting to install `doxygen` for future commits.
|
||||
@@ -102,7 +102,7 @@ The button for that is near the bottom of the PR's page on GitHub.
|
||||
This is a non-exhaustive list of recommended style guidelines. These are not always strictly enforced and serve as a way to keep the codebase coherent.
|
||||
|
||||
## Formatting
|
||||
Code must conform to `clang-format` version 17, unless the result would be unreasonably difficult to read or maintain.
|
||||
Code must conform to `clang-format` version 18, unless the result would be unreasonably difficult to read or maintain.
|
||||
In most cases the pre-commit hook will take care of formatting and will fix any issues automatically.
|
||||
To manually format your code, use `clang-format -i <your changed files>` for C++ files and `cmake-format -i <your changed files>` for CMake files.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ if (lint)
|
||||
endif ()
|
||||
message(STATUS "Using clang-tidy from CLIO_CLANG_TIDY_BIN")
|
||||
else ()
|
||||
find_program(_CLANG_TIDY_BIN NAMES "clang-tidy-17" "clang-tidy" REQUIRED)
|
||||
find_program(_CLANG_TIDY_BIN NAMES "clang-tidy-18" "clang-tidy" REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (NOT _CLANG_TIDY_BIN)
|
||||
|
||||
@@ -90,7 +90,7 @@ BackendInterface::fetchLedgerObject(
|
||||
auto obj = cache_.get(key, sequence);
|
||||
if (obj) {
|
||||
LOG(gLog.trace()) << "Cache hit - " << ripple::strHex(key);
|
||||
return *obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
LOG(gLog.trace()) << "Cache miss - " << ripple::strHex(key);
|
||||
@@ -302,10 +302,17 @@ BackendInterface::fetchLedgerPage(
|
||||
|
||||
std::vector<ripple::uint256> keys;
|
||||
bool reachedEnd = false;
|
||||
|
||||
while (keys.size() < limit && !reachedEnd) {
|
||||
ripple::uint256 const& curCursor = !keys.empty() ? keys.back() : (cursor ? *cursor : firstKey);
|
||||
ripple::uint256 const& curCursor = [&]() {
|
||||
if (!keys.empty())
|
||||
return keys.back();
|
||||
return (cursor ? *cursor : firstKey);
|
||||
}();
|
||||
|
||||
std::uint32_t const seq = outOfOrder ? range->maxSequence : ledgerSequence;
|
||||
auto succ = fetchSuccessorKey(curCursor, seq, yield);
|
||||
|
||||
if (!succ) {
|
||||
reachedEnd = true;
|
||||
} else {
|
||||
|
||||
@@ -561,7 +561,7 @@ public:
|
||||
if (auto const res = executor_.read(yield, schema_->selectObject, key, sequence); res) {
|
||||
if (auto const result = res->template get<Blob>(); result) {
|
||||
if (result->size())
|
||||
return *result;
|
||||
return result;
|
||||
} else {
|
||||
LOG(log_.debug()) << "Could not fetch ledger object - no rows";
|
||||
}
|
||||
@@ -597,7 +597,7 @@ public:
|
||||
if (auto const result = res->template get<ripple::uint256>(); result) {
|
||||
if (*result == lastKey)
|
||||
return std::nullopt;
|
||||
return *result;
|
||||
return result;
|
||||
}
|
||||
|
||||
LOG(log_.debug()) << "Could not fetch successor - no rows";
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
/**
|
||||
* @return The specified keyspace
|
||||
*/
|
||||
[[nodiscard]] inline std::string
|
||||
[[nodiscard]] std::string
|
||||
getKeyspace() const
|
||||
{
|
||||
return keyspace_;
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/**
|
||||
* @return The optional table prefix to use in all queries
|
||||
*/
|
||||
[[nodiscard]] inline std::optional<std::string>
|
||||
[[nodiscard]] std::optional<std::string>
|
||||
getTablePrefix() const
|
||||
{
|
||||
return tablePrefix_;
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
/**
|
||||
* @return The replication factor
|
||||
*/
|
||||
[[nodiscard]] inline uint16_t
|
||||
[[nodiscard]] uint16_t
|
||||
getReplicationFactor() const
|
||||
{
|
||||
return replicationFactor_;
|
||||
|
||||
@@ -49,7 +49,7 @@ struct Settings {
|
||||
*/
|
||||
struct ContactPoints {
|
||||
std::string contactPoints = "127.0.0.1"; // defaults to localhost
|
||||
std::optional<uint16_t> port = {};
|
||||
std::optional<uint16_t> port;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -87,16 +87,16 @@ struct Settings {
|
||||
std::size_t writeBatchSize = DEFAULT_BATCH_SIZE;
|
||||
|
||||
/** @brief Size of the IO queue */
|
||||
std::optional<uint32_t> queueSizeIO{};
|
||||
std::optional<uint32_t> queueSizeIO = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
/** @brief SSL certificate */
|
||||
std::optional<std::string> certificate{}; // ssl context
|
||||
std::optional<std::string> certificate = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
/** @brief Username/login */
|
||||
std::optional<std::string> username{};
|
||||
std::optional<std::string> username = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
/** @brief Password to match the `username` */
|
||||
std::optional<std::string> password{};
|
||||
std::optional<std::string> password = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
|
||||
/**
|
||||
* @brief Creates a new Settings object as a copy of the current one with overridden contact points.
|
||||
@@ -105,7 +105,7 @@ struct Settings {
|
||||
withContactPoints(std::string_view contactPoints)
|
||||
{
|
||||
auto tmp = *this;
|
||||
tmp.connectionInfo = ContactPoints{std::string{contactPoints}};
|
||||
tmp.connectionInfo = ContactPoints{.contactPoints = std::string{contactPoints}, .port = std::nullopt};
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,8 @@ ETLService::monitor()
|
||||
}
|
||||
} catch (std::runtime_error const& e) {
|
||||
LOG(log_.fatal()) << "Failed to load initial ledger: " << e.what();
|
||||
return amendmentBlockHandler_.onAmendmentBlock();
|
||||
amendmentBlockHandler_.onAmendmentBlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ledger) {
|
||||
@@ -152,7 +153,7 @@ ETLService::monitor()
|
||||
ASSERT(rng.has_value(), "Ledger range can't be null");
|
||||
uint32_t nextSequence = rng->maxSequence + 1;
|
||||
|
||||
LOG(log_.debug()) << "Database is populated. " << "Starting monitor loop. sequence = " << nextSequence;
|
||||
LOG(log_.debug()) << "Database is populated. Starting monitor loop. sequence = " << nextSequence;
|
||||
|
||||
while (not isStopping()) {
|
||||
nextSequence = publishNextSequence(nextSequence);
|
||||
@@ -205,7 +206,7 @@ ETLService::monitorReadOnly()
|
||||
|
||||
if (!rng) {
|
||||
if (auto net = networkValidatedLedgers_->getMostRecent()) {
|
||||
return *net;
|
||||
return net;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ LoadBalancer::loadInitialLedger(uint32_t sequence, bool cacheOnly)
|
||||
auto [data, res] = source.loadInitialLedger(sequence, downloadRanges_, cacheOnly);
|
||||
|
||||
if (!res) {
|
||||
LOG(log_.error()) << "Failed to download initial ledger." << " Sequence = " << sequence
|
||||
LOG(log_.error()) << "Failed to download initial ledger. Sequence = " << sequence
|
||||
<< " source = " << source.toString();
|
||||
} else {
|
||||
response = std::move(data);
|
||||
@@ -282,7 +282,7 @@ LoadBalancer::execute(Func f, uint32_t ledgerSequence)
|
||||
numAttempts++;
|
||||
if (numAttempts % sources_.size() == 0) {
|
||||
LOG(log_.info()) << "Ledger sequence " << ledgerSequence
|
||||
<< " is not yet available from any configured sources. " << "Sleeping and trying again";
|
||||
<< " is not yet available from any configured sources. Sleeping and trying again";
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
return CallStatus::ERRORED;
|
||||
}
|
||||
if (!status_.ok()) {
|
||||
LOG(log_.error()) << "AsyncCallData status_ not ok: " << " code = " << status_.error_code()
|
||||
LOG(log_.error()) << "AsyncCallData status_ not ok: code = " << status_.error_code()
|
||||
<< " message = " << status_.error_message();
|
||||
return CallStatus::ERRORED;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ GrpcSource::loadInitialLedger(uint32_t const sequence, uint32_t const numMarkers
|
||||
auto result = ptr->process(stub_, cq, *backend_, abort, cacheOnly);
|
||||
if (result != etl::impl::AsyncCallData::CallStatus::MORE) {
|
||||
++numFinished;
|
||||
LOG(log_.debug()) << "Finished a marker. " << "Current number of finished = " << numFinished;
|
||||
LOG(log_.debug()) << "Finished a marker. Current number of finished = " << numFinished;
|
||||
|
||||
if (auto lastKey = ptr->getLastKey(); !lastKey.empty())
|
||||
edgeKeys.push_back(std::move(lastKey));
|
||||
|
||||
@@ -158,7 +158,7 @@ private:
|
||||
auto const end = std::chrono::system_clock::now();
|
||||
auto const duration = ((end - start).count()) / 1000000000.0;
|
||||
|
||||
LOG(log_.info()) << "Load phase of etl : " << "Successfully wrote ledger! Ledger info: "
|
||||
LOG(log_.info()) << "Load phase of ETL. Successfully wrote ledger! Ledger info: "
|
||||
<< util::toString(lgrInfo) << ". txn count = " << numTxns
|
||||
<< ". object count = " << numObjects << ". load time = " << duration
|
||||
<< ". load txns per second = " << numTxns / duration
|
||||
|
||||
@@ -85,8 +85,8 @@ public:
|
||||
|
||||
private:
|
||||
class HandlerImpl final {
|
||||
std::map<std::string, BookChange> tally_ = {};
|
||||
std::optional<uint32_t> offerCancel_ = {};
|
||||
std::map<std::string, BookChange> tally_;
|
||||
std::optional<uint32_t> offerCancel_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] std::vector<BookChange>
|
||||
@@ -154,7 +154,11 @@ private:
|
||||
auto const g = to_string(deltaGets.issue());
|
||||
auto const p = to_string(deltaPays.issue());
|
||||
|
||||
auto const noswap = isXRP(deltaGets) ? true : (isXRP(deltaPays) ? false : (g < p));
|
||||
auto const noswap = [&]() {
|
||||
if (isXRP(deltaGets))
|
||||
return true;
|
||||
return isXRP(deltaPays) ? false : (g < p);
|
||||
}();
|
||||
|
||||
auto first = noswap ? deltaGets : deltaPays;
|
||||
auto second = noswap ? deltaPays : deltaGets;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/json/object.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
|
||||
@@ -196,10 +196,7 @@ accountFromStringStrict(std::string const& account)
|
||||
result = ripple::parseBase58<ripple::AccountID>(account);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result.value();
|
||||
}
|
||||
return {};
|
||||
return result;
|
||||
}
|
||||
|
||||
std::pair<std::shared_ptr<ripple::STTx const>, std::shared_ptr<ripple::STObject const>>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "rpc/common/Types.hpp"
|
||||
|
||||
#include <boost/json/value.hpp>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
|
||||
@@ -120,10 +120,10 @@ struct VoidOutput {};
|
||||
*/
|
||||
struct Context {
|
||||
boost::asio::yield_context yield;
|
||||
std::shared_ptr<web::ConnectionBase> session = {};
|
||||
std::shared_ptr<web::ConnectionBase> session = {}; // NOLINT(readability-redundant-member-init)
|
||||
bool isAdmin = false;
|
||||
std::string clientIp = {};
|
||||
uint32_t apiVersion = 0u; // invalid by default
|
||||
std::string clientIp = {}; // NOLINT(readability-redundant-member-init)
|
||||
uint32_t apiVersion = 0u; // invalid by default
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <fmt/core.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
#include <ripple/protocol/tokens.h>
|
||||
|
||||
|
||||
@@ -77,19 +77,19 @@ public:
|
||||
std::expected<uint32_t, std::string>
|
||||
parse(boost::json::object const& request) const override;
|
||||
|
||||
inline uint32_t
|
||||
uint32_t
|
||||
getDefaultVersion() const
|
||||
{
|
||||
return defaultVersion_;
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
uint32_t
|
||||
getMinVersion() const
|
||||
{
|
||||
return minVersion_;
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
uint32_t
|
||||
getMaxVersion() const
|
||||
{
|
||||
return maxVersion_;
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AMMCore.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Issue.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
@@ -67,16 +66,16 @@ AccountChannelsHandler::addChannel(std::vector<ChannelResponse>& jsonChannels, r
|
||||
}
|
||||
|
||||
if (auto const& v = channelSle[~ripple::sfExpiration])
|
||||
channel.expiration = *v;
|
||||
channel.expiration = v;
|
||||
|
||||
if (auto const& v = channelSle[~ripple::sfCancelAfter])
|
||||
channel.cancelAfter = *v;
|
||||
channel.cancelAfter = v;
|
||||
|
||||
if (auto const& v = channelSle[~ripple::sfSourceTag])
|
||||
channel.sourceTag = *v;
|
||||
channel.sourceTag = v;
|
||||
|
||||
if (auto const& v = channelSle[~ripple::sfDestinationTag])
|
||||
channel.destinationTag = *v;
|
||||
channel.destinationTag = v;
|
||||
|
||||
jsonChannels.push_back(channel);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Keylet.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/beast/utility/Zero.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Issue.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/protocol/nft.h>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Keylet.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
@@ -103,7 +102,7 @@ NFTOffersHandlerBase::iterateOfferDirectory(
|
||||
if (not sharedPtrBackend_->fetchLedgerObject(directory.key, lgrInfo.seq, yield))
|
||||
return Error{Status{RippledError::rpcOBJECT_NOT_FOUND, "notFound"}};
|
||||
|
||||
auto output = Output{input.nftID};
|
||||
auto output = Output{.nftID = input.nftID, .offers = {}, .limit = {}, .marker = {}};
|
||||
auto offers = std::vector<ripple::SLE>{};
|
||||
auto reserve = input.limit;
|
||||
auto cursor = uint256{};
|
||||
|
||||
@@ -57,13 +57,13 @@ public:
|
||||
* @brief A struct to hold the output data of the command
|
||||
*/
|
||||
struct Output {
|
||||
std::string nftID = {};
|
||||
std::vector<ripple::SLE> offers = {};
|
||||
std::string nftID;
|
||||
std::vector<ripple::SLE> offers;
|
||||
|
||||
// validated should be sent via framework
|
||||
bool validated = true;
|
||||
std::optional<uint32_t> limit = {};
|
||||
std::optional<std::string> marker = {};
|
||||
std::optional<uint32_t> limit;
|
||||
std::optional<std::string> marker;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <fmt/core.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
@@ -90,10 +90,10 @@ public:
|
||||
* @brief A struct to hold the admin section of the output
|
||||
*/
|
||||
struct AdminSection {
|
||||
boost::json::object counters = {};
|
||||
std::optional<boost::json::object> backendCounters = {};
|
||||
boost::json::object subscriptions = {};
|
||||
boost::json::object etl = {};
|
||||
boost::json::object counters;
|
||||
std::optional<boost::json::object> backendCounters;
|
||||
boost::json::object subscriptions;
|
||||
boost::json::object etl;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
*/
|
||||
struct ValidatedLedgerSection {
|
||||
uint32_t age = 0;
|
||||
std::string hash = {};
|
||||
std::string hash;
|
||||
ripple::LedgerIndex seq = {};
|
||||
std::optional<ripple::Fees> fees = std::nullopt;
|
||||
};
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
*/
|
||||
struct InfoSection {
|
||||
std::optional<AdminSection> adminSection = std::nullopt;
|
||||
std::string completeLedgers = {};
|
||||
std::string completeLedgers;
|
||||
uint32_t loadFactor = 1u;
|
||||
std::chrono::time_point<std::chrono::system_clock> time = std::chrono::system_clock::now();
|
||||
std::chrono::seconds uptime = {};
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
|
||||
|
||||
@@ -66,14 +66,16 @@ public:
|
||||
*/
|
||||
struct Output {
|
||||
uint32_t date = 0u;
|
||||
std::string hash{};
|
||||
std::string hash = {}; // NOLINT(readability-redundant-member-init)
|
||||
uint32_t ledgerIndex = 0u;
|
||||
std::optional<boost::json::object> meta{};
|
||||
std::optional<boost::json::object> tx{};
|
||||
std::optional<std::string> metaStr{};
|
||||
std::optional<std::string> txStr{};
|
||||
std::optional<std::string> ctid{}; // ctid when binary=true
|
||||
std::optional<ripple::LedgerHeader> ledgerHeader{}; // ledger hash when apiVersion >= 2
|
||||
std::optional<boost::json::object> meta = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
std::optional<boost::json::object> tx = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
std::optional<std::string> metaStr = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
std::optional<std::string> txStr = std::nullopt; // NOLINT(readability-redundant-member-init)
|
||||
std::optional<std::string> ctid =
|
||||
std::nullopt; // NOLINT(readability-redundant-member-init) ctid when binary=true
|
||||
std::optional<ripple::LedgerHeader> ledgerHeader =
|
||||
std::nullopt; // NOLINT(readability-redundant-member-init) ledger hash when apiVersion >= 2
|
||||
uint32_t apiVersion = 0u;
|
||||
bool validated = true;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ inline constexpr struct AssociatedExecutorExtractor {
|
||||
} extractAssociatedExecutor;
|
||||
|
||||
template <typename CtxType>
|
||||
[[nodiscard]] inline constexpr auto
|
||||
[[nodiscard]] constexpr auto
|
||||
getTimeoutHandleIfNeeded(CtxType& ctx, SomeOptStdDuration auto timeout, SomeStopSource auto& stopSource)
|
||||
{
|
||||
using TimerType = typename CtxType::Timer;
|
||||
@@ -57,7 +57,7 @@ getTimeoutHandleIfNeeded(CtxType& ctx, SomeOptStdDuration auto timeout, SomeStop
|
||||
}
|
||||
|
||||
template <SomeStopSource StopSourceType>
|
||||
[[nodiscard]] inline constexpr auto
|
||||
[[nodiscard]] constexpr auto
|
||||
outcomeForHandler(auto&& fn)
|
||||
{
|
||||
if constexpr (SomeHandlerWith<decltype(fn), typename StopSourceType::Token>) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "util/prometheus/Histogram.hpp"
|
||||
#include "util/prometheus/MetricBase.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "util/prometheus/MetricBuilder.hpp"
|
||||
#include "util/prometheus/OStream.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "util/prometheus/MetricsFamily.hpp"
|
||||
#include "util/prometheus/OStream.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
@@ -151,7 +151,9 @@ private:
|
||||
if (!range) {
|
||||
// for error that happened before the handler, we don't attach any warnings
|
||||
rpcEngine_->notifyNotReady();
|
||||
return web::impl::ErrorHelper(connection, std::move(request)).sendNotReadyError();
|
||||
web::impl::ErrorHelper(connection, std::move(request)).sendNotReadyError();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto const context = [&] {
|
||||
@@ -185,7 +187,9 @@ private:
|
||||
// we count all those as BadSyntax - as the WS path would.
|
||||
// Although over HTTP these will yield a 400 status with a plain text response (for most).
|
||||
rpcEngine_->notifyBadSyntax();
|
||||
return web::impl::ErrorHelper(connection, std::move(request)).sendError(err);
|
||||
web::impl::ErrorHelper(connection, std::move(request)).sendError(err);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto [result, timeDiff] = util::timed([&]() { return rpcEngine_->buildResponse(*context); });
|
||||
@@ -262,7 +266,9 @@ private:
|
||||
LOG(log_.error()) << connection->tag() << "Caught exception: " << ex.what();
|
||||
|
||||
rpcEngine_->notifyInternalError();
|
||||
return web::impl::ErrorHelper(connection, std::move(request)).sendInternalError();
|
||||
web::impl::ErrorHelper(connection, std::move(request)).sendInternalError();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
* @param ec The error code
|
||||
* @param message The message to include in the log
|
||||
*/
|
||||
inline void
|
||||
void
|
||||
fail(boost::system::error_code ec, char const* message)
|
||||
{
|
||||
if (ec == boost::asio::ssl::error::stream_truncated)
|
||||
@@ -285,8 +285,7 @@ private:
|
||||
onAccept(boost::beast::error_code ec, tcp::socket socket)
|
||||
{
|
||||
if (!ec) {
|
||||
auto ctxRef =
|
||||
ctx_ ? std::optional<std::reference_wrapper<boost::asio::ssl::context>>{ctx_.value()} : std::nullopt;
|
||||
auto ctxRef = ctx_ ? std::optional<std::reference_wrapper<boost::asio::ssl::context>>{ctx_} : std::nullopt;
|
||||
|
||||
std::make_shared<Detector<PlainSessionType, SslSessionType, HandlerType>>(
|
||||
std::move(socket), ctxRef, std::cref(tagFactory_), dosGuard_, handler_, adminVerification_
|
||||
|
||||
@@ -119,7 +119,7 @@ protected:
|
||||
util::Logger log_{"WebServer"};
|
||||
util::Logger perfLog_{"Performance"};
|
||||
|
||||
inline void
|
||||
void
|
||||
httpFail(boost::beast::error_code ec, char const* what)
|
||||
{
|
||||
// ssl::error::stream_truncated, also known as an SSL "short read",
|
||||
|
||||
@@ -54,7 +54,7 @@ struct BackendCountersTest : WithPrometheus {
|
||||
}
|
||||
|
||||
BackendCounters::PtrType const counters = BackendCounters::make();
|
||||
std::chrono::steady_clock::time_point startTime{};
|
||||
std::chrono::steady_clock::time_point startTime;
|
||||
};
|
||||
|
||||
TEST_F(BackendCountersTest, EmptyByDefault)
|
||||
|
||||
@@ -625,7 +625,7 @@ TEST_F(BackendCassandraTest, Basic)
|
||||
std::move(meta)
|
||||
);
|
||||
}
|
||||
for (auto [key, obj] : objs) {
|
||||
for (auto const& [key, obj] : objs) {
|
||||
backend->writeLedgerObject(std::string{key}, lgrInfo.seq, std::string{obj});
|
||||
}
|
||||
if (state.count(lgrInfo.seq - 1) == 0 ||
|
||||
@@ -819,8 +819,8 @@ TEST_F(BackendCassandraTest, Basic)
|
||||
auto flatten = [&](uint32_t max) {
|
||||
std::vector<std::pair<std::string, std::string>> flat;
|
||||
std::map<std::string, std::string> objs;
|
||||
for (auto [seq, diff] : state) {
|
||||
for (auto [k, v] : diff) {
|
||||
for (auto const& [seq, diff] : state) {
|
||||
for (auto const& [k, v] : diff) {
|
||||
if (seq > max) {
|
||||
if (!objs.contains(k))
|
||||
objs[k] = "";
|
||||
@@ -830,7 +830,7 @@ TEST_F(BackendCassandraTest, Basic)
|
||||
}
|
||||
}
|
||||
flat.reserve(objs.size());
|
||||
for (auto [key, value] : objs) {
|
||||
for (auto const& [key, value] : objs) {
|
||||
flat.emplace_back(key, value);
|
||||
}
|
||||
return flat;
|
||||
@@ -839,7 +839,7 @@ TEST_F(BackendCassandraTest, Basic)
|
||||
auto flattenAccountTx = [&](uint32_t max) {
|
||||
std::unordered_map<ripple::AccountID, std::vector<std::tuple<std::string, std::string, std::string>>>
|
||||
accountTx;
|
||||
for (auto [seq, map] : allAccountTx) {
|
||||
for (auto const& [seq, map] : allAccountTx) {
|
||||
if (seq > max)
|
||||
break;
|
||||
for (auto& [account, hashes] : map) {
|
||||
@@ -854,7 +854,7 @@ TEST_F(BackendCassandraTest, Basic)
|
||||
return accountTx;
|
||||
};
|
||||
|
||||
for (auto [seq, diff] : state) {
|
||||
for (auto const& [seq, diff] : state) {
|
||||
auto flat = flatten(seq);
|
||||
checkLedger(lgrInfos[seq], allTxns[seq], flat, flattenAccountTx(seq));
|
||||
}
|
||||
@@ -1234,8 +1234,8 @@ TEST_F(BackendCassandraTest, CacheIntegration)
|
||||
auto flatten = [&](uint32_t max) {
|
||||
std::vector<std::pair<std::string, std::string>> flat;
|
||||
std::map<std::string, std::string> objs;
|
||||
for (auto [seq, diff] : state) {
|
||||
for (auto [k, v] : diff) {
|
||||
for (auto const& [seq, diff] : state) {
|
||||
for (auto const& [k, v] : diff) {
|
||||
if (seq > max) {
|
||||
if (!objs.contains(k))
|
||||
objs[k] = "";
|
||||
@@ -1245,13 +1245,13 @@ TEST_F(BackendCassandraTest, CacheIntegration)
|
||||
}
|
||||
}
|
||||
flat.reserve(objs.size());
|
||||
for (auto [key, value] : objs) {
|
||||
for (auto const& [key, value] : objs) {
|
||||
flat.emplace_back(key, value);
|
||||
}
|
||||
return flat;
|
||||
};
|
||||
|
||||
for (auto [seq, diff] : state) {
|
||||
for (auto const& [seq, diff] : state) {
|
||||
auto flat = flatten(seq);
|
||||
checkLedger(lgrInfos[seq], flat);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_F(BackendCassandraBaseTest, ConnectionFailTimeout)
|
||||
{
|
||||
Settings settings;
|
||||
settings.connectionTimeout = std::chrono::milliseconds{30};
|
||||
settings.connectionInfo = Settings::ContactPoints{"127.0.0.2"};
|
||||
settings.connectionInfo = Settings::ContactPoints{.contactPoints = "127.0.0.2", .port = std::nullopt};
|
||||
|
||||
Handle const handle{settings};
|
||||
auto const f = handle.asyncConnect();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <boost/json/object.hpp>
|
||||
#include <boost/json/value_to.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@@ -137,11 +137,11 @@ struct MockPrometheusImpl : PrometheusInterface {
|
||||
MetricType&
|
||||
getMetric(std::string name, Labels labels)
|
||||
{
|
||||
auto const labelsString = labels.serialize();
|
||||
auto const key = name + labels.serialize();
|
||||
auto labelsString = labels.serialize();
|
||||
auto const key = name + labelsString;
|
||||
auto it = metrics.find(key);
|
||||
if (it == metrics.end()) {
|
||||
return makeMetric<MetricType>(std::move(name), labels.serialize());
|
||||
return makeMetric<MetricType>(std::move(name), std::move(labelsString));
|
||||
}
|
||||
auto* basePtr = it->second.get();
|
||||
auto* metricPtr = dynamic_cast<MetricType*>(basePtr);
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace http = boost::beast::http;
|
||||
class IPAdminVerificationStrategyTest : public NoLoggerFixture {
|
||||
protected:
|
||||
web::impl::IPAdminVerificationStrategy strat_;
|
||||
http::request<http::string_body> request_ = {};
|
||||
http::request<http::string_body> request_;
|
||||
};
|
||||
|
||||
TEST_F(IPAdminVerificationStrategyTest, IsAdminOnlyForIP_127_0_0_1)
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/json/parse.hpp>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
Reference in New Issue
Block a user