mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 08:46:46 +00:00
Merge branch 'pratik/otel-phase8-log-correlation' into pratik/otel-phase9-metric-gap-fill
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
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
|
||||
@@ -208,8 +207,6 @@ 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::scoped_lock>
|
||||
template <template <typename...> typename LockType = std::lock_guard>
|
||||
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::scoped_lock>
|
||||
template <template <typename...> typename LockType = std::lock_guard>
|
||||
Lock<ProtectedDataType, LockType, MutexType>
|
||||
lock()
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ isPowerOfTen(T value)
|
||||
struct MantissaRange
|
||||
{
|
||||
using rep = std::uint64_t;
|
||||
enum class mantissa_scale { small, large };
|
||||
enum 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 mantissa_scale::small:
|
||||
case small:
|
||||
return 1'000'000'000'000'000ULL;
|
||||
case mantissa_scale::large:
|
||||
case 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 class rounding_mode { to_nearest, towards_zero, downward, upward };
|
||||
enum 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::mantissa_scale::small};
|
||||
constexpr static MantissaRange smallRange{MantissaRange::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::mantissa_scale::large};
|
||||
constexpr static MantissaRange largeRange{MantissaRange::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::mantissa_scale::small:
|
||||
case MantissaRange::small:
|
||||
return "small";
|
||||
case MantissaRange::mantissa_scale::large:
|
||||
case MantissaRange::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::scoped_lock const l(m_);
|
||||
std::lock_guard const l(m_);
|
||||
|
||||
ret = l_;
|
||||
|
||||
@@ -121,7 +121,7 @@ class SlabAllocator
|
||||
{
|
||||
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
|
||||
|
||||
std::scoped_lock const l(m_);
|
||||
std::lock_guard 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::scoped_lock<mutex_type> const& l);
|
||||
initialFetch(key_type const& key, std::lock_guard<mutex_type> const& l);
|
||||
|
||||
void
|
||||
collect_metrics();
|
||||
@@ -266,7 +266,7 @@ private:
|
||||
typename KeyValueCacheType::map_type& partition,
|
||||
SweptPointersVector& stuffToSweep,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
std::lock_guard<std::recursive_mutex> const&);
|
||||
|
||||
[[nodiscard]] std::thread
|
||||
sweepHelper(
|
||||
@@ -275,7 +275,7 @@ private:
|
||||
typename KeyOnlyCacheType::map_type& partition,
|
||||
SweptPointersVector&,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
std::lock_guard<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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard lock(m_mutex);
|
||||
return m_cache.size();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ inline float
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
getHitRate()
|
||||
{
|
||||
std::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock<mutex_type> l(m_mutex);
|
||||
std::lock_guard<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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock l(m_mutex);
|
||||
std::lock_guard 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::scoped_lock l(m_mutex);
|
||||
std::lock_guard 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::scoped_lock<mutex_type> const& l)
|
||||
initialFetch(key_type const& key, std::lock_guard<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::scoped_lock lock(m_mutex);
|
||||
std::lock_guard 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::scoped_lock<std::recursive_mutex> const&)
|
||||
std::lock_guard<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::scoped_lock<std::recursive_mutex> const&)
|
||||
std::lock_guard<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::scoped_lock const lock(state.mutex);
|
||||
std::lock_guard 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::scoped_lock const lk(m);
|
||||
std::lock_guard const lk(m);
|
||||
std::uniform_int_distribution<std::uint64_t> distribution{1};
|
||||
seed = distribution(seeder);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void
|
||||
sample_one(Handler&& handler)
|
||||
{
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (m_cancel)
|
||||
throw std::logic_error("io_latency_probe is canceled");
|
||||
boost::asio::post(
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
void
|
||||
sample(Handler&& handler)
|
||||
{
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (m_cancel)
|
||||
throw std::logic_error("io_latency_probe is canceled");
|
||||
boost::asio::post(
|
||||
@@ -122,14 +122,14 @@ private:
|
||||
void
|
||||
addref()
|
||||
{
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
++m_count;
|
||||
}
|
||||
|
||||
void
|
||||
release()
|
||||
{
|
||||
std::scoped_lock const lock(m_mutex);
|
||||
std::lock_guard const lock(m_mutex);
|
||||
if (--m_count == 0)
|
||||
m_cond.notify_all();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
m_handler(elapsed);
|
||||
|
||||
{
|
||||
std::scoped_lock const lock(m_probe->m_mutex);
|
||||
std::lock_guard const lock(m_probe->m_mutex);
|
||||
if (m_probe->m_cancel)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace insight {
|
||||
* Replaces StatsD-based metric collection with native OTel Metrics SDK
|
||||
* instruments. Each beast::insight instrument maps to an OTel equivalent:
|
||||
*
|
||||
* - Counter -> OTel Counter<int64_t>
|
||||
* - Counter -> OTel Counter<uint64_t>
|
||||
* - Gauge -> OTel ObservableGauge<int64_t> (async callback)
|
||||
* - Event -> OTel Histogram<double> (duration in milliseconds)
|
||||
* - Meter -> OTel Counter<uint64_t> (monotonic, unsigned)
|
||||
|
||||
@@ -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::scoped_lock const lock{m_};
|
||||
std::lock_guard const lock{m_};
|
||||
if (--running_ == 0)
|
||||
cv_.notify_all();
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace beast::unit_test {
|
||||
class selector
|
||||
{
|
||||
public:
|
||||
enum class mode_t {
|
||||
enum 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_ == mode_t::automatch && pattern.empty())
|
||||
mode_ = mode_t::all;
|
||||
if (mode_ == automatch && pattern.empty())
|
||||
mode_ = all;
|
||||
}
|
||||
|
||||
template <class>
|
||||
@@ -63,18 +63,18 @@ selector::operator()(suite_info const& s)
|
||||
{
|
||||
switch (mode_)
|
||||
{
|
||||
case mode_t::automatch:
|
||||
case automatch:
|
||||
// suite or full name
|
||||
if (s.name() == pat_ || s.full_name() == pat_)
|
||||
{
|
||||
mode_ = mode_t::none;
|
||||
mode_ = none;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check module
|
||||
if (pat_ == s.module())
|
||||
{
|
||||
mode_ = mode_t::module;
|
||||
mode_ = module;
|
||||
library_ = s.library();
|
||||
return !s.manual();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ selector::operator()(suite_info const& s)
|
||||
// check library
|
||||
if (pat_ == s.library())
|
||||
{
|
||||
mode_ = mode_t::library;
|
||||
mode_ = library;
|
||||
return !s.manual();
|
||||
}
|
||||
|
||||
@@ -96,19 +96,19 @@ selector::operator()(suite_info const& s)
|
||||
|
||||
return false;
|
||||
|
||||
case mode_t::suite:
|
||||
case suite:
|
||||
return pat_ == s.name();
|
||||
|
||||
case mode_t::module:
|
||||
case module:
|
||||
return pat_ == s.module() && !s.manual();
|
||||
|
||||
case mode_t::library:
|
||||
case library:
|
||||
return pat_ == s.library() && !s.manual();
|
||||
|
||||
case mode_t::none:
|
||||
case none:
|
||||
return false;
|
||||
|
||||
case mode_t::all:
|
||||
case all:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
@@ -138,28 +138,28 @@ selector::operator()(suite_info const& s)
|
||||
inline selector
|
||||
match_auto(std::string const& name)
|
||||
{
|
||||
return selector(selector::mode_t::automatch, name);
|
||||
return selector(selector::automatch, name);
|
||||
}
|
||||
|
||||
/** Return a predicate that matches all suites not marked manual. */
|
||||
inline selector
|
||||
match_all()
|
||||
{
|
||||
return selector(selector::mode_t::all);
|
||||
return selector(selector::all);
|
||||
}
|
||||
|
||||
/** Returns a predicate that matches a specific suite. */
|
||||
inline selector
|
||||
match_suite(std::string const& name)
|
||||
{
|
||||
return selector(selector::mode_t::suite, name);
|
||||
return selector(selector::suite, name);
|
||||
}
|
||||
|
||||
/** Returns a predicate that matches all suites in a library. */
|
||||
inline selector
|
||||
match_library(std::string const& name)
|
||||
{
|
||||
return selector(selector::mode_t::library, name);
|
||||
return selector(selector::library, name);
|
||||
}
|
||||
|
||||
} // namespace beast::unit_test
|
||||
|
||||
@@ -62,8 +62,6 @@ 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::scoped_lock const lock(mutex_);
|
||||
std::lock_guard 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::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_pass();
|
||||
@@ -258,7 +258,7 @@ template <class>
|
||||
void
|
||||
runner::fail(std::string const& reason)
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (default_)
|
||||
testcase("");
|
||||
on_fail(reason);
|
||||
@@ -270,7 +270,7 @@ template <class>
|
||||
void
|
||||
runner::log(std::string const& s)
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard 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 class abort_t { no_abort_on_fail, abort_on_fail };
|
||||
enum 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 = abort_t::no_abort_on_fail);
|
||||
operator()(std::string const& name, abort_t abort = 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_t::abort_on_fail;
|
||||
suite_.abort_ = abort == abort_on_fail;
|
||||
suite_.runner_->testcase(name);
|
||||
}
|
||||
|
||||
inline suite::scoped_testcase
|
||||
suite::testcase_t::operator()(abort_t abort)
|
||||
{
|
||||
suite_.abort_ = abort == abort_t::abort_on_fail;
|
||||
suite_.abort_ = abort == abort_on_fail;
|
||||
return {suite_, ss_};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ 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::scoped_lock const lock{mutex_};
|
||||
std::lock_guard 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::scoped_lock const lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
if (!waitForClosures_)
|
||||
ret.emplace(*this, std::forward<Closure>(closure));
|
||||
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
bool
|
||||
joined() const
|
||||
{
|
||||
std::scoped_lock const lock{mutex_};
|
||||
std::lock_guard const lock{mutex_};
|
||||
return waitForClosures_;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ inline void
|
||||
JobQueue::Coro::yield() const
|
||||
{
|
||||
{
|
||||
std::scoped_lock lock(jq_.m_mutex);
|
||||
std::lock_guard lock(jq_.m_mutex);
|
||||
++jq_.nSuspend_;
|
||||
}
|
||||
(*yield_)();
|
||||
@@ -44,7 +44,7 @@ inline bool
|
||||
JobQueue::Coro::post()
|
||||
{
|
||||
{
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
std::lock_guard lk(mutex_run_);
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ JobQueue::Coro::post()
|
||||
}
|
||||
|
||||
// The coroutine will not run. Clean up running_.
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
std::lock_guard lk(mutex_run_);
|
||||
running_ = false;
|
||||
cv_.notify_all();
|
||||
return false;
|
||||
@@ -65,16 +65,16 @@ inline void
|
||||
JobQueue::Coro::resume()
|
||||
{
|
||||
{
|
||||
std::scoped_lock lk(mutex_run_);
|
||||
std::lock_guard lk(mutex_run_);
|
||||
running_ = true;
|
||||
}
|
||||
{
|
||||
std::scoped_lock lk(jq_.m_mutex);
|
||||
std::lock_guard lk(jq_.m_mutex);
|
||||
--jq_.nSuspend_;
|
||||
}
|
||||
auto saved = detail::getLocalValues().release();
|
||||
detail::getLocalValues().reset(&lvs_);
|
||||
std::scoped_lock lock(mutex_);
|
||||
std::lock_guard 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::scoped_lock lk(mutex_run_);
|
||||
std::lock_guard 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::scoped_lock lock(jq_.m_mutex);
|
||||
std::lock_guard lock(jq_.m_mutex);
|
||||
--jq_.nSuspend_;
|
||||
#ifndef NDEBUG
|
||||
finished_ = true;
|
||||
|
||||
@@ -11,8 +11,6 @@ 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::scoped_lock const lock(this->mutex_);
|
||||
std::lock_guard const lock(this->mutex_);
|
||||
return table_.contains({.nodeId = nodeId, .description = {}});
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void
|
||||
notify()
|
||||
{
|
||||
std::scoped_lock const lock{m_mutex};
|
||||
std::lock_guard const lock{m_mutex};
|
||||
++m_count;
|
||||
m_cond.notify_one();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
bool
|
||||
try_wait()
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
std::lock_guard lock{m_mutex};
|
||||
if (m_count == 0)
|
||||
return false;
|
||||
--m_count;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Json {
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
enum class CollectionType { array, object };
|
||||
enum CollectionType { array, object };
|
||||
|
||||
explicit Writer(Output const& output);
|
||||
Writer(Writer&&) noexcept;
|
||||
|
||||
@@ -70,8 +70,6 @@ public:
|
||||
static constexpr unsigned nest_limit{25};
|
||||
|
||||
private:
|
||||
// 53 files, protocol-wide
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TokenType {
|
||||
tokenEndOfStream = 0,
|
||||
tokenObjectBegin,
|
||||
|
||||
@@ -15,8 +15,6 @@ 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
|
||||
@@ -149,8 +147,6 @@ 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);
|
||||
@@ -475,8 +471,6 @@ 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,8 +7,6 @@
|
||||
|
||||
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::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
auto it = map_.find(seq);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void
|
||||
finishWork(LedgerIndex seq)
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
|
||||
map_.erase(seq);
|
||||
await_.notify_all();
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
bool
|
||||
pending(LedgerIndex seq)
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
return map_.contains(seq);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
std::map<LedgerIndex, bool>
|
||||
getSnapshot() const
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard 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::rounding_mode::towards_zero);
|
||||
NumberRoundModeGuard const mg(Number::towards_zero);
|
||||
return amount * reducedOfferPct;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ getAMMOfferStartWithTakerGets(
|
||||
if (targetQuality.rate() == beast::zero)
|
||||
return std::nullopt;
|
||||
|
||||
NumberRoundModeGuard const mg(Number::rounding_mode::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::to_nearest);
|
||||
auto const f = feeMult(tfee);
|
||||
auto const a = 1;
|
||||
auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out;
|
||||
@@ -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::rounding_mode::downward);
|
||||
toAmount<TOut>(getAsset(pool.out), nTakerGetsProposed, Number::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::rounding_mode::to_nearest);
|
||||
NumberRoundModeGuard const mg(Number::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::rounding_mode::downward);
|
||||
toAmount<TIn>(getAsset(pool.in), nTakerPaysProposed, Number::downward);
|
||||
return TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
|
||||
};
|
||||
|
||||
@@ -341,8 +341,7 @@ changeSpotPriceQuality(
|
||||
<< " " << to_string(pool.out) << " " << quality << " " << tfee;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto const takerPays =
|
||||
toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::rounding_mode::upward);
|
||||
auto const takerPays = toAmount<TIn>(getAsset(pool.in), nTakerPays, Number::upward);
|
||||
// should not fail
|
||||
if (auto amounts = TAmounts<TIn, TOut>{takerPays, swapAssetIn(pool, takerPays, tfee)};
|
||||
Quality{amounts} < quality &&
|
||||
@@ -448,32 +447,32 @@ swapAssetIn(TAmounts<TIn, TOut> const& pool, TIn const& assetIn, std::uint16_t t
|
||||
// fee
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
Number::setround(Number::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
auto const fee = getFee(tfee);
|
||||
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
Number::setround(Number::downward);
|
||||
auto const denom = pool.in + assetIn * (1 - fee);
|
||||
|
||||
if (denom.signum() <= 0)
|
||||
return toAmount<TOut>(getAsset(pool.out), 0);
|
||||
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
Number::setround(Number::upward);
|
||||
auto const ratio = numerator / denom;
|
||||
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
Number::setround(Number::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::rounding_mode::downward);
|
||||
return toAmount<TOut>(getAsset(pool.out), swapOut, Number::downward);
|
||||
}
|
||||
|
||||
return toAmount<TOut>(
|
||||
getAsset(pool.out),
|
||||
pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)),
|
||||
Number::rounding_mode::downward);
|
||||
Number::downward);
|
||||
}
|
||||
|
||||
/** Swap assetOut out of the pool and swap in a proportional amount
|
||||
@@ -510,36 +509,36 @@ swapAssetOut(TAmounts<TIn, TOut> const& pool, TOut const& assetOut, std::uint16_
|
||||
|
||||
saveNumberRoundMode const _{Number::getround()};
|
||||
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
Number::setround(Number::upward);
|
||||
auto const numerator = pool.in * pool.out;
|
||||
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
Number::setround(Number::downward);
|
||||
auto const denom = pool.out - assetOut;
|
||||
if (denom.signum() <= 0)
|
||||
{
|
||||
return toMaxAmount<TIn>(getAsset(pool.in));
|
||||
}
|
||||
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
Number::setround(Number::upward);
|
||||
auto const ratio = numerator / denom;
|
||||
auto const numerator2 = ratio - pool.in;
|
||||
auto const fee = getFee(tfee);
|
||||
|
||||
Number::setround(Number::rounding_mode::downward);
|
||||
Number::setround(Number::downward);
|
||||
auto const feeMult = 1 - fee;
|
||||
|
||||
Number::setround(Number::rounding_mode::upward);
|
||||
Number::setround(Number::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::rounding_mode::upward);
|
||||
return toAmount<TIn>(getAsset(pool.in), swapIn, Number::upward);
|
||||
}
|
||||
|
||||
return toAmount<TIn>(
|
||||
getAsset(pool.in),
|
||||
((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee),
|
||||
Number::rounding_mode::upward);
|
||||
Number::upward);
|
||||
}
|
||||
|
||||
/** Return square of n.
|
||||
@@ -598,8 +597,7 @@ getLPTokenRounding(IsDeposit isDeposit)
|
||||
{
|
||||
// Minimize on deposit, maximize on withdraw to ensure
|
||||
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
|
||||
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::downward
|
||||
: Number::rounding_mode::upward;
|
||||
return isDeposit == IsDeposit::Yes ? Number::downward : Number::upward;
|
||||
}
|
||||
|
||||
inline Number::rounding_mode
|
||||
@@ -607,8 +605,7 @@ getAssetRounding(IsDeposit isDeposit)
|
||||
{
|
||||
// Maximize on deposit, minimize on withdraw to ensure
|
||||
// AMM invariant sqrt(poolAsset1 * poolAsset2) >= LPTokensBalance
|
||||
return isDeposit == IsDeposit::Yes ? Number::rounding_mode::upward
|
||||
: Number::rounding_mode::downward;
|
||||
return isDeposit == IsDeposit::Yes ? Number::upward : Number::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::rounding_mode::upward);
|
||||
return roundToAsset(asset, periodicPayment, scale, Number::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 class FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN };
|
||||
enum FreezeHandling { fhIGNORE_FREEZE, fhZERO_IF_FROZEN };
|
||||
|
||||
/** Controls the treatment of unauthorized MPT balances */
|
||||
enum class AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED };
|
||||
enum AuthHandling { ahIGNORE_AUTH, ahZERO_IF_UNAUTHORIZED };
|
||||
|
||||
/** Controls whether to include the account's full spendable balance */
|
||||
enum class SpendableHandling { shSIMPLE_BALANCE, shFULL_BALANCE };
|
||||
enum 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 = SpendableHandling::shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -144,7 +144,7 @@ accountHolds(
|
||||
Issue const& issue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -154,7 +154,7 @@ accountHolds(
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = shSIMPLE_BALANCE);
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountHolds(
|
||||
@@ -164,7 +164,7 @@ accountHolds(
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance = SpendableHandling::shSIMPLE_BALANCE);
|
||||
SpendableHandling includeFullBalance = 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
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace xrpl {
|
||||
|
||||
/** The types of node objects. */
|
||||
enum class NodeObjectType : std::uint32_t {
|
||||
enum NodeObjectType : std::uint32_t {
|
||||
hotUNKNOWN = 0,
|
||||
hotLEDGER = 1,
|
||||
hotACCOUNT_NODE = 3,
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
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.
|
||||
@@ -22,7 +20,7 @@ enum {
|
||||
};
|
||||
|
||||
/** Return codes from Backend operations. */
|
||||
enum class Status {
|
||||
enum 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, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
write<std::uint8_t>(os, 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, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
write<std::uint8_t>(os, 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, static_cast<std::uint8_t>(NodeObjectType::hotUNKNOWN));
|
||||
write<std::uint8_t>(os, hotUNKNOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ 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,
|
||||
@@ -150,8 +148,6 @@ 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,8 +29,6 @@ namespace xrpl {
|
||||
|
||||
@ingroup protocol
|
||||
*/
|
||||
// Protocol-critical, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum LedgerEntryType : std::uint16_t {
|
||||
|
||||
#pragma push_macro("LEDGER_ENTRY")
|
||||
@@ -216,8 +214,6 @@ 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,7 +66,8 @@ struct MultiApiJson
|
||||
a[key] = v;
|
||||
}
|
||||
|
||||
enum class IsMemberResult : int { none = 0, some, all };
|
||||
// Intentionally not using class enum here, MultivarJson is scope enough
|
||||
enum IsMemberResult : int { none = 0, some, all };
|
||||
|
||||
[[nodiscard]] IsMemberResult
|
||||
isMember(char const* key) const
|
||||
@@ -79,8 +80,8 @@ struct MultiApiJson
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return IsMemberResult::none;
|
||||
return count < size ? IsMemberResult::some : IsMemberResult::all;
|
||||
return none;
|
||||
return count < size ? some : all;
|
||||
}
|
||||
|
||||
static constexpr struct visitor_t final
|
||||
|
||||
@@ -16,8 +16,6 @@ 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
|
||||
@@ -30,9 +28,6 @@ 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,8 +87,6 @@ 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)};
|
||||
@@ -127,8 +125,6 @@ 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,8 +11,6 @@
|
||||
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
|
||||
@@ -22,8 +20,7 @@ enum SOEStyle {
|
||||
// constructed with STObject::makeInnerObject()
|
||||
};
|
||||
|
||||
// Part of a Python-parsed DSL (transactions.macro); bare enumerator names required by the parser
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
/** Amount fields that can support MPT */
|
||||
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::mantissa_scale::small)
|
||||
if (Number::getMantissaScale() == MantissaRange::small)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
mValue <= std::numeric_limits<std::int64_t>::max(),
|
||||
|
||||
@@ -18,8 +18,6 @@ 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 class WhichFields : bool {
|
||||
enum WhichFields : bool {
|
||||
// These values are carefully chosen to do the right thing if passed
|
||||
// to SField::shouldInclude (bool) via static_cast<bool>
|
||||
// to SField::shouldInclude (bool)
|
||||
omitSigningFields = false,
|
||||
withAllFields = true
|
||||
};
|
||||
@@ -987,7 +987,7 @@ STObject::isFree() const
|
||||
inline void
|
||||
STObject::addWithoutSigningFields(Serializer& s) const
|
||||
{
|
||||
add(s, WhichFields::omitSigningFields);
|
||||
add(s, 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, WhichFields::withAllFields);
|
||||
add(s, withAllFields);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ 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 class Type : std::uint8_t { seq = 0, ticket };
|
||||
enum Type : std::uint8_t { seq = 0, ticket };
|
||||
|
||||
private:
|
||||
std::uint32_t value_;
|
||||
@@ -67,13 +67,13 @@ public:
|
||||
[[nodiscard]] constexpr bool
|
||||
isSeq() const
|
||||
{
|
||||
return type_ == Type::seq;
|
||||
return type_ == seq;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool
|
||||
isTicket() const
|
||||
{
|
||||
return type_ == Type::ticket;
|
||||
return type_ == ticket;
|
||||
}
|
||||
|
||||
// Occasionally it is convenient to be able to increase the value_
|
||||
|
||||
@@ -19,8 +19,6 @@ 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:
|
||||
@@ -52,8 +50,6 @@ 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:
|
||||
@@ -130,8 +126,6 @@ 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:
|
||||
@@ -176,8 +170,6 @@ 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:
|
||||
@@ -222,8 +214,6 @@ 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.
|
||||
@@ -239,8 +229,6 @@ 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,8 +35,6 @@ namespace xrpl {
|
||||
@ingroup protocol
|
||||
*/
|
||||
// clang-format off
|
||||
// Protocol-critical, hundreds of usages
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum TxType : std::uint16_t
|
||||
{
|
||||
|
||||
|
||||
@@ -130,19 +130,6 @@ 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 class Disposition {
|
||||
enum Disposition {
|
||||
/** No action required. */
|
||||
ok
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ struct Entry : public beast::List<Entry>::Node
|
||||
[[nodiscard]] bool
|
||||
isUnlimited() const
|
||||
{
|
||||
return key->kind == Kind::kindUnlimited;
|
||||
return key->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 class Kind { kindInbound, kindOutbound, kindUnlimited };
|
||||
enum Kind { kindInbound, kindOutbound, kindUnlimited };
|
||||
|
||||
} // namespace xrpl::Resource
|
||||
|
||||
@@ -92,11 +92,11 @@ public:
|
||||
Entry* entry(nullptr);
|
||||
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(Kind::kindInbound, address.at_port(0)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(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::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(Kind::kindOutbound, address), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(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::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = table_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(Kind::kindUnlimited, address.at_port(1)), // Key
|
||||
std::make_tuple(m_clock.now())); // Entry
|
||||
std::make_tuple(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::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
for (auto& inboundEntry : inbound_)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
Gossip gossip;
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
gossip.items.reserve(inbound_.size());
|
||||
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
{
|
||||
auto const elapsed = m_clock.now();
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
auto [resultIt, resultInserted] = importTable_.emplace(
|
||||
std::piecewise_construct,
|
||||
std::make_tuple(origin), // Key
|
||||
@@ -317,7 +317,7 @@ public:
|
||||
void
|
||||
periodicActivity()
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
auto const elapsed = m_clock.now();
|
||||
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
void
|
||||
erase(Table::iterator iter)
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
Entry& entry(iter->second);
|
||||
XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used");
|
||||
inactive_.erase(inactive_.iterator_to(entry));
|
||||
@@ -385,27 +385,27 @@ public:
|
||||
void
|
||||
acquire(Entry& entry)
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
++entry.refcount;
|
||||
}
|
||||
|
||||
void
|
||||
release(Entry& entry)
|
||||
{
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
if (--entry.refcount == 0)
|
||||
{
|
||||
JLOG(m_journal.debug()) << "Inactive " << entry;
|
||||
|
||||
switch (entry.key->kind)
|
||||
{
|
||||
case Kind::kindInbound:
|
||||
case kindInbound:
|
||||
inbound_.erase(inbound_.iterator_to(entry));
|
||||
break;
|
||||
case Kind::kindOutbound:
|
||||
case kindOutbound:
|
||||
outbound_.erase(outbound_.iterator_to(entry));
|
||||
break;
|
||||
case Kind::kindUnlimited:
|
||||
case kindUnlimited:
|
||||
admin_.erase(admin_.iterator_to(entry));
|
||||
break;
|
||||
default:
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
if (!context.empty())
|
||||
context = " (" + context + ")";
|
||||
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
int const balance(entry.add(fee.cost(), now));
|
||||
JLOG(getStream(fee.cost(), m_journal)) << "Charging " << entry << " for " << fee << context;
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
bool notify(false);
|
||||
auto const elapsed = m_clock.now();
|
||||
if (entry.balance(m_clock.now()) >= warningThreshold && elapsed != entry.lastWarningTime)
|
||||
@@ -479,7 +479,7 @@ public:
|
||||
if (entry.isUnlimited())
|
||||
return false;
|
||||
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard 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::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
return entry.balance(m_clock.now());
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ public:
|
||||
{
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
|
||||
std::scoped_lock const _(lock_);
|
||||
std::lock_guard const _(lock_);
|
||||
|
||||
{
|
||||
beast::PropertyStream::Set s("inbound", map);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
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::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
remoteTxnLoadFee_ = f;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getRemoteFee() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return remoteTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getLocalFee() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return localTxnLoadFee_;
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
getClusterFee() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return clusterTxnLoadFee_;
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ public:
|
||||
std::uint32_t
|
||||
getLoadFactor() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return std::max({clusterTxnLoadFee_, localTxnLoadFee_, remoteTxnLoadFee_});
|
||||
}
|
||||
|
||||
std::pair<std::uint32_t, std::uint32_t>
|
||||
getScalingFactors() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard 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::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
clusterTxnLoadFee_ = fee;
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ public:
|
||||
bool
|
||||
isLoadedLocal() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
bool
|
||||
isLoadedCluster() const
|
||||
{
|
||||
std::scoped_lock const sl(lock_);
|
||||
std::lock_guard const sl(lock_);
|
||||
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) ||
|
||||
(clusterTxnLoadFee_ != lftNormalFee);
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ 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,
|
||||
@@ -305,7 +303,7 @@ BaseHTTPPeer<Handler, Impl>::on_write(error_code const& ec, std::size_t bytes_tr
|
||||
return fail(ec, "write");
|
||||
bytes_out_ += bytes_transferred;
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
wq2_.clear();
|
||||
wq2_.reserve(wq_.size());
|
||||
std::swap(wq2_, wq_);
|
||||
@@ -397,7 +395,7 @@ BaseHTTPPeer<Handler, Impl>::write(void const* buf, std::size_t bytes)
|
||||
if (bytes == 0)
|
||||
return;
|
||||
if ([&] {
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
wq_.emplace_back(buf, bytes);
|
||||
return wq_.size() == 1 && wq2_.size() == 0;
|
||||
}())
|
||||
@@ -451,7 +449,7 @@ BaseHTTPPeer<Handler, Impl>::complete()
|
||||
complete_ = true;
|
||||
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (!wq_.empty() && !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
@@ -486,7 +484,7 @@ BaseHTTPPeer<Handler, Impl>::close(bool graceful)
|
||||
{
|
||||
graceful_ = true;
|
||||
{
|
||||
std::scoped_lock const lock(mutex_);
|
||||
std::lock_guard const lock(mutex_);
|
||||
if (!wq_.empty() || !wq2_.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,6 @@ 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::scoped_lock const lock(ios_->m_);
|
||||
std::lock_guard const lock(ios_->m_);
|
||||
ios_->map_.erase(this);
|
||||
if (--ios_->n_ == 0 && ios_->closed_)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ io_list::emplace(Args&&... args)
|
||||
auto sp = std::make_shared<T>(std::forward<Args>(args)...);
|
||||
decltype(sp) dead;
|
||||
|
||||
std::scoped_lock const lock(m_);
|
||||
std::lock_guard const lock(m_);
|
||||
if (!closed_)
|
||||
{
|
||||
++n_;
|
||||
|
||||
@@ -22,8 +22,6 @@ private:
|
||||
using CacheType = KeyCache;
|
||||
|
||||
public:
|
||||
// Need to be named before converting
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum { defaultCacheTargetSize = 0 };
|
||||
|
||||
using key_type = uint256;
|
||||
|
||||
@@ -123,8 +123,6 @@ 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 class Category {
|
||||
enum Category {
|
||||
/// Moves currency around, creates offers, etc.
|
||||
normal = 0,
|
||||
/// Affects the ability of subsequent transactions
|
||||
|
||||
@@ -25,8 +25,6 @@ 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 class Order { Before = 0, After = 1 };
|
||||
enum Order { Before = 0, After = 1 };
|
||||
struct MPTData
|
||||
{
|
||||
std::array<std::int64_t, 2> outstanding{};
|
||||
std::array<std::int64_t, After + 1> 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 class OfferCrossing { no = 0, yes = 1, sell = 2 };
|
||||
enum 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 != OfferCrossing::no && limitQuality)
|
||||
if (offerCrossing && limitQuality)
|
||||
{
|
||||
auto const strandQ = qualityUpperBound(sb, *strand);
|
||||
if (!strandQ || *strandQ < *limitQuality)
|
||||
@@ -797,8 +797,7 @@ flow(
|
||||
// fixFillOrKill amendment:
|
||||
// That case is handled here if tfSell is also not set; i.e,
|
||||
// case 1.
|
||||
if (offerCrossing == OfferCrossing::no ||
|
||||
(fillOrKillEnabled && offerCrossing != OfferCrossing::sell))
|
||||
if (!offerCrossing || (fillOrKillEnabled && offerCrossing != OfferCrossing::sell))
|
||||
return {tecPATH_PARTIAL, actualIn, actualOut, std::move(ofrsToRmOnFail)};
|
||||
}
|
||||
else if (actualOut == beast::zero)
|
||||
@@ -806,7 +805,7 @@ flow(
|
||||
return {tecPATH_DRY, std::move(ofrsToRmOnFail)};
|
||||
}
|
||||
}
|
||||
if (offerCrossing != OfferCrossing::no &&
|
||||
if (offerCrossing &&
|
||||
(!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 class Operation { unknown, set, destroy };
|
||||
Operation do_{Operation::unknown};
|
||||
enum Operation { unknown, set, destroy };
|
||||
Operation do_{unknown};
|
||||
std::uint32_t quorum_{0};
|
||||
std::vector<SignerEntries::SignerEntry> signers_;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace xrpl {
|
||||
class LedgerStateFix : public Transactor
|
||||
{
|
||||
public:
|
||||
enum class FixType : std::uint16_t {
|
||||
enum FixType : std::uint16_t {
|
||||
nfTokenPageLink = 1,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user