mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-01 01:22:27 +00:00
Compare commits
56 Commits
ximinez/di
...
bthomee/no
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
228ad1e98f | ||
|
|
c4b342a027 | ||
|
|
556d80e724 | ||
|
|
a9afd2c116 | ||
|
|
044f1e67b9 | ||
|
|
2502befb42 | ||
|
|
c3fae847f3 | ||
|
|
7f53351920 | ||
|
|
bb95a7d6cd | ||
|
|
0ad72fae8f | ||
|
|
cc383c5fb8 | ||
|
|
88715f1e5a | ||
|
|
e1477cef0c | ||
|
|
942874d7b0 | ||
|
|
79326fc6b5 | ||
|
|
48535d5226 | ||
|
|
d1a6558080 | ||
|
|
84f86b354f | ||
|
|
40a3985b02 | ||
|
|
208bd35d45 | ||
|
|
e90fbbf7b2 | ||
|
|
277450e648 | ||
|
|
e6993524ea | ||
|
|
b117ecc6a2 | ||
|
|
6c3b00c342 | ||
|
|
8c296a935a | ||
|
|
573ba82181 | ||
|
|
1542ab7e27 | ||
|
|
6374f4886d | ||
|
|
ebf336f472 | ||
|
|
ddc15ad612 | ||
|
|
82db6ac498 | ||
|
|
f749c41306 | ||
|
|
f25e47a58d | ||
|
|
2396799bd8 | ||
|
|
4855b9f96a | ||
|
|
b2f65cb7eb | ||
|
|
c523673885 | ||
|
|
caac4d63d3 | ||
|
|
29b0076fa8 | ||
|
|
c9aa1094a7 | ||
|
|
b86f69cb82 | ||
|
|
5d0bf78512 | ||
|
|
554df631c6 | ||
|
|
5e704bfdfb | ||
|
|
fe8cc02bfa | ||
|
|
061c033f52 | ||
|
|
832a7e7e4a | ||
|
|
b2371c4c02 | ||
|
|
b94a7c4b44 | ||
|
|
9b9027112d | ||
|
|
8e7889c66e | ||
|
|
d836c3788d | ||
|
|
1cb7c0293f | ||
|
|
52dabc1f79 | ||
|
|
2d78d41f7b |
10
.clang-tidy
10
.clang-tidy
@@ -87,16 +87,19 @@ Checks: "-*,
|
||||
# cppcoreguidelines-use-default-member-init, # has issues
|
||||
# cppcoreguidelines-virtual-class-destructor, # has issues
|
||||
hicpp-ignored-remove-result,
|
||||
# misc-definitions-in-headers, # has issues
|
||||
misc-const-correctness,
|
||||
misc-definitions-in-headers,
|
||||
misc-header-include-cycle,
|
||||
misc-misplaced-const,
|
||||
misc-redundant-expression,
|
||||
misc-static-assert,
|
||||
# misc-throw-by-value-catch-by-reference, # has issues
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-unused-alias-decls,
|
||||
misc-unused-using-decls,
|
||||
modernize-deprecated-headers,
|
||||
modernize-make-shared,
|
||||
modernize-make-unique,
|
||||
llvm-namespace-comment,
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
@@ -134,10 +137,7 @@ Checks: "-*,
|
||||
# ---
|
||||
# other checks that have issues that need to be resolved:
|
||||
#
|
||||
# llvm-namespace-comment,
|
||||
# misc-const-correctness,
|
||||
# misc-include-cleaner,
|
||||
# misc-redundant-expression,
|
||||
#
|
||||
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
|
||||
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable
|
||||
|
||||
@@ -44,6 +44,7 @@ libxrpl.tx > xrpl.server
|
||||
libxrpl.tx > xrpl.tx
|
||||
test.app > test.jtx
|
||||
test.app > test.rpc
|
||||
test.app > test.shamap
|
||||
test.app > test.toplevel
|
||||
test.app > test.unit_test
|
||||
test.app > xrpl.basics
|
||||
@@ -59,6 +60,7 @@ test.app > xrpl.protocol
|
||||
test.app > xrpl.rdb
|
||||
test.app > xrpl.resource
|
||||
test.app > xrpl.server
|
||||
test.app > xrpl.shamap
|
||||
test.app > xrpl.tx
|
||||
test.basics > test.jtx
|
||||
test.basics > test.unit_test
|
||||
|
||||
2
.github/workflows/check-pr-commits.yml
vendored
2
.github/workflows/check-pr-commits.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: Check PR commits
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
|
||||
# The action needs to have write permissions to post comments on the PR.
|
||||
permissions:
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
env:
|
||||
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
|
||||
run: |
|
||||
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
||||
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
|
||||
|
||||
- name: Upload clang-tidy output
|
||||
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}
|
||||
|
||||
@@ -270,14 +270,14 @@ Before running clang-tidy, you must build the project to generate required files
|
||||
Then run clang-tidy on your local changes:
|
||||
|
||||
```
|
||||
run-clang-tidy -p build src include tests
|
||||
run-clang-tidy -p build -allow-no-checks src tests
|
||||
```
|
||||
|
||||
This will check all source files in the `src`, `include` and `tests` directories using the compile commands from your `build` directory.
|
||||
If you wish to automatically fix whatever clang-tidy finds _and_ is capable of fixing, add `-fix` to the above command:
|
||||
|
||||
```
|
||||
run-clang-tidy -p build -fix src include tests
|
||||
run-clang-tidy -p build -quiet -fix -allow-no-checks src tests
|
||||
```
|
||||
|
||||
## Contracts and instrumentation
|
||||
|
||||
@@ -311,7 +311,7 @@ template <class T>
|
||||
bool
|
||||
set(T& target, T const& defaultValue, std::string const& name, Section const& section)
|
||||
{
|
||||
bool found_and_valid = set<T>(target, name, section);
|
||||
bool const found_and_valid = set<T>(target, name, section);
|
||||
if (!found_and_valid)
|
||||
target = defaultValue;
|
||||
return found_and_valid;
|
||||
|
||||
@@ -68,9 +68,7 @@ SharedIntrusive<T>::operator=(SharedIntrusive const& rhs)
|
||||
|
||||
template <class T>
|
||||
template <class TT>
|
||||
// clang-format off
|
||||
requires std::convertible_to<TT*, T*>
|
||||
// clang-format on
|
||||
requires std::convertible_to<TT*, T*>
|
||||
SharedIntrusive<T>&
|
||||
SharedIntrusive<T>::operator=(SharedIntrusive<TT> const& rhs)
|
||||
{
|
||||
@@ -101,9 +99,7 @@ SharedIntrusive<T>::operator=(SharedIntrusive&& rhs)
|
||||
|
||||
template <class T>
|
||||
template <class TT>
|
||||
// clang-format off
|
||||
requires std::convertible_to<TT*, T*>
|
||||
// clang-format on
|
||||
requires std::convertible_to<TT*, T*>
|
||||
SharedIntrusive<T>&
|
||||
SharedIntrusive<T>::operator=(SharedIntrusive<TT>&& rhs)
|
||||
{
|
||||
@@ -307,9 +303,7 @@ WeakIntrusive<T>::WeakIntrusive(SharedIntrusive<T> const& rhs) : ptr_{rhs.unsafe
|
||||
|
||||
template <class T>
|
||||
template <class TT>
|
||||
// clang-format off
|
||||
requires std::convertible_to<TT*, T*>
|
||||
// clang-format on
|
||||
requires std::convertible_to<TT*, T*>
|
||||
WeakIntrusive<T>&
|
||||
WeakIntrusive<T>::operator=(SharedIntrusive<TT> const& rhs)
|
||||
{
|
||||
@@ -454,9 +448,7 @@ SharedWeakUnion<T>::operator=(SharedWeakUnion const& rhs)
|
||||
|
||||
template <class T>
|
||||
template <class TT>
|
||||
// clang-format off
|
||||
requires std::convertible_to<TT*, T*>
|
||||
// clang-format on
|
||||
requires std::convertible_to<TT*, T*>
|
||||
SharedWeakUnion<T>&
|
||||
SharedWeakUnion<T>::operator=(SharedIntrusive<TT> const& rhs)
|
||||
{
|
||||
@@ -470,9 +462,7 @@ SharedWeakUnion<T>::operator=(SharedIntrusive<TT> const& rhs)
|
||||
|
||||
template <class T>
|
||||
template <class TT>
|
||||
// clang-format off
|
||||
requires std::convertible_to<TT*, T*>
|
||||
// clang-format on
|
||||
requires std::convertible_to<TT*, T*>
|
||||
SharedWeakUnion<T>&
|
||||
SharedWeakUnion<T>::operator=(SharedIntrusive<TT>&& rhs)
|
||||
{
|
||||
|
||||
@@ -448,7 +448,7 @@ inline void
|
||||
partialDestructorFinished(T** o)
|
||||
{
|
||||
T& self = **o;
|
||||
IntrusiveRefCounts::RefCountPair p =
|
||||
IntrusiveRefCounts::RefCountPair const p =
|
||||
self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask);
|
||||
XRPL_ASSERT(
|
||||
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),
|
||||
|
||||
@@ -94,7 +94,7 @@ class SlabAllocator
|
||||
std::uint8_t* ret;
|
||||
|
||||
{
|
||||
std::lock_guard l(m_);
|
||||
std::lock_guard const l(m_);
|
||||
|
||||
ret = l_;
|
||||
|
||||
@@ -123,7 +123,7 @@ class SlabAllocator
|
||||
{
|
||||
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
|
||||
|
||||
std::lock_guard l(m_);
|
||||
std::lock_guard const l(m_);
|
||||
|
||||
// Use memcpy to avoid unaligned UB
|
||||
// (will optimize to equivalent code)
|
||||
@@ -210,16 +210,13 @@ public:
|
||||
|
||||
// No slab can satisfy our request, so we attempt to allocate a new
|
||||
// one here:
|
||||
std::size_t size = slabSize_;
|
||||
std::size_t const size = slabSize_;
|
||||
|
||||
// We want to allocate the memory at a 2 MiB boundary, to make it
|
||||
// possible to use hugepage mappings on Linux:
|
||||
auto buf = boost::alignment::aligned_alloc(megabytes(std::size_t(2)), size);
|
||||
|
||||
// clang-format off
|
||||
if (!buf) [[unlikely]]
|
||||
return nullptr;
|
||||
// clang-format on
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
// When allocating large blocks, attempt to leverage Linux's
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
@@ -231,4 +232,11 @@ makeSlice(std::basic_string<char, Traits, Alloc> const& s)
|
||||
return Slice(s.data(), s.size());
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
Slice
|
||||
makeSlice(std::basic_string_view<char, Traits> const& s)
|
||||
{
|
||||
return Slice(s.data(), s.size());
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -66,12 +66,12 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
|
||||
|
||||
while (iter != end)
|
||||
{
|
||||
int cHigh = digitLookupTable[*iter++];
|
||||
int const cHigh = digitLookupTable[*iter++];
|
||||
|
||||
if (cHigh < 0)
|
||||
return {};
|
||||
|
||||
int cLow = digitLookupTable[*iter++];
|
||||
int const cLow = digitLookupTable[*iter++];
|
||||
|
||||
if (cLow < 0)
|
||||
return {};
|
||||
|
||||
@@ -212,7 +212,7 @@ private:
|
||||
while (in != sv.end())
|
||||
{
|
||||
std::uint32_t accum = {};
|
||||
for (std::uint32_t shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
|
||||
for (std::uint32_t const shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
|
||||
{
|
||||
if (auto const result = hexCharToUInt(*in++, shift, accum);
|
||||
result != ParseResult::okay)
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
|
||||
for (int i = WIDTH; i--;)
|
||||
{
|
||||
std::uint64_t n = carry + boost::endian::big_to_native(data_[i]) +
|
||||
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
|
||||
boost::endian::big_to_native(b.data_[i]);
|
||||
|
||||
data_[i] = boost::endian::native_to_big(static_cast<std::uint32_t>(n));
|
||||
|
||||
@@ -54,7 +54,7 @@ Throw(Args&&... args)
|
||||
|
||||
E e(std::forward<Args>(args)...);
|
||||
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
|
||||
throw e;
|
||||
throw std::move(e);
|
||||
}
|
||||
|
||||
/** Called when faulty logic causes a broken invariant. */
|
||||
|
||||
@@ -32,7 +32,7 @@ make_seed_pair() noexcept
|
||||
// state_t& operator=(state_t const&) = delete;
|
||||
};
|
||||
static state_t state;
|
||||
std::lock_guard lock(state.mutex);
|
||||
std::lock_guard const lock(state.mutex);
|
||||
return {state.dist(state.gen), state.dist(state.gen)};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,13 @@ namespace xrpl {
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
static_assert(
|
||||
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||
std::is_integral<beast::xor_shift_engine::result_type>::value &&
|
||||
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
|
||||
"The Ripple default PRNG engine must return an unsigned integral type.");
|
||||
|
||||
static_assert(
|
||||
// NOLINTNEXTLINE(misc-redundant-expression)
|
||||
std::numeric_limits<beast::xor_shift_engine::result_type>::max() >=
|
||||
std::numeric_limits<std::uint64_t>::max(),
|
||||
"The Ripple default PRNG engine return must be at least 64 bits wide.");
|
||||
@@ -58,7 +60,7 @@ default_prng()
|
||||
thread_local beast::xor_shift_engine engine = [] {
|
||||
std::uint64_t seed;
|
||||
{
|
||||
std::lock_guard lk(m);
|
||||
std::lock_guard const lk(m);
|
||||
std::uniform_int_distribution<std::uint64_t> distribution{1};
|
||||
seed = distribution(seeder);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void
|
||||
sample_one(Handler&& handler)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (m_cancel)
|
||||
throw std::logic_error("io_latency_probe is canceled");
|
||||
boost::asio::post(
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
void
|
||||
sample(Handler&& handler)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (m_cancel)
|
||||
throw std::logic_error("io_latency_probe is canceled");
|
||||
boost::asio::post(
|
||||
@@ -122,14 +122,14 @@ private:
|
||||
void
|
||||
addref()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
++m_count;
|
||||
}
|
||||
|
||||
void
|
||||
release()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (--m_count == 0)
|
||||
m_cond.notify_all();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
m_handler(elapsed);
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_probe->m_mutex);
|
||||
std::lock_guard const lock(m_probe->m_mutex);
|
||||
if (m_probe->m_cancel)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ template <
|
||||
class Allocator = std::allocator<std::pair<Key const, T>>>
|
||||
using aged_map = detail::aged_ordered_container<false, true, Key, T, Clock, Compare, Allocator>;
|
||||
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -16,4 +16,4 @@ template <
|
||||
class Allocator = std::allocator<std::pair<Key const, T>>>
|
||||
using aged_multimap = detail::aged_ordered_container<true, true, Key, T, Clock, Compare, Allocator>;
|
||||
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,4 +15,4 @@ template <
|
||||
class Allocator = std::allocator<Key>>
|
||||
using aged_multiset =
|
||||
detail::aged_ordered_container<true, false, Key, void, Clock, Compare, Allocator>;
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -15,4 +15,4 @@ template <
|
||||
class Allocator = std::allocator<Key>>
|
||||
using aged_set = detail::aged_ordered_container<false, false, Key, void, Clock, Compare, Allocator>;
|
||||
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -17,4 +17,4 @@ template <
|
||||
class Allocator = std::allocator<std::pair<Key const, T>>>
|
||||
using aged_unordered_map =
|
||||
detail::aged_unordered_container<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -17,4 +17,4 @@ template <
|
||||
class Allocator = std::allocator<std::pair<Key const, T>>>
|
||||
using aged_unordered_multimap =
|
||||
detail::aged_unordered_container<true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -17,4 +17,4 @@ template <
|
||||
using aged_unordered_multiset =
|
||||
detail::aged_unordered_container<true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
|
||||
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -16,4 +16,4 @@ template <
|
||||
class Allocator = std::allocator<Key>>
|
||||
using aged_unordered_set =
|
||||
detail::aged_unordered_container<false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
iterator
|
||||
erase(iterator pos) noexcept
|
||||
{
|
||||
Node* node = &*pos;
|
||||
Node const* node = &*pos;
|
||||
++pos;
|
||||
node->m_next->m_prev = node->m_prev;
|
||||
node->m_prev->m_next = node->m_next;
|
||||
|
||||
@@ -114,7 +114,7 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
|
||||
boost::context::fixedsize_stack(2 * 1024 * 1024),
|
||||
[&](yield_context yield) {
|
||||
f(yield);
|
||||
std::lock_guard lock{m_};
|
||||
std::lock_guard const lock{m_};
|
||||
if (--running_ == 0)
|
||||
cv_.notify_all();
|
||||
},
|
||||
|
||||
@@ -228,7 +228,7 @@ template <class>
|
||||
void
|
||||
runner::testcase(std::string const& name)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
// Name may not be empty
|
||||
BOOST_ASSERT(default_ || !name.empty());
|
||||
// Forgot to call pass or fail
|
||||
@@ -244,7 +244,7 @@ template <class>
|
||||
void
|
||||
runner::pass()
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_pass();
|
||||
@@ -255,7 +255,7 @@ template <class>
|
||||
void
|
||||
runner::fail(std::string const& reason)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_fail(reason);
|
||||
@@ -267,7 +267,7 @@ template <class>
|
||||
void
|
||||
runner::log(std::string const& s)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_log(s);
|
||||
|
||||
@@ -300,7 +300,7 @@ private:
|
||||
static suite**
|
||||
p_this_suite()
|
||||
{
|
||||
static suite* pts = nullptr;
|
||||
static suite* pts = nullptr; // NOLINT(misc-const-correctness)
|
||||
return &pts;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ struct Zero
|
||||
|
||||
namespace {
|
||||
static constexpr Zero zero{};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/** Default implementation of signum calls the method on the class. */
|
||||
template <typename T>
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
// a lock. This removes a small timing window that occurs if the
|
||||
// waiting thread is handling a spurious wakeup when closureCount_
|
||||
// drops to zero.
|
||||
std::lock_guard lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
|
||||
// Update closureCount_. Notify if stopping and closureCount_ == 0.
|
||||
if ((--closureCount_ == 0) && waitForClosures_)
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
{
|
||||
std::optional<Substitute<Closure>> ret;
|
||||
|
||||
std::lock_guard lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
if (!waitForClosures_)
|
||||
ret.emplace(*this, std::forward<Closure>(closure));
|
||||
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
bool
|
||||
joined() const
|
||||
{
|
||||
std::lock_guard lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
return waitForClosures_;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace xrpl {
|
||||
|
||||
namespace perf {
|
||||
class PerfLog;
|
||||
}
|
||||
} // namespace perf
|
||||
|
||||
class Logs;
|
||||
struct Coro_create_t
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
std::chrono::milliseconds{0})
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
int maxLimit = std::numeric_limits<int>::max();
|
||||
int const maxLimit = std::numeric_limits<int>::max();
|
||||
|
||||
auto add = [this](
|
||||
JobType jt,
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
bool
|
||||
contains(PublicKey const& nodeId)
|
||||
{
|
||||
std::lock_guard lock(this->mutex_);
|
||||
std::lock_guard const lock(this->mutex_);
|
||||
return table_.find({nodeId}) != table_.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace beast {
|
||||
class Journal;
|
||||
}
|
||||
} // namespace beast
|
||||
|
||||
namespace xrpl {
|
||||
class Application;
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace xrpl {
|
||||
// Forward declarations
|
||||
namespace NodeStore {
|
||||
class Database;
|
||||
}
|
||||
} // namespace NodeStore
|
||||
namespace Resource {
|
||||
class Manager;
|
||||
}
|
||||
} // namespace Resource
|
||||
namespace perf {
|
||||
class PerfLog;
|
||||
}
|
||||
} // namespace perf
|
||||
|
||||
// This is temporary until we migrate all code to use ServiceRegistry.
|
||||
class Application;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace xrpl {
|
||||
|
||||
namespace perf {
|
||||
class PerfLog;
|
||||
}
|
||||
} // namespace perf
|
||||
|
||||
/**
|
||||
* `Workers` is effectively a thread pool. The constructor takes a "callback"
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void
|
||||
notify()
|
||||
{
|
||||
std::lock_guard lock{m_mutex};
|
||||
std::lock_guard const lock{m_mutex};
|
||||
++m_count;
|
||||
m_cond.notify_one();
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ public:
|
||||
SelfType
|
||||
operator++(int)
|
||||
{
|
||||
SelfType temp(*this);
|
||||
SelfType const temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
@@ -649,7 +649,7 @@ public:
|
||||
SelfType
|
||||
operator--(int)
|
||||
{
|
||||
SelfType temp(*this);
|
||||
SelfType const temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
// Inject appropriate pseudo-transactions
|
||||
for (auto const& it : actions)
|
||||
{
|
||||
STTx amendTx(ttAMENDMENT, [&it, seq = lastClosedLedger->seq() + 1](auto& obj) {
|
||||
STTx const amendTx(ttAMENDMENT, [&it, seq = lastClosedLedger->seq() + 1](auto& obj) {
|
||||
obj.setAccountID(sfAccount, AccountID());
|
||||
obj.setFieldH256(sfAmendment, it.first);
|
||||
obj.setFieldU32(sfLedgerSequence, seq);
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
namespace xrpl {
|
||||
using CachedSLEs = TaggedCache<uint256, SLE const>;
|
||||
}
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
bool
|
||||
startWork(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto it = map_.find(seq);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void
|
||||
finishWork(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
map_.erase(seq);
|
||||
await_.notify_all();
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
bool
|
||||
pending(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
return map_.find(seq) != map_.end();
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
std::map<LedgerIndex, bool>
|
||||
getSnapshot() const
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
return map_;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ template <class = void>
|
||||
std::size_t
|
||||
write_varint(void* p0, std::size_t v)
|
||||
{
|
||||
// NOLINTNEXTLINE(misc-const-correctness)
|
||||
std::uint8_t* p = reinterpret_cast<std::uint8_t*>(p0);
|
||||
do
|
||||
{
|
||||
|
||||
@@ -244,7 +244,15 @@ message TMGetObjectByHash {
|
||||
|
||||
message TMLedgerNode {
|
||||
required bytes nodedata = 1;
|
||||
optional bytes nodeid = 2; // missing for ledger base data
|
||||
|
||||
// Used when protocol version <2.3. Not set for ledger base data.
|
||||
optional bytes nodeid = 2;
|
||||
|
||||
// Used when protocol version >=2.3. Neither value is set for ledger base data.
|
||||
oneof reference {
|
||||
bytes id = 3; // Set for inner nodes.
|
||||
uint32 depth = 4; // Set for leaf nodes.
|
||||
}
|
||||
}
|
||||
|
||||
enum TMLedgerInfoType {
|
||||
|
||||
@@ -102,7 +102,7 @@ template <typename T>
|
||||
T
|
||||
toAmount(Issue const& issue, Number const& n, Number::rounding_mode mode = Number::getround())
|
||||
{
|
||||
saveNumberRoundMode rm(Number::getround());
|
||||
saveNumberRoundMode const rm(Number::getround());
|
||||
if (isXRP(issue))
|
||||
Number::setround(mode);
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ operator<=>(Issue const& lhs, Issue const& rhs)
|
||||
inline Issue const&
|
||||
xrpIssue()
|
||||
{
|
||||
static Issue issue{xrpCurrency(), xrpAccount()};
|
||||
static Issue const issue{xrpCurrency(), xrpAccount()};
|
||||
return issue;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ xrpIssue()
|
||||
inline Issue const&
|
||||
noIssue()
|
||||
{
|
||||
static Issue issue{noCurrency(), noAccount()};
|
||||
static Issue const issue{noCurrency(), noAccount()};
|
||||
return issue;
|
||||
}
|
||||
|
||||
|
||||
@@ -304,8 +304,8 @@ Quality::ceil_TAmounts_helper(
|
||||
|
||||
// Use the existing STAmount implementation for now, but consider
|
||||
// replacing with code specific to IOUAMount and XRPAmount
|
||||
Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out));
|
||||
STAmount stLim(toSTAmount(limit));
|
||||
Amounts const stAmt(toSTAmount(amount.in), toSTAmount(amount.out));
|
||||
STAmount const stLim(toSTAmount(limit));
|
||||
Amounts const stRes = ((*this).*ceil_function)(stAmt, stLim, roundUp...);
|
||||
return TAmounts<In, Out>(toAmount<In>(stRes.in), toAmount<Out>(stRes.out));
|
||||
}
|
||||
|
||||
@@ -6,4 +6,4 @@ namespace xrpl {
|
||||
|
||||
using LedgerHash = uint256;
|
||||
|
||||
}
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -532,7 +532,7 @@ STAmount::fromNumber(A const& a, Number const& number)
|
||||
{
|
||||
bool const negative = number.mantissa() < 0;
|
||||
Number const working{negative ? -number : number};
|
||||
Asset asset{a};
|
||||
Asset const asset{a};
|
||||
if (asset.integral())
|
||||
{
|
||||
std::uint64_t const intValue = static_cast<std::int64_t>(working);
|
||||
@@ -716,7 +716,7 @@ roundToAsset(
|
||||
std::int32_t scale,
|
||||
Number::rounding_mode rounding = Number::getround())
|
||||
{
|
||||
NumberRoundModeGuard mg(rounding);
|
||||
NumberRoundModeGuard const mg(rounding);
|
||||
STAmount const ret{asset, value};
|
||||
if (ret.integral())
|
||||
return ret;
|
||||
|
||||
@@ -83,7 +83,7 @@ to_json(T const& t)
|
||||
|
||||
namespace detail {
|
||||
class STVar;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// VFALCO TODO fix this restriction on copy assignment.
|
||||
//
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace xrpl {
|
||||
class Rules;
|
||||
namespace test {
|
||||
class Invariants_test;
|
||||
}
|
||||
} // namespace test
|
||||
|
||||
class STLedgerEntry final : public STObject, public CountedObject<STLedgerEntry>
|
||||
{
|
||||
|
||||
@@ -1153,7 +1153,7 @@ STObject::getFieldByValue(SField const& field) const
|
||||
if (!rf)
|
||||
throwFieldNotFound(field);
|
||||
|
||||
SerializedTypeID id = rf->getSType();
|
||||
SerializedTypeID const id = rf->getSType();
|
||||
|
||||
if (id == STI_NOTPRESENT)
|
||||
return V(); // optional field not present
|
||||
@@ -1180,7 +1180,7 @@ STObject::getFieldByConstRef(SField const& field, V const& empty) const
|
||||
if (!rf)
|
||||
throwFieldNotFound(field);
|
||||
|
||||
SerializedTypeID id = rf->getSType();
|
||||
SerializedTypeID const id = rf->getSType();
|
||||
|
||||
if (id == STI_NOTPRESENT)
|
||||
return empty; // optional field not present
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
int
|
||||
add32(T i)
|
||||
{
|
||||
int ret = mData.size();
|
||||
int const ret = mData.size();
|
||||
mData.push_back(static_cast<unsigned char>((i >> 24) & 0xff));
|
||||
mData.push_back(static_cast<unsigned char>((i >> 16) & 0xff));
|
||||
mData.push_back(static_cast<unsigned char>((i >> 8) & 0xff));
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
int
|
||||
add64(T i)
|
||||
{
|
||||
int ret = mData.size();
|
||||
int const ret = mData.size();
|
||||
mData.push_back(static_cast<unsigned char>((i >> 56) & 0xff));
|
||||
mData.push_back(static_cast<unsigned char>((i >> 48) & 0xff));
|
||||
mData.push_back(static_cast<unsigned char>((i >> 40) & 0xff));
|
||||
@@ -299,7 +299,7 @@ template <class Iter>
|
||||
int
|
||||
Serializer::addVL(Iter begin, Iter end, int len)
|
||||
{
|
||||
int ret = addEncoded(len);
|
||||
int const ret = addEncoded(len);
|
||||
for (; begin != end; ++begin)
|
||||
{
|
||||
addRaw(begin->data(), begin->size());
|
||||
|
||||
@@ -4,4 +4,4 @@ namespace xrpl {
|
||||
|
||||
enum class TxSearched { All, Some, Unknown };
|
||||
|
||||
}
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -25,16 +25,10 @@ extern nonPresentObject_t nonPresentObject;
|
||||
|
||||
// Concept to constrain STVar constructors, which
|
||||
// instantiate ST* types from SerializedTypeID
|
||||
// clang-format off
|
||||
template <typename... Args>
|
||||
concept ValidConstructSTArgs =
|
||||
(std::is_same_v<
|
||||
std::tuple<std::remove_cvref_t<Args>...>,
|
||||
std::tuple<SField>> ||
|
||||
std::is_same_v<
|
||||
std::tuple<std::remove_cvref_t<Args>...>,
|
||||
std::tuple<SerialIter, SField>>);
|
||||
// clang-format on
|
||||
(std::is_same_v<std::tuple<std::remove_cvref_t<Args>...>, std::tuple<SField>> ||
|
||||
std::is_same_v<std::tuple<std::remove_cvref_t<Args>...>, std::tuple<SerialIter, SField>>);
|
||||
|
||||
// "variant" that can hold any type of serialized object
|
||||
// and includes a small-object allocation optimization.
|
||||
|
||||
@@ -11,66 +11,65 @@
|
||||
#error "undefined macro: XRPL_RETIRE_FIX"
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Add new amendments to the top of this list.
|
||||
// Keep it sorted in reverse chronological order.
|
||||
|
||||
XRPL_FIX (Security3_1_3, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PermissionedDomainInvariant, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (ExpiredNFTokenOfferRemoval, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (BatchInnerSigs, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionDelegationV1_1, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DirectoryLimit, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (IncludeKeyletFields, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicMPT, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (TokenEscrowV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PriceOracleOrder, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (MPTDeliveredAmount, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMClawbackRounding, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(TokenEscrow, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EnforceNFTokenTrustlineV2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_3, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDEX, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Batch, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(SingleAssetVault, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PayChanCancelAfter, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Security3_1_3, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PermissionedDomainInvariant, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (ExpiredNFTokenOfferRemoval, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (BatchInnerSigs, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionDelegationV1_1, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DirectoryLimit, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (IncludeKeyletFields, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicMPT, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (TokenEscrowV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PriceOracleOrder, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (MPTDeliveredAmount, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMClawbackRounding, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(TokenEscrow, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EnforceNFTokenTrustlineV2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_3, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDEX, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Batch, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(SingleAssetVault, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PayChanCancelAfter, Supported::yes, VoteBehavior::DefaultNo)
|
||||
// Check flags in Credential transactions
|
||||
XRPL_FIX (InvalidTxFlags, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (FrozenLPTokenTransfer, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DeepFreeze, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDomains, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicNFT, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
// InvariantsV1_1 will be changes to Supported::yes when all the
|
||||
// invariants expected to be included under it are complete.
|
||||
XRPL_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (InnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (ReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PreviousTxnID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (XChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EmptyDID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PriceOracle, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMOverflowOffer, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (InnerObjTemplate, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenReserve, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (FillOrKill, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (InvalidTxFlags, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (FrozenLPTokenTransfer, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DeepFreeze, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PermissionedDomains, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DynamicNFT, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
// InvariantsV1_1 will be changed to Supported::yes when all the invariants expected to be included
|
||||
// under it are complete.
|
||||
XRPL_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (InnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (ReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMv1_1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (PreviousTxnID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (XChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (EmptyDID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(PriceOracle, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMOverflowOffer, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (InnerObjTemplate, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenReserve, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (FillOrKill, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||
|
||||
// The following amendments are obsolete, but must remain supported
|
||||
// because they could potentially get enabled.
|
||||
@@ -144,5 +143,3 @@ XRPL_RETIRE_FEATURE(SortedDirectories)
|
||||
XRPL_RETIRE_FEATURE(TicketBatch)
|
||||
XRPL_RETIRE_FEATURE(TickSize)
|
||||
XRPL_RETIRE_FEATURE(TrustSetAuth)
|
||||
|
||||
// clang-format on
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#error "undefined macro: TYPED_SFIELD"
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
|
||||
// untyped
|
||||
UNTYPED_SFIELD(sfLedgerEntry, LEDGERENTRY, 257)
|
||||
@@ -421,5 +420,3 @@ UNTYPED_SFIELD(sfAcceptedCredentials, ARRAY, 28)
|
||||
UNTYPED_SFIELD(sfPermissions, ARRAY, 29)
|
||||
UNTYPED_SFIELD(sfRawTransactions, ARRAY, 30)
|
||||
UNTYPED_SFIELD(sfBatchSigners, ARRAY, 31, SField::sMD_Default, SField::notSigning)
|
||||
|
||||
// clang-format on
|
||||
|
||||
@@ -15,7 +15,7 @@ enum class TokenCodecErrc {
|
||||
overflowAdd,
|
||||
unknown,
|
||||
};
|
||||
}
|
||||
} // namespace xrpl
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
inline xrpl::detail::TokenCodecErrcCategory const&
|
||||
TokenCodecErrcCategory()
|
||||
{
|
||||
static xrpl::detail::TokenCodecErrcCategory c;
|
||||
static xrpl::detail::TokenCodecErrcCategory const c;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
3
include/xrpl/protocol_autogen/.clang-tidy
Normal file
3
include/xrpl/protocol_autogen/.clang-tidy
Normal file
@@ -0,0 +1,3 @@
|
||||
# This disables all checks for this directory and its subdirectories
|
||||
Checks: "-*"
|
||||
InheritParentConfig: false
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace soci {
|
||||
class session;
|
||||
}
|
||||
} // namespace soci
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace sqlite_api {
|
||||
struct sqlite3;
|
||||
}
|
||||
} // namespace sqlite_api
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
|
||||
@@ -5,38 +5,30 @@
|
||||
namespace xrpl {
|
||||
namespace Resource {
|
||||
|
||||
// clang-format off
|
||||
/** Schedule of fees charged for imposing load on the server. */
|
||||
/** @{ */
|
||||
extern Charge const feeMalformedRequest; // A request that we can immediately
|
||||
// tell is invalid
|
||||
extern Charge const feeRequestNoReply; // A request that we cannot satisfy
|
||||
extern Charge const feeInvalidSignature; // An object whose signature we had
|
||||
// to check and it failed
|
||||
extern Charge const feeUselessData; // Data we have no use for
|
||||
extern Charge const feeInvalidData; // Data we have to verify before
|
||||
// rejecting
|
||||
extern Charge const feeMalformedRequest; // A request that we can immediately tell is invalid.
|
||||
extern Charge const feeRequestNoReply; // A request that we cannot satisfy.
|
||||
extern Charge const feeInvalidSignature; // An object whose signature we had to check that failed.
|
||||
extern Charge const feeUselessData; // Data we have no use for.
|
||||
extern Charge const feeInvalidData; // Data we have to verify before rejecting.
|
||||
|
||||
// RPC loads
|
||||
extern Charge const feeMalformedRPC; // An RPC request that we can
|
||||
// immediately tell is invalid.
|
||||
extern Charge const feeReferenceRPC; // A default "reference" unspecified
|
||||
// load
|
||||
extern Charge const feeExceptionRPC; // RPC load that causes an exception
|
||||
extern Charge const feeMediumBurdenRPC; // A somewhat burdensome RPC load
|
||||
extern Charge const feeHeavyBurdenRPC; // A very burdensome RPC load
|
||||
extern Charge const feeMalformedRPC; // An RPC request that we can immediately tell is invalid.
|
||||
extern Charge const feeReferenceRPC; // A default "reference" unspecified load.
|
||||
extern Charge const feeExceptionRPC; // RPC load that causes an exception.
|
||||
extern Charge const feeMediumBurdenRPC; // A somewhat burdensome RPC load.
|
||||
extern Charge const feeHeavyBurdenRPC; // A very burdensome RPC load.
|
||||
|
||||
// Peer loads
|
||||
extern Charge const feeTrivialPeer; // Requires no reply
|
||||
extern Charge const feeModerateBurdenPeer; // Requires some work
|
||||
extern Charge const feeHeavyBurdenPeer; // Extensive work
|
||||
extern Charge const feeTrivialPeer; // Requires no reply.
|
||||
extern Charge const feeModerateBurdenPeer; // Requires some work.
|
||||
extern Charge const feeHeavyBurdenPeer; // Extensive work.
|
||||
|
||||
// Administrative
|
||||
extern Charge const feeWarning; // The cost of receiving a warning
|
||||
extern Charge const feeDrop; // The cost of being dropped for
|
||||
// excess load
|
||||
extern Charge const feeWarning; // The cost of receiving a warning.
|
||||
extern Charge const feeDrop; // The cost of being dropped for excess load.
|
||||
/** @} */
|
||||
// clang-format on
|
||||
|
||||
} // namespace Resource
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindInbound, address.at_port(0)), // Key
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindOutbound, address), // Key
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindUnlimited, address.at_port(1)), // Key
|
||||
@@ -191,11 +191,11 @@ public:
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
Json::Value ret(Json::objectValue);
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
for (auto& inboundEntry : inbound_)
|
||||
{
|
||||
int localBalance = inboundEntry.local_balance.value(now);
|
||||
int const localBalance = inboundEntry.local_balance.value(now);
|
||||
if ((localBalance + inboundEntry.remote_balance) >= threshold)
|
||||
{
|
||||
Json::Value& entry = (ret[inboundEntry.to_string()] = Json::objectValue);
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
}
|
||||
for (auto& outboundEntry : outbound_)
|
||||
{
|
||||
int localBalance = outboundEntry.local_balance.value(now);
|
||||
int const localBalance = outboundEntry.local_balance.value(now);
|
||||
if ((localBalance + outboundEntry.remote_balance) >= threshold)
|
||||
{
|
||||
Json::Value& entry = (ret[outboundEntry.to_string()] = Json::objectValue);
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
for (auto& adminEntry : admin_)
|
||||
{
|
||||
int localBalance = adminEntry.local_balance.value(now);
|
||||
int const localBalance = adminEntry.local_balance.value(now);
|
||||
if ((localBalance + adminEntry.remote_balance) >= threshold)
|
||||
{
|
||||
Json::Value& entry = (ret[adminEntry.to_string()] = Json::objectValue);
|
||||
@@ -236,7 +236,7 @@ public:
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
Gossip gossip;
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
gossip.items.reserve(inbound_.size());
|
||||
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
{
|
||||
auto const elapsed = m_clock.now();
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = importTable_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(origin), // Key
|
||||
@@ -318,7 +318,7 @@ public:
|
||||
void
|
||||
periodicActivity()
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
auto const elapsed = m_clock.now();
|
||||
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
void
|
||||
erase(Table::iterator iter)
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
Entry& entry(iter->second);
|
||||
XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used");
|
||||
inactive_.erase(inactive_.iterator_to(entry));
|
||||
@@ -384,14 +384,14 @@ public:
|
||||
void
|
||||
acquire(Entry& entry)
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
++entry.refcount;
|
||||
}
|
||||
|
||||
void
|
||||
release(Entry& entry)
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
if (--entry.refcount == 0)
|
||||
{
|
||||
JLOG(m_journal.debug()) << "Inactive " << entry;
|
||||
@@ -442,7 +442,7 @@ public:
|
||||
if (!context.empty())
|
||||
context = " (" + context + ")";
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
int const balance(entry.add(fee.cost(), now));
|
||||
JLOG(getStream(fee.cost(), m_journal)) << "Charging " << entry << " for " << fee << context;
|
||||
@@ -455,7 +455,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
bool notify(false);
|
||||
auto const elapsed = m_clock.now();
|
||||
if (entry.balance(m_clock.now()) >= warningThreshold && elapsed != entry.lastWarningTime)
|
||||
@@ -478,7 +478,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
bool drop(false);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
int const balance(entry.balance(now));
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
int
|
||||
balance(Entry& entry)
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
return entry.balance(m_clock.now());
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ public:
|
||||
{
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
{
|
||||
beast::PropertyStream::Set s("inbound", map);
|
||||
|
||||
@@ -39,28 +39,28 @@ public:
|
||||
setRemoteFee(std::uint32_t f)
|
||||
{
|
||||
JLOG(j_.trace()) << "setRemoteFee: " << f;
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
remoteTxnLoadFee_ = f;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getRemoteFee() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return remoteTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getLocalFee() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return localTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getClusterFee() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return clusterTxnLoadFee_;
|
||||
}
|
||||
|
||||
@@ -73,14 +73,14 @@ public:
|
||||
std::uint32_t
|
||||
getLoadFactor() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return std::max({clusterTxnLoadFee_, localTxnLoadFee_, remoteTxnLoadFee_});
|
||||
}
|
||||
|
||||
std::pair<std::uint32_t, std::uint32_t>
|
||||
getScalingFactors() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
|
||||
return std::make_pair(
|
||||
std::max(localTxnLoadFee_, remoteTxnLoadFee_),
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
setClusterFee(std::uint32_t fee)
|
||||
{
|
||||
JLOG(j_.trace()) << "setClusterFee: " << fee;
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
clusterTxnLoadFee_ = fee;
|
||||
}
|
||||
|
||||
@@ -103,14 +103,14 @@ public:
|
||||
bool
|
||||
isLoadedLocal() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
bool
|
||||
isLoadedCluster() const
|
||||
{
|
||||
std::lock_guard sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) ||
|
||||
(clusterTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ public:
|
||||
void
|
||||
for_each_manifest(Function&& f) const
|
||||
{
|
||||
std::shared_lock lock{mutex_};
|
||||
std::shared_lock const lock{mutex_};
|
||||
for (auto const& [_, manifest] : map_)
|
||||
{
|
||||
(void)_;
|
||||
@@ -429,7 +429,7 @@ public:
|
||||
void
|
||||
for_each_manifest(PreFun&& pf, EachFun&& f) const
|
||||
{
|
||||
std::shared_lock lock{mutex_};
|
||||
std::shared_lock const lock{mutex_};
|
||||
pf(map_.size());
|
||||
for (auto const& [_, manifest] : map_)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace boost {
|
||||
namespace asio {
|
||||
namespace ssl {
|
||||
class context;
|
||||
}
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ BaseHTTPPeer<Handler, Impl>::on_write(error_code const& ec, std::size_t bytes_tr
|
||||
return fail(ec, "write");
|
||||
bytes_out_ += bytes_transferred;
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
wq2_.clear();
|
||||
wq2_.reserve(wq_.size());
|
||||
std::swap(wq2_, wq_);
|
||||
@@ -392,7 +392,7 @@ BaseHTTPPeer<Handler, Impl>::write(void const* buf, std::size_t bytes)
|
||||
if (bytes == 0)
|
||||
return;
|
||||
if ([&] {
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
wq_.emplace_back(buf, bytes);
|
||||
return wq_.size() == 1 && wq2_.size() == 0;
|
||||
}())
|
||||
@@ -443,7 +443,7 @@ BaseHTTPPeer<Handler, Impl>::complete()
|
||||
complete_ = true;
|
||||
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (!wq_.empty() && !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
@@ -476,7 +476,7 @@ BaseHTTPPeer<Handler, Impl>::close(bool graceful)
|
||||
{
|
||||
graceful_ = true;
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (!wq_.empty() || !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ BaseWSPeer<Handler, Impl>::on_ping_pong(
|
||||
{
|
||||
if (kind == boost::beast::websocket::frame_type::pong)
|
||||
{
|
||||
boost::beast::string_view p(payload_.begin());
|
||||
boost::beast::string_view const p(payload_.begin());
|
||||
if (payload == p)
|
||||
{
|
||||
close_on_timer_ = false;
|
||||
|
||||
@@ -165,7 +165,7 @@ io_list::work::destroy()
|
||||
return;
|
||||
std::function<void(void)> f;
|
||||
{
|
||||
std::lock_guard lock(ios_->m_);
|
||||
std::lock_guard const lock(ios_->m_);
|
||||
ios_->map_.erase(this);
|
||||
if (--ios_->n_ == 0 && ios_->closed_)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ io_list::emplace(Args&&... args)
|
||||
auto sp = std::make_shared<T>(std::forward<Args>(args)...);
|
||||
decltype(sp) dead;
|
||||
|
||||
std::lock_guard lock(m_);
|
||||
std::lock_guard const lock(m_);
|
||||
if (!closed_)
|
||||
{
|
||||
++n_;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -253,7 +254,7 @@ public:
|
||||
bool
|
||||
getNodeFat(
|
||||
SHAMapNodeID const& wanted,
|
||||
std::vector<std::pair<SHAMapNodeID, Blob>>& data,
|
||||
std::vector<std::tuple<SHAMapNodeID, Blob, bool>>& data,
|
||||
bool fatLeaves,
|
||||
std::uint32_t depth) const;
|
||||
|
||||
@@ -280,10 +281,45 @@ public:
|
||||
void
|
||||
serializeRoot(Serializer& s) const;
|
||||
|
||||
/** Add a root node to the SHAMap during synchronization.
|
||||
*
|
||||
* This function is used when receiving the root node of a SHAMap from a peer during ledger
|
||||
* synchronization. The node must already have been deserialized.
|
||||
*
|
||||
* @param hash The expected hash of the root node.
|
||||
* @param rootNode A deserialized root node to add.
|
||||
* @param filter Optional sync filter to track received nodes.
|
||||
* @return Status indicating whether the node was useful, duplicate, or invalid.
|
||||
*
|
||||
* @note This function expects the rootNode to be a valid, deserialized SHAMapTreeNode. The
|
||||
* caller is responsible for deserialization and basic validation before calling this
|
||||
* function.
|
||||
*/
|
||||
SHAMapAddNode
|
||||
addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter* filter);
|
||||
addRootNode(
|
||||
SHAMapHash const& hash,
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode> rootNode,
|
||||
SHAMapSyncFilter const* filter);
|
||||
|
||||
/** Add a known node at a specific position in the SHAMap during synchronization.
|
||||
*
|
||||
* This function is used when receiving nodes from peers during ledger synchronization. The node
|
||||
* is inserted at the position specified by nodeID. The node must already have been
|
||||
* deserialized.
|
||||
*
|
||||
* @param nodeID The position in the tree where this node belongs.
|
||||
* @param treeNode A deserialized tree node to add.
|
||||
* @param filter Optional sync filter to track received nodes.
|
||||
* @return Status indicating whether the node was useful, duplicate, or invalid.
|
||||
*
|
||||
* @note This function expects that the caller has already validated that the nodeID is
|
||||
* consistent with the node's content.
|
||||
*/
|
||||
SHAMapAddNode
|
||||
addKnownNode(SHAMapNodeID const& nodeID, Slice const& rawNode, SHAMapSyncFilter* filter);
|
||||
addKnownNode(
|
||||
SHAMapNodeID const& nodeID,
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode> treeNode,
|
||||
SHAMapSyncFilter const* filter);
|
||||
|
||||
// status functions
|
||||
void
|
||||
@@ -344,11 +380,11 @@ private:
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
fetchNodeNT(SHAMapHash const& hash) const;
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
|
||||
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
fetchNode(SHAMapHash const& hash) const;
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
|
||||
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
|
||||
|
||||
/** Update hashes up to the root */
|
||||
void
|
||||
@@ -420,7 +456,7 @@ private:
|
||||
descendAsync(
|
||||
SHAMapInnerNode* parent,
|
||||
int branch,
|
||||
SHAMapSyncFilter* filter,
|
||||
SHAMapSyncFilter const* filter,
|
||||
bool& pending,
|
||||
descendCallback&&) const;
|
||||
|
||||
@@ -429,7 +465,7 @@ private:
|
||||
SHAMapInnerNode* parent,
|
||||
SHAMapNodeID const& parentID,
|
||||
int branch,
|
||||
SHAMapSyncFilter* filter) const;
|
||||
SHAMapSyncFilter const* filter) const;
|
||||
|
||||
// Non-storing
|
||||
// Does not hook the returned node to its parent
|
||||
|
||||
@@ -141,6 +141,7 @@ make_shamapitem(uint256 const& tag, Slice data)
|
||||
XRPL_ASSERT(
|
||||
data.size() <= megabytes<std::size_t>(16), "xrpl::make_shamapitem : maximum input size");
|
||||
|
||||
// NOLINTNEXTLINE(misc-const-correctness)
|
||||
std::uint8_t* raw = detail::slabber.allocate(data.size());
|
||||
|
||||
// If we can't grab memory from the slab allocators, we fall back to
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace xrpl {
|
||||
namespace path {
|
||||
namespace detail {
|
||||
struct FlowDebugInfo;
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace path
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace path {
|
||||
|
||||
namespace detail {
|
||||
struct FlowDebugInfo;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
/** RippleCalc calculates the quality of a payment path.
|
||||
|
||||
|
||||
@@ -147,29 +147,26 @@ public:
|
||||
|
||||
/**
|
||||
If this step is a DirectStepI, return the quality in of the dst account.
|
||||
*/
|
||||
*/
|
||||
virtual std::uint32_t
|
||||
lineQualityIn(ReadView const&) const
|
||||
{
|
||||
return QUALITY_ONE;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
/**
|
||||
Find an upper bound of quality for the step
|
||||
|
||||
@param v view to query the ledger state from
|
||||
@param prevStepDir Set to DebtDirection::redeems if the previous step redeems.
|
||||
@return A pair. The first element is the upper bound of quality for the step, or std::nullopt if the
|
||||
step is dry. The second element will be set to DebtDirection::redeems if this steps redeems,
|
||||
DebtDirection:issues if this step issues.
|
||||
@note it is an upper bound because offers on the books may be unfunded.
|
||||
If there is always a funded offer at the tip of the book, then we could
|
||||
rename this `theoreticalQuality` rather than `qualityUpperBound`. It
|
||||
could still differ from the actual quality, but except for "dust" amounts,
|
||||
it should be a good estimate for the actual quality.
|
||||
*/
|
||||
// clang-format on
|
||||
@return A pair. The first element is the upper bound of quality for the step, or std::nullopt
|
||||
if the step is dry. The second element will be set to DebtDirection::redeems if this
|
||||
steps redeems, DebtDirection:issues if this step issues.
|
||||
@note It is an upper bound because offers on the books may be unfunded. If there is always a
|
||||
funded offer at the tip of the book, then we could rename this `theoreticalQuality`
|
||||
rather than `qualityUpperBound`. It could still differ from the actual quality, but
|
||||
except for "dust" amounts, it should be a good estimate for the actual quality.
|
||||
*/
|
||||
virtual std::pair<std::optional<Quality>, DebtDirection>
|
||||
qualityUpperBound(ReadView const& v, DebtDirection prevStepDir) const = 0;
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ flow(
|
||||
|
||||
std::size_t const maxTries = 1000;
|
||||
std::size_t curTry = 0;
|
||||
std::uint32_t maxOffersToConsider = 1500;
|
||||
std::uint32_t const maxOffersToConsider = 1500;
|
||||
std::uint32_t offersConsidered = 0;
|
||||
|
||||
// There is a bug in gcc that incorrectly warns about using uninitialized
|
||||
|
||||
@@ -22,7 +22,7 @@ reduceOffer(auto const& amount)
|
||||
static Number const reducedOfferPct(9999, -4);
|
||||
|
||||
// Make sure the result is always less than amount or zero.
|
||||
NumberRoundModeGuard mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
return amount * reducedOfferPct;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,6 @@ withinRelativeDistance(Quality const& calcQuality, Quality const& reqQuality, Nu
|
||||
* @param dist requested relative distance
|
||||
* @return true if within dist, false otherwise
|
||||
*/
|
||||
// clang-format off
|
||||
template <typename Amt>
|
||||
requires(
|
||||
std::is_same_v<Amt, STAmount> || std::is_same_v<Amt, IOUAmount> ||
|
||||
@@ -134,7 +133,6 @@ withinRelativeDistance(Amt const& calc, Amt const& req, Number const& dist)
|
||||
auto const [min, max] = std::minmax(calc, req);
|
||||
return ((max - min) / max) < dist;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
/** Solve quadratic equation to find takerGets or takerPays. Round
|
||||
* to minimize the amount in order to maximize the quality.
|
||||
@@ -175,7 +173,7 @@ getAMMOfferStartWithTakerGets(
|
||||
if (targetQuality.rate() == beast::zero)
|
||||
return std::nullopt;
|
||||
|
||||
NumberRoundModeGuard mg(Number::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::to_nearest);
|
||||
auto const f = feeMult(tfee);
|
||||
auto const a = 1;
|
||||
auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out;
|
||||
@@ -242,7 +240,7 @@ getAMMOfferStartWithTakerPays(
|
||||
if (targetQuality.rate() == beast::zero)
|
||||
return std::nullopt;
|
||||
|
||||
NumberRoundModeGuard mg(Number::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::to_nearest);
|
||||
auto const f = feeMult(tfee);
|
||||
auto const& a = f;
|
||||
auto const b = pool.in * (1 + f);
|
||||
@@ -437,7 +435,7 @@ swapAssetIn(TAmounts<TIn, TOut> const& pool, TIn const& assetIn, std::uint16_t t
|
||||
// 1-fee
|
||||
// maximize:
|
||||
// fee
|
||||
saveNumberRoundMode _{Number::getround()};
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
@@ -501,7 +499,7 @@ swapAssetOut(TAmounts<TIn, TOut> const& pool, TOut const& assetOut, std::uint16_
|
||||
// maximize:
|
||||
// tfee/100000
|
||||
|
||||
saveNumberRoundMode _{Number::getround()};
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
|
||||
@@ -20,7 +20,7 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
|
||||
Throw<std::runtime_error>("Invalid source file");
|
||||
|
||||
using archive_ptr = std::unique_ptr<struct archive, void (*)(struct archive*)>;
|
||||
archive_ptr ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
|
||||
archive_ptr const ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
|
||||
if (!ar)
|
||||
Throw<std::runtime_error>("Failed to allocate archive");
|
||||
|
||||
@@ -36,7 +36,8 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
|
||||
Throw<std::runtime_error>(archive_error_string(ar.get()));
|
||||
}
|
||||
|
||||
archive_ptr aw{archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
|
||||
archive_ptr const aw{
|
||||
archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
|
||||
if (!aw)
|
||||
Throw<std::runtime_error>("Failed to allocate archive");
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ BasicConfig::section(std::string const& name)
|
||||
Section const&
|
||||
BasicConfig::section(std::string const& name) const
|
||||
{
|
||||
static Section none("");
|
||||
static Section const none("");
|
||||
auto const iter = map_.find(name);
|
||||
if (iter == map_.end())
|
||||
return none;
|
||||
|
||||
@@ -26,7 +26,7 @@ getFileContents(
|
||||
using namespace boost::filesystem;
|
||||
using namespace boost::system::errc;
|
||||
|
||||
path fullPath{canonical(sourcePath, ec)};
|
||||
path const fullPath{canonical(sourcePath, ec)};
|
||||
if (ec)
|
||||
return {};
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ Logs::open(boost::filesystem::path const& pathToLogFile)
|
||||
beast::Journal::Sink&
|
||||
Logs::get(std::string const& name)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
auto const result = sinks_.emplace(name, makeSink(name, thresh_));
|
||||
return *result.first->second;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ Logs::threshold() const
|
||||
void
|
||||
Logs::threshold(beast::severities::Severity thresh)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
thresh_ = thresh;
|
||||
for (auto& sink : sinks_)
|
||||
sink.second->threshold(thresh);
|
||||
@@ -155,7 +155,7 @@ std::vector<std::pair<std::string, std::string>>
|
||||
Logs::partition_severities() const
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> list;
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
list.reserve(sinks_.size());
|
||||
for (auto const& [name, sink] : sinks_)
|
||||
list.emplace_back(name, toString(fromSeverity(sink->threshold())));
|
||||
@@ -171,7 +171,7 @@ Logs::write(
|
||||
{
|
||||
std::string s;
|
||||
format(s, text, level, partition);
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
file_.writeln(s);
|
||||
if (!silent_)
|
||||
std::cerr << s << '\n';
|
||||
@@ -183,7 +183,7 @@ Logs::write(
|
||||
std::string
|
||||
Logs::rotate()
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
bool const wasOpened = file_.closeAndReopen();
|
||||
if (wasOpened)
|
||||
return "The log file was closed and reopened.";
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
std::unique_ptr<beast::Journal::Sink>
|
||||
set(std::unique_ptr<beast::Journal::Sink> sink)
|
||||
{
|
||||
std::lock_guard _(m_);
|
||||
std::lock_guard const _(m_);
|
||||
|
||||
using std::swap;
|
||||
swap(holder_, sink);
|
||||
@@ -431,7 +431,7 @@ public:
|
||||
beast::Journal::Sink&
|
||||
get()
|
||||
{
|
||||
std::lock_guard _(m_);
|
||||
std::lock_guard const _(m_);
|
||||
return sink_.get();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,7 +161,7 @@ Number::Guard::push(T d) noexcept
|
||||
inline unsigned
|
||||
Number::Guard::pop() noexcept
|
||||
{
|
||||
unsigned d = (digits_ & 0xF000'0000'0000'0000) >> 60;
|
||||
unsigned const d = (digits_ & 0xF000'0000'0000'0000) >> 60;
|
||||
digits_ <<= 4;
|
||||
return d;
|
||||
}
|
||||
@@ -325,7 +325,7 @@ Number::externalToInternal(rep mantissa)
|
||||
// int128_t, negate that, and cast it back down to the internalrep
|
||||
// In practice, this is only going to cover the case of
|
||||
// std::numeric_limits<rep>::min().
|
||||
int128_t temp = mantissa;
|
||||
int128_t const temp = mantissa;
|
||||
return static_cast<internalrep>(-temp);
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ Number::operator+=(Number const& y)
|
||||
uint128_t xm = mantissa_;
|
||||
auto xe = exponent_;
|
||||
|
||||
bool yn = y.negative_;
|
||||
bool const yn = y.negative_;
|
||||
uint128_t ym = y.mantissa_;
|
||||
auto ye = y.exponent_;
|
||||
Guard g;
|
||||
@@ -644,14 +644,14 @@ Number::operator*=(Number const& y)
|
||||
// *m = mantissa
|
||||
// *e = exponent
|
||||
|
||||
bool xn = negative_;
|
||||
int xs = xn ? -1 : 1;
|
||||
bool const xn = negative_;
|
||||
int const xs = xn ? -1 : 1;
|
||||
internalrep xm = mantissa_;
|
||||
auto xe = exponent_;
|
||||
|
||||
bool yn = y.negative_;
|
||||
int ys = yn ? -1 : 1;
|
||||
internalrep ym = y.mantissa_;
|
||||
bool const yn = y.negative_;
|
||||
int const ys = yn ? -1 : 1;
|
||||
internalrep const ym = y.mantissa_;
|
||||
auto ye = y.exponent_;
|
||||
|
||||
auto zm = uint128_t(xm) * uint128_t(ym);
|
||||
@@ -706,13 +706,13 @@ Number::operator/=(Number const& y)
|
||||
// *m = mantissa
|
||||
// *e = exponent
|
||||
|
||||
bool np = negative_;
|
||||
int ns = (np ? -1 : 1);
|
||||
bool const np = negative_;
|
||||
int const ns = (np ? -1 : 1);
|
||||
auto nm = mantissa_;
|
||||
auto ne = exponent_;
|
||||
|
||||
bool dp = y.negative_;
|
||||
int ds = (dp ? -1 : 1);
|
||||
bool const dp = y.negative_;
|
||||
int const ds = (dp ? -1 : 1);
|
||||
auto dm = y.mantissa_;
|
||||
auto de = y.exponent_;
|
||||
|
||||
@@ -728,7 +728,7 @@ Number::operator/=(Number const& y)
|
||||
// f can be up to 10^(38-19) = 10^19 safely
|
||||
static_assert(smallRange.log == 15);
|
||||
static_assert(largeRange.log == 18);
|
||||
bool small = Number::getMantissaScale() == MantissaRange::small;
|
||||
bool const small = Number::getMantissaScale() == MantissaRange::small;
|
||||
uint128_t const f = small ? 100'000'000'000'000'000 : 10'000'000'000'000'000'000ULL;
|
||||
XRPL_ASSERT_PARTS(f >= minMantissa * 10, "Number::operator/=", "factor expected size");
|
||||
|
||||
@@ -980,8 +980,8 @@ root(Number f, unsigned d)
|
||||
auto const di = static_cast<int>(d);
|
||||
auto ex = [e = e, di = di]() // Euclidean remainder of e/d
|
||||
{
|
||||
int k = (e >= 0 ? e : e - (di - 1)) / di;
|
||||
int k2 = e - (k * di);
|
||||
int const k = (e >= 0 ? e : e - (di - 1)) / di;
|
||||
int const k2 = e - (k * di);
|
||||
if (k2 == 0)
|
||||
return 0;
|
||||
return di - k2;
|
||||
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
void
|
||||
asyncHandlersComplete()
|
||||
{
|
||||
std::unique_lock<std::mutex> lk{m_mut};
|
||||
std::unique_lock<std::mutex> const lk{m_mut};
|
||||
m_asyncHandlersCompleted = true;
|
||||
m_cv.notify_all();
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
if (m_stopped.exchange(false))
|
||||
{
|
||||
{
|
||||
std::lock_guard lk{m_mut};
|
||||
std::lock_guard const lk{m_mut};
|
||||
m_asyncHandlersCompleted = false;
|
||||
}
|
||||
addReference();
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
return;
|
||||
|
||||
std::string const name(m_work.front().names.back());
|
||||
HandlerType handler(m_work.front().handler);
|
||||
HandlerType const handler(m_work.front().handler);
|
||||
|
||||
m_work.front().names.pop_back();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ bool
|
||||
parseUrl(parsedURL& pUrl, std::string const& strUrl)
|
||||
{
|
||||
// scheme://username:password@hostname:port/rest
|
||||
static boost::regex reUrl(
|
||||
static boost::regex const reUrl(
|
||||
"(?i)\\`\\s*"
|
||||
// required scheme
|
||||
"([[:alpha:]][-+.[:alpha:][:digit:]]*?):"
|
||||
|
||||
@@ -103,7 +103,7 @@ std::size_t constexpr decoded_size(std::size_t n)
|
||||
std::size_t
|
||||
encode(void* dest, void const* src, std::size_t len)
|
||||
{
|
||||
char* out = static_cast<char*>(dest);
|
||||
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
|
||||
char const* in = static_cast<char const*>(src);
|
||||
auto const tab = base64::get_alphabet();
|
||||
|
||||
@@ -154,7 +154,7 @@ encode(void* dest, void const* src, std::size_t len)
|
||||
std::pair<std::size_t, std::size_t>
|
||||
decode(void* dest, char const* src, std::size_t len)
|
||||
{
|
||||
char* out = static_cast<char*>(dest);
|
||||
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
|
||||
auto in = reinterpret_cast<unsigned char const*>(src);
|
||||
unsigned char c3[3]{}, c4[4]{};
|
||||
int i = 0;
|
||||
|
||||
@@ -140,7 +140,7 @@ initAnonymous(boost::asio::ssl::context& context)
|
||||
|
||||
auto const ts = std::time(nullptr) - (25 * 60 * 60);
|
||||
|
||||
int ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));
|
||||
int const ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));
|
||||
|
||||
buf[ret] = 0;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ seconds_clock_thread::~seconds_clock_thread()
|
||||
XRPL_ASSERT(
|
||||
thread_.joinable(), "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable");
|
||||
{
|
||||
std::lock_guard lock(mut_);
|
||||
std::lock_guard const lock(mut_);
|
||||
stop_ = true;
|
||||
} // publish stop_ asap so if waiting thread times-out, it will see it
|
||||
cv_.notify_one();
|
||||
|
||||
@@ -62,7 +62,7 @@ chopUInt(int& value, int limit, std::string& input)
|
||||
return std::isdigit(c, std::locale::classic());
|
||||
});
|
||||
|
||||
std::string item(input.begin(), left_iter);
|
||||
std::string const item(input.begin(), left_iter);
|
||||
|
||||
// Must not be empty
|
||||
if (item.empty())
|
||||
@@ -320,7 +320,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs)
|
||||
{
|
||||
XRPL_ASSERT(!isNumeric(right), "beast::compare : both inputs non-numeric");
|
||||
|
||||
int result = left.compare(right);
|
||||
int const result = left.compare(right);
|
||||
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
@@ -4,5 +4,5 @@ namespace beast {
|
||||
namespace insight {
|
||||
|
||||
Collector::~Collector() = default;
|
||||
}
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
Group::ptr const&
|
||||
get(std::string const& name) override
|
||||
{
|
||||
std::pair<Items::iterator, bool> result(m_items.emplace(name, Group::ptr()));
|
||||
std::pair<Items::iterator, bool> const result(m_items.emplace(name, Group::ptr()));
|
||||
Group::ptr& group(result.first->second);
|
||||
if (result.second)
|
||||
group = std::make_shared<GroupImp>(name, m_collector);
|
||||
|
||||
@@ -5,5 +5,5 @@ namespace beast {
|
||||
namespace insight {
|
||||
|
||||
HookImpl::~HookImpl() = default;
|
||||
}
|
||||
} // namespace insight
|
||||
} // namespace beast
|
||||
|
||||
@@ -293,14 +293,14 @@ public:
|
||||
void
|
||||
add(StatsDMetricBase& metric)
|
||||
{
|
||||
std::lock_guard _(metricsLock_);
|
||||
std::lock_guard const _(metricsLock_);
|
||||
metrics_.push_back(metric);
|
||||
}
|
||||
|
||||
void
|
||||
remove(StatsDMetricBase& metric)
|
||||
{
|
||||
std::lock_guard _(metricsLock_);
|
||||
std::lock_guard const _(metricsLock_);
|
||||
metrics_.erase(metrics_.iterator_to(metric));
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard _(metricsLock_);
|
||||
std::lock_guard const _(metricsLock_);
|
||||
|
||||
for (auto& m : metrics_)
|
||||
m.do_process();
|
||||
|
||||
@@ -120,8 +120,7 @@ operator>>(std::istream& is, Endpoint& endpoint)
|
||||
addrStr += i;
|
||||
|
||||
// don't exceed a reasonable length...
|
||||
if (addrStr.size() == INET6_ADDRSTRLEN ||
|
||||
((readTo != 0) && readTo == ':' && addrStr.size() > 15))
|
||||
if (addrStr.size() == INET6_ADDRSTRLEN || (readTo == ':' && addrStr.size() > 15))
|
||||
{
|
||||
is.setstate(std::ios_base::failbit);
|
||||
return is;
|
||||
|
||||
@@ -158,7 +158,7 @@ PropertyStream::Source::Source(std::string const& name)
|
||||
|
||||
PropertyStream::Source::~Source()
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
if (parent_ != nullptr)
|
||||
parent_->remove(*this);
|
||||
removeAll();
|
||||
@@ -174,8 +174,8 @@ void
|
||||
PropertyStream::Source::add(Source& source)
|
||||
{
|
||||
std::lock(lock_, source.lock_);
|
||||
std::lock_guard lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard lk2(source.lock_, std::adopt_lock);
|
||||
std::lock_guard const lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard const lk2(source.lock_, std::adopt_lock);
|
||||
|
||||
XRPL_ASSERT(
|
||||
source.parent_ == nullptr, "beast::PropertyStream::Source::add : null source parent");
|
||||
@@ -187,8 +187,8 @@ void
|
||||
PropertyStream::Source::remove(Source& child)
|
||||
{
|
||||
std::lock(lock_, child.lock_);
|
||||
std::lock_guard lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard lk2(child.lock_, std::adopt_lock);
|
||||
std::lock_guard const lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard const lk2(child.lock_, std::adopt_lock);
|
||||
|
||||
XRPL_ASSERT(
|
||||
child.parent_ == this, "beast::PropertyStream::Source::remove : child parent match");
|
||||
@@ -199,10 +199,10 @@ PropertyStream::Source::remove(Source& child)
|
||||
void
|
||||
PropertyStream::Source::removeAll()
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
for (auto iter = children_.begin(); iter != children_.end();)
|
||||
{
|
||||
std::lock_guard _cl((*iter)->lock_);
|
||||
std::lock_guard const _cl((*iter)->lock_);
|
||||
remove(*(*iter));
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ PropertyStream::Source::write(PropertyStream& stream)
|
||||
Map map(m_name, stream);
|
||||
onWrite(map);
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
for (auto& child : children_)
|
||||
child.source().write(stream);
|
||||
@@ -299,9 +299,9 @@ PropertyStream::Source::peel_name(std::string* path)
|
||||
if (path->empty())
|
||||
return "";
|
||||
|
||||
std::string::const_iterator first = (*path).begin();
|
||||
std::string::const_iterator last = (*path).end();
|
||||
std::string::const_iterator pos = std::find(first, last, '/');
|
||||
std::string::const_iterator const first = (*path).begin();
|
||||
std::string::const_iterator const last = (*path).end();
|
||||
std::string::const_iterator const pos = std::find(first, last, '/');
|
||||
std::string s(first, pos);
|
||||
|
||||
if (pos != last)
|
||||
@@ -320,11 +320,11 @@ PropertyStream::Source::peel_name(std::string* path)
|
||||
PropertyStream::Source*
|
||||
PropertyStream::Source::find_one_deep(std::string const& name)
|
||||
{
|
||||
Source* found = find_one(name);
|
||||
Source* found = find_one(name); // NOLINT(misc-const-correctness)
|
||||
if (found != nullptr)
|
||||
return found;
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
for (auto& s : children_)
|
||||
{
|
||||
found = s.source().find_one_deep(name);
|
||||
@@ -355,7 +355,7 @@ PropertyStream::Source::find_path(std::string path)
|
||||
PropertyStream::Source*
|
||||
PropertyStream::Source::find_one(std::string const& name)
|
||||
{
|
||||
std::lock_guard _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
for (auto& s : children_)
|
||||
{
|
||||
if (s.source().m_name == name)
|
||||
|
||||
@@ -22,7 +22,7 @@ HashRouter::emplace(uint256 const& key) -> std::pair<Entry&, bool>
|
||||
void
|
||||
HashRouter::addSuppression(uint256 const& key)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
emplace(key);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer)
|
||||
std::pair<bool, std::optional<Stopwatch::time_point>>
|
||||
HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto result = emplace(key);
|
||||
result.first.addPeer(peer);
|
||||
@@ -46,7 +46,7 @@ HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer)
|
||||
bool
|
||||
HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer, HashRouterFlags& flags)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto [s, created] = emplace(key);
|
||||
s.addPeer(peer);
|
||||
@@ -61,7 +61,7 @@ HashRouter::shouldProcess(
|
||||
HashRouterFlags& flags,
|
||||
std::chrono::seconds tx_interval)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto result = emplace(key);
|
||||
auto& s = result.first;
|
||||
@@ -73,7 +73,7 @@ HashRouter::shouldProcess(
|
||||
HashRouterFlags
|
||||
HashRouter::getFlags(uint256 const& key)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
return emplace(key).first.getFlags();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
|
||||
{
|
||||
XRPL_ASSERT(static_cast<bool>(flags), "xrpl::HashRouter::setFlags : valid input");
|
||||
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto& s = emplace(key).first;
|
||||
|
||||
@@ -97,7 +97,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
|
||||
auto
|
||||
HashRouter::shouldRelay(uint256 const& key) -> std::optional<std::set<PeerShortID>>
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto& s = emplace(key).first;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ JobQueue::JobQueue(
|
||||
job_count = m_collector->make_gauge("job_count");
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
|
||||
for (auto const& x : JobTypes::instance())
|
||||
{
|
||||
@@ -52,7 +52,7 @@ JobQueue::~JobQueue()
|
||||
void
|
||||
JobQueue::collect()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
job_count = m_jobSet.size();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
|
||||
"requires no threads");
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
auto result = m_jobSet.emplace(type, name, ++m_lastJob, data.load(), func);
|
||||
auto const& job = *result.first;
|
||||
|
||||
@@ -106,9 +106,9 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
|
||||
int
|
||||
JobQueue::getJobCount(JobType t) const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
|
||||
JobDataMap::const_iterator c = m_jobData.find(t);
|
||||
JobDataMap::const_iterator const c = m_jobData.find(t);
|
||||
|
||||
return (c == m_jobData.end()) ? 0 : c->second.waiting;
|
||||
}
|
||||
@@ -116,9 +116,9 @@ JobQueue::getJobCount(JobType t) const
|
||||
int
|
||||
JobQueue::getJobCountTotal(JobType t) const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
|
||||
JobDataMap::const_iterator c = m_jobData.find(t);
|
||||
JobDataMap::const_iterator const c = m_jobData.find(t);
|
||||
|
||||
return (c == m_jobData.end()) ? 0 : (c->second.waiting + c->second.running);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ JobQueue::getJobCountGE(JobType t) const
|
||||
// return the number of jobs at this priority level or greater
|
||||
int ret = 0;
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
|
||||
for (auto const& x : m_jobData)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ JobQueue::getJobCountGE(JobType t) const
|
||||
std::unique_ptr<LoadEvent>
|
||||
JobQueue::makeLoadEvent(JobType t, std::string const& name)
|
||||
{
|
||||
JobDataMap::iterator iter(m_jobData.find(t));
|
||||
JobDataMap::iterator const iter(m_jobData.find(t));
|
||||
XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::makeLoadEvent : valid job type input");
|
||||
|
||||
if (iter == m_jobData.end())
|
||||
@@ -158,7 +158,7 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed)
|
||||
if (isStopped())
|
||||
LogicError("JobQueue::addLoadEvents() called after JobQueue stopped");
|
||||
|
||||
JobDataMap::iterator iter(m_jobData.find(t));
|
||||
JobDataMap::iterator const iter(m_jobData.find(t));
|
||||
XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::addLoadEvents : valid job type input");
|
||||
iter->second.load().addSamples(count, elapsed);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ JobQueue::getJson(int c)
|
||||
|
||||
Json::Value priorities = Json::arrayValue;
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
|
||||
for (auto& x : m_jobData)
|
||||
{
|
||||
@@ -192,10 +192,10 @@ JobQueue::getJson(int c)
|
||||
|
||||
JobTypeData& data(x.second);
|
||||
|
||||
LoadMonitor::Stats stats(data.stats());
|
||||
LoadMonitor::Stats const stats(data.stats());
|
||||
|
||||
int waiting(data.waiting);
|
||||
int running(data.running);
|
||||
int const waiting(data.waiting);
|
||||
int const running(data.running);
|
||||
|
||||
if ((stats.count != 0) || (waiting != 0) || (stats.latencyPeak != 0ms) || (running != 0))
|
||||
{
|
||||
@@ -238,7 +238,7 @@ JobQueue::rendezvous()
|
||||
JobTypeData&
|
||||
JobQueue::getJobTypeData(JobType type)
|
||||
{
|
||||
JobDataMap::iterator c(m_jobData.find(type));
|
||||
JobDataMap::iterator const c(m_jobData.find(type));
|
||||
XRPL_ASSERT(c != m_jobData.end(), "xrpl::JobQueue::getJobTypeData : valid job type input");
|
||||
|
||||
// NIKB: This is ugly and I hate it. We must remove jtINVALID completely
|
||||
@@ -338,12 +338,12 @@ JobQueue::processTask(int instance)
|
||||
{
|
||||
Job job;
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
getNextJob(job);
|
||||
++m_processCount;
|
||||
}
|
||||
type = job.getType();
|
||||
JobTypeData& data(getJobTypeData(type));
|
||||
JobTypeData const& data(getJobTypeData(type));
|
||||
JLOG(m_journal.trace()) << "Doing " << data.name() << "job";
|
||||
|
||||
// The amount of time that the job was in the queue
|
||||
@@ -365,7 +365,7 @@ JobQueue::processTask(int instance)
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
// Job should be destroyed before stopping
|
||||
// otherwise destructors with side effects can access
|
||||
// parent objects that are already destroyed.
|
||||
|
||||
@@ -104,7 +104,7 @@ LoadMonitor::addLoadSample(LoadEvent const& s)
|
||||
void
|
||||
LoadMonitor::addSamples(int count, std::chrono::milliseconds latency)
|
||||
{
|
||||
std::lock_guard sl(mutex_);
|
||||
std::lock_guard const sl(mutex_);
|
||||
|
||||
update();
|
||||
mCounts += count;
|
||||
@@ -136,7 +136,7 @@ LoadMonitor::isOverTarget(std::chrono::milliseconds avg, std::chrono::millisecon
|
||||
bool
|
||||
LoadMonitor::isOver()
|
||||
{
|
||||
std::lock_guard sl(mutex_);
|
||||
std::lock_guard const sl(mutex_);
|
||||
|
||||
update();
|
||||
|
||||
@@ -153,7 +153,7 @@ LoadMonitor::getStats()
|
||||
using namespace std::chrono_literals;
|
||||
Stats stats;
|
||||
|
||||
std::lock_guard sl(mutex_);
|
||||
std::lock_guard const sl(mutex_);
|
||||
|
||||
update();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/core/PerfLog.h>
|
||||
#include <xrpl/core/detail/Workers.h>
|
||||
|
||||
@@ -96,11 +95,13 @@ Workers::stop()
|
||||
{
|
||||
setNumberOfThreads(0);
|
||||
|
||||
// Wait until all workers have paused AND no tasks are actively running.
|
||||
// Both conditions are needed because m_allPaused (mutex-protected) and
|
||||
// m_runningTaskCount (atomic) are not synchronized under the same lock,
|
||||
// so m_allPaused can momentarily be true while a task is still finishing.
|
||||
std::unique_lock<std::mutex> lk{m_mut};
|
||||
m_cv.wait(lk, [this] { return m_allPaused; });
|
||||
m_cv.wait(lk, [this] { return m_allPaused && numberOfCurrentlyRunningTasks() == 0; });
|
||||
lk.unlock();
|
||||
|
||||
XRPL_ASSERT(numberOfCurrentlyRunningTasks() == 0, "xrpl::Workers::stop : zero running tasks");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -120,7 +121,7 @@ Workers::deleteWorkers(beast::LockFreeStack<Worker>& stack)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
Worker* const worker = stack.pop_front();
|
||||
Worker const* const worker = stack.pop_front();
|
||||
|
||||
if (worker != nullptr)
|
||||
{
|
||||
@@ -149,7 +150,7 @@ Workers::Worker::Worker(Workers& workers, std::string const& threadName, int con
|
||||
Workers::Worker::~Worker()
|
||||
{
|
||||
{
|
||||
std::lock_guard lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
++wakeCount_;
|
||||
shouldExit_ = true;
|
||||
}
|
||||
@@ -161,7 +162,7 @@ Workers::Worker::~Worker()
|
||||
void
|
||||
Workers::Worker::notify()
|
||||
{
|
||||
std::lock_guard lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
++wakeCount_;
|
||||
wakeup_.notify_one();
|
||||
}
|
||||
@@ -177,7 +178,7 @@ Workers::Worker::run()
|
||||
//
|
||||
if (++m_workers.m_activeCount == 1)
|
||||
{
|
||||
std::lock_guard lk{m_workers.m_mut};
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
m_workers.m_allPaused = false;
|
||||
}
|
||||
|
||||
@@ -215,7 +216,18 @@ Workers::Worker::run()
|
||||
//
|
||||
++m_workers.m_runningTaskCount;
|
||||
m_workers.m_callback.processTask(instance_);
|
||||
--m_workers.m_runningTaskCount;
|
||||
|
||||
// When the running task count drops to zero, wake stop() which
|
||||
// may be waiting for both m_allPaused and zero running tasks.
|
||||
// Locking m_mut before notify_all() prevents a lost wakeup:
|
||||
// it serializes against the predicate check inside stop()'s
|
||||
// cv.wait(), ensuring the notification is not missed between
|
||||
// the predicate evaluation and the actual sleep.
|
||||
if (--m_workers.m_runningTaskCount == 0)
|
||||
{
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
m_workers.m_cv.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
// Any worker that goes into the paused list must
|
||||
@@ -229,7 +241,7 @@ Workers::Worker::run()
|
||||
//
|
||||
if (--m_workers.m_activeCount == 0)
|
||||
{
|
||||
std::lock_guard lk{m_workers.m_mut};
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
m_workers.m_allPaused = true;
|
||||
m_workers.m_cv.notify_all();
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ RFC1751::wsrch(std::string const& strWord, int iMin, int iMax)
|
||||
while (iResult < 0 && iMin != iMax)
|
||||
{
|
||||
// Have a range to search.
|
||||
int iMid = iMin + ((iMax - iMin) / 2);
|
||||
int iDir = strWord.compare(s_dictionary[iMid]);
|
||||
int const iMid = iMin + ((iMax - iMin) / 2);
|
||||
int const iDir = strWord.compare(s_dictionary[iMid]);
|
||||
|
||||
if (iDir == 0)
|
||||
{
|
||||
@@ -349,7 +349,7 @@ RFC1751::etob(std::string& strData, std::vector<std::string> vsHuman)
|
||||
|
||||
for (auto& strWord : vsHuman)
|
||||
{
|
||||
int l = strWord.length();
|
||||
int const l = strWord.length();
|
||||
|
||||
if (l > 4 || l < 1)
|
||||
return -1;
|
||||
|
||||
@@ -42,7 +42,7 @@ csprng_engine::mix_entropy(void* buffer, std::size_t count)
|
||||
e = rd();
|
||||
}
|
||||
|
||||
std::lock_guard lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
// We add data to the pool, but we conservatively assume that
|
||||
// it contributes no actual entropy.
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
void
|
||||
start(CollectionType ct)
|
||||
{
|
||||
char ch = (ct == array) ? openBracket : openBrace;
|
||||
char const ch = (ct == array) ? openBracket : openBrace;
|
||||
output({&ch, 1});
|
||||
stack_.push(Collection());
|
||||
stack_.top().type = ct;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user