mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
Merge branch 'pratik/otel-phase9-metric-gap-fill' into pratik/otel-phase10-workload-validation
This commit is contained in:
@@ -7,6 +7,7 @@ Checks: "-*,
|
||||
bugprone-bad-signal-to-kill-thread,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-casting-through-void,
|
||||
bugprone-capturing-this-in-member-variable,
|
||||
bugprone-chained-comparison,
|
||||
bugprone-compare-pointer-to-member-virtual-function,
|
||||
bugprone-copy-constructor-init,
|
||||
@@ -28,6 +29,7 @@ Checks: "-*,
|
||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
||||
bugprone-misplaced-pointer-arithmetic-in-alloc,
|
||||
bugprone-misplaced-widening-cast,
|
||||
bugprone-misleading-setter-of-reference,
|
||||
bugprone-move-forwarding-reference,
|
||||
bugprone-multi-level-implicit-pointer-conversion,
|
||||
bugprone-multiple-new-in-one-expression,
|
||||
@@ -85,6 +87,7 @@ Checks: "-*,
|
||||
cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||
cppcoreguidelines-use-default-member-init,
|
||||
cppcoreguidelines-use-enum-class,
|
||||
cppcoreguidelines-virtual-class-destructor,
|
||||
hicpp-ignored-remove-result,
|
||||
misc-const-correctness,
|
||||
@@ -109,6 +112,7 @@ Checks: "-*,
|
||||
modernize-use-nodiscard,
|
||||
modernize-use-override,
|
||||
modernize-use-ranges,
|
||||
modernize-use-scoped-lock,
|
||||
modernize-use-starts-ends-with,
|
||||
modernize-use-std-numbers,
|
||||
modernize-use-using,
|
||||
@@ -122,6 +126,7 @@ Checks: "-*,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-trivially-destructible,
|
||||
readability-ambiguous-smartptr-reset-call,
|
||||
readability-avoid-nested-conditional-operator,
|
||||
readability-avoid-return-with-void-value,
|
||||
readability-braces-around-statements,
|
||||
|
||||
0
.github/scripts/levelization/generate.py
vendored
Executable file → Normal file
0
.github/scripts/levelization/generate.py
vendored
Executable file → Normal file
12
.github/scripts/rename/README.md
vendored
12
.github/scripts/rename/README.md
vendored
@@ -1,11 +1,11 @@
|
||||
## Renaming ripple(d) to xrpl(d)
|
||||
|
||||
In the initial phases of development of the XRPL, the open source codebase was
|
||||
called "xrpld" and it remains with that name even today. Today, over 1000
|
||||
called "rippled" and it remains with that name even today. Today, over 1000
|
||||
nodes run the application, and code contributions have been submitted by
|
||||
developers located around the world. The XRPL community is larger than ever.
|
||||
In light of the decentralized and diversified nature of XRPL, we will rename any
|
||||
references to `ripple` and `xrpld` to `xrpl` and `xrpld`, when appropriate.
|
||||
references to `ripple` and `rippled` to `xrpl` and `xrpld`, when appropriate.
|
||||
|
||||
See [here](https://xls.xrpl.org/xls/XLS-0095-rename-rippled-to-xrpld.html) for
|
||||
more information.
|
||||
@@ -22,17 +22,17 @@ run from the repository root.
|
||||
2. `.github/scripts/rename/copyright.sh`: This script will remove superfluous
|
||||
copyright notices.
|
||||
3. `.github/scripts/rename/cmake.sh`: This script will rename all CMake files
|
||||
from `RippleXXX.cmake` or `XrpldXXX.cmake` to `XrplXXX.cmake`, and any
|
||||
references to `ripple` and `xrpld` (with or without capital letters) to
|
||||
from `RippleXXX.cmake` or `RippledXXX.cmake` to `XrplXXX.cmake`, and any
|
||||
references to `ripple` and `rippled` (with or without capital letters) to
|
||||
`xrpl` and `xrpld`, respectively. The name of the binary will remain as-is,
|
||||
and will only be renamed to `xrpld` by a later script.
|
||||
4. `.github/scripts/rename/binary.sh`: This script will rename the binary from
|
||||
`xrpld` to `xrpld`, and reverses the symlink so that `xrpld` points to
|
||||
`rippled` to `xrpld`, and reverses the symlink so that `rippled` points to
|
||||
the `xrpld` binary.
|
||||
5. `.github/scripts/rename/namespace.sh`: This script will rename the C++
|
||||
namespaces from `ripple` to `xrpl`.
|
||||
6. `.github/scripts/rename/config.sh`: This script will rename the config from
|
||||
`xrpld.cfg` to `xrpld.cfg`, and updating the code accordingly. The old
|
||||
`rippled.cfg` to `xrpld.cfg`, and updating the code accordingly. The old
|
||||
filename will still be accepted.
|
||||
7. `.github/scripts/rename/docs.sh`: This script will rename any lingering
|
||||
references of `ripple(d)` to `xrpl(d)` in code, comments, and documentation.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
namespace xrpl {
|
||||
|
||||
// DEPRECATED use beast::severities::Severity instead
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum LogSeverity {
|
||||
lsINVALID = -1, // used to indicate an invalid severity
|
||||
lsTRACE = 0, // Very low-level progress information, details inside
|
||||
@@ -207,6 +208,8 @@ public:
|
||||
fromString(std::string const& s);
|
||||
|
||||
private:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
// Maximum line length for log messages.
|
||||
// If the message exceeds this length it will be truncated with
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
* @tparam LockType The type of lock to use
|
||||
* @return A lock on the mutex and a reference to the protected data
|
||||
*/
|
||||
template <template <typename...> typename LockType = std::lock_guard>
|
||||
template <template <typename...> typename LockType = std::scoped_lock>
|
||||
Lock<ProtectedDataType const, LockType, MutexType>
|
||||
lock() const
|
||||
{
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
* @tparam LockType The type of lock to use
|
||||
* @return A lock on the mutex and a reference to the protected data
|
||||
*/
|
||||
template <template <typename...> typename LockType = std::lock_guard>
|
||||
template <template <typename...> typename LockType = std::scoped_lock>
|
||||
Lock<ProtectedDataType, LockType, MutexType>
|
||||
lock()
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ isPowerOfTen(T value)
|
||||
struct MantissaRange
|
||||
{
|
||||
using rep = std::uint64_t;
|
||||
enum mantissa_scale { small, large };
|
||||
enum class mantissa_scale { small, large };
|
||||
|
||||
explicit constexpr MantissaRange(mantissa_scale scale_)
|
||||
: min(getMin(scale_)), log(logTen(min).value_or(-1)), scale(scale_)
|
||||
@@ -88,9 +88,9 @@ private:
|
||||
{
|
||||
switch (scale_)
|
||||
{
|
||||
case small:
|
||||
case mantissa_scale::small:
|
||||
return 1'000'000'000'000'000ULL;
|
||||
case large:
|
||||
case mantissa_scale::large:
|
||||
return 1'000'000'000'000'000'000ULL;
|
||||
default:
|
||||
// Since this can never be called outside a non-constexpr
|
||||
@@ -384,7 +384,7 @@ public:
|
||||
root2(Number f);
|
||||
|
||||
// Thread local rounding control. Default is to_nearest
|
||||
enum rounding_mode { to_nearest, towards_zero, downward, upward };
|
||||
enum class rounding_mode { to_nearest, towards_zero, downward, upward };
|
||||
static rounding_mode
|
||||
getround();
|
||||
// Returns previously set mode
|
||||
@@ -443,14 +443,14 @@ private:
|
||||
static thread_local rounding_mode mode_;
|
||||
// The available ranges for mantissa
|
||||
|
||||
constexpr static MantissaRange smallRange{MantissaRange::small};
|
||||
constexpr static MantissaRange smallRange{MantissaRange::mantissa_scale::small};
|
||||
static_assert(isPowerOfTen(smallRange.min));
|
||||
static_assert(smallRange.min == 1'000'000'000'000'000LL);
|
||||
static_assert(smallRange.max == 9'999'999'999'999'999LL);
|
||||
static_assert(smallRange.log == 15);
|
||||
static_assert(smallRange.min < maxRep);
|
||||
static_assert(smallRange.max < maxRep);
|
||||
constexpr static MantissaRange largeRange{MantissaRange::large};
|
||||
constexpr static MantissaRange largeRange{MantissaRange::mantissa_scale::large};
|
||||
static_assert(isPowerOfTen(largeRange.min));
|
||||
static_assert(largeRange.min == 1'000'000'000'000'000'000ULL);
|
||||
static_assert(largeRange.max == internalrep(9'999'999'999'999'999'999ULL));
|
||||
@@ -759,9 +759,9 @@ to_string(MantissaRange::mantissa_scale const& scale)
|
||||
{
|
||||
switch (scale)
|
||||
{
|
||||
case MantissaRange::small:
|
||||
case MantissaRange::mantissa_scale::small:
|
||||
return "small";
|
||||
case MantissaRange::large:
|
||||
case MantissaRange::mantissa_scale::large:
|
||||
return "large";
|
||||
default:
|
||||
throw std::runtime_error("Bad scale");
|
||||
|
||||
@@ -92,7 +92,7 @@ class SlabAllocator
|
||||
std::uint8_t* ret = nullptr; // NOLINT(misc-const-correctness)
|
||||
|
||||
{
|
||||
std::lock_guard const l(m_);
|
||||
std::scoped_lock const l(m_);
|
||||
|
||||
ret = l_;
|
||||
|
||||
@@ -121,7 +121,7 @@ class SlabAllocator
|
||||
{
|
||||
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
|
||||
|
||||
std::lock_guard const l(m_);
|
||||
std::scoped_lock const l(m_);
|
||||
|
||||
// Use memcpy to avoid unaligned UB
|
||||
// (will optimize to equivalent code)
|
||||
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
|
||||
private:
|
||||
SharedPointerType
|
||||
initialFetch(key_type const& key, std::lock_guard<mutex_type> const& l);
|
||||
initialFetch(key_type const& key, std::scoped_lock<mutex_type> const& l);
|
||||
|
||||
void
|
||||
collect_metrics();
|
||||
@@ -266,7 +266,7 @@ private:
|
||||
typename KeyValueCacheType::map_type& partition,
|
||||
SweptPointersVector& stuffToSweep,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::lock_guard<std::recursive_mutex> const&);
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
|
||||
[[nodiscard]] std::thread
|
||||
sweepHelper(
|
||||
@@ -275,7 +275,7 @@ private:
|
||||
typename KeyOnlyCacheType::map_type& partition,
|
||||
SweptPointersVector&,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::lock_guard<std::recursive_mutex> const&);
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
|
||||
beast::Journal m_journal;
|
||||
clock_type& m_clock;
|
||||
|
||||
@@ -69,7 +69,7 @@ inline std::size_t
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
size() const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
return m_cache.size();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ inline int
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
getCacheSize() const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
return m_cache_count;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ inline int
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
getTrackSize() const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
return m_cache.size();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ inline float
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
getHitRate()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto const total = static_cast<float>(m_hits + m_misses);
|
||||
return m_hits * (100.0f / std::max(1.0f, total));
|
||||
}
|
||||
@@ -138,7 +138,7 @@ inline void
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
clear()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_cache.clear();
|
||||
m_cache_count = 0;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ inline void
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
reset()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_cache.clear();
|
||||
m_cache_count = 0;
|
||||
m_hits = 0;
|
||||
@@ -177,7 +177,7 @@ inline bool
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
touch_if_exists(KeyComparable const& key)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto const iter(m_cache.find(key));
|
||||
if (iter == m_cache.end())
|
||||
{
|
||||
@@ -212,7 +212,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
|
||||
auto const start = std::chrono::steady_clock::now();
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
|
||||
if (m_target_size == 0 || (static_cast<int>(m_cache.size()) <= m_target_size))
|
||||
{
|
||||
@@ -269,7 +269,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
{
|
||||
// Remove from cache, if !valid, remove from map too. Returns true if
|
||||
// removed from cache
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
|
||||
auto cit = m_cache.find(key);
|
||||
|
||||
@@ -309,7 +309,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
{
|
||||
// Return canonical value, store if needed, refresh in cache
|
||||
// Return values: true=we had the data already
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
|
||||
auto cit = m_cache.find(key);
|
||||
|
||||
@@ -423,7 +423,7 @@ inline SharedPointerType
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
fetch(key_type const& key)
|
||||
{
|
||||
std::lock_guard<mutex_type> l(m_mutex);
|
||||
std::scoped_lock<mutex_type> l(m_mutex);
|
||||
auto ret = initialFetch(key, l);
|
||||
if (!ret)
|
||||
++m_misses;
|
||||
@@ -474,7 +474,7 @@ inline auto
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
insert(key_type const& key) -> std::enable_if_t<IsKeyCache, ReturnType>
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
auto [it, inserted] = m_cache.emplace(
|
||||
std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now));
|
||||
@@ -538,7 +538,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
std::vector<key_type> v;
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
v.reserve(m_cache.size());
|
||||
for (auto const& _ : m_cache)
|
||||
v.push_back(_.first);
|
||||
@@ -560,7 +560,7 @@ inline double
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
rate() const
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto const tot = m_hits + m_misses;
|
||||
if (tot == 0)
|
||||
return 0;
|
||||
@@ -582,7 +582,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
fetch(key_type const& digest, Handler const& h)
|
||||
{
|
||||
{
|
||||
std::lock_guard l(m_mutex);
|
||||
std::scoped_lock l(m_mutex);
|
||||
if (auto ret = initialFetch(digest, l))
|
||||
return ret;
|
||||
}
|
||||
@@ -591,7 +591,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
if (!sle)
|
||||
return {};
|
||||
|
||||
std::lock_guard l(m_mutex);
|
||||
std::scoped_lock l(m_mutex);
|
||||
++m_misses;
|
||||
auto const [it, inserted] = m_cache.emplace(digest, Entry(m_clock.now(), std::move(sle)));
|
||||
if (!inserted)
|
||||
@@ -611,7 +611,7 @@ template <
|
||||
class Mutex>
|
||||
inline SharedPointerType
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
initialFetch(key_type const& key, std::lock_guard<mutex_type> const& l)
|
||||
initialFetch(key_type const& key, std::scoped_lock<mutex_type> const& l)
|
||||
{
|
||||
auto cit = m_cache.find(key);
|
||||
if (cit == m_cache.end())
|
||||
@@ -655,7 +655,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
{
|
||||
beast::insight::Gauge::value_type hit_rate(0);
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto const total(m_hits + m_misses);
|
||||
if (total != 0)
|
||||
hit_rate = (m_hits * 100) / total;
|
||||
@@ -681,7 +681,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
typename KeyValueCacheType::map_type& partition,
|
||||
SweptPointersVector& stuffToSweep,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::lock_guard<std::recursive_mutex> const&)
|
||||
std::scoped_lock<std::recursive_mutex> const&)
|
||||
{
|
||||
return std::thread([&, this]() {
|
||||
int cacheRemovals = 0;
|
||||
@@ -761,7 +761,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
typename KeyOnlyCacheType::map_type& partition,
|
||||
SweptPointersVector&,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::lock_guard<std::recursive_mutex> const&)
|
||||
std::scoped_lock<std::recursive_mutex> const&)
|
||||
{
|
||||
return std::thread([&, this]() {
|
||||
int cacheRemovals = 0;
|
||||
|
||||
@@ -32,7 +32,7 @@ make_seed_pair() noexcept
|
||||
// state_t& operator=(state_t const&) = delete;
|
||||
};
|
||||
static state_t state;
|
||||
std::lock_guard const lock(state.mutex);
|
||||
std::scoped_lock const lock(state.mutex);
|
||||
return {state.dist(state.gen), state.dist(state.gen)};
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ default_prng()
|
||||
thread_local beast::xor_shift_engine engine = [] {
|
||||
std::uint64_t seed = 0;
|
||||
{
|
||||
std::lock_guard const lk(m);
|
||||
std::scoped_lock 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 const lock(m_mutex);
|
||||
std::scoped_lock 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 const lock(m_mutex);
|
||||
std::scoped_lock 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 const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
++m_count;
|
||||
}
|
||||
|
||||
void
|
||||
release()
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
if (--m_count == 0)
|
||||
m_cond.notify_all();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
m_handler(elapsed);
|
||||
|
||||
{
|
||||
std::lock_guard const lock(m_probe->m_mutex);
|
||||
std::scoped_lock const lock(m_probe->m_mutex);
|
||||
if (m_probe->m_cancel)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
|
||||
boost::context::fixedsize_stack(2 * 1024 * 1024),
|
||||
[&](yield_context yield) {
|
||||
f(yield);
|
||||
std::lock_guard const lock{m_};
|
||||
std::scoped_lock const lock{m_};
|
||||
if (--running_ == 0)
|
||||
cv_.notify_all();
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace beast::unit_test {
|
||||
class selector
|
||||
{
|
||||
public:
|
||||
enum mode_t {
|
||||
enum class mode_t {
|
||||
// Run all tests except manual ones
|
||||
all,
|
||||
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
template <class>
|
||||
selector::selector(mode_t mode, std::string const& pattern) : mode_(mode), pat_(pattern)
|
||||
{
|
||||
if (mode_ == automatch && pattern.empty())
|
||||
mode_ = all;
|
||||
if (mode_ == mode_t::automatch && pattern.empty())
|
||||
mode_ = mode_t::all;
|
||||
}
|
||||
|
||||
template <class>
|
||||
@@ -63,18 +63,18 @@ selector::operator()(suite_info const& s)
|
||||
{
|
||||
switch (mode_)
|
||||
{
|
||||
case automatch:
|
||||
case mode_t::automatch:
|
||||
// suite or full name
|
||||
if (s.name() == pat_ || s.full_name() == pat_)
|
||||
{
|
||||
mode_ = none;
|
||||
mode_ = mode_t::none;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check module
|
||||
if (pat_ == s.module())
|
||||
{
|
||||
mode_ = module;
|
||||
mode_ = mode_t::module;
|
||||
library_ = s.library();
|
||||
return !s.manual();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ selector::operator()(suite_info const& s)
|
||||
// check library
|
||||
if (pat_ == s.library())
|
||||
{
|
||||
mode_ = library;
|
||||
mode_ = mode_t::library;
|
||||
return !s.manual();
|
||||
}
|
||||
|
||||
@@ -96,19 +96,19 @@ selector::operator()(suite_info const& s)
|
||||
|
||||
return false;
|
||||
|
||||
case suite:
|
||||
case mode_t::suite:
|
||||
return pat_ == s.name();
|
||||
|
||||
case module:
|
||||
case mode_t::module:
|
||||
return pat_ == s.module() && !s.manual();
|
||||
|
||||
case library:
|
||||
case mode_t::library:
|
||||
return pat_ == s.library() && !s.manual();
|
||||
|
||||
case none:
|
||||
case mode_t::none:
|
||||
return false;
|
||||
|
||||
case all:
|
||||
case mode_t::all:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
@@ -138,28 +138,28 @@ selector::operator()(suite_info const& s)
|
||||
inline selector
|
||||
match_auto(std::string const& name)
|
||||
{
|
||||
return selector(selector::automatch, name);
|
||||
return selector(selector::mode_t::automatch, name);
|
||||
}
|
||||
|
||||
/** Return a predicate that matches all suites not marked manual. */
|
||||
inline selector
|
||||
match_all()
|
||||
{
|
||||
return selector(selector::all);
|
||||
return selector(selector::mode_t::all);
|
||||
}
|
||||
|
||||
/** Returns a predicate that matches a specific suite. */
|
||||
inline selector
|
||||
match_suite(std::string const& name)
|
||||
{
|
||||
return selector(selector::suite, name);
|
||||
return selector(selector::mode_t::suite, name);
|
||||
}
|
||||
|
||||
/** Returns a predicate that matches all suites in a library. */
|
||||
inline selector
|
||||
match_library(std::string const& name)
|
||||
{
|
||||
return selector(selector::library, name);
|
||||
return selector(selector::mode_t::library, name);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
|
||||
@@ -62,6 +62,8 @@ private:
|
||||
{
|
||||
using run_time = std::pair<std::string, typename clock_type::duration>;
|
||||
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum { max_top = 10 };
|
||||
|
||||
std::size_t suites = 0;
|
||||
|
||||
@@ -231,7 +231,7 @@ template <class>
|
||||
void
|
||||
runner::testcase(std::string const& name)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
// Name may not be empty
|
||||
BOOST_ASSERT(default_ || !name.empty());
|
||||
// Forgot to call pass or fail
|
||||
@@ -247,7 +247,7 @@ template <class>
|
||||
void
|
||||
runner::pass()
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_pass();
|
||||
@@ -258,7 +258,7 @@ template <class>
|
||||
void
|
||||
runner::fail(std::string const& reason)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_fail(reason);
|
||||
@@ -270,7 +270,7 @@ template <class>
|
||||
void
|
||||
runner::log(std::string const& s)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_log(s);
|
||||
|
||||
@@ -37,7 +37,7 @@ make_reason(String const& reason, char const* file, int line)
|
||||
|
||||
class Thread;
|
||||
|
||||
enum abort_t { no_abort_on_fail, abort_on_fail };
|
||||
enum class abort_t { no_abort_on_fail, abort_on_fail };
|
||||
|
||||
/** A testsuite class.
|
||||
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
@param abort Determines if suite continues running after a failure.
|
||||
*/
|
||||
void
|
||||
operator()(std::string const& name, abort_t abort = no_abort_on_fail);
|
||||
operator()(std::string const& name, abort_t abort = abort_t::no_abort_on_fail);
|
||||
|
||||
scoped_testcase
|
||||
operator()(abort_t abort);
|
||||
@@ -363,14 +363,14 @@ public:
|
||||
inline void
|
||||
suite::testcase_t::operator()(std::string const& name, abort_t abort)
|
||||
{
|
||||
suite_.abort_ = abort == abort_on_fail;
|
||||
suite_.abort_ = abort == abort_t::abort_on_fail;
|
||||
suite_.runner_->testcase(name);
|
||||
}
|
||||
|
||||
inline suite::scoped_testcase
|
||||
suite::testcase_t::operator()(abort_t abort)
|
||||
{
|
||||
suite_.abort_ = abort == abort_on_fail;
|
||||
suite_.abort_ = abort == abort_t::abort_on_fail;
|
||||
return {suite_, ss_};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace beast {
|
||||
/** A namespace for easy access to logging severity values. */
|
||||
namespace severities {
|
||||
/** Severity level / threshold of a Journal message. */
|
||||
// Hundreds of usages via logging macros
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Severity {
|
||||
kAll = 0,
|
||||
|
||||
|
||||
@@ -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 const lock{mutex_};
|
||||
std::scoped_lock const lock{mutex_};
|
||||
|
||||
// Update closureCount_. Notify if stopping and closureCount_ == 0.
|
||||
if ((--closureCount_ == 0) && waitForClosures_)
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
{
|
||||
std::optional<Substitute<Closure>> ret;
|
||||
|
||||
std::lock_guard const lock{mutex_};
|
||||
std::scoped_lock const lock{mutex_};
|
||||
if (!waitForClosures_)
|
||||
ret.emplace(*this, std::forward<Closure>(closure));
|
||||
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
bool
|
||||
joined() const
|
||||
{
|
||||
std::lock_guard const lock{mutex_};
|
||||
std::scoped_lock const lock{mutex_};
|
||||
return waitForClosures_;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ inline void
|
||||
JobQueue::Coro::yield() const
|
||||
{
|
||||
{
|
||||
std::lock_guard lock(jq_.m_mutex);
|
||||
std::scoped_lock lock(jq_.m_mutex);
|
||||
++jq_.nSuspend_;
|
||||
}
|
||||
(*yield_)();
|
||||
@@ -44,7 +44,7 @@ inline bool
|
||||
JobQueue::Coro::post()
|
||||
{
|
||||
{
|
||||
std::lock_guard lk(mutex_run_);
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ JobQueue::Coro::post()
|
||||
}
|
||||
|
||||
// The coroutine will not run. Clean up running_.
|
||||
std::lock_guard lk(mutex_run_);
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
running_ = false;
|
||||
cv_.notify_all();
|
||||
return false;
|
||||
@@ -65,16 +65,16 @@ inline void
|
||||
JobQueue::Coro::resume()
|
||||
{
|
||||
{
|
||||
std::lock_guard lk(mutex_run_);
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
running_ = true;
|
||||
}
|
||||
{
|
||||
std::lock_guard lk(jq_.m_mutex);
|
||||
std::scoped_lock lk(jq_.m_mutex);
|
||||
--jq_.nSuspend_;
|
||||
}
|
||||
auto saved = detail::getLocalValues().release();
|
||||
detail::getLocalValues().reset(&lvs_);
|
||||
std::lock_guard lock(mutex_);
|
||||
std::scoped_lock lock(mutex_);
|
||||
// A late resume() can arrive after the coroutine has already completed.
|
||||
// This is an expected (if rare) outcome of the race condition documented
|
||||
// in JobQueue.h:354-377 where post() schedules a resume job before the
|
||||
@@ -89,7 +89,7 @@ JobQueue::Coro::resume()
|
||||
}
|
||||
detail::getLocalValues().release();
|
||||
detail::getLocalValues().reset(saved);
|
||||
std::lock_guard lk(mutex_run_);
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
running_ = false;
|
||||
cv_.notify_all();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ JobQueue::Coro::expectEarlyExit()
|
||||
//
|
||||
// That said, since we're outside the Coro's stack, we need to
|
||||
// decrement the nSuspend that the Coro's call to yield caused.
|
||||
std::lock_guard lock(jq_.m_mutex);
|
||||
std::scoped_lock lock(jq_.m_mutex);
|
||||
--jq_.nSuspend_;
|
||||
#ifndef NDEBUG
|
||||
finished_ = true;
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace xrpl {
|
||||
// Note that this queue should only be used for CPU-bound jobs
|
||||
// It is primarily intended for signature checking
|
||||
|
||||
// Protocol-wide
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum JobType {
|
||||
// Special type indicating an invalid job - will go away soon.
|
||||
jtINVALID = -1,
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
bool
|
||||
contains(PublicKey const& nodeId)
|
||||
{
|
||||
std::lock_guard const lock(this->mutex_);
|
||||
std::scoped_lock const lock(this->mutex_);
|
||||
return table_.contains({.nodeId = nodeId, .description = {}});
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void
|
||||
notify()
|
||||
{
|
||||
std::lock_guard const lock{m_mutex};
|
||||
std::scoped_lock const lock{m_mutex};
|
||||
++m_count;
|
||||
m_cond.notify_one();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
bool
|
||||
try_wait()
|
||||
{
|
||||
std::lock_guard lock{m_mutex};
|
||||
std::scoped_lock lock{m_mutex};
|
||||
if (m_count == 0)
|
||||
return false;
|
||||
--m_count;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Json {
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
enum CollectionType { array, object };
|
||||
enum class CollectionType { array, object };
|
||||
|
||||
explicit Writer(Output const& output);
|
||||
Writer(Writer&&) noexcept;
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
static constexpr unsigned nest_limit{25};
|
||||
|
||||
private:
|
||||
// 53 files, protocol-wide
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TokenType {
|
||||
tokenEndOfStream = 0,
|
||||
tokenObjectBegin,
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Json {
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
// Used throughout JSON layer
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum ValueType {
|
||||
nullValue = 0, ///< 'null' value
|
||||
intValue, ///< signed integer value
|
||||
@@ -147,6 +149,8 @@ private:
|
||||
class CZString
|
||||
{
|
||||
public:
|
||||
// Stored as int field, implicit conversion
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
|
||||
CZString(int index);
|
||||
CZString(char const* cstr, DuplicationPolicy allocate);
|
||||
@@ -471,6 +475,8 @@ operator>=(Value const& x, Value const& y)
|
||||
class ValueAllocator
|
||||
{
|
||||
public:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum { unknown = (unsigned)-1 };
|
||||
|
||||
virtual ~ValueAllocator() = default;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// Bitwise flag enum with existing operator overloads
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum ApplyFlags : std::uint32_t {
|
||||
tapNONE = 0x00,
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
bool
|
||||
startWork(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto it = map_.find(seq);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void
|
||||
finishWork(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
map_.erase(seq);
|
||||
await_.notify_all();
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
bool
|
||||
pending(LedgerIndex seq)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return map_.contains(seq);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
std::map<LedgerIndex, bool>
|
||||
getSnapshot() const
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
return map_;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ reduceOffer(auto const& amount)
|
||||
static Number const reducedOfferPct(9999, -4);
|
||||
|
||||
// Make sure the result is always less than amount or zero.
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::rounding_mode::towards_zero);
|
||||
return amount * reducedOfferPct;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ getAMMOfferStartWithTakerGets(
|
||||
if (targetQuality.rate() == beast::zero)
|
||||
return std::nullopt;
|
||||
|
||||
NumberRoundModeGuard const mg(Number::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest);
|
||||
auto const f = feeMult(tfee);
|
||||
auto const a = 1;
|
||||
auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out;
|
||||
@@ -202,7 +202,7 @@ getAMMOfferStartWithTakerGets(
|
||||
// Round downward to minimize the offer and to maximize the quality.
|
||||
// This has the most impact when takerGets is XRP.
|
||||
auto const takerGets =
|
||||
toAmount<TOut>(getAsset(pool.out), nTakerGetsProposed, Number::downward);
|
||||
toAmount<TOut>(getAsset(pool.out), nTakerGetsProposed, Number::rounding_mode::downward);
|
||||
return TAmounts<TIn, TOut>{swapAssetOut(pool, takerGets, tfee), takerGets};
|
||||
};
|
||||
|
||||
@@ -247,7 +247,7 @@ getAMMOfferStartWithTakerPays(
|
||||
if (targetQuality.rate() == beast::zero)
|
||||
return std::nullopt;
|
||||
|
||||
NumberRoundModeGuard const mg(Number::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest);
|
||||
auto const f = feeMult(tfee);
|
||||
auto const& a = f;
|
||||
auto const b = pool.in * (1 + f);
|
||||
@@ -269,7 +269,7 @@ getAMMOfferStartWithTakerPays(
|
||||
// Round downward to minimize the offer and to maximize the quality.
|
||||
// This has the most impact when takerPays is XRP.
|
||||
auto const takerPays =
|
||||
toAmount<TIn>(getAsset(pool.in), nTakerPaysProposed, Number::downward);
|
||||
toAmount<TIn>(getAsset(pool.in), nTakerPaysProposed, Number::rounding_mode::downward);
|
||||
return TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
|
||||
};
|
||||
|
||||
@@ -341,7 +341,8 @@ changeSpotPriceQuality(
|
||||
<< " " << to_string(pool.out) << " " << quality << " " << tfee;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto const takerPays = toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::upward);
|
||||
auto const takerPays =
|
||||
toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::rounding_mode::upward);
|
||||
// should not fail
|
||||
if (auto amounts = TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
|
||||
Quality{amounts} < quality &&
|
||||
@@ -447,32 +448,32 @@ swapAssetIn(TAmounts<TIn, TOut> const& pool, TIn const& assetIn, std::uint16_t t
|
||||
// fee
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::upward);
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
auto const fee = getFee(tfee);
|
||||
|
||||
Number::setround(Number::downward);
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
auto const denom = pool.in + assetIn * (1 - fee);
|
||||
|
||||
if (denom.signum() <= 0)
|
||||
return toAmount<TOut>(getAsset(pool.out), 0);
|
||||
|
||||
Number::setround(Number::upward);
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
auto const ratio = numerator / denom;
|
||||
|
||||
Number::setround(Number::downward);
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
auto const swapOut = pool.out - ratio;
|
||||
|
||||
if (swapOut.signum() < 0)
|
||||
return toAmount<TOut>(getAsset(pool.out), 0);
|
||||
|
||||
return toAmount<TOut>(getAsset(pool.out), swapOut, Number::downward);
|
||||
return toAmount<TOut>(getAsset(pool.out), swapOut, Number::rounding_mode::downward);
|
||||
}
|
||||
|
||||
return toAmount<TOut>(
|
||||
getAsset(pool.out),
|
||||
pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)),
|
||||
Number::downward);
|
||||
Number::rounding_mode::downward);
|
||||
}
|
||||
|
||||
/** Swap assetOut out of the pool and swap in a proportional amount
|
||||
@@ -509,36 +510,36 @@ swapAssetOut(TAmounts<TIn, TOut> const& pool, TOut const& assetOut, std::uint16_
|
||||
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::upward);
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
|
||||
Number::setround(Number::downward);
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
auto const denom = pool.out - assetOut;
|
||||
if (denom.signum() <= 0)
|
||||
{
|
||||
return toMaxAmount<TIn>(getAsset(pool.in));
|
||||
}
|
||||
|
||||
Number::setround(Number::upward);
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
auto const ratio = numerator / denom;
|
||||
auto const numerator2 = ratio - pool.in;
|
||||
auto const fee = getFee(tfee);
|
||||
|
||||
Number::setround(Number::downward);
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
auto const feeMult = 1 - fee;
|
||||
|
||||
Number::setround(Number::upward);
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
auto const swapIn = numerator2 / feeMult;
|
||||
if (swapIn.signum() < 0)
|
||||
return toAmount<TIn>(getAsset(pool.in), 0);
|
||||
|
||||
return toAmount<TIn>(getAsset(pool.in), swapIn, Number::upward);
|
||||
return toAmount<TIn>(getAsset(pool.in), swapIn, Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
return toAmount<TIn>(
|
||||
getAsset(pool.in),
|
||||
((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee),
|
||||
Number::upward);
|
||||
Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
/** Return square of n.
|
||||
@@ -597,7 +598,8 @@ getLPTokenRounding(IsDeposit isDeposit)
|
||||
{
|
||||
// Minimize on deposit, maximize on withdraw to ensure
|
||||
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
|
||||
return isDeposit == IsDeposit::Yes ? Number::downward : Number::upward;
|
||||
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::downward
|
||||
: Number::rounding_mode::upward;
|
||||
}
|
||||
|
||||
inline Number::rounding_mode
|
||||
@@ -605,7 +607,8 @@ getAssetRounding(IsDeposit isDeposit)
|
||||
{
|
||||
// Maximize on deposit, minimize on withdraw to ensure
|
||||
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
|
||||
return isDeposit == IsDeposit::Yes ? Number::upward : Number::downward;
|
||||
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::upward
|
||||
: Number::rounding_mode::downward;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -19,7 +19,7 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
|
||||
inline Number
|
||||
roundPeriodicPayment(Asset const& asset, Number const& periodicPayment, std::int32_t scale)
|
||||
{
|
||||
return roundToAsset(asset, periodicPayment, scale, Number::upward);
|
||||
return roundToAsset(asset, periodicPayment, scale, Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
/* Represents the breakdown of amounts to be paid and changes applied to the
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace xrpl {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Controls the treatment of frozen account balances */
|
||||
enum FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN };
|
||||
enum class FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN };
|
||||
|
||||
/** Controls the treatment of unauthorized MPT balances */
|
||||
enum AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED };
|
||||
enum class AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED };
|
||||
|
||||
/** Controls whether to include the account's full spendable balance */
|
||||
enum SpendableHandling { shSIMPLE_BALANCE, shFULL_BALANCE };
|
||||
enum class SpendableHandling { shSIMPLE_BALANCE, shFULL_BALANCE };
|
||||
|
||||
enum class WaiveTransferFee : bool { No = false, Yes };
|
||||
|
||||
@@ -135,7 +135,7 @@ accountHolds(
|
||||
AccountID const& issuer,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -144,7 +144,7 @@ accountHolds(
|
||||
Issue const& issue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -154,7 +154,7 @@ accountHolds(
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -164,7 +164,7 @@ accountHolds(
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
|
||||
// Returns the amount an account can spend of the currency type saDefault, or
|
||||
// returns saDefault if this account is the issuer of the currency in
|
||||
|
||||
@@ -76,16 +76,16 @@ public:
|
||||
If the object is not found or an error is encountered, the
|
||||
result will indicate the condition.
|
||||
@note This will be called concurrently.
|
||||
@param key A pointer to the key data.
|
||||
@param hash The hash of the object.
|
||||
@param pObject [out] The created object if successful.
|
||||
@return The result of the operation.
|
||||
*/
|
||||
virtual Status
|
||||
fetch(void const* key, std::shared_ptr<NodeObject>* pObject) = 0;
|
||||
fetch(uint256 const& hash, std::shared_ptr<NodeObject>* pObject) = 0;
|
||||
|
||||
/** Fetch a batch synchronously. */
|
||||
virtual std::pair<std::vector<std::shared_ptr<NodeObject>>, Status>
|
||||
fetchBatch(std::vector<uint256 const*> const& hashes) = 0;
|
||||
fetchBatch(std::vector<uint256> const& hashes) = 0;
|
||||
|
||||
/** Store a single object.
|
||||
Depending on the implementation this may happen immediately
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace xrpl {
|
||||
|
||||
/** The types of node objects. */
|
||||
enum NodeObjectType : std::uint32_t {
|
||||
enum class NodeObjectType : std::uint32_t {
|
||||
hotUNKNOWN = 0,
|
||||
hotLEDGER = 1,
|
||||
hotACCOUNT_NODE = 3,
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
// This is only used to pre-allocate the array for
|
||||
// batch objects and does not affect the amount written.
|
||||
@@ -20,7 +22,7 @@ enum {
|
||||
};
|
||||
|
||||
/** Return codes from Backend operations. */
|
||||
enum Status {
|
||||
enum class Status {
|
||||
ok = 0,
|
||||
notFound = 1,
|
||||
dataCorrupt = 2,
|
||||
|
||||
@@ -127,7 +127,7 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf)
|
||||
ostream os(out, result.second);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint8_t>(os, hotUNKNOWN);
|
||||
write<std::uint8_t>(os, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
write<std::uint32_t>(os, static_cast<std::uint32_t>(HashPrefix::innerNode));
|
||||
if (mask == 0)
|
||||
Throw<std::runtime_error>("nodeobject codec v1: empty inner node");
|
||||
@@ -173,7 +173,7 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf)
|
||||
ostream os(out, result.second);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint8_t>(os, hotUNKNOWN);
|
||||
write<std::uint8_t>(os, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
write<std::uint32_t>(os, static_cast<std::uint32_t>(HashPrefix::innerNode));
|
||||
write(os, is(512), 512);
|
||||
break;
|
||||
@@ -307,7 +307,7 @@ filter_inner(void* in, std::size_t in_size)
|
||||
ostream os(in, 9);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint32_t>(os, 0);
|
||||
write<std::uint8_t>(os, hotUNKNOWN);
|
||||
write<std::uint8_t>(os, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace xrpl {
|
||||
//
|
||||
// Please only append to this table. Do not "fill-in" gaps and do not re-use
|
||||
// or repurpose error code values.
|
||||
// Protocol-wide, 50+ files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum error_code_i {
|
||||
// -1 represents codes not listed in this enumeration
|
||||
rpcUNKNOWN = -1,
|
||||
@@ -148,6 +150,8 @@ enum error_code_i {
|
||||
|
||||
These values need to remain stable.
|
||||
*/
|
||||
// Protocol-wide, 50+ files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum warning_code_i {
|
||||
warnRPC_UNSUPPORTED_MAJORITY = 1001,
|
||||
warnRPC_AMENDMENT_BLOCKED = 1002,
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace xrpl {
|
||||
|
||||
@ingroup protocol
|
||||
*/
|
||||
// Protocol-critical, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum LedgerEntryType : std::uint16_t {
|
||||
|
||||
#pragma push_macro("LEDGER_ENTRY")
|
||||
@@ -214,6 +216,8 @@ enum LedgerEntryType : std::uint16_t {
|
||||
#define TO_VALUE(name, value) name = (value),
|
||||
#define NULL_NAME(name, values) values
|
||||
#define NULL_OUTPUT(name, value)
|
||||
// Bitwise flag enum
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum LedgerSpecificFlags : std::uint32_t { XMACRO(NULL_NAME, TO_VALUE, NULL_OUTPUT) };
|
||||
|
||||
// Create getter functions for each set of flags using Meyer's singleton pattern.
|
||||
|
||||
@@ -66,8 +66,7 @@ struct MultiApiJson
|
||||
a[key] = v;
|
||||
}
|
||||
|
||||
// Intentionally not using class enum here, MultivarJson is scope enough
|
||||
enum IsMemberResult : int { none = 0, some, all };
|
||||
enum class IsMemberResult : int { none = 0, some, all };
|
||||
|
||||
[[nodiscard]] IsMemberResult
|
||||
isMember(char const* key) const
|
||||
@@ -80,8 +79,8 @@ struct MultiApiJson
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return none;
|
||||
return count < size ? some : all;
|
||||
return IsMemberResult::none;
|
||||
return count < size ? IsMemberResult::some : IsMemberResult::all;
|
||||
}
|
||||
|
||||
static constexpr struct visitor_t final
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace xrpl {
|
||||
* conflicts with TxType, the GranularPermissionType is always set to a value
|
||||
* greater than the maximum value of uint16.
|
||||
*/
|
||||
// Macro-generated, complex
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum GranularPermissionType : std::uint32_t {
|
||||
#pragma push_macro("PERMISSION")
|
||||
#undef PERMISSION
|
||||
@@ -28,6 +30,9 @@ enum GranularPermissionType : std::uint32_t {
|
||||
#pragma pop_macro("PERMISSION")
|
||||
};
|
||||
|
||||
// Injected bare enumerators (xrpl::delegable / xrpl::notDelegable) are required by preprocessor
|
||||
// tricks in tests and macro-generated code; enum class would break that.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Delegation { delegable, notDelegable };
|
||||
|
||||
class Permission
|
||||
|
||||
@@ -87,6 +87,8 @@ class STCurrency;
|
||||
#define TO_ENUM(name, value) name = (value),
|
||||
#define TO_MAP(name, value) {#name, value},
|
||||
|
||||
// Protocol infrastructure, 39+ files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum SerializedTypeID { XMACRO(TO_ENUM) };
|
||||
|
||||
static std::map<std::string, int> const sTypeMap = {XMACRO(TO_MAP)};
|
||||
@@ -125,6 +127,8 @@ field_code(int id, int index)
|
||||
class SField
|
||||
{
|
||||
public:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
sMD_Never = 0x00,
|
||||
sMD_ChangeOrig = 0x01, // original value when it changes
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
namespace xrpl {
|
||||
|
||||
/** Kind of element in each entry of an SOTemplate. */
|
||||
// 2026 usages, 129 files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum SOEStyle {
|
||||
soeINVALID = -1,
|
||||
soeREQUIRED = 0, // required
|
||||
@@ -20,7 +22,8 @@ enum SOEStyle {
|
||||
// constructed with STObject::makeInnerObject()
|
||||
};
|
||||
|
||||
/** Amount fields that can support MPT */
|
||||
// Part of a Python-parsed DSL (transactions.macro); bare enumerator names required by the parser
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum SOETxMPTIssue { soeMPTNone, soeMPTSupported, soeMPTNotSupported };
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -319,7 +319,7 @@ STAmount::STAmount(
|
||||
: STBase(name), mAsset(asset), mValue(mantissa), mOffset(exponent), mIsNegative(negative)
|
||||
{
|
||||
// mValue is uint64, but needs to fit in the range of int64
|
||||
if (Number::getMantissaScale() == MantissaRange::small)
|
||||
if (Number::getMantissaScale() == MantissaRange::mantissa_scale::small)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
mValue <= std::numeric_limits<std::int64_t>::max(),
|
||||
|
||||
@@ -18,6 +18,8 @@ struct JsonOptions
|
||||
using underlying_t = unsigned int;
|
||||
underlying_t value;
|
||||
|
||||
// Bitwise flags with operator~
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum values : underlying_t {
|
||||
// clang-format off
|
||||
none = 0b0000'0000,
|
||||
|
||||
@@ -413,9 +413,9 @@ public:
|
||||
class FieldErr;
|
||||
|
||||
private:
|
||||
enum WhichFields : bool {
|
||||
enum class WhichFields : bool {
|
||||
// These values are carefully chosen to do the right thing if passed
|
||||
// to SField::shouldInclude (bool)
|
||||
// to SField::shouldInclude (bool) via static_cast<bool>
|
||||
omitSigningFields = false,
|
||||
withAllFields = true
|
||||
};
|
||||
@@ -987,7 +987,7 @@ STObject::isFree() const
|
||||
inline void
|
||||
STObject::addWithoutSigningFields(Serializer& s) const
|
||||
{
|
||||
add(s, omitSigningFields);
|
||||
add(s, WhichFields::omitSigningFields);
|
||||
}
|
||||
|
||||
// VFALCO NOTE does this return an expensive copy of an object with a
|
||||
@@ -997,7 +997,7 @@ inline Serializer
|
||||
STObject::getSerializer() const
|
||||
{
|
||||
Serializer s;
|
||||
add(s, withAllFields);
|
||||
add(s, WhichFields::withAllFields);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ class STPathElement final : public CountedObject<STPathElement>
|
||||
std::size_t hash_value_;
|
||||
|
||||
public:
|
||||
// Bitwise values (typeCurrency | typeMPT)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Type {
|
||||
typeNone = 0x00,
|
||||
typeAccount = 0x01, // Rippling through an account (vs taking an offer).
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace xrpl {
|
||||
class SeqProxy
|
||||
{
|
||||
public:
|
||||
enum Type : std::uint8_t { seq = 0, ticket };
|
||||
enum class Type : std::uint8_t { seq = 0, ticket };
|
||||
|
||||
private:
|
||||
std::uint32_t value_;
|
||||
@@ -67,13 +67,13 @@ public:
|
||||
[[nodiscard]] constexpr bool
|
||||
isSeq() const
|
||||
{
|
||||
return type_ == seq;
|
||||
return type_ == Type::seq;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool
|
||||
isTicket() const
|
||||
{
|
||||
return type_ == ticket;
|
||||
return type_ == Type::ticket;
|
||||
}
|
||||
|
||||
// Occasionally it is convenient to be able to increase the value_
|
||||
|
||||
@@ -19,6 +19,8 @@ using TERUnderlyingType = int;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TELcodes : TERUnderlyingType {
|
||||
// Note: Range is stable.
|
||||
// Exact numbers are used in ripple-binary-codec:
|
||||
@@ -50,6 +52,8 @@ enum TELcodes : TERUnderlyingType {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TEMcodes : TERUnderlyingType {
|
||||
// Note: Range is stable.
|
||||
// Exact numbers are used in ripple-binary-codec:
|
||||
@@ -126,6 +130,8 @@ enum TEMcodes : TERUnderlyingType {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TEFcodes : TERUnderlyingType {
|
||||
// Note: Range is stable.
|
||||
// Exact numbers are used in ripple-binary-codec:
|
||||
@@ -170,6 +176,8 @@ enum TEFcodes : TERUnderlyingType {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TERcodes : TERUnderlyingType {
|
||||
// Note: Range is stable.
|
||||
// Exact numbers are used in ripple-binary-codec:
|
||||
@@ -214,6 +222,8 @@ enum TERcodes : TERUnderlyingType {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TEScodes : TERUnderlyingType {
|
||||
// Note: Exact number must stay stable. This code is stored by value
|
||||
// in metadata for historic transactions.
|
||||
@@ -229,6 +239,8 @@ enum TEScodes : TERUnderlyingType {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Protocol-critical, mixed with custom TER wrapper type, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TECcodes : TERUnderlyingType {
|
||||
// Note: Exact numbers must stay stable. These codes are stored by
|
||||
// value in metadata for historic transactions.
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace xrpl {
|
||||
@ingroup protocol
|
||||
*/
|
||||
// clang-format off
|
||||
// Protocol-critical, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TxType : std::uint16_t
|
||||
{
|
||||
|
||||
|
||||
@@ -130,6 +130,19 @@ public:
|
||||
return sle_->at(sfFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if a specific flag is set.
|
||||
*
|
||||
* @param f The flag bitmask to check
|
||||
* @return true if all bits in f are set in the flags field
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
isFlag(std::uint32_t f) const
|
||||
{
|
||||
return sle_->isFlag(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the underlying SLE object.
|
||||
*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace xrpl::Resource {
|
||||
|
||||
/** The disposition of a consumer after applying a load charge. */
|
||||
enum Disposition {
|
||||
enum class Disposition {
|
||||
/** No action required. */
|
||||
ok
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ struct Entry : public beast::List<Entry>::Node
|
||||
[[nodiscard]] bool
|
||||
isUnlimited() const
|
||||
{
|
||||
return key->kind == kindUnlimited;
|
||||
return key->kind == Kind::kindUnlimited;
|
||||
}
|
||||
|
||||
// Balance including remote contributions
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace xrpl::Resource {
|
||||
* subjected to administrative restrictions, such as
|
||||
* use of some RPC commands like "stop".
|
||||
*/
|
||||
enum Kind { kindInbound, kindOutbound, kindUnlimited };
|
||||
enum class Kind { kindInbound, kindOutbound, kindUnlimited };
|
||||
|
||||
} // namespace xrpl::Resource
|
||||
|
||||
@@ -92,11 +92,11 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindInbound, address.at_port(0)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(Kind::kindInbound, address.at_port(0)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
|
||||
entry = &resultIt->second;
|
||||
entry->key = &resultIt->first;
|
||||
@@ -122,11 +122,11 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindOutbound, address), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(Kind::kindOutbound, address), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
|
||||
entry = &resultIt->second;
|
||||
entry->key = &resultIt->first;
|
||||
@@ -155,11 +155,11 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(kindUnlimited, address.at_port(1)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(Kind::kindUnlimited, address.at_port(1)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
|
||||
entry = &resultIt->second;
|
||||
entry->key = &resultIt->first;
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
Json::Value ret(Json::objectValue);
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
|
||||
for (auto& inboundEntry : inbound_)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
Gossip gossip;
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
|
||||
gossip.items.reserve(inbound_.size());
|
||||
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
{
|
||||
auto const elapsed = m_clock.now();
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
auto [resultIt, resultInserted] = importTable_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(origin), // Key
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
void
|
||||
periodicActivity()
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
|
||||
auto const elapsed = m_clock.now();
|
||||
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
void
|
||||
erase(Table::iterator iter)
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
Entry& entry(iter->second);
|
||||
XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used");
|
||||
inactive_.erase(inactive_.iterator_to(entry));
|
||||
@@ -385,27 +385,27 @@ public:
|
||||
void
|
||||
acquire(Entry& entry)
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
++entry.refcount;
|
||||
}
|
||||
|
||||
void
|
||||
release(Entry& entry)
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
if (--entry.refcount == 0)
|
||||
{
|
||||
JLOG(m_journal.debug()) << "Inactive " << entry;
|
||||
|
||||
switch (entry.key->kind)
|
||||
{
|
||||
case kindInbound:
|
||||
case Kind::kindInbound:
|
||||
inbound_.erase(inbound_.iterator_to(entry));
|
||||
break;
|
||||
case kindOutbound:
|
||||
case Kind::kindOutbound:
|
||||
outbound_.erase(outbound_.iterator_to(entry));
|
||||
break;
|
||||
case kindUnlimited:
|
||||
case Kind::kindUnlimited:
|
||||
admin_.erase(admin_.iterator_to(entry));
|
||||
break;
|
||||
default:
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
if (!context.empty())
|
||||
context = " (" + context + ")";
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock 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;
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
bool notify(false);
|
||||
auto const elapsed = m_clock.now();
|
||||
if (entry.balance(m_clock.now()) >= warningThreshold && elapsed != entry.lastWarningTime)
|
||||
@@ -479,7 +479,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
bool drop(false);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
int const balance(entry.balance(now));
|
||||
@@ -501,7 +501,7 @@ public:
|
||||
int
|
||||
balance(Entry& entry)
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
return entry.balance(m_clock.now());
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ public:
|
||||
{
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
|
||||
{
|
||||
beast::PropertyStream::Set s("inbound", map);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
namespace xrpl::Resource {
|
||||
|
||||
/** Tunable constants. */
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
// Balance at which a warning is issued
|
||||
warningThreshold = 5000
|
||||
|
||||
@@ -35,28 +35,28 @@ public:
|
||||
setRemoteFee(std::uint32_t f)
|
||||
{
|
||||
JLOG(j_.trace()) << "setRemoteFee: " << f;
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
remoteTxnLoadFee_ = f;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getRemoteFee() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return remoteTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getLocalFee() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return localTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getClusterFee() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return clusterTxnLoadFee_;
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ public:
|
||||
std::uint32_t
|
||||
getLoadFactor() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return std::max({clusterTxnLoadFee_, localTxnLoadFee_, remoteTxnLoadFee_});
|
||||
}
|
||||
|
||||
std::pair<std::uint32_t, std::uint32_t>
|
||||
getScalingFactors() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
|
||||
return std::make_pair(
|
||||
std::max(localTxnLoadFee_, remoteTxnLoadFee_),
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
setClusterFee(std::uint32_t fee)
|
||||
{
|
||||
JLOG(j_.trace()) << "setClusterFee: " << fee;
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
clusterTxnLoadFee_ = fee;
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ public:
|
||||
bool
|
||||
isLoadedLocal() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
bool
|
||||
isLoadedCluster() const
|
||||
{
|
||||
std::lock_guard const sl(lock_);
|
||||
std::scoped_lock const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) ||
|
||||
(clusterTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ protected:
|
||||
using endpoint_type = boost::asio::ip::tcp::endpoint;
|
||||
using yield_context = boost::asio::yield_context;
|
||||
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
// Size of our read/write buffer
|
||||
bufferSize = 4 * 1024,
|
||||
@@ -303,7 +305,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 const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
wq2_.clear();
|
||||
wq2_.reserve(wq_.size());
|
||||
std::swap(wq2_, wq_);
|
||||
@@ -395,7 +397,7 @@ BaseHTTPPeer<Handler, Impl>::write(void const* buf, std::size_t bytes)
|
||||
if (bytes == 0)
|
||||
return;
|
||||
if ([&] {
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
wq_.emplace_back(buf, bytes);
|
||||
return wq_.size() == 1 && wq2_.size() == 0;
|
||||
}())
|
||||
@@ -449,7 +451,7 @@ BaseHTTPPeer<Handler, Impl>::complete()
|
||||
complete_ = true;
|
||||
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
if (!wq_.empty() && !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
@@ -484,7 +486,7 @@ BaseHTTPPeer<Handler, Impl>::close(bool graceful)
|
||||
{
|
||||
graceful_ = true;
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
if (!wq_.empty() || !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ class ServerImpl : public Server
|
||||
private:
|
||||
using clock_type = std::chrono::system_clock;
|
||||
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum { historySize = 100 };
|
||||
|
||||
Handler& handler_;
|
||||
|
||||
@@ -165,7 +165,7 @@ io_list::work::destroy()
|
||||
return;
|
||||
std::function<void(void)> f;
|
||||
{
|
||||
std::lock_guard const lock(ios_->m_);
|
||||
std::scoped_lock 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 const lock(m_);
|
||||
std::scoped_lock const lock(m_);
|
||||
if (!closed_)
|
||||
{
|
||||
++n_;
|
||||
|
||||
@@ -22,6 +22,8 @@ private:
|
||||
using CacheType = KeyCache;
|
||||
|
||||
public:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum { defaultCacheTargetSize = 0 };
|
||||
|
||||
using key_type = uint256;
|
||||
|
||||
@@ -123,6 +123,8 @@ public:
|
||||
Transactor(Transactor const&) = delete;
|
||||
Transactor&
|
||||
operator=(Transactor const&) = delete;
|
||||
// 68 transactor subclass files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum ConsequencesFactoryType { Normal, Blocker, Custom };
|
||||
|
||||
/** Process the transaction. */
|
||||
|
||||
@@ -39,7 +39,7 @@ class TxConsequences
|
||||
public:
|
||||
/// Describes how the transaction affects subsequent
|
||||
/// transactions
|
||||
enum Category {
|
||||
enum class Category {
|
||||
/// Moves currency around, creates offers, etc.
|
||||
normal = 0,
|
||||
/// Affects the ability of subsequent transactions
|
||||
|
||||
@@ -25,6 +25,8 @@ not have the relevant amendments enabled_. It's intentionally a pain in the neck
|
||||
so that bad code gets caught and fixed as early as possible.
|
||||
*/
|
||||
|
||||
// Bitwise flags, 86 files
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Privilege {
|
||||
noPriv = 0x0000, // The transaction can not do any of the enumerated operations
|
||||
createAcct = 0x0001, // The transaction can create a new ACCOUNT_ROOT object.
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
*/
|
||||
class ValidMPTPayment
|
||||
{
|
||||
enum Order { Before = 0, After = 1 };
|
||||
enum class Order { Before = 0, After = 1 };
|
||||
struct MPTData
|
||||
{
|
||||
std::array<std::int64_t, After + 1> outstanding{};
|
||||
std::array<std::int64_t, 2> outstanding{};
|
||||
// sum (MPT after - MPT before)
|
||||
std::int64_t mptAmount{0};
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ class AMMContext;
|
||||
enum class DebtDirection { issues, redeems };
|
||||
enum class QualityDirection { in, out };
|
||||
enum class StrandDirection { forward, reverse };
|
||||
enum OfferCrossing { no = 0, yes = 1, sell = 2 };
|
||||
enum class OfferCrossing { no = 0, yes = 1, sell = 2 };
|
||||
|
||||
inline bool
|
||||
redeems(DebtDirection dir)
|
||||
|
||||
@@ -665,7 +665,7 @@ flow(
|
||||
// the previous strand execution failed. It has to be reset
|
||||
// since this strand might not have AMM liquidity.
|
||||
ammContext.clear();
|
||||
if (offerCrossing && limitQuality)
|
||||
if (offerCrossing != OfferCrossing::no && limitQuality)
|
||||
{
|
||||
auto const strandQ = qualityUpperBound(sb, *strand);
|
||||
if (!strandQ || *strandQ < *limitQuality)
|
||||
@@ -797,7 +797,8 @@ flow(
|
||||
// fixFillOrKill amendment:
|
||||
// That case is handled here if tfSell is also not set; i.e,
|
||||
// case 1.
|
||||
if (!offerCrossing || (fillOrKillEnabled && offerCrossing != OfferCrossing::sell))
|
||||
if (offerCrossing == OfferCrossing::no ||
|
||||
(fillOrKillEnabled && offerCrossing != OfferCrossing::sell))
|
||||
return {tecPATH_PARTIAL, actualIn, actualOut, std::move(ofrsToRmOnFail)};
|
||||
}
|
||||
else if (actualOut == beast::zero)
|
||||
@@ -805,7 +806,7 @@ flow(
|
||||
return {tecPATH_DRY, std::move(ofrsToRmOnFail)};
|
||||
}
|
||||
}
|
||||
if (offerCrossing &&
|
||||
if (offerCrossing != OfferCrossing::no &&
|
||||
(!partialPayment && (!fillOrKillEnabled || offerCrossing == OfferCrossing::sell)))
|
||||
{
|
||||
// If we're offer crossing and partialPayment is *not* true, then
|
||||
|
||||
@@ -18,8 +18,8 @@ class SignerListSet : public Transactor
|
||||
{
|
||||
private:
|
||||
// Values determined during preCompute for use later.
|
||||
enum Operation { unknown, set, destroy };
|
||||
Operation do_{unknown};
|
||||
enum class Operation { unknown, set, destroy };
|
||||
Operation do_{Operation::unknown};
|
||||
std::uint32_t quorum_{0};
|
||||
std::vector<SignerEntries::SignerEntry> signers_;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace xrpl {
|
||||
class LedgerStateFix : public Transactor
|
||||
{
|
||||
public:
|
||||
enum FixType : std::uint16_t {
|
||||
enum class FixType : std::uint16_t {
|
||||
nfTokenPageLink = 1,
|
||||
};
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ Logs::open(boost::filesystem::path const& pathToLogFile)
|
||||
beast::Journal::Sink&
|
||||
Logs::get(std::string const& name)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
auto const result = sinks_.emplace(name, makeSink(name, thresh_));
|
||||
return *result.first->second;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ Logs::threshold() const
|
||||
void
|
||||
Logs::threshold(beast::severities::Severity thresh)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
thresh_ = thresh;
|
||||
for (auto& sink : sinks_)
|
||||
sink.second->threshold(thresh);
|
||||
@@ -165,7 +165,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 const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
list.reserve(sinks_.size());
|
||||
for (auto const& [name, sink] : sinks_)
|
||||
list.emplace_back(name, toString(fromSeverity(sink->threshold())));
|
||||
@@ -181,7 +181,7 @@ Logs::write(
|
||||
{
|
||||
std::string s;
|
||||
format(s, text, level, partition);
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
file_.writeln(s);
|
||||
if (!silent_)
|
||||
std::cerr << s << '\n';
|
||||
@@ -193,7 +193,7 @@ Logs::write(
|
||||
std::string
|
||||
Logs::rotate()
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
bool const wasOpened = file_.closeAndReopen();
|
||||
if (wasOpened)
|
||||
return "The log file was closed and reopened.";
|
||||
@@ -447,7 +447,7 @@ public:
|
||||
std::unique_ptr<beast::Journal::Sink>
|
||||
set(std::unique_ptr<beast::Journal::Sink> sink)
|
||||
{
|
||||
std::lock_guard const _(m_);
|
||||
std::scoped_lock const _(m_);
|
||||
|
||||
using std::swap;
|
||||
swap(holder_, sink);
|
||||
@@ -467,7 +467,7 @@ public:
|
||||
beast::Journal::Sink&
|
||||
get()
|
||||
{
|
||||
std::lock_guard const _(m_);
|
||||
std::scoped_lock const _(m_);
|
||||
return sink_.get();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ using int128_t = __int128_t;
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
thread_local Number::rounding_mode Number::mode_ = Number::to_nearest;
|
||||
thread_local Number::rounding_mode Number::mode_ = Number::rounding_mode::to_nearest;
|
||||
thread_local std::reference_wrapper<MantissaRange const> Number::range_ = largeRange;
|
||||
|
||||
Number::rounding_mode
|
||||
@@ -51,9 +51,10 @@ Number::getMantissaScale()
|
||||
void
|
||||
Number::setMantissaScale(MantissaRange::mantissa_scale scale)
|
||||
{
|
||||
if (scale != MantissaRange::small && scale != MantissaRange::large)
|
||||
if (scale != MantissaRange::mantissa_scale::small &&
|
||||
scale != MantissaRange::mantissa_scale::large)
|
||||
LogicError("Unknown mantissa scale");
|
||||
range_ = scale == MantissaRange::small ? smallRange : largeRange;
|
||||
range_ = scale == MantissaRange::mantissa_scale::small ? smallRange : largeRange;
|
||||
}
|
||||
|
||||
// Guard
|
||||
@@ -176,10 +177,10 @@ Number::Guard::round() const noexcept
|
||||
{
|
||||
auto mode = Number::getround();
|
||||
|
||||
if (mode == towards_zero)
|
||||
if (mode == rounding_mode::towards_zero)
|
||||
return -1;
|
||||
|
||||
if (mode == downward)
|
||||
if (mode == rounding_mode::downward)
|
||||
{
|
||||
if (sbit_)
|
||||
{
|
||||
@@ -189,7 +190,7 @@ Number::Guard::round() const noexcept
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mode == upward)
|
||||
if (mode == rounding_mode::upward)
|
||||
{
|
||||
if (sbit_)
|
||||
return -1;
|
||||
@@ -729,7 +730,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 const small = Number::getMantissaScale() == MantissaRange::small;
|
||||
bool const small = Number::getMantissaScale() == MantissaRange::mantissa_scale::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");
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
if (m_stopped.exchange(false))
|
||||
{
|
||||
{
|
||||
std::lock_guard const lk{m_mut};
|
||||
std::scoped_lock const lk{m_mut};
|
||||
m_asyncHandlersCompleted = false;
|
||||
}
|
||||
addReference();
|
||||
|
||||
@@ -42,7 +42,7 @@ seconds_clock_thread::~seconds_clock_thread()
|
||||
XRPL_ASSERT(
|
||||
thread_.joinable(), "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable");
|
||||
{
|
||||
std::lock_guard const lock(mut_);
|
||||
std::scoped_lock const lock(mut_);
|
||||
stop_ = true;
|
||||
} // publish stop_ asap so if waiting thread times-out, it will see it
|
||||
cv_.notify_one();
|
||||
|
||||
@@ -204,6 +204,8 @@ class StatsDCollectorImp : public StatsDCollector,
|
||||
public std::enable_shared_from_this<StatsDCollectorImp>
|
||||
{
|
||||
private:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum {
|
||||
// max_packet_size = 484
|
||||
max_packet_size = 1472
|
||||
@@ -293,14 +295,14 @@ public:
|
||||
void
|
||||
add(StatsDMetricBase& metric)
|
||||
{
|
||||
std::lock_guard const _(metricsLock_);
|
||||
std::scoped_lock const _(metricsLock_);
|
||||
metrics_.push_back(metric);
|
||||
}
|
||||
|
||||
void
|
||||
remove(StatsDMetricBase& metric)
|
||||
{
|
||||
std::lock_guard const _(metricsLock_);
|
||||
std::scoped_lock const _(metricsLock_);
|
||||
metrics_.erase(metrics_.iterator_to(metric));
|
||||
}
|
||||
|
||||
@@ -444,7 +446,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard const _(metricsLock_);
|
||||
std::scoped_lock const _(metricsLock_);
|
||||
|
||||
for (auto& m : metrics_)
|
||||
m.do_process();
|
||||
|
||||
@@ -158,7 +158,7 @@ PropertyStream::Source::Source(std::string name) : m_name(std::move(name)), item
|
||||
|
||||
PropertyStream::Source::~Source()
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
if (parent_ != nullptr)
|
||||
parent_->remove(*this);
|
||||
removeAll();
|
||||
@@ -173,9 +173,7 @@ PropertyStream::Source::name() const
|
||||
void
|
||||
PropertyStream::Source::add(Source& source)
|
||||
{
|
||||
std::lock(lock_, source.lock_);
|
||||
std::lock_guard const lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard const lk2(source.lock_, std::adopt_lock);
|
||||
std::scoped_lock const lock(lock_, source.lock_);
|
||||
|
||||
XRPL_ASSERT(
|
||||
source.parent_ == nullptr, "beast::PropertyStream::Source::add : null source parent");
|
||||
@@ -186,9 +184,7 @@ PropertyStream::Source::add(Source& source)
|
||||
void
|
||||
PropertyStream::Source::remove(Source& child)
|
||||
{
|
||||
std::lock(lock_, child.lock_);
|
||||
std::lock_guard const lk1(lock_, std::adopt_lock);
|
||||
std::lock_guard const lk2(child.lock_, std::adopt_lock);
|
||||
std::scoped_lock const lock(lock_, child.lock_);
|
||||
|
||||
XRPL_ASSERT(
|
||||
child.parent_ == this, "beast::PropertyStream::Source::remove : child parent match");
|
||||
@@ -199,10 +195,10 @@ PropertyStream::Source::remove(Source& child)
|
||||
void
|
||||
PropertyStream::Source::removeAll()
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
for (auto iter = children_.begin(); iter != children_.end();)
|
||||
{
|
||||
std::lock_guard const _cl((*iter)->lock_);
|
||||
std::scoped_lock const _cl((*iter)->lock_);
|
||||
remove(*(*iter));
|
||||
}
|
||||
}
|
||||
@@ -222,7 +218,7 @@ PropertyStream::Source::write(PropertyStream& stream)
|
||||
Map map(m_name, stream);
|
||||
onWrite(map);
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
|
||||
for (auto& child : children_)
|
||||
child.source().write(stream);
|
||||
@@ -324,7 +320,7 @@ PropertyStream::Source::find_one_deep(std::string const& name)
|
||||
if (found != nullptr)
|
||||
return found;
|
||||
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
for (auto& s : children_)
|
||||
{
|
||||
found = s.source().find_one_deep(name);
|
||||
@@ -355,7 +351,7 @@ PropertyStream::Source::find_path(std::string path)
|
||||
PropertyStream::Source*
|
||||
PropertyStream::Source::find_one(std::string const& name)
|
||||
{
|
||||
std::lock_guard const _(lock_);
|
||||
std::scoped_lock const _(lock_);
|
||||
for (auto& s : children_)
|
||||
{
|
||||
if (s.source().m_name == name)
|
||||
|
||||
@@ -34,7 +34,7 @@ HashRouter::emplace(uint256 const& key) -> std::pair<Entry&, bool>
|
||||
void
|
||||
HashRouter::addSuppression(uint256 const& key)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
emplace(key);
|
||||
}
|
||||
@@ -48,7 +48,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 const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto result = emplace(key);
|
||||
result.first.addPeer(peer);
|
||||
@@ -58,7 +58,7 @@ HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer)
|
||||
bool
|
||||
HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer, HashRouterFlags& flags)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto [s, created] = emplace(key);
|
||||
s.addPeer(peer);
|
||||
@@ -73,7 +73,7 @@ HashRouter::shouldProcess(
|
||||
HashRouterFlags& flags,
|
||||
std::chrono::seconds tx_interval)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto result = emplace(key);
|
||||
auto& s = result.first;
|
||||
@@ -85,7 +85,7 @@ HashRouter::shouldProcess(
|
||||
HashRouterFlags
|
||||
HashRouter::getFlags(uint256 const& key)
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
return emplace(key).first.getFlags();
|
||||
}
|
||||
@@ -95,7 +95,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
|
||||
{
|
||||
XRPL_ASSERT(static_cast<bool>(flags), "xrpl::HashRouter::setFlags : valid input");
|
||||
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto& s = emplace(key).first;
|
||||
|
||||
@@ -109,7 +109,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
|
||||
auto
|
||||
HashRouter::shouldRelay(uint256 const& key) -> std::optional<std::set<PeerShortID>>
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto& s = emplace(key).first;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ JobQueue::JobQueue(
|
||||
job_count = m_collector->make_gauge("job_count");
|
||||
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
|
||||
for (auto const& x : JobTypes::instance())
|
||||
{
|
||||
@@ -65,7 +65,7 @@ JobQueue::~JobQueue()
|
||||
void
|
||||
JobQueue::collect()
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
job_count = m_jobSet.size();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
|
||||
"requires no threads");
|
||||
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
auto result = m_jobSet.emplace(type, name, ++m_lastJob, data.load(), func);
|
||||
auto const& job = *result.first;
|
||||
|
||||
@@ -119,7 +119,7 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
|
||||
int
|
||||
JobQueue::getJobCount(JobType t) const
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
|
||||
JobDataMap::const_iterator const c = m_jobData.find(t);
|
||||
|
||||
@@ -129,7 +129,7 @@ JobQueue::getJobCount(JobType t) const
|
||||
int
|
||||
JobQueue::getJobCountTotal(JobType t) const
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
|
||||
JobDataMap::const_iterator const c = m_jobData.find(t);
|
||||
|
||||
@@ -142,7 +142,7 @@ JobQueue::getJobCountGE(JobType t) const
|
||||
// return the number of jobs at this priority level or greater
|
||||
int ret = 0;
|
||||
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
|
||||
for (auto const& x : m_jobData)
|
||||
{
|
||||
@@ -192,7 +192,7 @@ JobQueue::getJson(int c)
|
||||
|
||||
Json::Value priorities = Json::arrayValue;
|
||||
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
|
||||
for (auto& x : m_jobData)
|
||||
{
|
||||
@@ -349,7 +349,7 @@ JobQueue::processTask(int instance)
|
||||
{
|
||||
Job job;
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
getNextJob(job);
|
||||
++m_processCount;
|
||||
}
|
||||
@@ -376,7 +376,7 @@ JobQueue::processTask(int instance)
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard const lock(m_mutex);
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
// Job should be destroyed before stopping
|
||||
// otherwise destructors with side effects can access
|
||||
// parent objects that are already destroyed.
|
||||
|
||||
@@ -108,7 +108,7 @@ LoadMonitor::addLoadSample(LoadEvent const& s)
|
||||
void
|
||||
LoadMonitor::addSamples(int count, std::chrono::milliseconds latency)
|
||||
{
|
||||
std::lock_guard const sl(mutex_);
|
||||
std::scoped_lock const sl(mutex_);
|
||||
|
||||
update();
|
||||
mCounts += count;
|
||||
@@ -140,7 +140,7 @@ LoadMonitor::isOverTarget(std::chrono::milliseconds avg, std::chrono::millisecon
|
||||
bool
|
||||
LoadMonitor::isOver()
|
||||
{
|
||||
std::lock_guard const sl(mutex_);
|
||||
std::scoped_lock const sl(mutex_);
|
||||
|
||||
update();
|
||||
|
||||
@@ -157,7 +157,7 @@ LoadMonitor::getStats()
|
||||
using namespace std::chrono_literals;
|
||||
Stats stats;
|
||||
|
||||
std::lock_guard const sl(mutex_);
|
||||
std::scoped_lock const sl(mutex_);
|
||||
|
||||
update();
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ Workers::Worker::Worker(Workers& workers, std::string threadName, int const inst
|
||||
Workers::Worker::~Worker()
|
||||
{
|
||||
{
|
||||
std::lock_guard const lock{mutex_};
|
||||
std::scoped_lock const lock{mutex_};
|
||||
++wakeCount_;
|
||||
shouldExit_ = true;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ Workers::Worker::~Worker()
|
||||
void
|
||||
Workers::Worker::notify()
|
||||
{
|
||||
std::lock_guard const lock{mutex_};
|
||||
std::scoped_lock const lock{mutex_};
|
||||
++wakeCount_;
|
||||
wakeup_.notify_one();
|
||||
}
|
||||
@@ -179,7 +179,7 @@ Workers::Worker::run()
|
||||
//
|
||||
if (++m_workers.m_activeCount == 1)
|
||||
{
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
std::scoped_lock const lk{m_workers.m_mut};
|
||||
m_workers.m_allPaused = false;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ Workers::Worker::run()
|
||||
// the predicate evaluation and the actual sleep.
|
||||
if (--m_workers.m_runningTaskCount == 0)
|
||||
{
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
std::scoped_lock const lk{m_workers.m_mut};
|
||||
m_workers.m_cv.notify_all();
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ Workers::Worker::run()
|
||||
//
|
||||
if (--m_workers.m_activeCount == 0)
|
||||
{
|
||||
std::lock_guard const lk{m_workers.m_mut};
|
||||
std::scoped_lock const lk{m_workers.m_mut};
|
||||
m_workers.m_allPaused = true;
|
||||
m_workers.m_cv.notify_all();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ csprng_engine::mix_entropy(void* buffer, std::size_t count)
|
||||
e = rd();
|
||||
}
|
||||
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
// We add data to the pool, but we conservatively assume that
|
||||
// it contributes no actual entropy.
|
||||
@@ -60,7 +60,7 @@ csprng_engine::operator()(void* ptr, std::size_t count)
|
||||
// with thread support, so we don't need to grab a mutex.
|
||||
// https://mta.openssl.org/pipermail/openssl-users/2020-November/013146.html
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || !defined(OPENSSL_THREADS)
|
||||
std::lock_guard lock(mutex_);
|
||||
std::scoped_lock lock(mutex_);
|
||||
#endif
|
||||
|
||||
auto const result = RAND_bytes(reinterpret_cast<unsigned char*>(ptr), count);
|
||||
|
||||
@@ -45,7 +45,7 @@ outputJson(Json::Value const& value, Writer& writer)
|
||||
}
|
||||
|
||||
case Json::arrayValue: {
|
||||
writer.startRoot(Writer::array);
|
||||
writer.startRoot(Writer::CollectionType::array);
|
||||
for (auto const& i : value)
|
||||
{
|
||||
writer.rawAppend();
|
||||
@@ -56,7 +56,7 @@ outputJson(Json::Value const& value, Writer& writer)
|
||||
}
|
||||
|
||||
case Json::objectValue: {
|
||||
writer.startRoot(Writer::object);
|
||||
writer.startRoot(Writer::CollectionType::object);
|
||||
auto members = value.getMemberNames();
|
||||
for (auto const& tag : members)
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
void
|
||||
start(CollectionType ct)
|
||||
{
|
||||
char const ch = (ct == array) ? openBracket : openBrace;
|
||||
char const ch = (ct == CollectionType::array) ? openBracket : openBrace;
|
||||
output({&ch, 1});
|
||||
stack_.emplace(Collection{.type = ct});
|
||||
}
|
||||
@@ -134,7 +134,9 @@ public:
|
||||
auto t = stack_.top().type;
|
||||
if (t != type)
|
||||
{
|
||||
check(false, "Not an " + ((type == array ? "array: " : "object: ") + message));
|
||||
check(
|
||||
false,
|
||||
"Not an " + ((type == CollectionType::array ? "array: " : "object: ") + message));
|
||||
}
|
||||
if (stack_.top().isFirst)
|
||||
{
|
||||
@@ -171,7 +173,7 @@ public:
|
||||
{
|
||||
check(!empty(), "Empty stack in finish()");
|
||||
|
||||
auto isArray = stack_.top().type == array;
|
||||
auto isArray = stack_.top().type == CollectionType::array;
|
||||
auto ch = isArray ? closeBracket : closeBrace;
|
||||
output_({&ch, 1});
|
||||
stack_.pop();
|
||||
@@ -301,7 +303,7 @@ Writer::finishAll()
|
||||
void
|
||||
Writer::rawAppend()
|
||||
{
|
||||
impl_->nextCollectionEntry(array, "append");
|
||||
impl_->nextCollectionEntry(CollectionType::array, "append");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -309,7 +311,7 @@ Writer::rawSet(std::string const& tag)
|
||||
{
|
||||
check(!tag.empty(), "Tag can't be empty");
|
||||
|
||||
impl_->nextCollectionEntry(object, "set");
|
||||
impl_->nextCollectionEntry(CollectionType::object, "set");
|
||||
impl_->writeObjectTag(tag);
|
||||
}
|
||||
|
||||
@@ -322,14 +324,14 @@ Writer::startRoot(CollectionType type)
|
||||
void
|
||||
Writer::startAppend(CollectionType type)
|
||||
{
|
||||
impl_->nextCollectionEntry(array, "startAppend");
|
||||
impl_->nextCollectionEntry(CollectionType::array, "startAppend");
|
||||
impl_->start(type);
|
||||
}
|
||||
|
||||
void
|
||||
Writer::startSet(CollectionType type, std::string const& key)
|
||||
{
|
||||
impl_->nextCollectionEntry(object, "startSet");
|
||||
impl_->nextCollectionEntry(CollectionType::object, "startSet");
|
||||
impl_->writeObjectTag(key);
|
||||
impl_->start(type);
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ AcceptedLedgerTx::AcceptedLedgerTx(
|
||||
*ledger,
|
||||
account,
|
||||
amount,
|
||||
fhIGNORE_FREEZE,
|
||||
ahIGNORE_AUTH,
|
||||
FreezeHandling::fhIGNORE_FREEZE,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
beast::Journal{beast::Journal::getNullSink()});
|
||||
mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText();
|
||||
}
|
||||
|
||||
@@ -13,21 +13,21 @@ namespace xrpl {
|
||||
void
|
||||
BookListeners::addSubscriber(InfoSub::ref sub)
|
||||
{
|
||||
std::lock_guard const sl(mLock);
|
||||
std::scoped_lock const sl(mLock);
|
||||
mListeners[sub->getSeq()] = sub;
|
||||
}
|
||||
|
||||
void
|
||||
BookListeners::removeSubscriber(std::uint64_t seq)
|
||||
{
|
||||
std::lock_guard const sl(mLock);
|
||||
std::scoped_lock const sl(mLock);
|
||||
mListeners.erase(seq);
|
||||
}
|
||||
|
||||
void
|
||||
BookListeners::publish(MultiApiJson const& jvObj, hash_set<std::uint64_t>& havePublished)
|
||||
{
|
||||
std::lock_guard const sl(mLock);
|
||||
std::scoped_lock const sl(mLock);
|
||||
auto it = mListeners.cbegin();
|
||||
|
||||
while (it != mListeners.cend())
|
||||
|
||||
@@ -30,7 +30,7 @@ CachedViewImpl::read(Keylet const& k) const
|
||||
|
||||
auto const digest = [&]() -> std::optional<uint256> {
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
auto const iter = map_.find(k.key);
|
||||
if (iter != map_.end())
|
||||
{
|
||||
@@ -66,7 +66,7 @@ CachedViewImpl::read(Keylet const& k) const
|
||||
// Avoid acquiring this lock unless necessary. It is only necessary if
|
||||
// the key was not found in the map_. The lock is needed to add the key
|
||||
// and digest.
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
map_.emplace(k.key, *digest);
|
||||
}
|
||||
if (!sle || !k.check(*sle))
|
||||
|
||||
@@ -204,7 +204,7 @@ Ledger::Ledger(
|
||||
rawInsert(sle);
|
||||
}
|
||||
|
||||
stateMap_.flushDirty(hotACCOUNT_NODE);
|
||||
stateMap_.flushDirty(NodeObjectType::hotACCOUNT_NODE);
|
||||
setImmutable();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ STAmount
|
||||
ammLPTokens(STAmount const& asset1, STAmount const& asset2, Asset const& lptIssue)
|
||||
{
|
||||
// AMM invariant: sqrt(asset1 * asset2) >= LPTokensBalance
|
||||
auto const rounding = isFeatureEnabled(fixAMMv1_3) ? Number::downward : Number::getround();
|
||||
auto const rounding =
|
||||
isFeatureEnabled(fixAMMv1_3) ? Number::rounding_mode::downward : Number::getround();
|
||||
NumberRoundModeGuard const g(rounding);
|
||||
auto const tokens = root2(asset1 * asset2);
|
||||
return toSTAmount(lptIssue, tokens);
|
||||
@@ -77,7 +78,7 @@ lpTokensOut(
|
||||
|
||||
// minimize tokens out
|
||||
auto const frac = (r - c) / (1 + c);
|
||||
return multiply(lptAMMBalance, frac, Number::downward);
|
||||
return multiply(lptAMMBalance, frac, Number::rounding_mode::downward);
|
||||
}
|
||||
|
||||
/* Equation 4 solves equation 3 for b:
|
||||
@@ -113,7 +114,7 @@ ammAssetIn(
|
||||
|
||||
// maximize deposit
|
||||
auto const frac = solveQuadraticEq(a, b, c);
|
||||
return multiply(asset1Balance, frac, Number::upward);
|
||||
return multiply(asset1Balance, frac, Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
/* Equation 7:
|
||||
@@ -138,7 +139,7 @@ lpTokensIn(
|
||||
|
||||
// maximize tokens in
|
||||
auto const frac = (c - root2(c * c - 4 * fr)) / 2;
|
||||
return multiply(lptAMMBalance, frac, Number::upward);
|
||||
return multiply(lptAMMBalance, frac, Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
/* Equation 8 solves equation 7 for b:
|
||||
@@ -168,7 +169,7 @@ ammAssetOut(
|
||||
|
||||
// minimize withdraw
|
||||
auto const frac = (t1 * t1 - t1 * (2 - f)) / (t1 * f - 1);
|
||||
return multiply(assetBalance, frac, Number::downward);
|
||||
return multiply(assetBalance, frac, Number::rounding_mode::downward);
|
||||
}
|
||||
|
||||
Number
|
||||
|
||||
@@ -93,8 +93,8 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval)
|
||||
bool
|
||||
isRounded(Asset const& asset, Number const& value, std::int32_t scale)
|
||||
{
|
||||
return roundToAsset(asset, value, scale, Number::downward) ==
|
||||
roundToAsset(asset, value, scale, Number::upward);
|
||||
return roundToAsset(asset, value, scale, Number::rounding_mode::downward) ==
|
||||
roundToAsset(asset, value, scale, Number::rounding_mode::upward);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
@@ -458,7 +458,11 @@ tryOverpayment(
|
||||
// preserved rounding errors. This ensures the loan's tracked state remains
|
||||
// consistent with its payment history.
|
||||
auto const principalOutstanding = std::clamp(
|
||||
roundToAsset(asset, newTheoreticalState.principalOutstanding, loanScale, Number::upward),
|
||||
roundToAsset(
|
||||
asset,
|
||||
newTheoreticalState.principalOutstanding,
|
||||
loanScale,
|
||||
Number::rounding_mode::upward),
|
||||
numZero,
|
||||
roundedOldState.principalOutstanding);
|
||||
auto const totalValueOutstanding = std::clamp(
|
||||
@@ -466,7 +470,7 @@ tryOverpayment(
|
||||
asset,
|
||||
principalOutstanding + newTheoreticalState.interestOutstanding(),
|
||||
loanScale,
|
||||
Number::upward),
|
||||
Number::rounding_mode::upward),
|
||||
numZero,
|
||||
roundedOldState.valueOutstanding);
|
||||
auto const managementFeeOutstanding = std::clamp(
|
||||
@@ -836,7 +840,8 @@ computeFullPayment(
|
||||
// Split the full payment interest into net interest (to vault) and
|
||||
// management fee (to broker), applying proper rounding.
|
||||
auto const [roundedFullInterest, roundedFullManagementFee] = [&]() {
|
||||
auto const interest = roundToAsset(asset, fullPaymentInterest, loanScale, Number::downward);
|
||||
auto const interest =
|
||||
roundToAsset(asset, fullPaymentInterest, loanScale, Number::rounding_mode::downward);
|
||||
return computeInterestAndFeeParts(asset, interest, managementFeeRate, loanScale);
|
||||
}();
|
||||
|
||||
@@ -1286,7 +1291,7 @@ checkLoanGuards(
|
||||
// loan can't be amortized in the specified number of payments, raise an
|
||||
// error
|
||||
{
|
||||
NumberRoundModeGuard const mg(Number::upward);
|
||||
NumberRoundModeGuard const mg(Number::rounding_mode::upward);
|
||||
|
||||
if (std::int64_t const computedPayments{
|
||||
properties.loanState.valueOutstanding / roundedPayment};
|
||||
@@ -1465,7 +1470,8 @@ computeManagementFee(
|
||||
TenthBips32 managementFeeRate,
|
||||
std::int32_t scale)
|
||||
{
|
||||
return roundToAsset(asset, tenthBipsOfValue(value, managementFeeRate), scale, Number::downward);
|
||||
return roundToAsset(
|
||||
asset, tenthBipsOfValue(value, managementFeeRate), scale, Number::rounding_mode::downward);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1519,7 +1525,8 @@ computeLoanProperties(
|
||||
|
||||
auto const [totalValueOutstanding, loanScale] = [&]() {
|
||||
// only round up if there should be interest
|
||||
NumberRoundModeGuard const mg(periodicRate == 0 ? Number::to_nearest : Number::upward);
|
||||
NumberRoundModeGuard const mg(
|
||||
periodicRate == 0 ? Number::rounding_mode::to_nearest : Number::rounding_mode::upward);
|
||||
// Use STAmount's internal rounding instead of roundToAsset, because
|
||||
// we're going to use this result to determine the scale for all the
|
||||
// other rounding.
|
||||
@@ -1548,7 +1555,7 @@ computeLoanProperties(
|
||||
// validate that the principal fits in it, so to allow this function to
|
||||
// succeed, round it here, and let the caller do the validation.
|
||||
auto const roundedPrincipalOutstanding =
|
||||
roundToAsset(asset, principalOutstanding, loanScale, Number::to_nearest);
|
||||
roundToAsset(asset, principalOutstanding, loanScale, Number::rounding_mode::to_nearest);
|
||||
|
||||
// Equation (31) from XLS-66 spec, Section A-2 Equation Glossary
|
||||
auto const totalInterestOutstanding = totalValueOutstanding - roundedPrincipalOutstanding;
|
||||
|
||||
@@ -165,7 +165,7 @@ getLineIfUsable(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (zeroIfFrozen == fhZERO_IF_FROZEN)
|
||||
if (zeroIfFrozen == FreezeHandling::fhZERO_IF_FROZEN)
|
||||
{
|
||||
if (isFrozen(view, account, currency, issuer) ||
|
||||
isDeepFrozen(view, account, currency, issuer))
|
||||
@@ -252,7 +252,7 @@ accountHolds(
|
||||
return {xrpLiquid(view, account, 0, j)};
|
||||
}
|
||||
|
||||
bool const returnSpendable = (includeFullBalance == shFULL_BALANCE);
|
||||
bool const returnSpendable = (includeFullBalance == SpendableHandling::shFULL_BALANCE);
|
||||
if (returnSpendable && account == issuer)
|
||||
{
|
||||
// If the account is the issuer, then their limit is effectively
|
||||
@@ -290,7 +290,7 @@ accountHolds(
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance)
|
||||
{
|
||||
bool const returnSpendable = (includeFullBalance == shFULL_BALANCE);
|
||||
bool const returnSpendable = (includeFullBalance == SpendableHandling::shFULL_BALANCE);
|
||||
STAmount amount{mptIssue};
|
||||
auto const& issuer = mptIssue.getIssuer();
|
||||
bool const mptokensV2 = view.rules().enabled(featureMPTokensV2);
|
||||
@@ -317,7 +317,7 @@ accountHolds(
|
||||
{
|
||||
amount.clear(mptIssue);
|
||||
}
|
||||
else if (zeroIfFrozen == fhZERO_IF_FROZEN && isFrozen(view, account, mptIssue))
|
||||
else if (zeroIfFrozen == FreezeHandling::fhZERO_IF_FROZEN && isFrozen(view, account, mptIssue))
|
||||
{
|
||||
amount.clear(mptIssue);
|
||||
}
|
||||
@@ -327,14 +327,14 @@ accountHolds(
|
||||
|
||||
// Only if auth check is needed, as it needs to do an additional read
|
||||
// operation. Note featureSingleAssetVault will affect error codes.
|
||||
if (zeroIfUnauthorized == ahZERO_IF_UNAUTHORIZED &&
|
||||
if (zeroIfUnauthorized == AuthHandling::ahZERO_IF_UNAUTHORIZED &&
|
||||
view.rules().enabled(featureSingleAssetVault))
|
||||
{
|
||||
if (auto const err = requireAuth(view, mptIssue, account, AuthType::StrongAuth);
|
||||
!isTesSuccess(err))
|
||||
amount.clear(mptIssue);
|
||||
}
|
||||
else if (zeroIfUnauthorized == ahZERO_IF_UNAUTHORIZED)
|
||||
else if (zeroIfUnauthorized == AuthHandling::ahZERO_IF_UNAUTHORIZED)
|
||||
{
|
||||
auto const sleIssuance = view.read(keylet::mptIssuance(mptIssue.getMptID()));
|
||||
|
||||
@@ -401,7 +401,13 @@ accountFunds(
|
||||
[&](Issue const&) { return accountFunds(view, id, saDefault, freezeHandling, j); },
|
||||
[&](MPTIssue const&) {
|
||||
return accountHolds(
|
||||
view, id, saDefault.asset(), freezeHandling, authHandling, j, shFULL_BALANCE);
|
||||
view,
|
||||
id,
|
||||
saDefault.asset(),
|
||||
freezeHandling,
|
||||
authHandling,
|
||||
j,
|
||||
SpendableHandling::shFULL_BALANCE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ BatchWriter::store(std::shared_ptr<NodeObject> const& object)
|
||||
int
|
||||
BatchWriter::getWriteLoad()
|
||||
{
|
||||
std::lock_guard const sl(mWriteMutex);
|
||||
std::scoped_lock const sl(mWriteMutex);
|
||||
|
||||
return std::max(mWriteLoad, static_cast<int>(mWriteSet.size()));
|
||||
}
|
||||
@@ -68,7 +68,7 @@ BatchWriter::writeBatch()
|
||||
set.reserve(batchWritePreallocationSize);
|
||||
|
||||
{
|
||||
std::lock_guard const sl(mWriteMutex);
|
||||
std::scoped_lock const sl(mWriteMutex);
|
||||
|
||||
mWriteSet.swap(set);
|
||||
XRPL_ASSERT(
|
||||
|
||||
@@ -143,7 +143,7 @@ void
|
||||
Database::stop()
|
||||
{
|
||||
{
|
||||
std::lock_guard const lock(readLock_);
|
||||
std::scoped_lock const lock(readLock_);
|
||||
|
||||
if (!readStopping_.exchange(true, std::memory_order_relaxed))
|
||||
{
|
||||
@@ -179,7 +179,7 @@ Database::asyncFetch(
|
||||
std::uint32_t ledgerSeq,
|
||||
std::function<void(std::shared_ptr<NodeObject> const&)>&& cb)
|
||||
{
|
||||
std::lock_guard const lock(readLock_);
|
||||
std::scoped_lock const lock(readLock_);
|
||||
|
||||
if (!isStopping())
|
||||
{
|
||||
|
||||
@@ -48,11 +48,11 @@ DatabaseNodeImp::fetchNodeObject(
|
||||
bool duplicate)
|
||||
{
|
||||
std::shared_ptr<NodeObject> nodeObject = nullptr;
|
||||
Status status = ok;
|
||||
Status status = Status::ok;
|
||||
|
||||
try
|
||||
{
|
||||
status = backend_->fetch(hash.data(), &nodeObject);
|
||||
status = backend_->fetch(hash, &nodeObject);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
@@ -63,15 +63,15 @@ DatabaseNodeImp::fetchNodeObject(
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case ok:
|
||||
case notFound:
|
||||
case Status::ok:
|
||||
case Status::notFound:
|
||||
break;
|
||||
case dataCorrupt:
|
||||
case Status::dataCorrupt:
|
||||
JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": nodestore data is corrupted";
|
||||
break;
|
||||
default:
|
||||
JLOG(j_.warn()) << "fetchNodeObject " << hash << ": backend returns unknown result "
|
||||
<< status;
|
||||
<< static_cast<int>(status);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -87,18 +87,10 @@ DatabaseNodeImp::fetchBatch(std::vector<uint256> const& hashes)
|
||||
using namespace std::chrono;
|
||||
auto const before = steady_clock::now();
|
||||
|
||||
std::vector<uint256 const*> batch{};
|
||||
batch.reserve(hashes.size());
|
||||
for (size_t i = 0; i < hashes.size(); ++i)
|
||||
{
|
||||
auto const& hash = hashes[i];
|
||||
batch.push_back(&hash);
|
||||
}
|
||||
|
||||
// Get the node objects that match the hashes from the backend. To protect
|
||||
// against the backends returning fewer or more results than expected, the
|
||||
// container is resized to the number of hashes.
|
||||
auto results = backend_->fetchBatch(batch).first;
|
||||
auto results = backend_->fetchBatch(hashes).first;
|
||||
XRPL_ASSERT(
|
||||
results.size() == hashes.size() || results.empty(),
|
||||
"number of output objects either matches number of input hashes or is empty");
|
||||
|
||||
@@ -53,7 +53,7 @@ DatabaseRotatingImp::rotate(
|
||||
// deleted.
|
||||
std::shared_ptr<NodeStore::Backend> oldArchiveBackend;
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
archiveBackend_->setDeletePath();
|
||||
oldArchiveBackend = std::move(archiveBackend_);
|
||||
@@ -70,14 +70,14 @@ DatabaseRotatingImp::rotate(
|
||||
std::string
|
||||
DatabaseRotatingImp::getName() const
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return writableBackend_->getName();
|
||||
}
|
||||
|
||||
std::int32_t
|
||||
DatabaseRotatingImp::getWriteLoad() const
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return writableBackend_->getWriteLoad();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void
|
||||
DatabaseRotatingImp::importDatabase(Database& source)
|
||||
{
|
||||
auto const backend = [&] {
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return writableBackend_;
|
||||
}();
|
||||
|
||||
@@ -95,7 +95,7 @@ DatabaseRotatingImp::importDatabase(Database& source)
|
||||
void
|
||||
DatabaseRotatingImp::sync()
|
||||
{
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
writableBackend_->sync();
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ DatabaseRotatingImp::store(NodeObjectType type, Blob&& data, uint256 const& hash
|
||||
auto nObj = NodeObject::createObject(type, std::move(data), hash);
|
||||
|
||||
auto const backend = [&] {
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return writableBackend_;
|
||||
}();
|
||||
|
||||
@@ -121,11 +121,11 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
bool duplicate)
|
||||
{
|
||||
auto fetch = [&](std::shared_ptr<Backend> const& backend) {
|
||||
Status status = ok;
|
||||
Status status = Status::ok;
|
||||
std::shared_ptr<NodeObject> nodeObject;
|
||||
try
|
||||
{
|
||||
status = backend->fetch(hash.data(), &nodeObject);
|
||||
status = backend->fetch(hash, &nodeObject);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
@@ -135,14 +135,14 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case ok:
|
||||
case notFound:
|
||||
case Status::ok:
|
||||
case Status::notFound:
|
||||
break;
|
||||
case dataCorrupt:
|
||||
case Status::dataCorrupt:
|
||||
JLOG(j_.fatal()) << "Corrupt NodeObject #" << hash;
|
||||
break;
|
||||
default:
|
||||
JLOG(j_.warn()) << "Unknown status=" << status;
|
||||
JLOG(j_.warn()) << "Unknown status=" << static_cast<int>(status);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
std::shared_ptr<NodeObject> nodeObject;
|
||||
|
||||
auto [writable, archive] = [&] {
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return std::make_pair(writableBackend_, archiveBackend_);
|
||||
}();
|
||||
|
||||
@@ -167,7 +167,7 @@ DatabaseRotatingImp::fetchNodeObject(
|
||||
{
|
||||
{
|
||||
// Refresh the writable backend pointer
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
writable = writableBackend_;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ void
|
||||
DatabaseRotatingImp::for_each(std::function<void(std::shared_ptr<NodeObject>)> f)
|
||||
{
|
||||
auto [writable, archive] = [&] {
|
||||
std::lock_guard const lock(mutex_);
|
||||
std::scoped_lock const lock(mutex_);
|
||||
return std::make_pair(writableBackend_, archiveBackend_);
|
||||
}();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
|
||||
|
||||
m_success = false;
|
||||
m_key = key;
|
||||
m_objectType = hotUNKNOWN;
|
||||
m_objectType = NodeObjectType::hotUNKNOWN;
|
||||
m_objectData = nullptr;
|
||||
m_dataBytes = std::max(0, valueBytes - 9);
|
||||
|
||||
@@ -46,10 +46,10 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
|
||||
default:
|
||||
break;
|
||||
|
||||
case hotUNKNOWN:
|
||||
case hotLEDGER:
|
||||
case hotACCOUNT_NODE:
|
||||
case hotTRANSACTION_NODE:
|
||||
case NodeObjectType::hotUNKNOWN:
|
||||
case NodeObjectType::hotLEDGER:
|
||||
case NodeObjectType::hotACCOUNT_NODE:
|
||||
case NodeObjectType::hotTRANSACTION_NODE:
|
||||
m_success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -96,14 +96,14 @@ ManagerImp::make_Database(
|
||||
void
|
||||
ManagerImp::insert(Factory& factory)
|
||||
{
|
||||
std::lock_guard const _(mutex_);
|
||||
std::scoped_lock const _(mutex_);
|
||||
list_.push_back(&factory);
|
||||
}
|
||||
|
||||
void
|
||||
ManagerImp::erase(Factory& factory)
|
||||
{
|
||||
std::lock_guard const _(mutex_);
|
||||
std::scoped_lock const _(mutex_);
|
||||
auto const iter =
|
||||
std::ranges::find_if(list_, [&factory](Factory* other) { return other == &factory; });
|
||||
XRPL_ASSERT(iter != list_.end(), "xrpl::NodeStore::ManagerImp::erase : valid input");
|
||||
@@ -113,7 +113,7 @@ ManagerImp::erase(Factory& factory)
|
||||
Factory*
|
||||
ManagerImp::find(std::string const& name)
|
||||
{
|
||||
std::lock_guard const _(mutex_);
|
||||
std::scoped_lock const _(mutex_);
|
||||
auto const iter = std::ranges::find_if(
|
||||
list_, [&name](Factory* other) { return boost::iequals(name, other->getName()); });
|
||||
if (iter == list_.end())
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
MemoryDB&
|
||||
open(std::string const& path)
|
||||
{
|
||||
std::lock_guard const _(mutex_);
|
||||
std::scoped_lock const _(mutex_);
|
||||
auto const result =
|
||||
map_.emplace(std::piecewise_construct, std::make_tuple(path), std::make_tuple());
|
||||
MemoryDB& db = result.first->second;
|
||||
@@ -134,16 +134,16 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(db_, "xrpl::NodeStore::MemoryBackend::fetch : non-null database");
|
||||
|
||||
std::lock_guard const _(db_->mutex);
|
||||
std::scoped_lock const _(db_->mutex);
|
||||
|
||||
Map::iterator const iter = db_->table.find(hash);
|
||||
if (iter == db_->table.end())
|
||||
{
|
||||
pObject->reset();
|
||||
return notFound;
|
||||
return Status::notFound;
|
||||
}
|
||||
*pObject = iter->second;
|
||||
return ok;
|
||||
return Status::ok;
|
||||
}
|
||||
|
||||
std::pair<std::vector<std::shared_ptr<NodeObject>>, Status>
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
{
|
||||
std::shared_ptr<NodeObject> nObj;
|
||||
Status const status = fetch(h, &nObj);
|
||||
if (status != ok)
|
||||
if (status != Status::ok)
|
||||
{
|
||||
results.push_back({});
|
||||
}
|
||||
@@ -165,14 +165,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return {results, ok};
|
||||
return {results, Status::ok};
|
||||
}
|
||||
|
||||
void
|
||||
store(std::shared_ptr<NodeObject> const& object) override
|
||||
{
|
||||
XRPL_ASSERT(db_, "xrpl::NodeStore::MemoryBackend::store : non-null database");
|
||||
std::lock_guard const _(db_->mutex);
|
||||
std::scoped_lock const _(db_->mutex);
|
||||
db_->table.emplace(object->getHash(), object);
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
Status
|
||||
fetch(uint256 const& hash, std::shared_ptr<NodeObject>* pno) override
|
||||
{
|
||||
Status status = ok;
|
||||
Status status = Status::ok;
|
||||
pno->reset();
|
||||
nudb::error_code ec;
|
||||
db_.fetch(
|
||||
@@ -218,15 +218,15 @@ public:
|
||||
DecodedBlob decoded(hash.data(), result.first, result.second);
|
||||
if (!decoded.wasOk())
|
||||
{
|
||||
status = dataCorrupt;
|
||||
status = Status::dataCorrupt;
|
||||
return;
|
||||
}
|
||||
*pno = decoded.createObject();
|
||||
status = ok;
|
||||
status = Status::ok;
|
||||
},
|
||||
ec);
|
||||
if (ec == nudb::error::key_not_found)
|
||||
return notFound;
|
||||
return Status::notFound;
|
||||
if (ec)
|
||||
Throw<nudb::system_error>(ec);
|
||||
return status;
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
{
|
||||
std::shared_ptr<NodeObject> nObj;
|
||||
Status const status = fetch(h, &nObj);
|
||||
if (status != ok)
|
||||
if (status != Status::ok)
|
||||
{
|
||||
results.push_back({});
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return {results, ok};
|
||||
return {results, Status::ok};
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -47,13 +47,13 @@ public:
|
||||
}
|
||||
|
||||
Status
|
||||
fetch(void const*, std::shared_ptr<NodeObject>*) override
|
||||
fetch(uint256 const&, std::shared_ptr<NodeObject>*) override
|
||||
{
|
||||
return notFound;
|
||||
return Status::notFound;
|
||||
}
|
||||
|
||||
std::pair<std::vector<std::shared_ptr<NodeObject>>, Status>
|
||||
fetchBatch(std::vector<uint256 const*> const& hashes) override
|
||||
fetchBatch(std::vector<uint256> const& hashes) override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
XRPL_ASSERT(m_db, "xrpl::NodeStore::RocksDBBackend::fetch : non-null database");
|
||||
pObject->reset();
|
||||
|
||||
Status status(ok);
|
||||
Status status(Status::ok);
|
||||
|
||||
rocksdb::ReadOptions const options;
|
||||
rocksdb::Slice const slice(std::bit_cast<char const*>(hash.data()), m_keyBytes);
|
||||
@@ -306,22 +306,23 @@ public:
|
||||
{
|
||||
// Decoding failed, probably corrupted!
|
||||
//
|
||||
status = dataCorrupt;
|
||||
status = Status::dataCorrupt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getStatus.IsCorruption())
|
||||
{
|
||||
status = dataCorrupt;
|
||||
status = Status::dataCorrupt;
|
||||
}
|
||||
else if (getStatus.IsNotFound())
|
||||
{
|
||||
status = notFound;
|
||||
status = Status::notFound;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = Status(customCode + unsafe_cast<int>(getStatus.code()));
|
||||
status = static_cast<Status>(
|
||||
static_cast<int>(Status::customCode) + unsafe_cast<int>(getStatus.code()));
|
||||
|
||||
JLOG(m_journal.error()) << getStatus.ToString();
|
||||
}
|
||||
@@ -339,7 +340,7 @@ public:
|
||||
{
|
||||
std::shared_ptr<NodeObject> nObj;
|
||||
Status const status = fetch(h, &nObj);
|
||||
if (status != ok)
|
||||
if (status != Status::ok)
|
||||
{
|
||||
results.push_back({});
|
||||
}
|
||||
@@ -349,7 +350,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return {results, ok};
|
||||
return {results, Status::ok};
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
packed_spinlock sl(locks_, index % 64);
|
||||
|
||||
{
|
||||
std::lock_guard const lock(sl);
|
||||
std::scoped_lock const lock(sl);
|
||||
|
||||
// The check against the first character of the encoding ensures
|
||||
// that we don't mishandle the case of the all-zero account:
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
XRPL_ASSERT(ret.size() <= 38, "xrpl::detail::AccountIdCache : maximum result size");
|
||||
|
||||
{
|
||||
std::lock_guard const lock(sl);
|
||||
std::scoped_lock const lock(sl);
|
||||
cache_[index].id = id;
|
||||
std::strcpy(cache_[index].encoding, ret.c_str());
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ setCurrentTransactionRules(std::optional<Rules> r)
|
||||
// the value is needed. That could get expensive fast.
|
||||
bool const enableLargeNumbers =
|
||||
!r || (r->enabled(featureSingleAssetVault) || r->enabled(featureLendingProtocol));
|
||||
Number::setMantissaScale(enableLargeNumbers ? MantissaRange::large : MantissaRange::small);
|
||||
Number::setMantissaScale(
|
||||
enableLargeNumbers ? MantissaRange::mantissa_scale::large
|
||||
: MantissaRange::mantissa_scale::small);
|
||||
|
||||
*getCurrentTransactionRulesRef() = std::move(r);
|
||||
}
|
||||
|
||||
@@ -1612,7 +1612,7 @@ mulRoundImpl(STAmount const& v1, STAmount const& v2, Asset const& asset, bool ro
|
||||
STAmount result = [&]() {
|
||||
// If appropriate, tell Number to round down. This gives the desired
|
||||
// result from STAmount::canonicalize.
|
||||
MightSaveRound const savedRound(Number::towards_zero);
|
||||
MightSaveRound const savedRound(Number::rounding_mode::towards_zero);
|
||||
return STAmount(asset, amount, offset, resultNegative);
|
||||
}();
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user