Merge branch 'develop' into pratik/Retire_fixUniversalNumber_amendment

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
Pratik Mankawde
2026-05-26 16:56:31 +01:00
934 changed files with 22281 additions and 14305 deletions

View File

@@ -148,17 +148,23 @@ public:
}
[[nodiscard]] constexpr E const&
error() const
error() const&
{
return Base::error();
}
constexpr E&
error()
[[nodiscard]] constexpr E&
error() &
{
return Base::error();
}
[[nodiscard]] constexpr E&&
error() &&
{
return std::move(Base::error());
}
constexpr explicit
operator bool() const
{
@@ -215,17 +221,23 @@ public:
}
[[nodiscard]] constexpr E const&
error() const
error() const&
{
return Base::error();
}
constexpr E&
error()
[[nodiscard]] constexpr E&
error() &
{
return Base::error();
}
[[nodiscard]] constexpr E&&
error() &&
{
return std::move(Base::error());
}
constexpr explicit
operator bool() const
{

View File

@@ -406,8 +406,8 @@ private:
// pointer. The low bit must be masked to zero when converting back to a
// pointer. If the low bit is '1', this is a weak pointer.
std::uintptr_t tp_{0};
static constexpr std::uintptr_t kTAG_MASK = 1;
static constexpr std::uintptr_t kPTR_MASK = ~kTAG_MASK;
static constexpr std::uintptr_t kTagMask = 1;
static constexpr std::uintptr_t kPtrMask = ~kTagMask;
private:
/** Return the raw pointer held by this object.

View File

@@ -567,14 +567,14 @@ template <class T>
bool
SharedWeakUnion<T>::isStrong() const
{
return (tp_ & kTAG_MASK) == 0u;
return (tp_ & kTagMask) == 0u;
}
template <class T>
bool
SharedWeakUnion<T>::isWeak() const
{
return (tp_ & kTAG_MASK) != 0u;
return (tp_ & kTagMask) != 0u;
}
template <class T>
@@ -641,7 +641,7 @@ template <class T>
T*
SharedWeakUnion<T>::unsafeGetRawPtr() const
{
return reinterpret_cast<T*>(tp_ & kPTR_MASK);
return reinterpret_cast<T*>(tp_ & kPtrMask);
}
template <class T>
@@ -650,7 +650,7 @@ SharedWeakUnion<T>::unsafeSetRawPtr(T* p, RefStrength rs)
{
tp_ = reinterpret_cast<std::uintptr_t>(p);
if (tp_ && rs == RefStrength::Weak)
tp_ |= kTAG_MASK;
tp_ |= kTagMask;
}
template <class T>

View File

@@ -98,11 +98,11 @@ private:
// enough for strong pointers and 14 bit counts are enough for weak
// pointers. Use type aliases to make it easy to switch types.
using CountType = std::uint16_t;
static constexpr size_t kSTRONG_COUNT_NUM_BITS = sizeof(CountType) * 8;
static constexpr size_t kWEAK_COUNT_NUM_BITS = kSTRONG_COUNT_NUM_BITS - 2;
static constexpr size_t kStrongCountNumBits = sizeof(CountType) * 8;
static constexpr size_t kWeakCountNumBits = kStrongCountNumBits - 2;
using FieldType = std::uint32_t;
static constexpr size_t kFIELD_TYPE_BITS = sizeof(FieldType) * 8;
static constexpr FieldType kONE = 1;
static constexpr size_t kFieldTypeBits = sizeof(FieldType) * 8;
static constexpr FieldType kOne = 1;
/** `refCounts` consists of four fields that are treated atomically:
@@ -137,21 +137,21 @@ private:
*/
mutable std::atomic<FieldType> refCounts_{kSTRONG_DELTA};
mutable std::atomic<FieldType> refCounts_{kStrongDelta};
/** Amount to change the strong count when adding or releasing a reference
Note: The strong count is stored in the low `StrongCountNumBits` bits
of refCounts
*/
static constexpr FieldType kSTRONG_DELTA = 1;
static constexpr FieldType kStrongDelta = 1;
/** Amount to change the weak count when adding or releasing a reference
Note: The weak count is stored in the high `WeakCountNumBits` bits of
refCounts
*/
static constexpr FieldType kWEAK_DELTA = (kONE << kSTRONG_COUNT_NUM_BITS);
static constexpr FieldType kWeakDelta = (kOne << kStrongCountNumBits);
/** Flag that is set when the partialDestroy function has started running
(or is about to start running).
@@ -159,34 +159,33 @@ private:
See description of the `refCounts` field for a fuller description of
this field.
*/
static constexpr FieldType kPARTIAL_DESTROY_STARTED_MASK = (kONE << (kFIELD_TYPE_BITS - 1));
static constexpr FieldType kPartialDestroyStartedMask = (kOne << (kFieldTypeBits - 1));
/** Flag that is set when the partialDestroy function has finished running
See description of the `refCounts` field for a fuller description of
this field.
*/
static constexpr FieldType kPARTIAL_DESTROY_FINISHED_MASK = (kONE << (kFIELD_TYPE_BITS - 2));
static constexpr FieldType kPartialDestroyFinishedMask = (kOne << (kFieldTypeBits - 2));
/** Mask that will zero out all the `count` bits and leave the tag bits
unchanged.
*/
static constexpr FieldType kTAG_MASK =
kPARTIAL_DESTROY_STARTED_MASK | kPARTIAL_DESTROY_FINISHED_MASK;
static constexpr FieldType kTagMask = kPartialDestroyStartedMask | kPartialDestroyFinishedMask;
/** Mask that will zero out the `tag` bits and leave the count bits
unchanged.
*/
static constexpr FieldType kVALUE_MASK = ~kTAG_MASK;
static constexpr FieldType kValueMask = ~kTagMask;
/** Mask that will zero out everything except the strong count.
*/
static constexpr FieldType kSTRONG_MASK = ((kONE << kSTRONG_COUNT_NUM_BITS) - 1) & kVALUE_MASK;
static constexpr FieldType kStrongMask = ((kOne << kStrongCountNumBits) - 1) & kValueMask;
/** Mask that will zero out everything except the weak count.
*/
static constexpr FieldType kWEAK_MASK =
(((kONE << kWEAK_COUNT_NUM_BITS) - 1) << kSTRONG_COUNT_NUM_BITS) & kVALUE_MASK;
static constexpr FieldType kWeakMask =
(((kOne << kWeakCountNumBits) - 1) << kStrongCountNumBits) & kValueMask;
/** Unpack the count and tag fields from the packed atomic integer form. */
struct RefCountPair
@@ -211,29 +210,29 @@ private:
[[nodiscard]] FieldType
combinedValue() const noexcept;
static constexpr CountType kMAX_STRONG_VALUE =
static_cast<CountType>((kONE << kSTRONG_COUNT_NUM_BITS) - 1);
static constexpr CountType kMAX_WEAK_VALUE =
static_cast<CountType>((kONE << kWEAK_COUNT_NUM_BITS) - 1);
static constexpr CountType kMaxStrongValue =
static_cast<CountType>((kOne << kStrongCountNumBits) - 1);
static constexpr CountType kMaxWeakValue =
static_cast<CountType>((kOne << kWeakCountNumBits) - 1);
/** Put an extra margin to detect when running up against limits.
This is only used in debug code, and is useful if we reduce the
number of bits in the strong and weak counts (to 16 and 14 bits).
*/
static constexpr CountType kCHECK_STRONG_MAX_VALUE = kMAX_STRONG_VALUE - 32;
static constexpr CountType kCHECK_WEAK_MAX_VALUE = kMAX_WEAK_VALUE - 32;
static constexpr CountType kCheckStrongMaxValue = kMaxStrongValue - 32;
static constexpr CountType kCheckWeakMaxValue = kMaxWeakValue - 32;
};
};
inline void
IntrusiveRefCounts::addStrongRef() const noexcept
{
refCounts_.fetch_add(kSTRONG_DELTA, std::memory_order_acq_rel);
refCounts_.fetch_add(kStrongDelta, std::memory_order_acq_rel);
}
inline void
IntrusiveRefCounts::addWeakRef() const noexcept
{
refCounts_.fetch_add(kWEAK_DELTA, std::memory_order_acq_rel);
refCounts_.fetch_add(kWeakDelta, std::memory_order_acq_rel);
}
inline ReleaseStrongRefAction
@@ -252,10 +251,10 @@ IntrusiveRefCounts::releaseStrongRef() const
{
RefCountPair const prevVal{prevIntVal};
XRPL_ASSERT(
(prevVal.strong >= kSTRONG_DELTA),
(prevVal.strong >= kStrongDelta),
"xrpl::IntrusiveRefCounts::releaseStrongRef : previous ref "
"higher than new");
auto nextIntVal = prevIntVal - kSTRONG_DELTA;
auto nextIntVal = prevIntVal - kStrongDelta;
ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1)
{
@@ -265,7 +264,7 @@ IntrusiveRefCounts::releaseStrongRef() const
}
else
{
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK;
nextIntVal |= kPartialDestroyStartedMask;
action = PartialDestroy;
}
}
@@ -276,7 +275,7 @@ IntrusiveRefCounts::releaseStrongRef() const
// count to zero can start a partial destroy, and that can't happen
// twice.
XRPL_ASSERT(
(action == NoOp) || !(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK),
(action == NoOp) || !(prevIntVal & kPartialDestroyStartedMask),
"xrpl::IntrusiveRefCounts::releaseStrongRef : not in partial "
"destroy");
return action;
@@ -289,8 +288,8 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
{
using enum ReleaseStrongRefAction;
static_assert(kWEAK_DELTA > kSTRONG_DELTA);
auto constexpr kDELTA = kWEAK_DELTA - kSTRONG_DELTA;
static_assert(kWeakDelta > kStrongDelta);
static constexpr auto kDelta = kWeakDelta - kStrongDelta;
auto prevIntVal = refCounts_.load(std::memory_order_acquire);
// This loop will almost always run once. The loop is needed to atomically
// change the counts and flags (the count could be atomically changed, but
@@ -312,7 +311,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not in "
"partial destroy");
auto nextIntVal = prevIntVal + kDELTA;
auto nextIntVal = prevIntVal + kDelta;
ReleaseStrongRefAction action = NoOp;
if (prevVal.strong == 1)
{
@@ -322,14 +321,14 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
}
else
{
nextIntVal |= kPARTIAL_DESTROY_STARTED_MASK;
nextIntVal |= kPartialDestroyStartedMask;
action = PartialDestroy;
}
}
if (refCounts_.compare_exchange_weak(prevIntVal, nextIntVal, std::memory_order_acq_rel))
{
XRPL_ASSERT(
(!(prevIntVal & kPARTIAL_DESTROY_STARTED_MASK)),
(!(prevIntVal & kPartialDestroyStartedMask)),
"xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef : not "
"started partial destroy");
return action;
@@ -340,7 +339,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const
inline ReleaseWeakRefAction
IntrusiveRefCounts::releaseWeakRef() const
{
auto prevIntVal = refCounts_.fetch_sub(kWEAK_DELTA, std::memory_order_acq_rel);
auto prevIntVal = refCounts_.fetch_sub(kWeakDelta, std::memory_order_acq_rel);
RefCountPair prev = prevIntVal;
if (prev.weak == 1 && prev.strong == 0)
{
@@ -357,7 +356,7 @@ IntrusiveRefCounts::releaseWeakRef() const
{
// partial destroy MUST finish before running a full destroy (when
// using weak pointers)
refCounts_.wait(prevIntVal - kWEAK_DELTA, std::memory_order_acquire);
refCounts_.wait(prevIntVal - kWeakDelta, std::memory_order_acquire);
}
return ReleaseWeakRefAction::Destroy;
}
@@ -376,7 +375,7 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept
if (prev.strong == 0u)
return false;
desiredValue = curValue + kSTRONG_DELTA;
desiredValue = curValue + kStrongDelta;
}
return true;
}
@@ -400,23 +399,22 @@ inline IntrusiveRefCounts::~IntrusiveRefCounts() noexcept
#ifndef NDEBUG
auto v = refCounts_.load(std::memory_order_acquire);
XRPL_ASSERT(
(!(v & kVALUE_MASK)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & kTAG_MASK;
XRPL_ASSERT(
(!t || t == kTAG_MASK), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
(!(v & kValueMask)), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : count must be zero");
auto t = v & kTagMask;
XRPL_ASSERT((!t || t == kTagMask), "xrpl::IntrusiveRefCounts::~IntrusiveRefCounts : valid tag");
#endif
}
//------------------------------------------------------------------------------
inline IntrusiveRefCounts::RefCountPair::RefCountPair(IntrusiveRefCounts::FieldType v) noexcept
: strong{static_cast<CountType>(v & kSTRONG_MASK)}
, weak{static_cast<CountType>((v & kWEAK_MASK) >> kSTRONG_COUNT_NUM_BITS)}
, partialDestroyStartedBit{v & kPARTIAL_DESTROY_STARTED_MASK}
, partialDestroyFinishedBit{v & kPARTIAL_DESTROY_FINISHED_MASK}
: strong{static_cast<CountType>(v & kStrongMask)}
, weak{static_cast<CountType>((v & kWeakMask) >> kStrongCountNumBits)}
, partialDestroyStartedBit{v & kPartialDestroyStartedMask}
, partialDestroyFinishedBit{v & kPartialDestroyFinishedMask}
{
XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
(strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair(FieldType) : inputs inside "
"range");
}
@@ -427,7 +425,7 @@ inline IntrusiveRefCounts::RefCountPair::RefCountPair(
: strong{s}, weak{w}
{
XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
(strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair(CountType, CountType) : "
"inputs inside range");
}
@@ -436,11 +434,11 @@ inline IntrusiveRefCounts::FieldType
IntrusiveRefCounts::RefCountPair::combinedValue() const noexcept
{
XRPL_ASSERT(
(strong < kCHECK_STRONG_MAX_VALUE && weak < kCHECK_WEAK_MAX_VALUE),
(strong < kCheckStrongMaxValue && weak < kCheckWeakMaxValue),
"xrpl::IntrusiveRefCounts::RefCountPair::combinedValue : inputs "
"inside range");
return (static_cast<IntrusiveRefCounts::FieldType>(weak)
<< IntrusiveRefCounts::kSTRONG_COUNT_NUM_BITS) |
<< IntrusiveRefCounts::kStrongCountNumBits) |
static_cast<IntrusiveRefCounts::FieldType>(strong) | partialDestroyStartedBit |
partialDestroyFinishedBit;
}
@@ -451,7 +449,7 @@ partialDestructorFinished(T** o)
{
T& self = **o;
IntrusiveRefCounts::RefCountPair const p =
self.refCounts_.fetch_or(IntrusiveRefCounts::kPARTIAL_DESTROY_FINISHED_MASK);
self.refCounts_.fetch_or(IntrusiveRefCounts::kPartialDestroyFinishedMask);
XRPL_ASSERT(
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),
"xrpl::partialDestructorFinished : not a weak ref");

View File

@@ -55,8 +55,8 @@ template <class = void>
boost::thread_specific_ptr<detail::LocalValues>&
getLocalValues()
{
static boost::thread_specific_ptr<detail::LocalValues> kTSP(&detail::LocalValues::cleanup);
return kTSP;
static boost::thread_specific_ptr<detail::LocalValues> kTsp(&detail::LocalValues::cleanup);
return kTsp;
}
} // namespace detail

View File

@@ -10,24 +10,11 @@
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <utility>
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
// an operation
LSDebug = 1, // Function-level progress information, operations
LSInfo = 2, // Server-level progress information, major operations
LSWarning = 3, // Conditions that warrant human attention, may indicate
// a problem
LSError = 4, // A condition that indicates a problem
LSFatal = 5 // A severe condition that indicates a server problem
};
/** Manages partitions for logging. */
class Logs
{
@@ -39,17 +26,17 @@ private:
std::string partition_;
public:
Sink(std::string partition, beast::severities::Severity thresh, Logs& logs);
Sink(std::string partition, beast::Severity thresh, Logs& logs);
Sink(Sink const&) = delete;
Sink&
operator=(Sink const&) = delete;
void
write(beast::severities::Severity level, std::string const& text) override;
write(beast::Severity level, std::string const& text) override;
void
writeAlways(beast::severities::Severity level, std::string const& text) override;
writeAlways(beast::Severity level, std::string const& text) override;
};
/** Manages a system file containing logged output.
@@ -136,12 +123,12 @@ private:
std::mutex mutable mutex_;
std::map<std::string, std::unique_ptr<beast::Journal::Sink>, boost::beast::iless> sinks_;
beast::severities::Severity thresh_;
beast::Severity thresh_;
File file_;
bool silent_ = false;
public:
Logs(beast::severities::Severity level);
Logs(beast::Severity level);
Logs(Logs const&) = delete;
Logs&
@@ -161,18 +148,18 @@ public:
beast::Journal
journal(std::string const& name);
beast::severities::Severity
beast::Severity
threshold() const;
void
threshold(beast::severities::Severity thresh);
threshold(beast::Severity thresh);
std::vector<std::pair<std::string, std::string>>
partitionSeverities() const;
void
write(
beast::severities::Severity level,
beast::Severity level,
std::string const& partition,
std::string const& text,
bool console);
@@ -192,36 +179,25 @@ public:
}
virtual std::unique_ptr<beast::Journal::Sink>
makeSink(std::string const& partition, beast::severities::Severity startingLevel);
makeSink(std::string const& partition, beast::Severity startingLevel);
public:
static LogSeverity
fromSeverity(beast::severities::Severity level);
static beast::severities::Severity
toSeverity(LogSeverity level);
static std::string
toString(LogSeverity s);
toString(beast::Severity s);
static LogSeverity
static std::optional<beast::Severity>
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
// ellipses.
MaximumMessageCharacters = 12 * 1024
};
// Maximum line length for log messages.
// If the message exceeds this length it will be truncated with ellipses.
static constexpr auto kMaximumMessageCharacters = 12 * 1024;
static void
format(
std::string& output,
std::string const& message,
beast::severities::Severity severity,
beast::Severity severity,
std::string const& partition);
};

View File

@@ -214,12 +214,12 @@ class Number
public:
// The range for the exponent when normalized
constexpr static int kMIN_EXPONENT = -32768;
constexpr static int kMAX_EXPONENT = 32768;
static constexpr int kMinExponent = -32768;
static constexpr int kMaxExponent = 32768;
constexpr static internalrep kMAX_REP = std::numeric_limits<rep>::max();
static_assert(kMAX_REP == 9'223'372'036'854'775'807);
static_assert(-kMAX_REP == std::numeric_limits<rep>::min() + 1);
static constexpr internalrep kMaxRep = std::numeric_limits<rep>::max();
static_assert(kMaxRep == 9'223'372'036'854'775'807);
static_assert(-kMaxRep == std::numeric_limits<rep>::min() + 1);
// May need to make unchecked private
struct Unchecked
@@ -409,26 +409,26 @@ public:
static internalrep
minMantissa()
{
return kRANGE.get().min;
return kRange.get().min;
}
static internalrep
maxMantissa()
{
return kRANGE.get().max;
return kRange.get().max;
}
static int
mantissaLog()
{
return kRANGE.get().log;
return kRange.get().log;
}
/// oneSmall is needed because the ranges are private
constexpr static Number
static constexpr Number
oneSmall();
/// oneLarge is needed because the ranges are private
constexpr static Number
static constexpr Number
oneLarge();
// And one is needed because it needs to choose between oneSmall and
@@ -445,25 +445,25 @@ private:
static thread_local RoundingMode mode;
// The available ranges for mantissa
constexpr static MantissaRange kSMALL_RANGE{MantissaRange::MantissaScale::Small};
static_assert(isPowerOfTen(kSMALL_RANGE.min));
static_assert(kSMALL_RANGE.min == 1'000'000'000'000'000LL);
static_assert(kSMALL_RANGE.max == 9'999'999'999'999'999LL);
static_assert(kSMALL_RANGE.log == 15);
static_assert(kSMALL_RANGE.min < kMAX_REP);
static_assert(kSMALL_RANGE.max < kMAX_REP);
constexpr static MantissaRange kLARGE_RANGE{MantissaRange::MantissaScale::Large};
static_assert(isPowerOfTen(kLARGE_RANGE.min));
static_assert(kLARGE_RANGE.min == 1'000'000'000'000'000'000ULL);
static_assert(kLARGE_RANGE.max == internalrep(9'999'999'999'999'999'999ULL));
static_assert(kLARGE_RANGE.log == 18);
static_assert(kLARGE_RANGE.min < kMAX_REP);
static_assert(kLARGE_RANGE.max > kMAX_REP);
static constexpr MantissaRange kSmallRange{MantissaRange::MantissaScale::Small};
static_assert(isPowerOfTen(kSmallRange.min));
static_assert(kSmallRange.min == 1'000'000'000'000'000LL);
static_assert(kSmallRange.max == 9'999'999'999'999'999LL);
static_assert(kSmallRange.log == 15);
static_assert(kSmallRange.min < kMaxRep);
static_assert(kSmallRange.max < kMaxRep);
static constexpr MantissaRange kLargeRange{MantissaRange::MantissaScale::Large};
static_assert(isPowerOfTen(kLargeRange.min));
static_assert(kLargeRange.min == 1'000'000'000'000'000'000ULL);
static_assert(kLargeRange.max == internalrep(9'999'999'999'999'999'999ULL));
static_assert(kLargeRange.log == 18);
static_assert(kLargeRange.min < kMaxRep);
static_assert(kLargeRange.max > kMaxRep);
// The range for the mantissa when normalized.
// Use reference_wrapper to avoid making copies, and prevent accidentally
// changing the values inside the range.
static thread_local std::reference_wrapper<MantissaRange const> kRANGE;
static thread_local std::reference_wrapper<MantissaRange const> kRange;
void
normalize();
@@ -471,7 +471,7 @@ private:
/** Normalize Number components to an arbitrary range.
*
* min/maxMantissa are parameters because this function is used by both
* normalize(), which reads from kRANGE, and by normalizeToRange,
* normalize(), which reads from kRange, and by normalizeToRange,
* which is public and can accept an arbitrary range from the caller.
*/
template <class T>
@@ -521,7 +521,7 @@ constexpr Number::Number(internalrep mantissa, int exponent, Unchecked) noexcept
{
}
constexpr static Number kNUM_ZERO{};
static constexpr Number kNumZero{};
inline Number::Number(bool negative, internalrep mantissa, int exponent, Normalized)
: Number(negative, mantissa, exponent, Unchecked{})
@@ -552,10 +552,10 @@ constexpr Number::rep
Number::mantissa() const noexcept
{
auto m = mantissa_;
if (m > kMAX_REP)
if (m > kMaxRep)
{
XRPL_ASSERT_PARTS(
!isnormal() || (m % 10 == 0 && m / 10 <= kMAX_REP),
!isnormal() || (m % 10 == 0 && m / 10 <= kMaxRep),
"xrpl::Number::mantissa",
"large normalized mantissa has no remainder");
m /= 10;
@@ -573,10 +573,10 @@ constexpr int
Number::exponent() const noexcept
{
auto e = exponent_;
if (mantissa_ > kMAX_REP)
if (mantissa_ > kMaxRep)
{
XRPL_ASSERT_PARTS(
!isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMAX_REP),
!isnormal() || (mantissa_ % 10 == 0 && mantissa_ / 10 <= kMaxRep),
"xrpl::Number::exponent",
"large normalized mantissa has no remainder");
++e;
@@ -671,29 +671,29 @@ operator/(Number const& x, Number const& y)
inline Number
Number::min() noexcept
{
return Number{false, kRANGE.get().min, kMIN_EXPONENT, Unchecked{}};
return Number{false, kRange.get().min, kMinExponent, Unchecked{}};
}
inline Number
Number::max() noexcept
{
return Number{false, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
return Number{false, std::min(kRange.get().max, kMaxRep), kMaxExponent, Unchecked{}};
}
inline Number
Number::lowest() noexcept
{
return Number{true, std::min(kRANGE.get().max, kMAX_REP), kMAX_EXPONENT, Unchecked{}};
return Number{true, std::min(kRange.get().max, kMaxRep), kMaxExponent, Unchecked{}};
}
inline bool
Number::isnormal() const noexcept
{
MantissaRange const& range = kRANGE;
MantissaRange const& range = kRange;
auto const absM = mantissa_;
return *this == Number{} ||
(range.min <= absM && absM <= range.max && (absM <= kMAX_REP || absM % 10 == 0) &&
kMIN_EXPONENT <= exponent_ && exponent_ <= kMAX_EXPONENT);
(range.min <= absM && absM <= range.max && (absM <= kMaxRep || absM % 10 == 0) &&
kMinExponent <= exponent_ && exponent_ <= kMaxExponent);
}
template <Integral64 T>

View File

@@ -21,12 +21,12 @@ public:
}
[[nodiscard]] uint256 const&
asUint256() const
asUInt256() const
{
return hash_;
}
uint256&
asUint256()
asUInt256()
{
return hash_;
}
@@ -93,7 +93,7 @@ template <>
inline std::size_t
extract(SHAMapHash const& key)
{
return *reinterpret_cast<std::size_t const*>(key.asUint256().data());
return *reinterpret_cast<std::size_t const*>(key.asUInt256().data());
}
} // namespace xrpl

View File

@@ -57,10 +57,10 @@ template <class T>
std::shared_ptr<T> const&
SharedWeakCachePointer<T>::getStrong() const
{
static std::shared_ptr<T> const kEMPTY;
static std::shared_ptr<T> const kEmpty;
if (auto p = std::get_if<std::shared_ptr<T>>(&combo_))
return *p;
return kEMPTY;
return kEmpty;
}
template <class T>

View File

@@ -7,9 +7,11 @@
#include <boost/utility/string_view.hpp>
#include <array>
#include <concepts>
#include <cstdint>
#include <optional>
#include <string>
#include <type_traits>
namespace xrpl {
@@ -26,28 +28,39 @@ namespace xrpl {
std::string
sqlBlobLiteral(Blob const& blob);
namespace detail {
template <typename T>
concept SomeChar = std::same_as<std::remove_cvref_t<T>, int8_t> ||
std::same_as<std::remove_cvref_t<T>, char> || std::same_as<std::remove_cvref_t<T>, uint8_t>;
inline constexpr std::array<std::optional<int>, 256> const kDigitLookupTable = []() {
std::array<std::optional<int>, 256> t{};
for (int i = 0; i < 10; ++i)
t['0' + i] = i;
for (int i = 0; i < 6; ++i)
{
t['A' + i] = 10 + i;
t['a' + i] = 10 + i;
}
return t;
}();
inline std::optional<int>
hexCharToInt(SomeChar auto hexChar)
{
return kDigitLookupTable[static_cast<uint8_t>(hexChar)];
}
} // namespace detail
template <class Iterator>
std::optional<Blob>
strUnHex(std::size_t strSize, Iterator begin, Iterator end)
{
static constexpr std::array<int, 256> const kDIGIT_LOOKUP_TABLE = []() {
std::array<int, 256> t{};
for (auto& x : t)
x = -1;
for (int i = 0; i < 10; ++i)
t['0' + i] = i;
for (int i = 0; i < 6; ++i)
{
t['A' + i] = 10 + i;
t['a' + i] = 10 + i;
}
return t;
}();
Blob out;
out.reserve((strSize + 1) / 2);
@@ -56,27 +69,26 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
if (strSize & 1)
{
int c = kDIGIT_LOOKUP_TABLE[*iter++];
if (c < 0)
auto const c = detail::hexCharToInt(*iter++);
if (!c.has_value())
return {};
out.push_back(c);
out.push_back(static_cast<unsigned char>(*c));
}
while (iter != end)
{
int const cHigh = kDIGIT_LOOKUP_TABLE[*iter++];
auto const cHigh = detail::hexCharToInt(*iter++);
if (cHigh < 0)
if (!cHigh.has_value())
return {};
int const cLow = kDIGIT_LOOKUP_TABLE[*iter++];
auto const cLow = detail::hexCharToInt(*iter++);
if (cLow < 0)
if (!cLow.has_value())
return {};
out.push_back(static_cast<unsigned char>((cHigh << 4) | cLow));
out.push_back(static_cast<unsigned char>((*cHigh << 4) | *cLow));
}
return {std::move(out)};
@@ -120,7 +132,7 @@ std::string
trimWhitespace(std::string str);
std::optional<std::uint64_t>
toUint64(std::string const& s);
toUInt64(std::string const& s);
/** Determines if the given string looks like a TOML-file hosting domain.

View File

@@ -181,14 +181,14 @@ private:
beast::insight::Collector::ptr const& collector)
: hook(collector->makeHook(handler))
, size(collector->makeGauge(prefix, "size"))
, hit_rate(collector->makeGauge(prefix, "hit_rate"))
, hitRate(collector->makeGauge(prefix, "hit_rate"))
{
}
beast::insight::Hook hook;
beast::insight::Gauge size;
beast::insight::Gauge hit_rate;
beast::insight::Gauge hitRate;
std::size_t hits{0};
std::size_t misses{0};
@@ -197,16 +197,16 @@ private:
class KeyOnlyEntry
{
public:
clock_type::time_point last_access;
clock_type::time_point lastAccess;
explicit KeyOnlyEntry(clock_type::time_point const& lastAccess) : last_access(lastAccess)
explicit KeyOnlyEntry(clock_type::time_point const& lastAccess) : lastAccess(lastAccess)
{
}
void
touch(clock_type::time_point const& now)
{
last_access = now;
lastAccess = now;
}
};
@@ -214,10 +214,10 @@ private:
{
public:
shared_weak_combo_pointer_type ptr;
clock_type::time_point last_access;
clock_type::time_point lastAccess;
ValueEntry(clock_type::time_point const& lastAccess, shared_pointer_type const& ptr)
: ptr(ptr), last_access(lastAccess)
: ptr(ptr), lastAccess(lastAccess)
{
}
@@ -246,7 +246,7 @@ private:
void
touch(clock_type::time_point const& now)
{
last_access = now;
lastAccess = now;
}
};
@@ -286,13 +286,13 @@ private:
std::string name_;
// Desired number of cache entries (0 = ignore)
int const target_size_;
int const targetSize_;
// Desired maximum cache age
clock_type::duration const target_age_;
clock_type::duration const targetAge_;
// Number of items cached
int cache_count_{0};
int cacheCount_{0};
cache_type cache_; // Hold strong reference to recent objects
std::uint64_t hits_{0};
std::uint64_t misses_{0};

View File

@@ -34,8 +34,8 @@ inline TaggedCache<
, clock_(clock)
, stats_(name, std::bind(&TaggedCache::collectMetrics, this), collector)
, name_(name)
, target_size_(size)
, target_age_(expiration)
, targetSize_(size)
, targetAge_(expiration)
{
}
@@ -86,7 +86,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
getCacheSize() const
{
std::scoped_lock const lock(mutex_);
return cache_count_;
return cacheCount_;
}
template <
@@ -139,7 +139,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
std::scoped_lock const lock(mutex_);
cache_.clear();
cache_count_ = 0;
cacheCount_ = 0;
}
template <
@@ -157,7 +157,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
std::scoped_lock const lock(mutex_);
cache_.clear();
cache_count_ = 0;
cacheCount_ = 0;
hits_ = 0;
misses_ = 0;
}
@@ -213,21 +213,21 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
{
std::scoped_lock const lock(mutex_);
if (target_size_ == 0 || (static_cast<int>(cache_.size()) <= target_size_))
if (targetSize_ == 0 || (static_cast<int>(cache_.size()) <= targetSize_))
{
whenExpire = now - target_age_;
whenExpire = now - targetAge_;
}
else
{
whenExpire = now - (target_age_ * target_size_ / cache_.size());
whenExpire = now - (targetAge_ * targetSize_ / cache_.size());
clock_type::duration const minimumAge(std::chrono::seconds(1));
if (whenExpire > (now - minimumAge))
whenExpire = now - minimumAge;
JLOG(journal_.trace())
<< name_ << " is growing fast " << cache_.size() << " of " << target_size_
<< " aging at " << (now - whenExpire).count() << " of " << target_age_.count();
<< name_ << " is growing fast " << cache_.size() << " of " << targetSize_
<< " aging at " << (now - whenExpire).count() << " of " << targetAge_.count();
}
std::vector<std::thread> workers;
@@ -242,7 +242,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
for (std::thread& worker : workers)
worker.join();
cache_count_ -= allRemovals;
cacheCount_ -= allRemovals;
}
// At this point allStuffToSweep will go out of scope outside the lock
// and decrement the reference count on each strong pointer.
@@ -280,7 +280,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (entry.isCached())
{
--cache_count_;
--cacheCount_;
entry.ptr.convertToWeak();
ret = true;
}
@@ -317,7 +317,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
std::piecewise_construct,
std::forward_as_tuple(key),
std::forward_as_tuple(clock_.now(), data));
++cache_count_;
++cacheCount_;
return false;
}
@@ -366,12 +366,12 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
data = cachedData;
}
++cache_count_;
++cacheCount_;
return true;
}
entry.ptr = data;
++cache_count_;
++cacheCount_;
return false;
}
@@ -477,7 +477,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
auto [it, inserted] = cache_.emplace(
std::piecewise_construct, std::forward_as_tuple(key), std::forward_as_tuple(now));
if (!inserted)
it->second.last_access = now;
it->second.lastAccess = now;
return inserted;
}
@@ -626,7 +626,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (entry.isCached())
{
// independent of cache size, so not counted as a hit
++cache_count_;
++cacheCount_;
entry.touch(clock_.now());
return entry.ptr.getStrong();
}
@@ -658,7 +658,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
if (total != 0)
hitRate = (hits_ * 100) / total;
}
stats_.hit_rate.set(hitRate);
stats_.hitRate.set(hitRate);
}
}
@@ -706,7 +706,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
++cit;
}
}
else if (cit->second.last_access <= whenExpire)
else if (cit->second.lastAccess <= whenExpire)
{
// strong, expired
++cacheRemovals;
@@ -773,12 +773,12 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
auto cit = partition.begin();
while (cit != partition.end())
{
if (cit->second.last_access > now)
if (cit->second.lastAccess > now)
{
cit->second.last_access = now;
cit->second.lastAccess = now;
++cit;
}
else if (cit->second.last_access <= whenExpire)
else if (cit->second.lastAccess <= whenExpire)
{
cit = partition.erase(cit);
}

View File

@@ -30,8 +30,8 @@ public:
now(); // seconds since xrpld program start
private:
static std::atomic<rep> kNOW;
static std::atomic<bool> kSTOP;
static std::atomic<rep> kNow;
static std::atomic<bool> kStop;
struct UpdateThread : private std::thread
{

View File

@@ -46,6 +46,11 @@ struct IsContiguousContainer<Slice> : std::true_type
{
};
template <typename...>
struct AlwaysFalseT : std::bool_constant<false>
{
};
} // namespace detail
/** Integers of any length that is a multiple of 32-bits
@@ -62,18 +67,18 @@ struct IsContiguousContainer<Slice> : std::true_type
number of bits.
*/
template <std::size_t Bits, class Tag = void>
class BaseUint
class BaseUInt
{
static_assert((Bits % 32) == 0, "The length of a base_uint in bits must be a multiple of 32.");
static_assert(Bits >= 64, "The length of a base_uint in bits must be at least 64.");
static constexpr std::size_t kWIDTH = Bits / 32;
static constexpr std::size_t kWidth = Bits / 32;
// This is really big-endian in byte order.
// We sometimes use std::uint32_t for speed.
std::array<std::uint32_t, kWIDTH> data_;
std::array<std::uint32_t, kWidth> data_;
public:
//--------------------------------------------------------------------------
@@ -81,8 +86,8 @@ public:
// STL Container Interface
//
static std::size_t constexpr kBYTES = Bits / 8;
static_assert(sizeof(data_) == kBYTES, "");
static constexpr std::size_t kBytes = Bits / 8;
static_assert(sizeof(data_) == kBytes, "");
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
@@ -116,7 +121,7 @@ public:
iterator
end()
{
return data() + kBYTES;
return data() + kBytes;
}
[[nodiscard]] const_iterator
begin() const
@@ -126,7 +131,7 @@ public:
[[nodiscard]] const_iterator
end() const
{
return data() + kBYTES;
return data() + kBytes;
}
[[nodiscard]] const_iterator
cbegin() const
@@ -136,7 +141,7 @@ public:
[[nodiscard]] const_iterator
cend() const
{
return data() + kBYTES;
return data() + kBytes;
}
/** Value hashing function.
@@ -160,9 +165,9 @@ private:
explicit VoidHelper() = default;
};
explicit BaseUint(void const* data, VoidHelper)
explicit BaseUInt(void const* data, VoidHelper)
{
memcpy(data_.data(), data, kBYTES);
memcpy(data_.data(), data, kBytes);
}
// Helper function to initialize a base_uint from a std::string_view.
@@ -244,15 +249,15 @@ private:
}
public:
constexpr BaseUint() : data_{}
constexpr BaseUInt() : data_{}
{
}
constexpr BaseUint(beast::Zero) : data_{}
constexpr BaseUInt(beast::Zero) : data_{}
{
}
explicit BaseUint(std::uint64_t b)
explicit BaseUInt(std::uint64_t b)
{
*this = b;
}
@@ -260,7 +265,7 @@ public:
// This constructor is intended to be used at compile time since it might
// throw at runtime. Consider declaring this constructor consteval once
// we get to C++23.
explicit constexpr BaseUint(std::string_view sv) noexcept(false)
explicit constexpr BaseUInt(std::string_view sv) noexcept(false)
: data_(parseFromStringViewThrows(sv))
{
}
@@ -270,24 +275,42 @@ public:
class = std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>>>
explicit BaseUint(Container const& c)
explicit BaseUInt(Container const& c)
{
// Use AlwaysFalseT so the static_assert condition is dependent
// and only triggers when this constructor template is instantiated.
static_assert(
detail::AlwaysFalseT<Container>::value,
"This constructor is not intended to be used and will be soon removed. "
"Use base_uint::fromRaw instead.");
}
template <
class Container,
class = std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>>>
static BaseUInt
fromRaw(Container const& c)
{
BaseUInt result;
XRPL_ASSERT(
c.size() * sizeof(typename Container::value_type) == size(),
"xrpl::base_uint::base_uint(Container auto) : input size match");
std::memcpy(data_.data(), c.data(), size());
"xrpl::BaseUInt::fromRaw(Container auto) : input size match");
std::memcpy(result.data_.data(), c.data(), size());
return result;
}
template <class Container>
std::enable_if_t<
detail::IsContiguousContainer<Container>::value &&
std::is_trivially_copyable_v<typename Container::value_type>,
BaseUint&>
BaseUInt&>
operator=(Container const& c)
{
XRPL_ASSERT(
c.size() * sizeof(typename Container::value_type) == size(),
"xrpl::base_uint::operator=(Container auto) : input size match");
"xrpl::BaseUInt::operator=(Container auto) : input size match");
std::memcpy(data_.data(), c.data(), size());
return *this;
}
@@ -295,14 +318,14 @@ public:
/* Construct from a raw pointer.
The buffer pointed to by `data` must be at least Bits/8 bytes.
*/
static BaseUint
static BaseUInt
fromVoid(void const* data)
{
return BaseUint(data, VoidHelper());
return BaseUInt(data, VoidHelper());
}
template <class T>
static std::optional<BaseUint>
static std::optional<BaseUInt>
fromVoidChecked(T const& from)
{
if (from.size() != size())
@@ -313,7 +336,7 @@ public:
[[nodiscard]] constexpr int
signum() const
{
for (int i = 0; i < kWIDTH; i++)
for (int i = 0; i < kWidth; i++)
{
if (data_[i] != 0)
return 1;
@@ -325,24 +348,24 @@ public:
bool
operator!() const
{
return *this == beast::kZERO;
return *this == beast::kZero;
}
constexpr BaseUint
constexpr BaseUInt
operator~() const
{
BaseUint ret;
BaseUInt ret;
for (int i = 0; i < kWIDTH; i++)
for (int i = 0; i < kWidth; i++)
ret.data_[i] = ~data_[i];
return ret;
}
BaseUint&
BaseUInt&
operator=(std::uint64_t uHost)
{
*this = beast::kZERO;
*this = beast::kZero;
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
union
{
@@ -352,43 +375,43 @@ public:
// NOLINTEND(cppcoreguidelines-pro-type-member-init)
// Put in least significant bits.
ul = boost::endian::native_to_big(uHost);
data_[kWIDTH - 2] = u[0];
data_[kWIDTH - 1] = u[1];
data_[kWidth - 2] = u[0];
data_[kWidth - 1] = u[1];
return *this;
}
BaseUint&
operator^=(BaseUint const& b)
BaseUInt&
operator^=(BaseUInt const& b)
{
for (int i = 0; i < kWIDTH; i++)
for (int i = 0; i < kWidth; i++)
data_[i] ^= b.data_[i];
return *this;
}
BaseUint&
operator&=(BaseUint const& b)
BaseUInt&
operator&=(BaseUInt const& b)
{
for (int i = 0; i < kWIDTH; i++)
for (int i = 0; i < kWidth; i++)
data_[i] &= b.data_[i];
return *this;
}
BaseUint&
operator|=(BaseUint const& b)
BaseUInt&
operator|=(BaseUInt const& b)
{
for (int i = 0; i < kWIDTH; i++)
for (int i = 0; i < kWidth; i++)
data_[i] |= b.data_[i];
return *this;
}
BaseUint&
BaseUInt&
operator++()
{
// prefix operator
for (int i = kWIDTH - 1; i >= 0; --i)
for (int i = kWidth - 1; i >= 0; --i)
{
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) + 1);
if (data_[i] != 0)
@@ -398,20 +421,20 @@ public:
return *this;
}
BaseUint
BaseUInt
operator++(int)
{
// postfix operator
BaseUint const ret = *this;
BaseUInt const ret = *this;
++(*this);
return ret;
}
BaseUint&
BaseUInt&
operator--()
{
for (int i = kWIDTH - 1; i >= 0; --i)
for (int i = kWidth - 1; i >= 0; --i)
{
auto prev = data_[i];
data_[i] = boost::endian::native_to_big(boost::endian::big_to_native(data_[i]) - 1);
@@ -423,36 +446,36 @@ public:
return *this;
}
BaseUint
BaseUInt
operator--(int)
{
// postfix operator
BaseUint const ret = *this;
BaseUInt const ret = *this;
--(*this);
return ret;
}
[[nodiscard]] BaseUint
[[nodiscard]] BaseUInt
next() const
{
auto ret = *this;
return ++ret;
}
[[nodiscard]] BaseUint
[[nodiscard]] BaseUInt
prev() const
{
auto ret = *this;
return --ret;
}
BaseUint&
operator+=(BaseUint const& b)
BaseUInt&
operator+=(BaseUInt const& b)
{
std::uint64_t carry = 0;
for (int i = kWIDTH - 1; i >= 0; i--)
for (int i = kWidth - 1; i >= 0; i--)
{
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]);
@@ -466,7 +489,7 @@ public:
template <class Hasher>
friend void
hash_append(Hasher& h, BaseUint const& a) noexcept
hash_append(Hasher& h, BaseUInt const& a) noexcept
{
// Do not allow any endian transformations on this memory
h(a.data_.data(), sizeof(a.data_));
@@ -503,13 +526,13 @@ public:
return parseHex(std::string_view{str});
}
constexpr static std::size_t
static constexpr std::size_t
size()
{
return kBYTES;
return kBytes;
}
BaseUint<Bits, Tag>&
BaseUInt<Bits, Tag>&
operator=(beast::Zero)
{
data_.fill(0);
@@ -520,28 +543,28 @@ public:
[[nodiscard]] bool
isZero() const
{
return *this == beast::kZERO;
return *this == beast::kZero;
}
[[nodiscard]] bool
isNonZero() const
{
return *this != beast::kZERO;
return *this != beast::kZero;
}
void
zero()
{
*this = beast::kZERO;
*this = beast::kZero;
}
};
using uint128 = BaseUint<128>;
using uint160 = BaseUint<160>;
using uint256 = BaseUint<256>;
using uint192 = BaseUint<192>;
using uint128 = BaseUInt<128>;
using uint160 = BaseUInt<160>;
using uint256 = BaseUInt<256>;
using uint192 = BaseUInt<192>;
template <std::size_t Bits, class Tag>
[[nodiscard]] constexpr std::strong_ordering
operator<=>(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
operator<=>(BaseUInt<Bits, Tag> const& lhs, BaseUInt<Bits, Tag> const& rhs)
{
// This comparison might seem wrong on a casual inspection because it
// compares data internally stored as std::uint32_t byte-by-byte. But
@@ -562,7 +585,7 @@ operator<=>(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
template <std::size_t Bits, typename Tag>
[[nodiscard]] constexpr bool
operator==(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
operator==(BaseUInt<Bits, Tag> const& lhs, BaseUInt<Bits, Tag> const& rhs)
{
return (lhs <=> rhs) == 0;
}
@@ -570,59 +593,59 @@ operator==(BaseUint<Bits, Tag> const& lhs, BaseUint<Bits, Tag> const& rhs)
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
constexpr bool
operator==(BaseUint<Bits, Tag> const& a, std::uint64_t b)
operator==(BaseUInt<Bits, Tag> const& a, std::uint64_t b)
{
return a == BaseUint<Bits, Tag>(b);
return a == BaseUInt<Bits, Tag>(b);
}
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
constexpr BaseUint<Bits, Tag>
operator^(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
constexpr BaseUInt<Bits, Tag>
operator^(BaseUInt<Bits, Tag> const& a, BaseUInt<Bits, Tag> const& b)
{
return BaseUint<Bits, Tag>(a) ^= b;
return BaseUInt<Bits, Tag>(a) ^= b;
}
template <std::size_t Bits, class Tag>
constexpr BaseUint<Bits, Tag>
operator&(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
constexpr BaseUInt<Bits, Tag>
operator&(BaseUInt<Bits, Tag> const& a, BaseUInt<Bits, Tag> const& b)
{
return BaseUint<Bits, Tag>(a) &= b;
return BaseUInt<Bits, Tag>(a) &= b;
}
template <std::size_t Bits, class Tag>
constexpr BaseUint<Bits, Tag>
operator|(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
constexpr BaseUInt<Bits, Tag>
operator|(BaseUInt<Bits, Tag> const& a, BaseUInt<Bits, Tag> const& b)
{
return BaseUint<Bits, Tag>(a) |= b;
return BaseUInt<Bits, Tag>(a) |= b;
}
template <std::size_t Bits, class Tag>
constexpr BaseUint<Bits, Tag>
operator+(BaseUint<Bits, Tag> const& a, BaseUint<Bits, Tag> const& b)
constexpr BaseUInt<Bits, Tag>
operator+(BaseUInt<Bits, Tag> const& a, BaseUInt<Bits, Tag> const& b)
{
return BaseUint<Bits, Tag>(a) += b;
return BaseUInt<Bits, Tag>(a) += b;
}
//------------------------------------------------------------------------------
template <std::size_t Bits, class Tag>
inline std::string
to_string(BaseUint<Bits, Tag> const& a)
to_string(BaseUInt<Bits, Tag> const& a)
{
return strHex(a.cbegin(), a.cend());
}
template <std::size_t Bits, class Tag>
inline std::string
toShortString(BaseUint<Bits, Tag> const& a)
toShortString(BaseUInt<Bits, Tag> const& a)
{
static_assert(BaseUint<Bits, Tag>::kBYTES > 4, "For 4 bytes or less, use a native type");
static_assert(BaseUInt<Bits, Tag>::kBytes > 4, "For 4 bytes or less, use a native type");
return strHex(a.cbegin(), a.cbegin() + 4) + "...";
}
template <std::size_t Bits, class Tag>
inline std::ostream&
operator<<(std::ostream& out, BaseUint<Bits, Tag> const& u)
operator<<(std::ostream& out, BaseUInt<Bits, Tag> const& u)
{
return out << to_string(u);
}
@@ -650,7 +673,7 @@ static_assert(sizeof(uint256) == 256 / 8, "There should be no padding bytes");
namespace beast {
template <std::size_t Bits, class Tag>
struct IsUniquelyRepresented<xrpl::BaseUint<Bits, Tag>> : public std::true_type
struct IsUniquelyRepresented<xrpl::BaseUInt<Bits, Tag>> : public std::true_type
{
explicit IsUniquelyRepresented() = default;
};

View File

@@ -30,10 +30,10 @@ using weeks = std::chrono::duration<int, std::ratio_multiply<days::period, std::
= seconds(946684800)
*/
constexpr static std::chrono::seconds kEPOCH_OFFSET =
static constexpr std::chrono::seconds kEpochOffset =
date::sys_days{date::year{2000} / 1 / 1} - date::sys_days{date::year{1970} / 1 / 1};
static_assert(kEPOCH_OFFSET.count() == 946684800);
static_assert(kEpochOffset.count() == 946684800);
class NetClock
{
@@ -60,7 +60,7 @@ to_string(NetClock::time_point tp)
{
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
using namespace std::chrono;
return to_string(system_clock::time_point{tp.time_since_epoch() + kEPOCH_OFFSET});
return to_string(system_clock::time_point{tp.time_since_epoch() + kEpochOffset});
}
template <class Duration>
@@ -77,7 +77,7 @@ toStringIso(NetClock::time_point tp)
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
// Note, NetClock::duration is seconds, as checked by static_assert
static_assert(std::is_same_v<NetClock::duration::period, std::ratio<1>>);
return toStringIso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEPOCH_OFFSET});
return toStringIso(date::sys_time<NetClock::duration>{tp.time_since_epoch() + kEpochOffset});
}
/** A clock for measuring elapsed time.

View File

@@ -31,9 +31,9 @@ makeSeedPair() noexcept
// state_t(state_t const&) = delete;
// state_t& operator=(state_t const&) = delete;
};
static StateT kSTATE;
std::scoped_lock const lock(kSTATE.mutex);
return {kSTATE.dist(kSTATE.gen), kSTATE.dist(kSTATE.gen)};
static StateT kState;
std::scoped_lock const lock(kState.mutex);
return {kState.dist(kState.gen), kState.dist(kState.gen)};
}
} // namespace detail

View File

@@ -5,7 +5,7 @@
#include <optional>
namespace xrpl {
auto constexpr kMULDIV_MAX = std::numeric_limits<std::uint64_t>::max();
constexpr auto kMuldivMax = std::numeric_limits<std::uint64_t>::max();
/** Return value*mul/div accurately.
Computes the result of the multiplication and division in

View File

@@ -236,7 +236,7 @@ public:
map_.resize(partitions_);
XRPL_ASSERT(
partitions_,
"xrpl::partitioned_unordered_map::partitioned_unordered_map : "
"xrpl::PartitionedUnorderedMap::PartitionedUnorderedMap : "
"nonzero partitions");
}

View File

@@ -47,7 +47,7 @@ inline beast::xor_shift_engine&
defaultPrng()
{
// This is used to seed the thread-specific PRNGs on demand
static beast::xor_shift_engine kSEEDER = [] {
static beast::xor_shift_engine kSeeder = [] {
std::random_device rng;
std::uniform_int_distribution<std::uint64_t> distribution{1};
return beast::xor_shift_engine(distribution(rng));
@@ -57,17 +57,17 @@ defaultPrng()
static std::mutex kM;
// The thread-specific PRNGs:
thread_local beast::xor_shift_engine kENGINE = [] {
thread_local beast::xor_shift_engine kEngine = [] {
std::uint64_t seed = 0;
{
std::scoped_lock const lk(kM);
std::uniform_int_distribution<std::uint64_t> distribution{1};
seed = distribution(kSEEDER);
seed = distribution(kSeeder);
}
return beast::xor_shift_engine{seed};
}();
return kENGINE;
return kEngine;
}
/** Return a uniformly distributed random integer.
@@ -94,7 +94,7 @@ template <class Engine, class Integral>
std::enable_if_t<std::is_integral_v<Integral> && detail::is_engine<Engine>::value, Integral>
randInt(Engine& engine, Integral min, Integral max)
{
XRPL_ASSERT(max > min, "xrpl::rand_int : max over min inputs");
XRPL_ASSERT(max > min, "xrpl::randInt : max over min inputs");
// This should have no state and constructing it should
// be very cheap. If that turns out not to be the case

View File

@@ -22,9 +22,9 @@ safeCast(Src s) noexcept
{
static_assert(
std::is_signed_v<Dest> || std::is_unsigned_v<Src>, "Cannot cast signed to unsigned");
constexpr unsigned kNOT_SAME = std::is_signed_v<Dest> != std::is_signed_v<Src>;
constexpr unsigned kNotSame = std::is_signed_v<Dest> != std::is_signed_v<Src>;
static_assert(
sizeof(Dest) >= sizeof(Src) + kNOT_SAME,
sizeof(Dest) >= sizeof(Src) + kNotSame,
"Destination is too small to hold all values of source");
return static_cast<Dest>(s);
}
@@ -81,7 +81,7 @@ safeDowncast(Src* s) noexcept
return static_cast<Dest>(s); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
#else
auto* result = dynamic_cast<Dest>(s);
XRPL_ASSERT(result != nullptr, "xrpl::safe_downcast : pointer downcast is valid");
XRPL_ASSERT(result != nullptr, "xrpl::safeDowncast : pointer downcast is valid");
return result;
#endif
}
@@ -94,7 +94,7 @@ safeDowncast(Src& s) noexcept
#ifndef NDEBUG
XRPL_ASSERT(
dynamic_cast<std::add_pointer_t<std::remove_reference_t<Dest>>>(&s) != nullptr,
"xrpl::safe_downcast : reference downcast is valid");
"xrpl::safeDowncast : reference downcast is valid");
#endif
return static_cast<Dest>(s); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
}

View File

@@ -24,20 +24,20 @@ namespace xrpl {
template <class EF>
class ScopeExit
{
EF exit_function_;
bool execute_on_destruction_{true};
EF exitFunction_;
bool executeOnDestruction_{true};
public:
~ScopeExit()
{
if (execute_on_destruction_)
exit_function_();
if (executeOnDestruction_)
exitFunction_();
}
ScopeExit(ScopeExit&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
: exitFunction_{std::forward<EF>(rhs.exitFunction_)}
, executeOnDestruction_{rhs.executeOnDestruction_}
{
rhs.release();
}
@@ -51,7 +51,7 @@ public:
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, ScopeExit> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)}
: exitFunction_{std::forward<EFP>(f)}
{
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
}
@@ -59,7 +59,7 @@ public:
void
release() noexcept
{
execute_on_destruction_ = false;
executeOnDestruction_ = false;
}
};
@@ -69,22 +69,22 @@ ScopeExit(EF) -> ScopeExit<EF>;
template <class EF>
class ScopeFail
{
EF exit_function_;
bool execute_on_destruction_{true};
int uncaught_on_creation_{std::uncaught_exceptions()};
EF exitFunction_;
bool executeOnDestruction_{true};
int uncaughtOnCreation_{std::uncaught_exceptions()};
public:
~ScopeFail()
{
if (execute_on_destruction_ && std::uncaught_exceptions() > uncaught_on_creation_)
exit_function_();
if (executeOnDestruction_ && std::uncaught_exceptions() > uncaughtOnCreation_)
exitFunction_();
}
ScopeFail(ScopeFail&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
, uncaught_on_creation_{rhs.uncaught_on_creation_}
: exitFunction_{std::forward<EF>(rhs.exitFunction_)}
, executeOnDestruction_{rhs.executeOnDestruction_}
, uncaughtOnCreation_{rhs.uncaughtOnCreation_}
{
rhs.release();
}
@@ -98,7 +98,7 @@ public:
std::enable_if_t<
!std::is_same_v<std::remove_cv_t<EFP>, ScopeFail> &&
std::is_constructible_v<EF, EFP>>* = 0) noexcept
: exit_function_{std::forward<EFP>(f)}
: exitFunction_{std::forward<EFP>(f)}
{
static_assert(std::is_nothrow_constructible_v<EF, decltype(std::forward<EFP>(f))>);
}
@@ -106,7 +106,7 @@ public:
void
release() noexcept
{
execute_on_destruction_ = false;
executeOnDestruction_ = false;
}
};
@@ -116,22 +116,22 @@ ScopeFail(EF) -> ScopeFail<EF>;
template <class EF>
class ScopeSuccess
{
EF exit_function_;
bool execute_on_destruction_{true};
int uncaught_on_creation_{std::uncaught_exceptions()};
EF exitFunction_;
bool executeOnDestruction_{true};
int uncaughtOnCreation_{std::uncaught_exceptions()};
public:
~ScopeSuccess() noexcept(noexcept(exit_function_()))
~ScopeSuccess() noexcept(noexcept(exitFunction_()))
{
if (execute_on_destruction_ && std::uncaught_exceptions() <= uncaught_on_creation_)
exit_function_();
if (executeOnDestruction_ && std::uncaught_exceptions() <= uncaughtOnCreation_)
exitFunction_();
}
ScopeSuccess(ScopeSuccess&& rhs) noexcept(
std::is_nothrow_move_constructible_v<EF> || std::is_nothrow_copy_constructible_v<EF>)
: exit_function_{std::forward<EF>(rhs.exit_function_)}
, execute_on_destruction_{rhs.execute_on_destruction_}
, uncaught_on_creation_{rhs.uncaught_on_creation_}
: exitFunction_{std::forward<EF>(rhs.exitFunction_)}
, executeOnDestruction_{rhs.executeOnDestruction_}
, uncaughtOnCreation_{rhs.uncaughtOnCreation_}
{
rhs.release();
}
@@ -146,14 +146,14 @@ public:
!std::is_same_v<std::remove_cv_t<EFP>, ScopeSuccess> &&
std::is_constructible_v<EF, EFP>>* =
0) noexcept(std::is_nothrow_constructible_v<EF, EFP> || std::is_nothrow_constructible_v<EF, EFP&>)
: exit_function_{std::forward<EFP>(f)}
: exitFunction_{std::forward<EFP>(f)}
{
}
void
release() noexcept
{
execute_on_destruction_ = false;
executeOnDestruction_ = false;
}
};
@@ -205,7 +205,7 @@ class ScopeUnlock
public:
explicit ScopeUnlock(std::unique_lock<Mutex>& lock) noexcept(true) : plock_(&lock)
{
XRPL_ASSERT(plock_->owns_lock(), "xrpl::scope_unlock::scope_unlock : mutex must be locked");
XRPL_ASSERT(plock_->owns_lock(), "xrpl::ScopeUnlock::ScopeUnlock : mutex must be locked");
plock_->unlock();
}

View File

@@ -103,7 +103,7 @@ public:
{
XRPL_ASSERT(
index >= 0 && (mask_ != 0),
"xrpl::packed_spinlock::packed_spinlock : valid index and mask");
"xrpl::PackedSpinlock::PackedSpinlock : valid index and mask");
}
[[nodiscard]] bool

View File

@@ -15,7 +15,7 @@ namespace beast {
/** Measures handler latency on an io_context queue. */
template <class Clock>
class IoLatencyProbe
class IOLatencyProbe
{
private:
using duration = typename Clock::duration;
@@ -30,12 +30,12 @@ private:
bool cancel_{false};
public:
IoLatencyProbe(duration const& period, boost::asio::io_context& ios)
IOLatencyProbe(duration const& period, boost::asio::io_context& ios)
: period_(period), ios_(ios), timer_(ios_)
{
}
~IoLatencyProbe()
~IOLatencyProbe()
{
std::unique_lock<decltype(mutex_)> lock(mutex_);
cancel(lock, true);
@@ -85,7 +85,7 @@ public:
{
std::scoped_lock const lock(mutex_);
if (cancel_)
throw std::logic_error("io_latency_probe is canceled");
throw std::logic_error("IOLatencyProbe is canceled");
boost::asio::post(
ios_, SampleOp<Handler>(std::forward<Handler>(handler), Clock::now(), false, this));
}
@@ -100,7 +100,7 @@ public:
{
std::scoped_lock const lock(mutex_);
if (cancel_)
throw std::logic_error("io_latency_probe is canceled");
throw std::logic_error("IOLatencyProbe is canceled");
boost::asio::post(
ios_, SampleOp<Handler>(std::forward<Handler>(handler), Clock::now(), true, this));
}
@@ -140,18 +140,18 @@ private:
Handler handler;
time_point start;
bool repeat;
IoLatencyProbe* probe;
IOLatencyProbe* probe;
SampleOp(
Handler const& handler,
time_point const& start,
bool repeat,
IoLatencyProbe* probe)
IOLatencyProbe* probe)
: handler(handler), start(start), repeat(repeat), probe(probe)
{
XRPL_ASSERT(
probe,
"beast::io_latency_probe::sample_op::sample_op : non-null "
"beast::IOLatencyProbe::SampleOp::SampleOp : non-null "
"probe input");
probe->addref();
}
@@ -164,7 +164,7 @@ private:
{
XRPL_ASSERT(
probe,
"beast::io_latency_probe::sample_op::sample_op(sample_op&&) : "
"beast::IOLatencyProbe::SampleOp::SampleOp(SampleOp&&) : "
"non-null probe input");
from.probe = nullptr;
}

View File

@@ -83,8 +83,8 @@ template <class Facade, class Clock = Facade>
AbstractClock<Facade>&
getAbstractClock()
{
static detail::AbstractClockWrapper<Facade, Clock> kCLOCK;
return kCLOCK;
static detail::AbstractClockWrapper<Facade, Clock> kClock;
return kClock;
}
} // namespace beast

View File

@@ -1370,7 +1370,7 @@ private:
buck_.resize(size() + additional, cont_);
XRPL_ASSERT(
loadFactor() <= maxLoadFactor(),
"beast::detail::AgedUnorderedContainer::maybe_rehash : maximum "
"beast::detail::AgedUnorderedContainer::maybeRehash : maximum "
"load factor");
}

View File

@@ -21,7 +21,7 @@ setCurrentThreadName(std::string_view newThreadName);
// On Linux, thread names are limited to 16 bytes including the null terminator.
// Maximum number of characters is therefore 15.
constexpr std::size_t kMAX_THREAD_NAME_LENGTH = 15;
constexpr std::size_t kMaxThreadNameLength = 15;
/** Sets the name of the caller thread with compile-time size checking.
@tparam N The size of the string literal including null terminator
@@ -34,7 +34,7 @@ template <std::size_t N>
void
setCurrentThreadName(char const (&newThreadName)[N])
{
static_assert(N <= kMAX_THREAD_NAME_LENGTH + 1, "Thread name cannot exceed 15 characters");
static_assert(N <= kMaxThreadNameLength + 1, "Thread name cannot exceed 15 characters");
setCurrentThreadName(std::string_view(newThreadName, N - 1));
}

View File

@@ -53,7 +53,7 @@ inline void
maybeReverseBytes(T& t, Hasher&)
{
maybeReverseBytes(
t, std::integral_constant<bool, Hasher::kENDIAN != boost::endian::order::native>{});
t, std::integral_constant<bool, Hasher::kEndian != boost::endian::order::native>{});
}
} // namespace detail
@@ -154,7 +154,7 @@ struct IsContiguouslyHashable
: public std::integral_constant<
bool,
IsUniquelyRepresented<T>::value &&
(sizeof(T) == 1 || HashAlgorithm::kENDIAN == boost::endian::order::native)>
(sizeof(T) == 1 || HashAlgorithm::kEndian == boost::endian::order::native)>
{
explicit IsContiguouslyHashable() = default;
};

View File

@@ -21,9 +21,9 @@ private:
static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t");
// Have an internal buffer to avoid the streaming API
// A 64-byte buffer should to be big enough for us
static constexpr std::size_t kINTERNAL_BUFFER_SIZE = 64;
static constexpr std::size_t kInternalBufferSize = 64;
alignas(64) std::array<std::uint8_t, kINTERNAL_BUFFER_SIZE> buffer_{};
alignas(64) std::array<std::uint8_t, kInternalBufferSize> buffer_{};
std::span<std::uint8_t> readBuffer_;
std::span<std::uint8_t> writeBuffer_;
@@ -102,7 +102,7 @@ private:
}
public:
static constexpr auto const kENDIAN = boost::endian::order::native;
static constexpr auto kEndian = boost::endian::order::native;
Xxhasher(Xxhasher const&) = delete;
Xxhasher&

View File

@@ -62,9 +62,7 @@ private:
{
using run_time = std::pair<std::string, typename clock_type::duration>;
// Need to be named before converting
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum { MaxTop = 10 };
static constexpr auto kMaxTop = 10;
std::size_t suites = 0;
std::size_t cases = 0;
@@ -79,8 +77,8 @@ private:
std::ostream& os_;
Results results_;
SuiteResults suite_results_;
CaseResults case_results_;
SuiteResults suiteResults_;
CaseResults caseResults_;
public:
Reporter(Reporter const&) = delete;
@@ -148,11 +146,11 @@ Reporter<Unused>::Results::add(SuiteResults const& r)
});
if (iter != top.end())
{
if (top.size() == MaxTop)
if (top.size() == kMaxTop)
top.resize(top.size() - 1);
top.emplace(iter, r.name, elapsed);
}
else if (top.size() < MaxTop)
else if (top.size() < kMaxTop)
{
top.emplace_back(r.name, elapsed);
}
@@ -198,22 +196,22 @@ template <class Unused>
void
Reporter<Unused>::onSuiteBegin(SuiteInfo const& info)
{
suite_results_ = SuiteResults{info.fullName()};
suiteResults_ = SuiteResults{info.fullName()};
}
template <class Unused>
void
Reporter<Unused>::onSuiteEnd()
{
results_.add(suite_results_);
results_.add(suiteResults_);
}
template <class Unused>
void
Reporter<Unused>::onCaseBegin(std::string const& name)
{
case_results_ = CaseResults(name);
os_ << suite_results_.name << (case_results_.name.empty() ? "" : (" " + case_results_.name))
caseResults_ = CaseResults(name);
os_ << suiteResults_.name << (caseResults_.name.empty() ? "" : (" " + caseResults_.name))
<< std::endl;
}
@@ -221,23 +219,23 @@ template <class Unused>
void
Reporter<Unused>::onCaseEnd()
{
suite_results_.add(case_results_);
suiteResults_.add(caseResults_);
}
template <class Unused>
void
Reporter<Unused>::onPass()
{
++case_results_.total;
++caseResults_.total;
}
template <class Unused>
void
Reporter<Unused>::onFail(std::string const& reason)
{
++case_results_.failed;
++case_results_.total;
os_ << "#" << case_results_.total << " failed" << (reason.empty() ? "" : ": ") << reason
++caseResults_.failed;
++caseResults_.total;
os_ << "#" << caseResults_.total << " failed" << (reason.empty() ? "" : ": ") << reason
<< std::endl;
}

View File

@@ -299,8 +299,8 @@ private:
static Suite**
pThisSuite()
{
static Suite* kP_TS = nullptr; // NOLINT TODO
return &kP_TS;
static Suite* kPTs = nullptr; // NOLINT TODO
return &kPTs;
}
/** Runs the suite. */

View File

@@ -2,29 +2,25 @@
#include <xrpl/beast/utility/instrumentation.h>
#include <cstdint>
#include <sstream>
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,
enum class Severity : std::uint8_t {
All = 0,
KTrace = KAll,
KDebug = 1,
KInfo = 2,
KWarning = 3,
KError = 4,
KFatal = 5,
Trace = All,
Debug = 1,
Info = 2,
Warning = 3,
Error = 4,
Fatal = 5,
KDisabled = 6,
KNone = KDisabled
Disabled = 6,
None = Disabled
};
} // namespace severities
/** A generic endpoint for log messages.
@@ -44,9 +40,6 @@ public:
class Sink;
private:
// Severity level / threshold of a Journal message.
using Severity = severities::Severity;
// Invariant: sink_ always points to a valid Sink
Sink* sink_;
@@ -183,7 +176,7 @@ public:
{
public:
/** Create a stream which produces no output. */
explicit Stream() : sink_(getNullSink()), level_(severities::KDisabled)
explicit Stream() : sink_(getNullSink()), level_(Severity::Disabled)
{
}
@@ -194,7 +187,7 @@ public:
Stream(Sink& sink, Severity level) : sink_(sink), level_(level)
{
XRPL_ASSERT(
level_ < severities::KDisabled, "beast::Journal::Stream::Stream : maximum level");
level_ < Severity::Disabled, "beast::Journal::Stream::Stream : maximum level");
}
/** Construct or copy another Stream. */
@@ -297,37 +290,37 @@ public:
[[nodiscard]] Stream
trace() const
{
return {*sink_, severities::KTrace};
return {*sink_, Severity::Trace};
}
[[nodiscard]] Stream
debug() const
{
return {*sink_, severities::KDebug};
return {*sink_, Severity::Debug};
}
[[nodiscard]] Stream
info() const
{
return {*sink_, severities::KInfo};
return {*sink_, Severity::Info};
}
[[nodiscard]] Stream
warn() const
{
return {*sink_, severities::KWarning};
return {*sink_, Severity::Warning};
}
[[nodiscard]] Stream
error() const
{
return {*sink_, severities::KError};
return {*sink_, Severity::Error};
}
[[nodiscard]] Stream
fatal() const
{
return {*sink_, severities::KFatal};
return {*sink_, Severity::Fatal};
}
/** @} */
};

View File

@@ -36,7 +36,7 @@ public:
}
[[nodiscard]] bool
active(beast::severities::Severity level) const override
active(beast::Severity level) const override
{
return sink_.active(level);
}
@@ -53,27 +53,27 @@ public:
sink_.console(output);
}
[[nodiscard]] beast::severities::Severity
[[nodiscard]] beast::Severity
threshold() const override
{
return sink_.threshold();
}
void
threshold(beast::severities::Severity thresh) override
threshold(beast::Severity thresh) override
{
sink_.threshold(thresh);
}
void
write(beast::severities::Severity level, std::string const& text) override
write(beast::Severity level, std::string const& text) override
{
using beast::Journal;
sink_.write(level, prefix_ + text);
}
void
writeAlways(severities::Severity level, std::string const& text) override
writeAlways(Severity level, std::string const& text) override
{
using beast::Journal;
sink_.writeAlways(level, prefix_ + text);

View File

@@ -27,7 +27,7 @@ struct Zero
};
namespace {
constexpr Zero kZERO{};
constexpr Zero kZero{};
} // namespace
/** Default implementation of signum calls the method on the class. */
@@ -102,42 +102,42 @@ template <typename T>
bool
operator==(Zero, T const& t)
{
return t == kZERO;
return t == kZero;
}
template <typename T>
bool
operator!=(Zero, T const& t)
{
return t != kZERO;
return t != kZero;
}
template <typename T>
bool
operator<(Zero, T const& t)
{
return t > kZERO;
return t > kZero;
}
template <typename T>
bool
operator>(Zero, T const& t)
{
return t < kZERO;
return t < kZero;
}
template <typename T>
bool
operator>=(Zero, T const& t)
{
return t <= kZERO;
return t <= kZero;
}
template <typename T>
bool
operator<=(Zero, T const& t)
{
return t >= kZERO;
return t >= kZero;
}
} // namespace beast

View File

@@ -14,23 +14,23 @@ void
rngfill(void* const buffer, std::size_t const bytes, Generator& g)
{
using result_type = typename Generator::result_type;
constexpr std::size_t kRESULT_SIZE = sizeof(result_type);
constexpr std::size_t kResultSize = sizeof(result_type);
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
std::size_t const completeIterations = bytes / kRESULT_SIZE;
std::size_t const bytesRemaining = bytes % kRESULT_SIZE;
std::size_t const completeIterations = bytes / kResultSize;
std::size_t const bytesRemaining = bytes % kResultSize;
for (std::size_t count = 0; count < completeIterations; ++count)
{
result_type const v = g();
std::size_t const offset = count * kRESULT_SIZE;
std::memcpy(bufferStart + offset, &v, kRESULT_SIZE);
std::size_t const offset = count * kResultSize;
std::memcpy(bufferStart + offset, &v, kResultSize);
}
if (bytesRemaining > 0)
{
result_type const v = g();
std::size_t const offset = completeIterations * kRESULT_SIZE;
std::size_t const offset = completeIterations * kResultSize;
std::memcpy(bufferStart + offset, &v, bytesRemaining);
}
}

View File

@@ -26,12 +26,14 @@ public:
result_type
operator()();
static result_type constexpr min()
static constexpr result_type
min()
{
return std::numeric_limits<result_type>::min();
}
static result_type constexpr max()
static constexpr result_type
max()
{
return std::numeric_limits<result_type>::max();
}

View File

@@ -27,7 +27,7 @@ public:
that were previously considered valid to no longer
be allowed.
*/
static constexpr std::size_t kMAX_SERIALIZED_CONDITION = 128;
static constexpr std::size_t kMaxSerializedCondition = 128;
/** Load a condition from its binary form

View File

@@ -16,7 +16,7 @@ public:
that were previously considered valid to no longer
be allowed.
*/
static constexpr std::size_t kMAX_SERIALIZED_FULFILLMENT = 256;
static constexpr std::size_t kMaxSerializedFulfillment = 256;
/** Load a fulfillment from its binary form

View File

@@ -23,7 +23,7 @@ public:
While future versions of this code will never lower
this limit, they may opt to raise it.
*/
static constexpr std::size_t kMAX_PREIMAGE_LENGTH = 128;
static constexpr std::size_t kMaxPreimageLength = 128;
/** Parse the payload for a PreimageSha256 condition
@@ -65,7 +65,7 @@ public:
return {};
}
if (s.size() > kMAX_PREIMAGE_LENGTH)
if (s.size() > kMaxPreimageLength)
{
ec = Error::PreimageTooLong;
return {};

View File

@@ -6,7 +6,7 @@ namespace xrpl {
/// Coroutine stack size (1.5 MB). Increased from 1 MB because
/// ASAN-instrumented deep call stacks exceeded the original limit.
constexpr std::size_t kCORO_STACK_SIZE = 1536 * 1024;
constexpr std::size_t kCoroStackSize = 1536 * 1024;
template <class F>
JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name, F&& f)
@@ -14,7 +14,7 @@ JobQueue::Coro::Coro(CoroCreateT, JobQueue& jq, JobType type, std::string name,
, type_(type)
, name_(std::move(name))
, coro_(
boost::context::protected_fixedsize_stack(kCORO_STACK_SIZE),
boost::context::protected_fixedsize_stack(kCoroStackSize),
[this, fn = std::forward<F>(f)](boost::coroutines2::coroutine<void>::push_type& doYield) {
yield_ = &doYield;
yield();
@@ -47,7 +47,7 @@ inline bool
JobQueue::Coro::post()
{
{
std::scoped_lock const lk(mutex_run_);
std::scoped_lock const lk(mutexRun_);
running_ = true;
}
@@ -58,7 +58,7 @@ JobQueue::Coro::post()
}
// The coroutine will not run. Clean up running_.
std::scoped_lock const lk(mutex_run_);
std::scoped_lock const lk(mutexRun_);
running_ = false;
cv_.notify_all();
return false;
@@ -68,7 +68,7 @@ inline void
JobQueue::Coro::resume()
{
{
std::scoped_lock const lk(mutex_run_);
std::scoped_lock const lk(mutexRun_);
running_ = true;
}
{
@@ -92,7 +92,7 @@ JobQueue::Coro::resume()
}
detail::getLocalValues().release();
detail::getLocalValues().reset(saved);
std::scoped_lock const lk(mutex_run_);
std::scoped_lock const lk(mutexRun_);
running_ = false;
cv_.notify_all();
}
@@ -127,7 +127,7 @@ JobQueue::Coro::expectEarlyExit()
inline void
JobQueue::Coro::join()
{
std::unique_lock<std::mutex> lk(mutex_run_);
std::unique_lock<std::mutex> lk(mutexRun_);
cv_.wait(lk, [this]() { return !running_; });
}

View File

@@ -127,7 +127,7 @@ private:
std::function<void()> job_;
std::shared_ptr<LoadEvent> loadEvent_;
std::string name_;
clock_type::time_point queue_time_;
clock_type::time_point queueTime_;
};
using JobCounter = ClosureCounter<void>;

View File

@@ -52,7 +52,7 @@ public:
std::string name_;
bool running_{false};
std::mutex mutex_;
std::mutex mutex_run_;
std::mutex mutexRun_;
std::condition_variable cv_;
boost::coroutines2::coroutine<void>::push_type* yield_{};
boost::coroutines2::coroutine<void>::pull_type coro_;
@@ -246,7 +246,7 @@ private:
// Statistics tracking
perf::PerfLog& perfLog_;
beast::insight::Collector::ptr collector_;
beast::insight::Gauge job_count_;
beast::insight::Gauge jobCount_;
beast::insight::Hook hook_;
std::condition_variable cv_;

View File

@@ -101,8 +101,8 @@ public:
static JobTypes const&
instance()
{
static JobTypes const kTYPES;
return kTYPES;
static JobTypes const kTypes;
return kTypes;
}
static std::string const&

View File

@@ -5,7 +5,7 @@
namespace xrpl {
/** A PropertyStream::Sink which produces a json::Value of type objectValue. */
/** A PropertyStream::Sink which produces a json::Value of type ValueType::Object. */
class JsonPropertyStream : public beast::PropertyStream
{
public:

View File

@@ -161,7 +161,7 @@ public:
* While the JSON spec doesn't explicitly disallow this, you should avoid
* calling this method twice with the same tag for the same object.
*
* If CHECK_JSON_WRITER is defined, this function throws an exception if if
* If CHECK_JSON_WRITER is defined, this function throws an exception if
* the tag you use has already been used in this object.
*/
template <typename Type>

View File

@@ -67,27 +67,25 @@ public:
[[nodiscard]] std::string
getFormattedErrorMessages() const;
static constexpr unsigned kNEST_LIMIT{25};
static constexpr unsigned kNestLimit{25};
private:
// 53 files, protocol-wide
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum TokenType {
TokenEndOfStream = 0,
TokenObjectBegin,
TokenObjectEnd,
TokenArrayBegin,
TokenArrayEnd,
TokenString,
TokenInteger,
TokenDouble,
TokenTrue,
TokenFalse,
TokenNull,
TokenArraySeparator,
TokenMemberSeparator,
TokenComment,
TokenError
enum class TokenType {
EndOfStream = 0,
ObjectBegin,
ObjectEnd,
ArrayBegin,
ArrayEnd,
String,
Integer,
Double,
True,
False,
Null,
ArraySeparator,
MemberSeparator,
Comment,
Error
};
class Token

View File

@@ -15,22 +15,20 @@ 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
UintValue, ///< unsigned integer value
RealValue, ///< double value
StringValue, ///< UTF-8 string value
BooleanValue, ///< bool value
ArrayValue, ///< array value (ordered list)
ObjectValue ///< object value (collection of name/value pairs).
enum class ValueType {
Null = 0, ///< 'null' value
Int, ///< signed integer value
UInt, ///< unsigned integer value
Real, ///< double value
String, ///< UTF-8 string value
Boolean, ///< bool value
Array, ///< array value (ordered list)
Object ///< object value (collection of name/value pairs).
};
/** \brief Lightweight wrapper to tag static string.
*
* Value constructor and objectValue member assignment takes advantage of the
* Value constructor and ValueType::Object member assignment takes advantage of the
* StaticString and avoid the cost of string duplication when storing the
* string or the member name.
*
@@ -104,8 +102,8 @@ operator!=(StaticString x, std::string const& y)
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
*
* This class is a discriminated union wrapper that can represent a:
* - signed integer [range: Value::minInt - Value::maxInt]
* - unsigned integer (range: 0 - Value::maxUInt)
* - signed integer [range: Value::kMinInt - Value::kMaxInt]
* - unsigned integer (range: 0 - Value::kMaxUInt)
* - double
* - UTF-8 string
* - boolean
@@ -116,16 +114,16 @@ operator!=(StaticString x, std::string const& y)
* The type of the held value is represented by a #ValueType and
* can be obtained using type().
*
* values of an #objectValue or #arrayValue can be accessed using operator[]()
* methods. Non const methods will automatically create the a #nullValue element
* values of an ValueType::Object or ValueType::Array can be accessed using operator[]()
* methods. Non const methods will automatically create the a ValueType::Null element
* if it does not exist.
* The sequence of an #arrayValue will be automatically resize and initialized
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
* The sequence of an ValueType::Array will be automatically resize and initialized
* with ValueType::Null. resize() can be used to enlarge or truncate an ValueType::Array.
*
* The get() methods can be used to obtain a default value in the case the
* required element does not exist.
*
* It is possible to iterate over the list of a #objectValue values using
* It is possible to iterate over the list of a ValueType::Object values using
* the getMemberNames() method.
*/
class Value
@@ -140,18 +138,16 @@ public:
using Int = json::Int;
using ArrayIndex = UInt;
static Value const kNULL;
static constexpr Int kMIN_INT = std::numeric_limits<Int>::min();
static constexpr Int kMAX_INT = std::numeric_limits<Int>::max();
static constexpr UInt kMAX_U_INT = std::numeric_limits<UInt>::max();
static Value const kNull;
static constexpr Int kMinInt = std::numeric_limits<Int>::min();
static constexpr Int kMaxInt = std::numeric_limits<Int>::max();
static constexpr UInt kMaxUInt = std::numeric_limits<UInt>::max();
private:
class CZString
{
public:
// Stored as int field, implicit conversion
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum DuplicationPolicy { NoDuplication = 0, Duplicate, DuplicateOnCopy };
enum class DuplicationPolicy { NoDuplication = 0, Duplicate, DuplicateOnCopy };
CZString(int index);
CZString(char const* cstr, DuplicationPolicy allocate);
@@ -182,19 +178,19 @@ public:
/** \brief Create a default Value of the given type.
This is a very useful constructor.
To create an empty array, pass arrayValue.
To create an empty object, pass objectValue.
To create an empty array, pass ValueType::Array.
To create an empty object, pass ValueType::Object.
Another Value can then be set to this one by assignment.
This is useful since clear() and resize() will not alter types.
Examples:
\code
json::Value null_value; // null
json::Value arr_value(json::arrayValue); // []
json::Value obj_value(json::objectValue); // {}
json::Value arr_value(json::ValueType::Array); // []
json::Value obj_value(json::ValueType::Object); // {}
\endcode
*/
Value(ValueType type = NullValue);
Value(ValueType type = ValueType::Null);
Value(Int value);
Value(UInt value);
Value(double value);
@@ -290,7 +286,7 @@ public:
operator bool() const;
/// Remove all object members and array elements.
/// \pre type() is arrayValue, objectValue, or nullValue
/// \pre type() is ValueType::Array, ValueType::Object, or ValueType::Null
/// \post type() is unchanged
void
clear();
@@ -367,7 +363,7 @@ public:
///
/// Do nothing if it did not exist.
/// \return the removed Value, or null.
/// \pre type() is objectValue or nullValue
/// \pre type() is ValueType::Object or ValueType::Null
/// \post type() is unchanged
Value
removeMember(char const* key);
@@ -388,8 +384,8 @@ public:
/// \brief Return a list of the member names.
///
/// If null, return an empty list.
/// \pre type() is objectValue or nullValue
/// \post if type() was nullValue, it remains nullValue
/// \pre type() is ValueType::Object or ValueType::Null
/// \post if type() was ValueType::Null, it remains ValueType::Null
[[nodiscard]] Members
getMemberNames() const;
@@ -469,16 +465,14 @@ operator>=(Value const& x, Value const& y)
* string value memory management done by Value.
*
* - makeMemberName() and releaseMemberName() are called to respectively
* duplicate and free an json::objectValue member name.
* duplicate and free an json::ValueType::Object member name.
* - duplicateStringValue() and releaseStringValue() are called similarly to
* duplicate and free a json::stringValue value.
* duplicate and free a json::ValueType::String value.
*/
class ValueAllocator
{
public:
// Need to be named before converting
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum { Unknown = (unsigned)-1 };
static constexpr auto kUnknown = (unsigned)-1;
virtual ~ValueAllocator() = default;
@@ -487,7 +481,7 @@ public:
virtual void
releaseMemberName(char* memberName) = 0;
virtual char*
duplicateStringValue(char const* value, unsigned int length = Unknown) = 0;
duplicateStringValue(char const* value, unsigned int length = kUnknown) = 0;
virtual void
releaseStringValue(char* value) = 0;
};
@@ -523,12 +517,12 @@ public:
[[nodiscard]] Value
key() const;
/// Return the index of the referenced Value. -1 if it is not an arrayValue.
/// Return the index of the referenced Value. -1 if it is not an ValueType::Array.
[[nodiscard]] UInt
index() const;
/// Return the member name of the referenced Value. "" if it is not an
/// objectValue.
/// ValueType::Object.
[[nodiscard]] char const*
memberName() const;

View File

@@ -204,31 +204,31 @@ writeValue(Write const& write, Value const& value)
{
switch (value.type())
{
case NullValue:
case ValueType::Null:
write("null", 4);
break;
case IntValue:
case ValueType::Int:
writeString(write, valueToString(value.asInt()));
break;
case UintValue:
case ValueType::UInt:
writeString(write, valueToString(value.asUInt()));
break;
case RealValue:
case ValueType::Real:
writeString(write, valueToString(value.asDouble()));
break;
case StringValue:
case ValueType::String:
writeString(write, valueToQuotedString(value.asCString()));
break;
case BooleanValue:
case ValueType::Boolean:
writeString(write, valueToString(value.asBool()));
break;
case ArrayValue: {
case ValueType::Array: {
write("[", 1);
int const size = value.size();
for (int index = 0; index < size; ++index)
@@ -241,7 +241,7 @@ writeValue(Write const& write, Value const& value)
break;
}
case ObjectValue: {
case ValueType::Object: {
Value::Members const members = value.getMemberNames();
write("{", 1);
for (auto it = members.begin(); it != members.end(); ++it)

View File

@@ -67,7 +67,7 @@ public:
[[nodiscard]] virtual json::Value
getJson(bool isAdmin) const = 0;
/** Returns a json::objectValue. */
/** Returns a json::ValueType::Object. */
[[nodiscard]] virtual json::Value
getJson(uint256 const& amendment, bool isAdmin) const = 0;

View File

@@ -9,7 +9,7 @@ class BookDirs
private:
ReadView const* view_ = nullptr;
uint256 const root_;
uint256 const next_quality_;
uint256 const nextQuality_;
uint256 const key_;
std::shared_ptr<SLE const> sle_ = nullptr;
unsigned int entry_ = 0;
@@ -67,15 +67,15 @@ private:
friend class BookDirs;
const_iterator(ReadView const& view, uint256 const& root, uint256 const& dirKey)
: view_(&view), root_(root), key_(dirKey), cur_key_(dirKey)
: view_(&view), root_(root), key_(dirKey), curKey_(dirKey)
{
}
ReadView const* view_ = nullptr;
uint256 root_;
uint256 next_quality_;
uint256 nextQuality_;
uint256 key_;
uint256 cur_key_;
uint256 curKey_;
std::shared_ptr<SLE const> sle_;
unsigned int entry_ = 0;
uint256 index_;

View File

@@ -24,7 +24,7 @@ struct CreateGenesisT
{
explicit CreateGenesisT() = default;
};
extern CreateGenesisT const kCREATE_GENESIS;
extern CreateGenesisT const kCreateGenesis;
/** Holds a ledger.

View File

@@ -12,7 +12,7 @@ namespace xrpl {
Values should not be duplicated.
@see getNextLedgerTimeResolution
*/
std::chrono::seconds constexpr kLEDGER_POSSIBLE_TIME_RESOLUTIONS[] = {
constexpr std::chrono::seconds kLedgerPossibleTimeResolutions[] = {
std::chrono::seconds{10},
std::chrono::seconds{20},
std::chrono::seconds{30},
@@ -21,16 +21,16 @@ std::chrono::seconds constexpr kLEDGER_POSSIBLE_TIME_RESOLUTIONS[] = {
std::chrono::seconds{120}};
//! Initial resolution of ledger close time.
auto constexpr kLEDGER_DEFAULT_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[2];
constexpr auto kLedgerDefaultTimeResolution = kLedgerPossibleTimeResolutions[2];
//! Close time resolution in genesis ledger
auto constexpr kLEDGER_GENESIS_TIME_RESOLUTION = kLEDGER_POSSIBLE_TIME_RESOLUTIONS[0];
constexpr auto kLedgerGenesisTimeResolution = kLedgerPossibleTimeResolutions[0];
//! How often we increase the close time resolution (in numbers of ledgers)
auto constexpr kINCREASE_LEDGER_TIME_RESOLUTION_EVERY = 8;
constexpr auto kIncreaseLedgerTimeResolutionEvery = 8;
//! How often we decrease the close time resolution (in numbers of ledgers)
auto constexpr kDECREASE_LEDGER_TIME_RESOLUTION_EVERY = 1;
constexpr auto kDecreaseLedgerTimeResolutionEvery = 1;
/** Calculates the close time resolution for the specified ledger.
@@ -46,7 +46,7 @@ auto constexpr kDECREASE_LEDGER_TIME_RESOLUTION_EVERY = 1;
@param ledgerSeq the sequence number of the new ledger
@pre previousResolution must be a valid bin
from @ref kLEDGER_POSSIBLE_TIME_RESOLUTIONS
from @ref kLedgerPossibleTimeResolutions
@tparam Rep Type representing number of ticks in std::chrono::duration
@tparam Period An std::ratio representing tick period in
@@ -67,30 +67,30 @@ getNextLedgerTimeResolution(
using namespace std::chrono;
// Find the current resolution:
auto iter = std::find(
std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS),
std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS),
std::begin(kLedgerPossibleTimeResolutions),
std::end(kLedgerPossibleTimeResolutions),
previousResolution);
XRPL_ASSERT(
iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS),
iter != std::end(kLedgerPossibleTimeResolutions),
"xrpl::getNextLedgerTimeResolution : found time resolution");
// This should never happen, but just as a precaution
if (iter == std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS))
if (iter == std::end(kLedgerPossibleTimeResolutions))
return previousResolution;
// If we did not previously agree, we try to decrease the resolution to
// improve the chance that we will agree now.
if (!previousAgree && (ledgerSeq % Seq{kDECREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0}))
if (!previousAgree && (ledgerSeq % Seq{kDecreaseLedgerTimeResolutionEvery} == Seq{0}))
{
if (++iter != std::end(kLEDGER_POSSIBLE_TIME_RESOLUTIONS))
if (++iter != std::end(kLedgerPossibleTimeResolutions))
return *iter;
}
// If we previously agreed, we try to increase the resolution to determine
// if we can continue to agree.
if (previousAgree && (ledgerSeq % Seq{kINCREASE_LEDGER_TIME_RESOLUTION_EVERY} == Seq{0}))
if (previousAgree && (ledgerSeq % Seq{kIncreaseLedgerTimeResolutionEvery} == Seq{0}))
{
if (iter-- != std::begin(kLEDGER_POSSIBLE_TIME_RESOLUTIONS))
if (iter-- != std::begin(kLedgerPossibleTimeResolutions))
return *iter;
}

View File

@@ -23,7 +23,7 @@ namespace xrpl {
inline constexpr struct OpenLedgerT
{
explicit constexpr OpenLedgerT() = default;
} kOPEN_LEDGER{};
} kOpenLedger{};
/** Batch view construction tag.
@@ -33,7 +33,7 @@ inline constexpr struct OpenLedgerT
inline constexpr struct BatchViewT
{
explicit constexpr BatchViewT() = default;
} kBATCH_VIEW{};
} kBatchView{};
//------------------------------------------------------------------------------
@@ -47,7 +47,7 @@ private:
// Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc.
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256);
static constexpr size_t kInitialBufferSize = kilobytes(256);
class TxsIterImpl;
@@ -76,7 +76,7 @@ private:
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
// easily moved.
std::unique_ptr<boost::container::pmr::monotonic_buffer_resource> monotonic_resource_;
std::unique_ptr<boost::container::pmr::monotonic_buffer_resource> monotonicResource_;
txs_map txs_;
Rules rules_;
LedgerHeader header_;
@@ -139,7 +139,7 @@ public:
std::shared_ptr<void const> hold = nullptr);
OpenView(OpenLedgerT, Rules const& rules, std::shared_ptr<ReadView const> const& base)
: OpenView(kOPEN_LEDGER, &*base, rules, base)
: OpenView(kOpenLedger, &*base, rules, base)
{
}

View File

@@ -57,7 +57,7 @@ isVaultPseudoAccountFrozen(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptShare,
int depth);
std::uint8_t depth);
[[nodiscard]] bool
isLPTokenFrozen(

View File

@@ -19,17 +19,17 @@ public:
// Initial size for the monotonic_buffer_resource used for allocations
// The size was chosen from the old `qalloc` code (which this replaces).
// It is unclear how the size initially chosen in qalloc.
static constexpr size_t kINITIAL_BUFFER_SIZE = kilobytes(256);
static constexpr size_t kInitialBufferSize = kilobytes(256);
RawStateTable()
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)}
, items_{monotonic_resource_.get()} {};
: monotonicResource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kInitialBufferSize)}
, items_{monotonicResource_.get()} {};
RawStateTable(RawStateTable const& rhs)
: monotonic_resource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kINITIAL_BUFFER_SIZE)}
, items_{rhs.items_, monotonic_resource_.get()}
: monotonicResource_{std::make_unique<boost::container::pmr::monotonic_buffer_resource>(
kInitialBufferSize)}
, items_{rhs.items_, monotonicResource_.get()}
, dropsDestroyed_{rhs.dropsDestroyed_} {};
RawStateTable(RawStateTable&&) = default;
@@ -101,7 +101,7 @@ private:
boost::container::pmr::polymorphic_allocator<std::pair<key_type const, SleAction>>>;
// monotonic_resource_ must outlive `items_`. Make a pointer so it may be
// easily moved.
std::unique_ptr<boost::container::pmr::monotonic_buffer_resource> monotonic_resource_;
std::unique_ptr<boost::container::pmr::monotonic_buffer_resource> monotonicResource_;
items_t items_;
XRPAmount dropsDestroyed_{0};

View File

@@ -25,11 +25,11 @@ namespace detail {
Number
reduceOffer(auto const& amount)
{
static Number const kREDUCED_OFFER_PCT(9999, -4);
static Number const kReducedOfferPct(9999, -4);
// Make sure the result is always less than amount or zero.
NumberRoundModeGuard const mg(Number::RoundingMode::TowardsZero);
return amount * kREDUCED_OFFER_PCT;
return amount * kReducedOfferPct;
}
} // namespace detail
@@ -177,7 +177,7 @@ getAMMOfferStartWithTakerGets(
Quality const& targetQuality,
std::uint16_t const& tfee)
{
if (targetQuality.rate() == beast::kZERO)
if (targetQuality.rate() == beast::kZero)
return std::nullopt;
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);
@@ -244,7 +244,7 @@ getAMMOfferStartWithTakerPays(
Quality const& targetQuality,
std::uint16_t tfee)
{
if (targetQuality.rate() == beast::kZERO)
if (targetQuality.rate() == beast::kZero)
return std::nullopt;
NumberRoundModeGuard const mg(Number::RoundingMode::ToNearest);

View File

@@ -19,14 +19,10 @@ namespace credentials {
// Check if credential sfExpiration field has passed ledger's parentCloseTime
bool
checkExpired(std::shared_ptr<SLE const> const& sleCredential, NetClock::time_point const& closed);
// Return true if any expired credential was found in arr (and deleted)
bool
removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j);
checkExpired(SLE const& sleCredential, NetClock::time_point const& closed);
// Actually remove a credentials object from the ledger
TER
[[nodiscard]] TER
deleteSLE(ApplyView& view, std::shared_ptr<SLE> const& sleCredential, beast::Journal j);
// Amendment and parameters checks for sfCredentialIDs field

View File

@@ -70,21 +70,21 @@ escrowUnlockApplyHelper<Issue>(
initialBalance.get<Issue>().account = noAccount();
if (TER const ter = trustCreate(
view, // payment sandbox
recvLow, // is dest low?
issuer, // source
receiver, // destination
trustLineKey.key, // ledger index
sleDest, // Account to add to
false, // authorize account
(sleDest->getFlags() & lsfDefaultRipple) == 0, //
false, // freeze trust line
false, // deep freeze trust line
initialBalance, // zero initial balance
Issue(currency, receiver), // limit of zero
0, // quality in
0, // quality out
journal); // journal
view, // payment sandbox
recvLow, // is dest low?
issuer, // source
receiver, // destination
trustLineKey.key, // ledger index
sleDest, // Account to add to
false, // authorize account
!sleDest->isFlag(lsfDefaultRipple), //
false, // freeze trust line
false, // deep freeze trust line
initialBalance, // zero initial balance
Issue(currency, receiver), // limit of zero
0, // quality in
0, // quality out
journal); // journal
!isTesSuccess(ter))
{
return ter; // LCOV_EXCL_LINE
@@ -111,7 +111,7 @@ escrowUnlockApplyHelper<Issue>(
// whereas in a normal payment, the transfer fee is taken on top of the
// sending amount.
auto finalAmt = amount;
if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE)
if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
{
// compute transfer fee, if any
auto const xferFee =
@@ -211,7 +211,7 @@ escrowUnlockApplyHelper<MPTIssue>(
// whereas in a normal payment, the transfer fee is taken on top of the
// sending amount.
auto finalAmt = amount;
if ((!senderIssuer && !receiverIssuer) && lockedRate != kPARITY_RATE)
if ((!senderIssuer && !receiverIssuer) && lockedRate != kParityRate)
{
// compute transfer fee, if any
auto const xferFee = amount.value() - divideRound(amount, lockedRate, amount.asset(), true);

View File

@@ -4,13 +4,43 @@
#include <xrpl/protocol/Rules.h>
#include <xrpl/protocol/st.h>
#include <string_view>
namespace xrpl {
/**
* Broker cover preclaim precision guard (fixCleanup3_2_0).
*
* Prevents a "silent sub-ULP no-op" where a deposit, withdrawal, or clawback
* amount is so small that it rounds to zero at `sfCoverAvailable`'s scale.
* Without this guard, both the pseudo trust-line and `sfCoverAvailable` would
* identically absorb the rounded zero, resulting in a successful transaction
* (tesSUCCESS) where no funds actually moved.
*
* @param view Read view (rules used for amendment gating).
* @param sleBroker The loan broker SLE (read-only).
* @param vaultAsset The underlying vault asset (the broker's cover asset).
* @param amount The effective subtraction/addition amount.
* @param j Journal for logging.
* @param logPrefix Transactor name for log diagnostics.
*
* @return `tecPRECISION_LOSS` if the request rounds to zero at cover scale.
* `tesSUCCESS` if the amendment is disabled or the request is safely supra-ULP.
*/
[[nodiscard]] TER
canApplyToBrokerCover(
ReadView const& view,
SLE::const_ref sleBroker,
Asset const& vaultAsset,
STAmount const& amount,
beast::Journal j,
std::string_view logPrefix);
// Lending protocol has dependencies, so capture them here.
bool
checkLendingProtocolDependencies(Rules const& rules, STTx const& tx);
static constexpr std::uint32_t kSECONDS_IN_YEAR = 365 * 24 * 60 * 60;
static constexpr std::uint32_t kSecondsInYear = 365 * 24 * 60 * 60;
Number
loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
@@ -42,14 +72,14 @@ struct LoanPaymentParts
// The amount of principal paid that reduces the loan balance.
// This amount is subtracted from sfPrincipalOutstanding in the Loan object
// and paid to the Vault
Number principalPaid = kNUM_ZERO;
Number principalPaid = kNumZero;
// The total amount of interest paid to the Vault.
// This includes:
// - Tracked interest from the amortization schedule
// - Untracked interest (e.g., late payment penalty interest)
// This value is always non-negative.
Number interestPaid = kNUM_ZERO;
Number interestPaid = kNumZero;
// The change in the loan's total value outstanding.
// - If valueChange < 0: Loan value decreased
@@ -62,7 +92,7 @@ struct LoanPaymentParts
// - Late payments add penalty interest to the loan value
// - Early full payment may increase or decrease the loan value based on
// terms
Number valueChange = kNUM_ZERO;
Number valueChange = kNumZero;
/* The total amount of fees paid to the Broker.
* This includes:
@@ -70,7 +100,7 @@ struct LoanPaymentParts
* - Untracked fees (e.g., late payment fees, service fees, origination
* fees) This value is always non-negative.
*/
Number feePaid = kNUM_ZERO;
Number feePaid = kNumZero;
LoanPaymentParts&
operator+=(LoanPaymentParts const& other);
@@ -161,7 +191,7 @@ adjustImpreciseNumber(
{
value = roundToAsset(asset, value + adjustment, vaultScale);
if (*value < beast::kZERO)
if (*value < beast::kZero)
value = 0;
}
@@ -169,10 +199,25 @@ inline int
getAssetsTotalScale(SLE::const_ref vaultSle)
{
if (!vaultSle)
return Number::kMIN_EXPONENT - 1; // LCOV_EXCL_LINE
return Number::kMinExponent - 1; // LCOV_EXCL_LINE
return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset));
}
// Compute the minimum required broker cover, rounded consistently.
// DebtTotal is a broker-level aggregate maintained at vault scale, so the
// rounding must also use vault scale — never an individual loan's scale.
inline Number
minimumBrokerCover(Number const& debtTotal, TenthBips32 coverRateMinimum, SLE::const_ref vaultSle)
{
XRPL_ASSERT(
vaultSle && vaultSle->getType() == ltVAULT, "xrpl::minimumBrokerCover : valid Vault sle");
NumberRoundModeGuard const mg(Number::RoundingMode::Upward);
return roundToAsset(
vaultSle->at(sfAsset),
tenthBipsOfValue(debtTotal, coverRateMinimum),
getAssetsTotalScale(vaultSle));
}
TER
checkLoanGuards(
Asset const& vaultAsset,
@@ -184,6 +229,7 @@ checkLoanGuards(
LoanState
computeTheoreticalLoanState(
Rules const& rules,
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t const paymentRemaining,
@@ -310,7 +356,7 @@ struct ExtendedPaymentComponents : public PaymentComponents
// borrower is sufficient to cover all components of the payment.
Number totalDue;
ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNUM_ZERO)
ExtendedPaymentComponents(PaymentComponents const& p, Number fee, Number interest = kNumZero)
: PaymentComponents(p)
, untrackedManagementFee(fee)
, untrackedInterest(interest)
@@ -353,6 +399,7 @@ struct LoanStateDeltas
Expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
tryOverpayment(
Rules const& rules,
Asset const& asset,
std::int32_t loanScale,
ExtendedPaymentComponents const& overpaymentComponents,
@@ -363,11 +410,17 @@ tryOverpayment(
TenthBips16 const managementFeeRate,
beast::Journal j);
Number
computeRaisedRate(Number const& periodicRate, std::uint32_t paymentsRemaining);
[[nodiscard]] Number
computePowerMinusOne(Number const& periodicRate, std::uint32_t paymentsRemaining);
Number
computePaymentFactor(Number const& periodicRate, std::uint32_t paymentsRemaining);
[[nodiscard]] Number
computePowerMinusOneHybrid(Number const& periodicRate, std::uint32_t paymentsRemaining);
[[nodiscard]] Number
computePaymentFactor(
Rules const& rules,
Number const& periodicRate,
std::uint32_t paymentsRemaining);
std::pair<Number, Number>
computeInterestAndFeeParts(
@@ -378,12 +431,14 @@ computeInterestAndFeeParts(
Number
loanPeriodicPayment(
Rules const& rules,
Number const& principalOutstanding,
Number const& periodicRate,
std::uint32_t paymentsRemaining);
Number
loanPrincipalFromPeriodicPayment(
Rules const& rules,
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t paymentsRemaining);
@@ -415,6 +470,7 @@ computeOverpaymentComponents(
PaymentComponents
computePaymentComponents(
Rules const& rules,
Asset const& asset,
std::int32_t scale,
Number const& totalValueOutstanding,
@@ -438,6 +494,7 @@ operator+(LoanState const& lhs, detail::LoanStateDeltas const& rhs);
LoanProperties
computeLoanProperties(
Rules const& rules,
Asset const& asset,
Number const& principalOutstanding,
TenthBips32 interestRate,
@@ -448,6 +505,7 @@ computeLoanProperties(
LoanProperties
computeLoanProperties(
Rules const& rules,
Asset const& asset,
Number const& principalOutstanding,
Number const& periodicRate,

View File

@@ -27,14 +27,18 @@ isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
isIndividualFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue);
[[nodiscard]] bool
isFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue, int depth = 0);
isFrozen(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptIssue,
std::uint8_t depth = 0);
[[nodiscard]] bool
isAnyFrozen(
ReadView const& view,
std::initializer_list<AccountID> const& accounts,
MPTIssue const& mptIssue,
int depth = 0);
std::uint8_t depth = 0);
//------------------------------------------------------------------------------
//
@@ -88,7 +92,7 @@ requireAuth(
MPTIssue const& mptIssue,
AccountID const& account,
AuthType authType = AuthType::Legacy,
int depth = 0);
std::uint8_t depth = 0);
/** Enforce account has MPToken to match its authorization.
*
@@ -104,22 +108,77 @@ enforceMPTokenAuthorization(
XRPAmount const& priorBalance,
beast::Journal j);
/** Check if the destination account is allowed
* to receive MPT. Return tecNO_AUTH if it doesn't
* and tesSUCCESS otherwise.
/** Resolve the underlying asset of a vault share.
*
* Reads sfReferenceHolding from @p sleShareIssuance to determine which
* asset the vault wraps. @p sleHolding must be the SLE that
* sfReferenceHolding points to — either an ltMPTOKEN (returns its
* MPTIssue) or an ltRIPPLE_STATE (returns its low/high Issue).
*
* @pre Both SLEs must exist and @p sleHolding must be of type ltMPTOKEN
* or ltRIPPLE_STATE. Passing any other type is undefined behaviour.
* @param sleShareIssuance MPTokenIssuance SLE for the vault share token.
* @param sleHolding SLE referenced by sfReferenceHolding.
* @return The underlying Asset (MPTIssue or Issue).
*/
[[nodiscard]] Asset
assetOfHolding(SLE const& sleShareIssuance, SLE const& sleHolding);
/** Check whether @p to may receive the given MPT from @p from.
*
* The check passes when any of the following is true:
* - @p waive is WaiveMPTCanTransfer::Yes (recovery-path exemption), or
* - @p from or @p to is the issuer, or
* - lsfMPTCanTransfer is set on the MPTokenIssuance.
*
* For vault shares (MPTokenIssuances that carry sfReferenceHolding) the
* check recurses into the underlying asset's transferability. This
* recursion is defensive; vault-of-vault-shares is rejected at vault
* creation, so in practice depth never exceeds 1.
*
* @param view Ledger state to read from.
* @param mptIssue The MPT issuance being transferred.
* @param from Sending account.
* @param to Receiving account.
* @param waive WaiveMPTCanTransfer::Yes skips the lsfMPTCanTransfer
* check. Use for recovery paths (e.g. unwinding SAV or
* Lending Protocol positions after an issuer revokes
* transferability).
* @param depth Recursion depth; bounded at kMaxAssetCheckDepth.
* @return tesSUCCESS if the transfer is allowed, tecNO_AUTH otherwise.
*/
[[nodiscard]] TER
canTransfer(
ReadView const& view,
MPTIssue const& mptIssue,
AccountID const& from,
AccountID const& to);
AccountID const& to,
WaiveMPTCanTransfer waive = WaiveMPTCanTransfer::No,
std::uint8_t depth = 0);
/** Check if Asset can be traded on DEX. return tecNO_PERMISSION
* if it doesn't and tesSUCCESS otherwise.
/** Check whether @p asset may be traded on the DEX.
*
* For IOU assets the check delegates to the existing offer/AMM freeze
* logic. For MPT assets it checks lsfMPTCanTrade on the MPTokenIssuance.
* Vault shares recurse into the underlying asset's tradability via
* sfReferenceHolding; depth is bounded at kMaxAssetCheckDepth.
*
* @param view Ledger state to read from.
* @param asset The asset to check.
* @param depth Recursion depth; bounded at kMaxAssetCheckDepth.
* @return tesSUCCESS if trading is allowed, tecNO_PERMISSION otherwise.
*/
[[nodiscard]] TER
canTrade(ReadView const& view, Asset const& asset);
canTrade(ReadView const& view, Asset const& asset, std::uint8_t depth = 0);
/** Convenience to combine canTrade/Transfer. Returns tesSUCCESS if Asset is Issue.
*/
[[nodiscard]] TER
canMPTTradeAndTransfer(
ReadView const& v,
Asset const& asset,
AccountID const& from,
AccountID const& to);
//------------------------------------------------------------------------------
//
@@ -227,17 +286,4 @@ issuerFundsToSelfIssue(ReadView const& view, MPTIssue const& issue);
void
issuerSelfDebitHookMPT(ApplyView& view, MPTIssue const& issue, std::uint64_t amount);
//------------------------------------------------------------------------------
//
// MPT DEX
//
//------------------------------------------------------------------------------
/* Return true if a transaction is allowed for the specified MPT/account. The
* function checks MPTokenIssuance and MPToken objects flags to determine if the
* transaction is allowed.
*/
TER
checkMPTTxAllowed(ReadView const& v, TxType tx, Asset const& asset, AccountID const& accountID);
} // namespace xrpl

View File

@@ -93,7 +93,7 @@ isFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
// Overload with depth parameter for uniformity with MPTIssue version.
// The depth parameter is ignored for IOUs since they don't have vault recursion.
[[nodiscard]] inline bool
isFrozen(ReadView const& view, AccountID const& account, Issue const& issue, int /*depth*/)
isFrozen(ReadView const& view, AccountID const& account, Issue const& issue, std::uint8_t /*depth*/)
{
return isFrozen(view, account, issue);
}
@@ -110,7 +110,7 @@ isDeepFrozen(
ReadView const& view,
AccountID const& account,
Issue const& issue,
int = 0 /*ignored*/)
std::uint8_t = 0 /*ignored*/)
{
return isDeepFrozen(view, account, issue.currency, issue.account);
}

View File

@@ -34,6 +34,15 @@ enum class WaiveTransferFee : bool { No = false, Yes };
/** Controls whether accountSend is allowed to overflow OutstandingAmount **/
enum class AllowMPTOverflow : bool { No = false, Yes };
/** Controls whether canTransfer enforces lsfMPTCanTransfer on MPTs.
*
* Default is No (enforce). Use Yes at call sites that must remain available
* even when an MPT issuer has cleared lsfMPTCanTransfer - for example,
* unwinding existing positions in SAV or the Lending Protocol. Has no
* effect on the IOU branch of canTransfer.
*/
enum class WaiveMPTCanTransfer : bool { No = false, Yes };
/* Check if MPToken (for MPT) or trust line (for IOU) exists:
* - StrongAuth - before checking if authorization is required
* - WeakAuth
@@ -54,16 +63,26 @@ enum class AuthType { StrongAuth, WeakAuth, Legacy };
[[nodiscard]] bool
isGlobalFrozen(ReadView const& view, Asset const& asset);
[[nodiscard]] TER
checkGlobalFrozen(ReadView const& view, Asset const& asset);
[[nodiscard]] bool
isIndividualFrozen(ReadView const& view, AccountID const& account, Asset const& asset);
[[nodiscard]] TER
checkIndividualFrozen(ReadView const& view, AccountID const& account, Asset const& asset);
/**
* isFrozen check is recursive for MPT shares in a vault, descending to
* assets in the vault, up to maxAssetCheckDepth recursion depth. This is
* purely defensive, as we currently do not allow such vaults to be created.
*/
[[nodiscard]] bool
isFrozen(ReadView const& view, AccountID const& account, Asset const& asset, int depth = 0);
isFrozen(
ReadView const& view,
AccountID const& account,
Asset const& asset,
std::uint8_t depth = 0);
[[nodiscard]] TER
checkFrozen(ReadView const& view, AccountID const& account, Issue const& issue);
@@ -85,14 +104,14 @@ isAnyFrozen(
ReadView const& view,
std::initializer_list<AccountID> const& accounts,
Asset const& asset,
int depth = 0);
std::uint8_t depth = 0);
[[nodiscard]] bool
isDeepFrozen(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptIssue,
int depth = 0);
std::uint8_t depth = 0);
/**
* isFrozen check is recursive for MPT shares in a vault, descending to
@@ -100,7 +119,11 @@ isDeepFrozen(
* purely defensive, as we currently do not allow such vaults to be created.
*/
[[nodiscard]] bool
isDeepFrozen(ReadView const& view, AccountID const& account, Asset const& asset, int depth = 0);
isDeepFrozen(
ReadView const& view,
AccountID const& account,
Asset const& asset,
std::uint8_t depth = 0);
[[nodiscard]] TER
checkDeepFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue);
@@ -234,7 +257,13 @@ requireAuth(
AuthType authType = AuthType::Legacy);
[[nodiscard]] TER
canTransfer(ReadView const& view, Asset const& asset, AccountID const& from, AccountID const& to);
canTransfer(
ReadView const& view,
Asset const& asset,
AccountID const& from,
AccountID const& to,
WaiveMPTCanTransfer waive = WaiveMPTCanTransfer::No,
std::uint8_t depth = 0);
//------------------------------------------------------------------------------
//

View File

@@ -20,7 +20,7 @@ class HTTPClient
public:
explicit HTTPClient() = default;
static constexpr auto kMAX_CLIENT_HEADER_BYTES = kilobytes(32);
static constexpr auto kMaxClientHeaderBytes = kilobytes(32);
static void
initializeSSLContext(

View File

@@ -21,13 +21,13 @@ public:
bool sslVerify,
beast::Journal j,
boost::asio::ssl::context_base::method method = boost::asio::ssl::context::sslv23)
: ssl_context_{method}, j_(j), verify_{sslVerify}
: sslContext_{method}, j_(j), verify_{sslVerify}
{
boost::system::error_code ec;
if (sslVerifyFile.empty())
{
registerSSLCerts(ssl_context_, ec, j_);
registerSSLCerts(sslContext_, ec, j_);
if (ec && sslVerifyDir.empty())
{
@@ -37,12 +37,12 @@ public:
}
else
{
ssl_context_.load_verify_file(sslVerifyFile);
sslContext_.load_verify_file(sslVerifyFile);
}
if (!sslVerifyDir.empty())
{
ssl_context_.add_verify_path(sslVerifyDir, ec);
sslContext_.add_verify_path(sslVerifyDir, ec);
if (ec)
{
@@ -55,7 +55,7 @@ public:
boost::asio::ssl::context&
context()
{
return ssl_context_;
return sslContext_;
}
[[nodiscard]] bool
@@ -153,7 +153,7 @@ public:
}
private:
boost::asio::ssl::context ssl_context_;
boost::asio::ssl::context sslContext_;
beast::Journal const j_;
bool const verify_;
};

View File

@@ -83,10 +83,6 @@ public:
virtual Status
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& hashes) = 0;
/** Store a single object.
Depending on the implementation this may happen immediately
or deferred using a scheduled task.

View File

@@ -29,7 +29,7 @@ enum class NodeObjectType : std::uint32_t {
class NodeObject : public CountedObject<NodeObject>
{
public:
static constexpr std::size_t kKEY_BYTES = 32;
static constexpr std::size_t kKeyBytes = 32;
private:
// This hack is used to make the constructor effectively private

View File

@@ -6,20 +6,16 @@
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.
//
BatchWritePreallocationSize = 256,
// This is only used to pre-allocate the array for
// batch objects and does not affect the amount written.
//
static constexpr auto kBatchWritePreallocationSize = 256;
// This sets a limit on the maximum number of writes
// in a batch. Actual usage can be twice this since
// we have a new batch growing as we write the old.
//
BatchWriteLimitSize = 65536
};
// This sets a limit on the maximum number of writes
// in a batch. Actual usage can be twice this since
// we have a new batch growing as we write the old.
//
static constexpr auto kBatchWriteLimitSize = 65536;
/** Return codes from Backend operations. */
enum class Status {

View File

@@ -67,9 +67,6 @@ public:
backend_->sync();
}
std::vector<std::shared_ptr<NodeObject>>
fetchBatch(std::vector<uint256> const& hashes);
void
asyncFetch(
uint256 const& hash,

View File

@@ -55,7 +55,7 @@ lz4Compress(void const* in, std::size_t inSize, BufferFactory&& bf)
using std::runtime_error;
using namespace nudb::detail;
std::pair<void const*, std::size_t> result;
std::array<std::uint8_t, varint_traits<std::size_t>::kMAX> vi{};
std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
auto const n = writeVarint(vi.data(), inSize);
auto const outMax = LZ4_compressBound(inSize);
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + outMax));
@@ -254,12 +254,12 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
}
}
std::array<std::uint8_t, varint_traits<std::size_t>::kMAX> vi{};
std::array<std::uint8_t, varint_traits<std::size_t>::kMax> vi{};
constexpr std::size_t kCODEC_TYPE = 1;
auto const vn = writeVarint(vi.data(), kCODEC_TYPE);
static constexpr std::size_t kCodecType = 1;
auto const vn = writeVarint(vi.data(), kCodecType);
std::pair<void const*, std::size_t> result;
switch (kCODEC_TYPE)
switch (kCodecType)
{
// case 0 was uncompressed data; we always compress now.
case 1: // lz4
@@ -275,7 +275,7 @@ nodeobjectCompress(void const* in, std::size_t inSize, BufferFactory&& bf)
break;
}
default:
Throw<std::logic_error>("nodeobject codec: unknown=" + std::to_string(kCODEC_TYPE));
Throw<std::logic_error>("nodeobject codec: unknown=" + std::to_string(kCodecType));
};
return result;
}

View File

@@ -25,7 +25,7 @@ struct varint_traits<T, true>
{
explicit varint_traits() = default;
static std::size_t constexpr kMAX = (8 * sizeof(T) + 6) / 7;
static constexpr std::size_t kMax = (8 * sizeof(T) + 6) / 7;
};
// Returns: Number of bytes consumed or 0 on error,

View File

@@ -8,21 +8,21 @@
namespace xrpl {
std::uint16_t constexpr kTRADING_FEE_THRESHOLD = 1000; // 1%
constexpr std::uint16_t kTradingFeeThreshold = 1000; // 1%
// Auction slot
std::uint32_t constexpr kTOTAL_TIME_SLOT_SECS = 24 * 3600;
std::uint16_t constexpr kAUCTION_SLOT_TIME_INTERVALS = 20;
std::uint16_t constexpr kAUCTION_SLOT_MAX_AUTH_ACCOUNTS = 4;
std::uint32_t constexpr kAUCTION_SLOT_FEE_SCALE_FACTOR = 100000;
std::uint32_t constexpr kAUCTION_SLOT_DISCOUNTED_FEE_FRACTION = 10;
std::uint32_t constexpr kAUCTION_SLOT_MIN_FEE_FRACTION = 25;
std::uint32_t constexpr kAUCTION_SLOT_INTERVAL_DURATION =
kTOTAL_TIME_SLOT_SECS / kAUCTION_SLOT_TIME_INTERVALS;
constexpr std::uint32_t kTotalTimeSlotSecs = 24 * 3600;
constexpr std::uint16_t kAuctionSlotTimeIntervals = 20;
constexpr std::uint16_t kAuctionSlotMaxAuthAccounts = 4;
constexpr std::uint32_t kAuctionSlotFeeScaleFactor = 100000;
constexpr std::uint32_t kAuctionSlotDiscountedFeeFraction = 10;
constexpr std::uint32_t kAuctionSlotMinFeeFraction = 25;
constexpr std::uint32_t kAuctionSlotIntervalDuration =
kTotalTimeSlotSecs / kAuctionSlotTimeIntervals;
// Votes
std::uint16_t constexpr kVOTE_MAX_SLOTS = 8;
std::uint32_t constexpr kVOTE_WEIGHT_SCALE_FACTOR = 100000;
constexpr std::uint16_t kVoteMaxSlots = 8;
constexpr std::uint32_t kVoteWeightScaleFactor = 100000;
class STObject;
class STAmount;
@@ -77,7 +77,7 @@ ammEnabled(Rules const&);
inline Number
getFee(std::uint16_t tfee)
{
return Number{tfee} / kAUCTION_SLOT_FEE_SCALE_FACTOR;
return Number{tfee} / kAuctionSlotFeeScaleFactor;
}
/** Get fee multiplier (1 - tfee)

View File

@@ -25,7 +25,7 @@ public:
} // namespace detail
/** A 160-bit unsigned that uniquely identifies an account. */
using AccountID = BaseUint<160, detail::AccountIDTag>;
using AccountID = BaseUInt<160, detail::AccountIDTag>;
/** Convert AccountID to base58 checked string */
std::string
@@ -69,7 +69,7 @@ toIssuer(AccountID&, std::string const&);
inline bool
isXRP(AccountID const& c)
{
return c == beast::kZERO;
return c == beast::kZero;
}
// DEPRECATED

View File

@@ -96,9 +96,9 @@ inline MPTAmount
toAmount<MPTAmount>(STAmount const& amt)
{
XRPL_ASSERT(
amt.holds<MPTIssue>() && amt.mantissa() <= kMAX_MP_TOKEN_AMOUNT && amt.exponent() == 0,
amt.holds<MPTIssue>() && amt.mantissa() <= kMaxMpTokenAmount && amt.exponent() == 0,
"xrpl::toAmount<MPTAmount> : maximum mantissa");
if (amt.mantissa() > kMAX_MP_TOKEN_AMOUNT || amt.exponent() != 0)
if (amt.mantissa() > kMaxMpTokenAmount || amt.exponent() != 0)
Throw<std::runtime_error>("toAmount<MPTAmount>: invalid mantissa or exponent");
bool const isNeg = amt.negative();
std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa();
@@ -167,8 +167,8 @@ toAmount(Asset const& asset, Number const& n, Number::RoundingMode mode = Number
}
else
{
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for toAmount");
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kAlwaysFalse, "Unsupported type for toAmount");
}
}
@@ -178,30 +178,30 @@ toMaxAmount(Asset const& asset)
{
if constexpr (std::is_same_v<IOUAmount, T>)
{
return IOUAmount(STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET);
return IOUAmount(STAmount::kMaxValue, STAmount::kMaxOffset);
}
else if constexpr (std::is_same_v<XRPAmount, T>)
{
return XRPAmount(static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N));
return XRPAmount(static_cast<std::int64_t>(STAmount::kMaxNativeN));
}
else if constexpr (std::is_same_v<MPTAmount, T>)
{
return MPTAmount(kMAX_MP_TOKEN_AMOUNT);
return MPTAmount(kMaxMpTokenAmount);
}
else if constexpr (std::is_same_v<STAmount, T>)
{
return asset.visit(
[](Issue const& issue) {
if (isXRP(issue))
return STAmount(issue, static_cast<std::int64_t>(STAmount::kMAX_NATIVE_N));
return STAmount(issue, STAmount::kMAX_VALUE, STAmount::kMAX_OFFSET);
return STAmount(issue, static_cast<std::int64_t>(STAmount::kMaxNativeN));
return STAmount(issue, STAmount::kMaxValue, STAmount::kMaxOffset);
},
[](MPTIssue const& issue) { return STAmount(issue, kMAX_MP_TOKEN_AMOUNT); });
[](MPTIssue const& issue) { return STAmount(issue, kMaxMpTokenAmount); });
}
else
{
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for toMaxAmount");
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kAlwaysFalse, "Unsupported type for toMaxAmount");
}
}
@@ -233,8 +233,8 @@ getAsset(T const& amt)
}
else
{
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for getIssue");
static constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kAlwaysFalse, "Unsupported type for getIssue");
}
}
@@ -260,8 +260,8 @@ get(STAmount const& a)
}
else
{
constexpr bool kALWAYS_FALSE = !std::is_same_v<T, T>;
static_assert(kALWAYS_FALSE, "Unsupported type for get");
constexpr bool kAlwaysFalse = !std::is_same_v<T, T>;
static_assert(kAlwaysFalse, "Unsupported type for get");
}
}

View File

@@ -35,49 +35,49 @@ namespace xrpl {
namespace RPC {
template <unsigned int Version>
constexpr static std::integral_constant<unsigned, Version> kAPI_VERSION = {};
static constexpr std::integral_constant<unsigned, Version> kApiVersion = {};
constexpr static auto kAPI_INVALID_VERSION = kAPI_VERSION<0>;
constexpr static auto kAPI_MINIMUM_SUPPORTED_VERSION = kAPI_VERSION<1>;
constexpr static auto kAPI_MAXIMUM_SUPPORTED_VERSION = kAPI_VERSION<2>;
constexpr static auto kAPI_VERSION_IF_UNSPECIFIED = kAPI_VERSION<1>;
constexpr static auto kAPI_COMMAND_LINE_VERSION = kAPI_VERSION<1>; // TODO Bump to 2 later
constexpr static auto kAPI_BETA_VERSION = kAPI_VERSION<3>;
constexpr static auto kAPI_MAXIMUM_VALID_VERSION = kAPI_BETA_VERSION;
static constexpr auto kApiInvalidVersion = kApiVersion<0>;
static constexpr auto kApiMinimumSupportedVersion = kApiVersion<1>;
static constexpr auto kApiMaximumSupportedVersion = kApiVersion<2>;
static constexpr auto kApiVersionIfUnspecified = kApiVersion<1>;
static constexpr auto kApiCommandLineVersion = kApiVersion<1>; // TODO Bump to 2 later
static constexpr auto kApiBetaVersion = kApiVersion<3>;
static constexpr auto kApiMaximumValidVersion = kApiBetaVersion;
static_assert(kAPI_INVALID_VERSION < kAPI_MINIMUM_SUPPORTED_VERSION);
static_assert(kApiInvalidVersion < kApiMinimumSupportedVersion);
static_assert(
kAPI_VERSION_IF_UNSPECIFIED >= kAPI_MINIMUM_SUPPORTED_VERSION &&
kAPI_VERSION_IF_UNSPECIFIED <= kAPI_MAXIMUM_SUPPORTED_VERSION);
kApiVersionIfUnspecified >= kApiMinimumSupportedVersion &&
kApiVersionIfUnspecified <= kApiMaximumSupportedVersion);
static_assert(
kAPI_COMMAND_LINE_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION &&
kAPI_COMMAND_LINE_VERSION <= kAPI_MAXIMUM_SUPPORTED_VERSION);
static_assert(kAPI_MAXIMUM_SUPPORTED_VERSION >= kAPI_MINIMUM_SUPPORTED_VERSION);
static_assert(kAPI_BETA_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION);
static_assert(kAPI_MAXIMUM_VALID_VERSION >= kAPI_MAXIMUM_SUPPORTED_VERSION);
kApiCommandLineVersion >= kApiMinimumSupportedVersion &&
kApiCommandLineVersion <= kApiMaximumSupportedVersion);
static_assert(kApiMaximumSupportedVersion >= kApiMinimumSupportedVersion);
static_assert(kApiBetaVersion >= kApiMaximumSupportedVersion);
static_assert(kApiMaximumValidVersion >= kApiMaximumSupportedVersion);
inline void
setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
{
XRPL_ASSERT(apiVersion != kAPI_INVALID_VERSION, "xrpl::RPC::setVersion : input is valid");
XRPL_ASSERT(apiVersion != kApiInvalidVersion, "xrpl::RPC::setVersion : input is valid");
auto& retObj = parent[jss::version] = json::ObjectValue;
auto& retObj = parent[jss::version] = json::ValueType::Object;
if (apiVersion == kAPI_VERSION_IF_UNSPECIFIED)
if (apiVersion == kApiVersionIfUnspecified)
{
// API version numbers used in API version 1
static beast::SemanticVersion const kFIRST_VERSION{"1.0.0"};
static beast::SemanticVersion const kGOOD_VERSION{"1.0.0"};
static beast::SemanticVersion const kLAST_VERSION{"1.0.0"};
static beast::SemanticVersion const kFirstVersion{"1.0.0"};
static beast::SemanticVersion const kGoodVersion{"1.0.0"};
static beast::SemanticVersion const kLastVersion{"1.0.0"};
retObj[jss::first] = kFIRST_VERSION.print();
retObj[jss::good] = kGOOD_VERSION.print();
retObj[jss::last] = kLAST_VERSION.print();
retObj[jss::first] = kFirstVersion.print();
retObj[jss::good] = kGoodVersion.print();
retObj[jss::last] = kLastVersion.print();
}
else
{
retObj[jss::first] = kAPI_MINIMUM_SUPPORTED_VERSION.value;
retObj[jss::last] = betaEnabled ? kAPI_BETA_VERSION : kAPI_MAXIMUM_SUPPORTED_VERSION;
retObj[jss::first] = kApiMinimumSupportedVersion.value;
retObj[jss::last] = betaEnabled ? kApiBetaVersion : kApiMaximumSupportedVersion;
}
}
@@ -98,9 +98,9 @@ setVersion(json::Value& parent, unsigned int apiVersion, bool betaEnabled)
inline unsigned int
getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
{
static json::Value const kMIN_VERSION(RPC::kAPI_MINIMUM_SUPPORTED_VERSION);
static json::Value const kMinVersion(RPC::kApiMinimumSupportedVersion);
json::Value const maxVersion(
betaEnabled ? RPC::kAPI_BETA_VERSION : RPC::kAPI_MAXIMUM_SUPPORTED_VERSION);
betaEnabled ? RPC::kApiBetaVersion : RPC::kApiMaximumSupportedVersion);
if (jv.isObject())
{
@@ -109,18 +109,18 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
auto const specifiedVersion = jv[jss::api_version];
if (!specifiedVersion.isInt() && !specifiedVersion.isUInt())
{
return RPC::kAPI_INVALID_VERSION;
return RPC::kApiInvalidVersion;
}
auto const specifiedVersionInt = specifiedVersion.asInt();
if (specifiedVersionInt < kMIN_VERSION || specifiedVersionInt > maxVersion)
if (specifiedVersionInt < kMinVersion || specifiedVersionInt > maxVersion)
{
return RPC::kAPI_INVALID_VERSION;
return RPC::kApiInvalidVersion;
}
return specifiedVersionInt;
}
}
return RPC::kAPI_VERSION_IF_UNSPECIFIED;
return RPC::kApiVersionIfUnspecified;
}
} // namespace RPC
@@ -128,33 +128,33 @@ getAPIVersionNumber(json::Value const& jv, bool betaEnabled)
template <unsigned MinVer, unsigned MaxVer, typename Fn, typename... Args>
void
forApiVersions(Fn const& fn, Args&&... args)
requires //
(MaxVer >= MinVer) && //
(MinVer >= RPC::kAPI_MINIMUM_SUPPORTED_VERSION) && //
(RPC::kAPI_MAXIMUM_VALID_VERSION >= MaxVer) && requires {
requires //
(MaxVer >= MinVer) && //
(MinVer >= RPC::kApiMinimumSupportedVersion) && //
(RPC::kApiMaximumValidVersion >= MaxVer) && requires {
fn(std::integral_constant<unsigned int, MinVer>{}, std::forward<Args>(args)...);
fn(std::integral_constant<unsigned int, MaxVer>{}, std::forward<Args>(args)...);
}
{
constexpr auto kSIZE = MaxVer + 1 - MinVer;
static constexpr auto kSize = MaxVer + 1 - MinVer;
[&]<std::size_t... Offset>(std::index_sequence<Offset...>) {
// NOLINTBEGIN(bugprone-use-after-move)
(((void)fn(
std::integral_constant<unsigned int, MinVer + Offset>{}, std::forward<Args>(args)...)),
...);
// NOLINTEND(bugprone-use-after-move)
}(std::make_index_sequence<kSIZE>{});
}(std::make_index_sequence<kSize>{});
}
template <typename Fn, typename... Args>
void
forAllApiVersions(Fn const& fn, Args&&... args)
requires requires {
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>(
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...);
}
{
forApiVersions<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>(
forApiVersions<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>(
fn, std::forward<Args>(args)...);
}

View File

@@ -148,10 +148,10 @@ public:
};
template <ValidIssueType TIss>
constexpr bool kIS_ISSUE_V = std::is_same_v<TIss, Issue>;
constexpr bool kIsIssueV = std::is_same_v<TIss, Issue>;
template <ValidIssueType TIss>
constexpr bool kIS_MPTISSUE_V = std::is_same_v<TIss, MPTIssue>;
constexpr bool kIsMptissueV = std::is_same_v<TIss, MPTIssue>;
inline json::Value
toJson(Asset const& asset)
@@ -242,7 +242,7 @@ operator<=>(Asset const& lhs, Asset const& rhs)
{
return std::weak_ordering(lhs <=> rhs);
}
else if constexpr (kIS_ISSUE_V<TLhs> && kIS_MPTISSUE_V<TRhs>)
else if constexpr (kIsIssueV<TLhs> && kIsMptissueV<TRhs>)
{
return std::weak_ordering::greater;
}

View File

@@ -140,8 +140,8 @@ private:
using issue_hasher = std::hash<xrpl::Issue>;
using mptissue_hasher = std::hash<xrpl::MPTIssue>;
issue_hasher m_issue_hasher_;
mptissue_hasher m_mptissue_hasher_;
issue_hasher mIssueHasher_;
mptissue_hasher mMptissueHasher_;
public:
explicit hash() = default;
@@ -151,11 +151,11 @@ public:
{
return asset.visit(
[&](xrpl::Issue const& issue) {
value_type const result(m_issue_hasher_(issue));
value_type const result(mIssueHasher_(issue));
return result;
},
[&](xrpl::MPTIssue const& issue) {
value_type const result(m_mptissue_hasher_(issue));
value_type const result(mMptissueHasher_(issue));
return result;
});
}
@@ -170,8 +170,8 @@ private:
using asset_hasher = std::hash<xrpl::Asset>;
using uint256_hasher = xrpl::uint256::hasher;
asset_hasher issue_hasher_;
uint256_hasher uint256_hasher_;
asset_hasher issueHasher_;
uint256_hasher uint256Hasher_;
public:
hash() = default;
@@ -182,11 +182,11 @@ public:
value_type
operator()(argument_type const& value) const
{
value_type result(issue_hasher_(value.in));
boost::hash_combine(result, issue_hasher_(value.out));
value_type result(issueHasher_(value.in));
boost::hash_combine(result, issueHasher_(value.out));
if (value.domain)
boost::hash_combine(result, uint256_hasher_(*value.domain));
boost::hash_combine(result, uint256Hasher_(*value.domain));
return result;
}

View File

@@ -172,24 +172,24 @@ struct ErrorInfo
{
// Default ctor needed to produce an empty std::array during constexpr eval.
constexpr ErrorInfo()
: code(RpcUnknown), token("unknown"), message("An unknown error code."), http_status(200)
: code(RpcUnknown), token("unknown"), message("An unknown error code."), httpStatus(200)
{
}
constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message)
: code(code), token(token), message(message), http_status(200)
: code(code), token(token), message(message), httpStatus(200)
{
}
constexpr ErrorInfo(ErrorCodeI code, char const* token, char const* message, int httpStatus)
: code(code), token(token), message(message), http_status(httpStatus)
: code(code), token(token), message(message), httpStatus(httpStatus)
{
}
ErrorCodeI code;
json::StaticString token;
json::StaticString message;
int http_status;
int httpStatus;
};
/** Returns an ErrorInfo that reflects the error code. */

View File

@@ -65,11 +65,11 @@
namespace xrpl {
// Feature names must not exceed this length (in characters, excluding the null terminator).
static constexpr std::size_t kMAX_FEATURE_NAME_SIZE = 63;
static constexpr std::size_t kMaxFeatureNameSize = 63;
// Reserve this exact feature-name length (in characters/bytes, excluding the null terminator)
// so that a 32-byte uint256 (for example, in WASM or other interop contexts) can be used
// as a compact, fixed-size feature selector without conflicting with human-readable names.
static constexpr std::size_t kRESERVED_FEATURE_NAME_SIZE = 32;
static constexpr std::size_t kReservedFeatureNameSize = 32;
// Both validFeatureNameSize and validFeatureName are consteval functions that can be used in
// static_asserts to validate feature names at compile time. They are only used inside
@@ -81,14 +81,14 @@ validFeatureNameSize(auto fn) -> bool
{
constexpr char const* kN = fn();
// Note, std::strlen is not constexpr, we need to implement our own here.
constexpr std::size_t kLEN = [](auto n) {
constexpr std::size_t kLen = [](auto n) {
std::size_t ret = 0;
for (auto ptr = n; *ptr != '\0'; ret++, ++ptr)
;
return ret;
}(kN);
return kLEN != kRESERVED_FEATURE_NAME_SIZE && //
kLEN <= kMAX_FEATURE_NAME_SIZE;
return kLen != kReservedFeatureNameSize && //
kLen <= kMaxFeatureNameSize;
}
consteval auto
@@ -136,7 +136,7 @@ namespace detail {
// Feature.cpp. Because it's only used to reserve storage, and determine how
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
// the actual number of amendments. A LogicError on startup will verify this.
static constexpr std::size_t kNUM_FEATURES =
static constexpr std::size_t kNumFeatures =
(0 +
#include <xrpl/protocol/detail/features.macro>
);
@@ -184,9 +184,9 @@ bitsetIndexToFeature(size_t i);
std::string
featureToName(uint256 const& f);
class FeatureBitset : private std::bitset<detail::kNUM_FEATURES>
class FeatureBitset : private std::bitset<detail::kNumFeatures>
{
using base = std::bitset<detail::kNUM_FEATURES>;
using base = std::bitset<detail::kNumFeatures>;
template <class... Fs>
void

View File

@@ -6,7 +6,7 @@ namespace xrpl {
// Deprecated constant for backwards compatibility with pre-XRPFees amendment.
// This was the reference fee units used in the old fee calculation.
inline constexpr std::uint32_t kFEE_UNITS_DEPRECATED = 10;
inline constexpr std::uint32_t kFeeUnitsDeprecated = 10;
/** Reflects the fee settings for a particular ledger.

View File

@@ -91,7 +91,7 @@ public:
inline IOUAmount::IOUAmount(beast::Zero)
{
*this = beast::kZERO;
*this = beast::kZero;
}
inline IOUAmount::IOUAmount(mantissa_type mantissa, exponent_type exponent)

View File

@@ -82,7 +82,7 @@ struct BookT
Keylet
operator()(Book const& b) const;
};
static BookT const kBOOK{};
static BookT const kBook{};
/** The index of a trust line for a given currency
@@ -126,7 +126,7 @@ struct NextT
Keylet
operator()(Keylet const& k) const;
};
static NextT const kNEXT{};
static NextT const kNext{};
/** A ticket belonging to an account */
struct TicketT
@@ -145,7 +145,7 @@ struct TicketT
return {ltTICKET, key};
}
};
static TicketT const kTICKET{};
static TicketT const kTicket{};
/** A SignerList */
Keylet
@@ -373,7 +373,7 @@ struct KeyletDesc
// This list should include all of the keylet functions that take a single
// AccountID parameter.
std::array<KeyletDesc<AccountID const&>, 6> const kDIRECT_ACCOUNT_KEYLETS{
std::array<KeyletDesc<AccountID const&>, 6> const kDirectAccountKeylets{
{{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false},
{.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true},
{.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true},

View File

@@ -96,16 +96,16 @@ operator<=>(Issue const& lhs, Issue const& rhs)
inline Issue const&
xrpIssue()
{
static Issue const kISSUE{xrpCurrency(), xrpAccount()};
return kISSUE;
static Issue const kIssue{xrpCurrency(), xrpAccount()};
return kIssue;
}
/** Returns an asset specifier that represents no account and currency. */
inline Issue const&
noIssue()
{
static Issue const kISSUE{noCurrency(), noAccount()};
return kISSUE;
static Issue const kIssue{noCurrency(), noAccount()};
return kIssue;
}
inline bool

View File

@@ -26,12 +26,12 @@ struct LedgerHeader
//
// Closed means "tx set already determined"
uint256 hash = beast::kZERO;
uint256 txHash = beast::kZERO;
uint256 accountHash = beast::kZERO;
uint256 parentHash = beast::kZERO;
uint256 hash = beast::kZero;
uint256 txHash = beast::kZero;
uint256 accountHash = beast::kZero;
uint256 parentHash = beast::kZero;
XRPAmount drops = beast::kZERO;
XRPAmount drops = beast::kZero;
// If validated is false, it means "not yet validated."
// Once validated is true, it will never be set false at a later time.
@@ -53,12 +53,12 @@ struct LedgerHeader
};
// ledger close flags
static std::uint32_t const kS_LCF_NO_CONSENSUS_TIME = 0x01;
static std::uint32_t const kSLcfNoConsensusTime = 0x01;
inline bool
getCloseAgree(LedgerHeader const& info)
{
return (info.closeFlags & kS_LCF_NO_CONSENSUS_TIME) == 0;
return (info.closeFlags & kSLcfNoConsensusTime) == 0;
}
void

View File

@@ -88,7 +88,7 @@ constexpr MPTAmount::MPTAmount(value_type value) : value_(value)
constexpr MPTAmount::MPTAmount(beast::Zero)
{
*this = beast::kZERO;
*this = beast::kZero;
}
constexpr MPTAmount&

View File

@@ -15,14 +15,14 @@ namespace xrpl {
namespace detail {
template <typename T>
constexpr bool kIS_INTEGRAL_CONSTANT = false;
constexpr bool kIsIntegralConstant = false;
template <typename I, auto A>
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A>&> = true;
constexpr bool kIsIntegralConstant<std::integral_constant<I, A>&> = true;
template <typename I, auto A>
constexpr bool kIS_INTEGRAL_CONSTANT<std::integral_constant<I, A> const&> = true;
constexpr bool kIsIntegralConstant<std::integral_constant<I, A> const&> = true;
template <typename T>
concept some_integral_constant = detail::kIS_INTEGRAL_CONSTANT<T&>;
concept some_integral_constant = detail::kIsIntegralConstant<T&>;
// This class is designed to wrap a collection of _almost_ identical json::Value
// objects, indexed by version (i.e. there is some mapping of version to object
@@ -47,8 +47,8 @@ struct MultiApiJson
return (v < MinVer) ? 0 : static_cast<std::size_t>(v - MinVer);
}
constexpr static std::size_t kSIZE = MaxVer + 1 - MinVer;
std::array<json::Value, kSIZE> val = {};
static constexpr std::size_t kSize = MaxVer + 1 - MinVer;
std::array<json::Value, kSize> val = {};
explicit MultiApiJson(json::Value const& init = {})
{
@@ -80,7 +80,7 @@ struct MultiApiJson
if (count == 0)
return IsMemberResult::None;
return count < kSIZE ? IsMemberResult::Some : IsMemberResult::All;
return count < kSize ? IsMemberResult::Some : IsMemberResult::All;
}
static constexpr struct VisitorT final
@@ -100,7 +100,7 @@ struct MultiApiJson
std::integral_constant<unsigned int, Version>,
Args&&...>
{
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE);
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
return std::invoke(fn, json.val[index(Version)], version, std::forward<Args>(args)...);
}
@@ -111,7 +111,7 @@ struct MultiApiJson
operator()(Json& json, std::integral_constant<unsigned int, Version> const, Fn fn) const
-> std::invoke_result_t<Fn, decltype(json.val[0])>
{
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSIZE);
static_assert(valid(Version) && index(Version) >= 0 && index(Version) < kSize);
return std::invoke(fn, json.val[index(Version)]);
}
@@ -124,7 +124,7 @@ struct MultiApiJson
-> std::invoke_result_t<Fn, decltype(json.val[0]), Version, Args&&...>
{
XRPL_ASSERT(
valid(version) && index(version) >= 0 && index(version) < kSIZE,
valid(version) && index(version) >= 0 && index(version) < kSize,
"xrpl::detail::MultiApijson::operator<Args...>() : valid "
"version");
return std::invoke(fn, json.val[index(version)], version, std::forward<Args>(args)...);
@@ -139,20 +139,20 @@ struct MultiApiJson
-> std::invoke_result_t<Fn, decltype(json.val[0])>
{
XRPL_ASSERT(
valid(version) && index(version) >= 0 && index(version) < kSIZE,
valid(version) && index(version) >= 0 && index(version) < kSize,
"xrpl::detail::MultiApijson::operator() : valid version");
return std::invoke(fn, json.val[index(version)]);
}
} kVISITOR = {};
} kVisitor = {};
auto
visit()
{
return [self = this](auto... args)
requires requires {
kVISITOR(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...);
kVisitor(std::declval<MultiApiJson&>(), std::declval<decltype(args)>()...);
}
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); };
{ return kVisitor(*self, std::forward<decltype(args)>(args)...); };
}
[[nodiscard]] auto
@@ -160,27 +160,27 @@ struct MultiApiJson
{
return [self = this](auto... args)
requires requires {
kVISITOR(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...);
kVisitor(std::declval<MultiApiJson const&>(), std::declval<decltype(args)>()...);
}
{ return kVISITOR(*self, std::forward<decltype(args)>(args)...); };
{ return kVisitor(*self, std::forward<decltype(args)>(args)...); };
}
template <typename... Args>
auto
visit(Args... args) -> std::invoke_result_t<VisitorT, MultiApiJson&, Args...>
requires(sizeof...(args) > 0) &&
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); }
requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
{
return kVISITOR(*this, std::forward<decltype(args)>(args)...);
return kVisitor(*this, std::forward<decltype(args)>(args)...);
}
template <typename... Args>
[[nodiscard]] auto
visit(Args... args) const -> std::invoke_result_t<VisitorT, MultiApiJson const&, Args...>
requires(sizeof...(args) > 0) &&
requires { kVISITOR(*this, std::forward<decltype(args)>(args)...); }
requires { kVisitor(*this, std::forward<decltype(args)>(args)...); }
{
return kVISITOR(*this, std::forward<decltype(args)>(args)...);
return kVisitor(*this, std::forward<decltype(args)>(args)...);
}
};
@@ -188,6 +188,6 @@ struct MultiApiJson
// Wrapper for Json for all supported API versions.
using MultiApiJson =
detail::MultiApiJson<RPC::kAPI_MINIMUM_SUPPORTED_VERSION, RPC::kAPI_MAXIMUM_VALID_VERSION>;
detail::MultiApiJson<RPC::kApiMinimumSupportedVersion, RPC::kApiMaximumValidVersion>;
} // namespace xrpl

View File

@@ -52,10 +52,10 @@ public:
};
template <ValidPathAsset PA>
constexpr bool kIS_CURRENCY_V = std::is_same_v<PA, Currency>;
constexpr bool kIsCurrencyV = std::is_same_v<PA, Currency>;
template <ValidPathAsset PA>
constexpr bool kIS_MPTID_V = std::is_same_v<PA, MPTID>;
constexpr bool kIsMptidV = std::is_same_v<PA, MPTID>;
inline PathAsset::PathAsset(Asset const& asset)
{

View File

@@ -19,40 +19,40 @@ namespace xrpl {
@ingroup protocol
*/
/** Smallest legal byte size of a transaction. */
std::size_t constexpr kTX_MIN_SIZE_BYTES = 32;
constexpr std::size_t kTxMinSizeBytes = 32;
/** Largest legal byte size of a transaction. */
std::size_t constexpr kTX_MAX_SIZE_BYTES = megabytes(1);
constexpr std::size_t kTxMaxSizeBytes = megabytes(1);
/** The maximum number of unfunded offers to delete at once */
std::size_t constexpr kUNFUNDED_OFFER_REMOVE_LIMIT = 1000;
constexpr std::size_t kUnfundedOfferRemoveLimit = 1000;
/** The maximum number of expired offers to delete at once */
std::size_t constexpr kEXPIRED_OFFER_REMOVE_LIMIT = 256;
constexpr std::size_t kExpiredOfferRemoveLimit = 256;
/** The maximum number of metadata entries allowed in one transaction */
std::size_t constexpr kOVERSIZE_META_DATA_CAP = 5200;
constexpr std::size_t kOversizeMetaDataCap = 5200;
/** The maximum number of entries per directory page */
std::size_t constexpr kDIR_NODE_MAX_ENTRIES = 32;
constexpr std::size_t kDirNodeMaxEntries = 32;
/** The maximum number of pages allowed in a directory
Made obsolete by fixDirectoryLimit amendment.
*/
std::uint64_t constexpr kDIR_NODE_MAX_PAGES = 262144;
constexpr std::uint64_t kDirNodeMaxPages = 262144;
/** The maximum number of items in an NFT page */
std::size_t constexpr kDIR_MAX_TOKENS_PER_PAGE = 32;
constexpr std::size_t kDirMaxTokensPerPage = 32;
/** The maximum number of owner directory entries for account to be deletable */
std::size_t constexpr kMAX_DELETABLE_DIR_ENTRIES = 1000;
constexpr std::size_t kMaxDeletableDirEntries = 1000;
/** The maximum number of token offers that can be canceled at once */
std::size_t constexpr kMAX_TOKEN_OFFER_CANCEL_COUNT = 500;
constexpr std::size_t kMaxTokenOfferCancelCount = 500;
/** The maximum number of offers in an offer directory for NFT to be burnable */
std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500;
constexpr std::size_t kMaxDeletableTokenOfferEntries = 500;
/** The maximum token transfer fee allowed.
@@ -63,7 +63,7 @@ std::size_t constexpr kMAX_DELETABLE_TOKEN_OFFER_ENTRIES = 500;
Note that for extremely low transfer fees values, it is possible that the
calculated fee will be 0.
*/
std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000;
constexpr std::uint16_t kMaxTransferFee = 50000;
/** There are 10,000 basis points (bips) in 100%.
*
@@ -81,32 +81,32 @@ std::uint16_t constexpr kMAX_TRANSFER_FEE = 50000;
*
* Example: 50% is 0.50 * bipsPerUnity = 5,000 bps.
*/
Bips32 constexpr kBIPS_PER_UNITY(100 * 100);
static_assert(kBIPS_PER_UNITY == Bips32{10'000});
TenthBips32 constexpr kTENTH_BIPS_PER_UNITY(kBIPS_PER_UNITY.value() * 10);
static_assert(kTENTH_BIPS_PER_UNITY == TenthBips32(100'000));
constexpr Bips32 kBipsPerUnity(100 * 100);
static_assert(kBipsPerUnity == Bips32{10'000});
constexpr TenthBips32 kTenthBipsPerUnity(kBipsPerUnity.value() * 10);
static_assert(kTenthBipsPerUnity == TenthBips32(100'000));
constexpr Bips32
percentageToBips(std::uint32_t percentage)
{
return Bips32(percentage * kBIPS_PER_UNITY.value() / 100);
return Bips32(percentage * kBipsPerUnity.value() / 100);
}
constexpr TenthBips32
percentageToTenthBips(std::uint32_t percentage)
{
return TenthBips32(percentage * kTENTH_BIPS_PER_UNITY.value() / 100);
return TenthBips32(percentage * kTenthBipsPerUnity.value() / 100);
}
template <typename T, class TBips>
constexpr T
bipsOfValue(T value, Bips<TBips> bips)
{
return value * bips.value() / kBIPS_PER_UNITY.value();
return value * bips.value() / kBipsPerUnity.value();
}
template <typename T, class TBips>
constexpr T
tenthBipsOfValue(T value, TenthBips<TBips> bips)
{
return value * bips.value() / kTENTH_BIPS_PER_UNITY.value();
return value * bips.value() / kTenthBipsPerUnity.value();
}
namespace Lending {
@@ -114,54 +114,54 @@ namespace Lending {
Valid values are between 0 and 10% inclusive.
*/
TenthBips16 constexpr kMAX_MANAGEMENT_FEE_RATE(
constexpr TenthBips16 kMaxManagementFeeRate(
unsafeCast<std::uint16_t>(percentageToTenthBips(10).value()));
static_assert(kMAX_MANAGEMENT_FEE_RATE == TenthBips16(std::uint16_t(10'000u)));
static_assert(kMaxManagementFeeRate == TenthBips16(std::uint16_t(10'000u)));
/** The maximum coverage rate required of a loan broker in 1/10 bips.
Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_COVER_RATE = percentageToTenthBips(100);
static_assert(kMAX_COVER_RATE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxCoverRate = percentageToTenthBips(100);
static_assert(kMaxCoverRate == TenthBips32(100'000u));
/** The maximum overpayment fee on a loan in 1/10 bips.
*
Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_OVERPAYMENT_FEE = percentageToTenthBips(100);
static_assert(kMAX_OVERPAYMENT_FEE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxOverpaymentFee = percentageToTenthBips(100);
static_assert(kMaxOverpaymentFee == TenthBips32(100'000u));
/** Annualized interest rate of the Loan in 1/10 bips.
*
* Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_INTEREST_RATE = percentageToTenthBips(100);
static_assert(kMAX_INTEREST_RATE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxInterestRate = percentageToTenthBips(100);
static_assert(kMaxInterestRate == TenthBips32(100'000u));
/** The maximum premium added to the interest rate for late payments on a loan
* in 1/10 bips.
*
* Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_LATE_INTEREST_RATE = percentageToTenthBips(100);
static_assert(kMAX_LATE_INTEREST_RATE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxLateInterestRate = percentageToTenthBips(100);
static_assert(kMaxLateInterestRate == TenthBips32(100'000u));
/** The maximum close interest rate charged for repaying a loan early in 1/10
* bips.
*
* Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_CLOSE_INTEREST_RATE = percentageToTenthBips(100);
static_assert(kMAX_CLOSE_INTEREST_RATE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxCloseInterestRate = percentageToTenthBips(100);
static_assert(kMaxCloseInterestRate == TenthBips32(100'000u));
/** The maximum overpayment interest rate charged on loan overpayments in 1/10
* bips.
*
* Valid values are between 0 and 100% inclusive.
*/
TenthBips32 constexpr kMAX_OVERPAYMENT_INTEREST_RATE = percentageToTenthBips(100);
static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u));
constexpr TenthBips32 kMaxOverpaymentInterestRate = percentageToTenthBips(100);
static_assert(kMaxOverpaymentInterestRate == TenthBips32(100'000u));
/** LoanPay transaction cost will be one base fee per X combined payments
*
@@ -172,7 +172,7 @@ static_assert(kMAX_OVERPAYMENT_INTEREST_RATE == TenthBips32(100'000u));
* This number was chosen arbitrarily, but should not be changed once released
* without an amendment
*/
static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5;
static constexpr int kLoanPaymentsPerFeeIncrement = 5;
/** Maximum number of combined payments that a LoanPay transaction will process
*
@@ -196,65 +196,65 @@ static constexpr int kLOAN_PAYMENTS_PER_FEE_INCREMENT = 5;
* This number was chosen arbitrarily, but should not be changed once released
* without an amendment
*/
static constexpr int kLOAN_MAXIMUM_PAYMENTS_PER_TRANSACTION = 100;
static constexpr int kLoanMaximumPaymentsPerTransaction = 100;
} // namespace Lending
/** The maximum length of a URI inside an NFT */
std::size_t constexpr kMAX_TOKEN_URI_LENGTH = 256;
constexpr std::size_t kMaxTokenUriLength = 256;
/** The maximum length of a Data element inside a DID */
std::size_t constexpr kMAX_DID_DOCUMENT_LENGTH = 256;
constexpr std::size_t kMaxDidDocumentLength = 256;
/** The maximum length of a URI inside a DID */
std::size_t constexpr kMAX_DIDURI_LENGTH = 256;
constexpr std::size_t kMaxDidUriLength = 256;
/** The maximum length of an Attestation inside a DID */
std::size_t constexpr kMAX_DID_DATA_LENGTH = 256;
constexpr std::size_t kMaxDidDataLength = 256;
/** The maximum length of a domain */
std::size_t constexpr kMAX_DOMAIN_LENGTH = 256;
constexpr std::size_t kMaxDomainLength = 256;
/** The maximum length of a URI inside a Credential */
std::size_t constexpr kMAX_CREDENTIAL_URI_LENGTH = 256;
constexpr std::size_t kMaxCredentialUriLength = 256;
/** The maximum length of a CredentialType inside a Credential */
std::size_t constexpr kMAX_CREDENTIAL_TYPE_LENGTH = 64;
constexpr std::size_t kMaxCredentialTypeLength = 64;
/** The maximum number of credentials can be passed in array */
std::size_t constexpr kMAX_CREDENTIALS_ARRAY_SIZE = 8;
constexpr std::size_t kMaxCredentialsArraySize = 8;
/** The maximum number of credentials can be passed in array for permissioned
* domain */
std::size_t constexpr kMAX_PERMISSIONED_DOMAIN_CREDENTIALS_ARRAY_SIZE = 10;
constexpr std::size_t kMaxPermissionedDomainCredentialsArraySize = 10;
/** The maximum length of MPTokenMetadata */
std::size_t constexpr kMAX_MP_TOKEN_METADATA_LENGTH = 1024;
constexpr std::size_t kMaxMpTokenMetadataLength = 1024;
/** The maximum amount of MPTokenIssuance */
std::uint64_t constexpr kMAX_MP_TOKEN_AMOUNT = 0x7FFF'FFFF'FFFF'FFFFull;
static_assert(Number::kMAX_REP >= kMAX_MP_TOKEN_AMOUNT);
constexpr std::uint64_t kMaxMpTokenAmount = 0x7FFF'FFFF'FFFF'FFFFull;
static_assert(Number::kMaxRep >= kMaxMpTokenAmount);
/** The maximum length of Data payload */
std::size_t constexpr kMAX_DATA_PAYLOAD_LENGTH = 256;
constexpr std::size_t kMaxDataPayloadLength = 256;
/** Vault withdrawal policies */
std::uint8_t constexpr kVAULT_STRATEGY_FIRST_COME_FIRST_SERVE = 1;
constexpr std::uint8_t kVaultStrategyFirstComeFirstServe = 1;
/** Default IOU scale factor for a Vault */
std::uint8_t constexpr kVAULT_DEFAULT_IOU_SCALE = 6;
constexpr std::uint8_t kVaultDefaultIouScale = 6;
/** Maximum scale factor for a Vault. The number is chosen to ensure that
1 IOU can be always converted to shares.
10^19 > maxMPTokenAmount (2^64-1) > 10^18 */
std::uint8_t constexpr kVAULT_MAXIMUM_IOU_SCALE = 18;
constexpr std::uint8_t kVaultMaximumIouScale = 18;
/** Maximum recursion depth for vault shares being put as an asset inside
* another vault; counted from 0 */
std::uint8_t constexpr kMAX_ASSET_CHECK_DEPTH = 5;
constexpr std::uint8_t kMaxAssetCheckDepth = 5;
/** A ledger index. */
using LedgerIndex = std::uint32_t;
std::uint32_t constexpr kFLAG_LEDGER_INTERVAL = 256;
constexpr std::uint32_t kFlagLedgerInterval = 256;
/** Returns true if the given ledgerIndex is a voting ledgerIndex */
bool
@@ -273,38 +273,38 @@ using TxID = uint256;
/** The maximum number of trustlines to delete as part of AMM account
* deletion cleanup.
*/
std::uint16_t constexpr kMAX_DELETABLE_AMM_TRUST_LINES = 512;
constexpr std::uint16_t kMaxDeletableAmmTrustLines = 512;
/** The maximum length of a URI inside an Oracle */
std::size_t constexpr kMAX_ORACLE_URI = 256;
constexpr std::size_t kMaxOracleUri = 256;
/** The maximum length of a Provider inside an Oracle */
std::size_t constexpr kMAX_ORACLE_PROVIDER = 256;
constexpr std::size_t kMaxOracleProvider = 256;
/** The maximum size of a data series array inside an Oracle */
std::size_t constexpr kMAX_ORACLE_DATA_SERIES = 10;
constexpr std::size_t kMaxOracleDataSeries = 10;
/** The maximum length of a SymbolClass inside an Oracle */
std::size_t constexpr kMAX_ORACLE_SYMBOL_CLASS = 16;
constexpr std::size_t kMaxOracleSymbolClass = 16;
/** The maximum allowed time difference between lastUpdateTime and the time
of the last closed ledger
*/
std::size_t constexpr kMAX_LAST_UPDATE_TIME_DELTA = 300;
constexpr std::size_t kMaxLastUpdateTimeDelta = 300;
/** The maximum price scaling factor
*/
std::size_t constexpr kMAX_PRICE_SCALE = 20;
constexpr std::size_t kMaxPriceScale = 20;
/** The maximum percentage of outliers to trim
*/
std::size_t constexpr kMAX_TRIM = 25;
constexpr std::size_t kMaxTrim = 25;
/** The maximum number of delegate permissions an account can grant
*/
std::size_t constexpr kPERMISSION_MAX_SIZE = 10;
constexpr std::size_t kPermissionMaxSize = 10;
/** The maximum number of transactions that can be in a batch. */
std::size_t constexpr kMAX_BATCH_TX_COUNT = 8;
constexpr std::size_t kMaxBatchTxCount = 8;
} // namespace xrpl

View File

@@ -43,8 +43,8 @@ class PublicKey
protected:
// All the constructed public keys are valid, non-empty and contain 33
// bytes of data.
static constexpr std::size_t kSIZE = 33;
std::uint8_t buf_[kSIZE]{}; // should be large enough
static constexpr std::size_t kSize = 33;
std::uint8_t buf_[kSize]{}; // should be large enough
public:
using const_iterator = std::uint8_t const*;
@@ -72,7 +72,7 @@ public:
static std::size_t
size() noexcept
{
return kSIZE;
return kSize;
}
[[nodiscard]] const_iterator
@@ -90,19 +90,19 @@ public:
[[nodiscard]] const_iterator
end() const noexcept
{
return buf_ + kSIZE;
return buf_ + kSize;
}
[[nodiscard]] const_iterator
cend() const noexcept
{
return buf_ + kSIZE;
return buf_ + kSize;
}
[[nodiscard]] Slice
slice() const noexcept
{
return {buf_, kSIZE};
return {buf_, kSize};
}
operator Slice() const noexcept
@@ -267,10 +267,10 @@ getOrThrow(json::Value const& v, xrpl::SField const& field)
{
using namespace xrpl;
std::string const b58 = getOrThrow<std::string>(v, field);
if (auto pubKeyBlob = strUnHex(b58); pubKeyBlob && publicKeyType(makeSlice(*pubKeyBlob)))
if (auto pubKeyBlob = strUnHex(b58);
pubKeyBlob.has_value() && publicKeyType(makeSlice(*pubKeyBlob)))
{
return PublicKey{makeSlice(
*pubKeyBlob)}; // NOLINT(bugprone-unchecked-optional-access) checked in condition above
return PublicKey{makeSlice(*pubKeyBlob)};
}
for (auto const tokenType : {TokenType::NodePublic, TokenType::AccountPublic})
{

View File

@@ -26,7 +26,7 @@ struct TAmounts
{
TAmounts() = default;
TAmounts(beast::Zero, beast::Zero) : in(beast::kZERO), out(beast::kZERO)
TAmounts(beast::Zero, beast::Zero) : in(beast::kZero), out(beast::kZero)
{
}
@@ -38,7 +38,7 @@ struct TAmounts
[[nodiscard]] bool
empty() const noexcept
{
return in <= beast::kZERO || out <= beast::kZERO;
return in <= beast::kZero || out <= beast::kZero;
}
TAmounts&
@@ -94,8 +94,8 @@ public:
// have lower unsigned integer representations.
using value_type = std::uint64_t;
static int const kMIN_TICK_SIZE = 3;
static int const kMAX_TICK_SIZE = 16;
static int const kMinTickSize = 3;
static int const kMaxTickSize = 16;
private:
// This has the same representation as STAmount, see the comment on the
@@ -316,10 +316,10 @@ TAmounts<In, Out>
Quality::ceilIn(TAmounts<In, Out> const& amount, In const& limit) const
{
// Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&) const =
static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&) const =
&Quality::ceilIn;
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR);
return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr);
}
template <class In, class Out>
@@ -327,10 +327,10 @@ TAmounts<In, Out>
Quality::ceilInStrict(TAmounts<In, Out> const& amount, In const& limit, bool roundUp) const
{
// Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_IN_FN_PTR)(Amounts const&, STAmount const&, bool)
const = &Quality::ceilInStrict;
static constexpr Amounts (Quality::*kCeilInFnPtr)(Amounts const&, STAmount const&, bool) const =
&Quality::ceilInStrict;
return ceilTAmountsHelper(amount, limit, amount.in, kCEIL_IN_FN_PTR, roundUp);
return ceilTAmountsHelper(amount, limit, amount.in, kCeilInFnPtr, roundUp);
}
template <class In, class Out>
@@ -338,10 +338,10 @@ TAmounts<In, Out>
Quality::ceilOut(TAmounts<In, Out> const& amount, Out const& limit) const
{
// Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&) const =
static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&) const =
&Quality::ceilOut;
return ceil_TAmounts_helper(amount, limit, amount.out, kCEIL_OUT_FN_PTR);
return ceil_TAmounts_helper(amount, limit, amount.out, kCeilOutFnPtr);
}
template <class In, class Out>
@@ -349,10 +349,10 @@ TAmounts<In, Out>
Quality::ceilOutStrict(TAmounts<In, Out> const& amount, Out const& limit, bool roundUp) const
{
// Construct a function pointer to the function we want to call.
static constexpr Amounts (Quality::*kCEIL_OUT_FN_PTR)(Amounts const&, STAmount const&, bool)
static constexpr Amounts (Quality::*kCeilOutFnPtr)(Amounts const&, STAmount const&, bool)
const = &Quality::ceilOutStrict;
return ceilTAmountsHelper(amount, limit, amount.out, kCEIL_OUT_FN_PTR, roundUp);
return ceilTAmountsHelper(amount, limit, amount.out, kCeilOutFnPtr, roundUp);
}
/** Calculate the quality of a two-hop path given the two hops.

View File

@@ -72,7 +72,7 @@ QualityFunction::QualityFunction(
std::uint32_t tfee,
QualityFunction::AMMTag)
{
if (amounts.in <= beast::kZERO || amounts.out <= beast::kZERO)
if (amounts.in <= beast::kZero || amounts.out <= beast::kZero)
Throw<std::runtime_error>("QualityFunction amounts are 0.");
Number const cfee = feeMult(tfee);
m_ = -cfee / amounts.in;

View File

@@ -72,6 +72,6 @@ transferFeeAsRate(std::uint16_t fee);
} // namespace nft
/** A transfer rate signifying a 1:1 exchange */
extern Rate const kPARITY_RATE;
extern Rate const kParityRate;
} // namespace xrpl

View File

@@ -92,7 +92,7 @@ class STCurrency;
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum SerializedTypeID { XMACRO(TO_ENUM) };
static std::map<std::string, int> const kS_TYPE_MAP = {XMACRO(TO_MAP)};
static std::map<std::string, int> const kSTypeMap = {XMACRO(TO_MAP)};
#undef XMACRO
#undef TO_ENUM
@@ -129,26 +129,23 @@ fieldCode(int id, int index)
class SField
{
public:
// Need to be named before converting
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
enum {
SMdNever = 0x00,
SMdChangeOrig = 0x01, // original value when it changes
SMdChangeNew = 0x02, // new value when it changes
SMdDeleteFinal = 0x04, // final value when it is deleted
SMdCreate = 0x08, // value when it's created
SMdAlways = 0x10, // value when node containing it is affected at all
SMdBaseTen = 0x20, // value is treated as base 10, overriding behavior
SMdPseudoAccount = 0x40, // if this field is set in an ACCOUNT_ROOT
// _only_, then it is a pseudo-account
SMdNeedsAsset = 0x80, // This field needs to be associated with an
// asset before it is serialized as a ledger
// object. Intended for STNumber.
SMdDefault = SMdChangeOrig | SMdChangeNew | SMdDeleteFinal | SMdCreate
};
static constexpr auto kSmdNever = 0x00;
static constexpr auto kSmdChangeOrig = 0x01; // original value when it changes
static constexpr auto kSmdChangeNew = 0x02; // new value when it changes
static constexpr auto kSmdDeleteFinal = 0x04; // final value when it is deleted
static constexpr auto kSmdCreate = 0x08; // value when it's created
static constexpr auto kSmdAlways = 0x10; // value when node containing it is affected at all
static constexpr auto kSmdBaseTen = 0x20; // value is treated as base 10, overriding behavior
static constexpr auto kSmdPseudoAccount = 0x40; // if this field is set in an ACCOUNT_ROOT
// _only_, then it is a pseudo-account
static constexpr auto kSmdNeedsAsset = 0x80; // This field needs to be associated with an
// asset before it is serialized as a ledger
// object. Intended for STNumber.
static constexpr auto kSmdDefault =
kSmdChangeOrig | kSmdChangeNew | kSmdDeleteFinal | kSmdCreate;
enum class IsSigning : unsigned char { No, Yes };
static IsSigning const kNOT_SIGNING = IsSigning::No;
static IsSigning const kNotSigning = IsSigning::No;
int const fieldCodeMem; // (type<<16)|index // TODO: rename, clashes with function
SerializedTypeID const fieldType; // STI_*
@@ -175,7 +172,7 @@ public:
SerializedTypeID tid,
int fv,
char const* fn,
int meta = SMdDefault,
int meta = kSmdDefault,
IsSigning signing = IsSigning::Yes);
explicit SField(PrivateAccessTagT, int fc, char const* fn);
@@ -368,8 +365,8 @@ using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SField const sfName;
#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) extern SF_##stiSuffix const sfName;
extern SField const kSF_INVALID;
extern SField const kSF_GENERIC;
extern SField const sfInvalid; // NOLINT(readability-identifier-naming)
extern SField const sfGeneric; // NOLINT(readability-identifier-naming)
#include <xrpl/protocol/detail/sfields.macro>

View File

@@ -3,11 +3,13 @@
#include <xrpl/basics/CountedObject.h>
#include <xrpl/basics/LocalValue.h>
#include <xrpl/basics/Number.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/IOUAmount.h>
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/MPTAmount.h>
#include <xrpl/protocol/Protocol.h>
#include <xrpl/protocol/SField.h>
#include <xrpl/protocol/STBase.h>
#include <xrpl/protocol/Serializer.h>
@@ -42,24 +44,24 @@ private:
public:
using value_type = STAmount;
constexpr static int kMIN_OFFSET = -96;
constexpr static int kMAX_OFFSET = 80;
static constexpr int kMinOffset = -96;
static constexpr int kMaxOffset = 80;
// Maximum native value supported by the code
constexpr static std::uint64_t kMIN_VALUE = 1'000'000'000'000'000ull;
static_assert(isPowerOfTen(kMIN_VALUE));
constexpr static std::uint64_t kMAX_VALUE = (kMIN_VALUE * 10) - 1;
static_assert(kMAX_VALUE == 9'999'999'999'999'999ull);
constexpr static std::uint64_t kMAX_NATIVE = 9'000'000'000'000'000'000ull;
static constexpr std::uint64_t kMinValue = 1'000'000'000'000'000ull;
static_assert(isPowerOfTen(kMinValue));
static constexpr std::uint64_t kMaxValue = (kMinValue * 10) - 1;
static_assert(kMaxValue == 9'999'999'999'999'999ull);
static constexpr std::uint64_t kMaxNative = 9'000'000'000'000'000'000ull;
// Max native value on network.
constexpr static std::uint64_t kMAX_NATIVE_N = 100'000'000'000'000'000ull;
constexpr static std::uint64_t kISSUED_CURRENCY = 0x8'000'000'000'000'000ull;
constexpr static std::uint64_t kPOSITIVE = 0x4'000'000'000'000'000ull;
constexpr static std::uint64_t kMP_TOKEN = 0x2'000'000'000'000'000ull;
constexpr static std::uint64_t kVALUE_MASK = ~(kPOSITIVE | kMP_TOKEN);
static constexpr std::uint64_t kMaxNativeN = 100'000'000'000'000'000ull;
static constexpr std::uint64_t kIssuedCurrency = 0x8'000'000'000'000'000ull;
static constexpr std::uint64_t kPositive = 0x4'000'000'000'000'000ull;
static constexpr std::uint64_t kMpToken = 0x2'000'000'000'000'000ull;
static constexpr std::uint64_t kValueMask = ~(kPositive | kMpToken);
static std::uint64_t const kU_RATE_ONE;
static std::uint64_t const kURateOne;
//--------------------------------------------------------------------------
STAmount(SerialIter& sit, SField const& name);
@@ -184,6 +186,24 @@ public:
[[nodiscard]] STAmount const&
value() const noexcept;
/**
* Checks if this amount evaluates to zero when constrained to a specific
* accounting scale.
*
* For XRP and MPT `roundToScale` is a no-op, returns true only when the amount itself is zero.
* The `scale` argument is ignored in that case.
* For IOU, the amount is rounded to the given scale using Number::RoundingMode::ToNearest mode
* and the result is checked for zero; if `scale <= exponent()`, `roundToScale` short-circuits
* and returns the value unchanged, so this returns false for any non-zero amount.
*
* @param scale The target accounting scale to evaluate against.
* @return `true` if this amount rounds to zero at the given scale, `false` otherwise.
*
* @see roundToScale
*/
[[nodiscard]] bool
isZeroAtScale(int scale) const;
//--------------------------------------------------------------------------
//
// Operators
@@ -241,7 +261,7 @@ public:
[[nodiscard]] std::string
getText() const override;
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override;
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::Values::None) const override;
void
add(Serializer& s) const override;
@@ -356,7 +376,7 @@ STAmount::STAmount(A const& asset, int mantissa, int exponent)
// Legacy support for new-style amounts
inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
: asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZERO)
: asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZero)
{
if (isNegative_)
{
@@ -371,7 +391,7 @@ inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
}
inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue)
: asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZERO)
: asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZero)
{
if (isNegative_)
{
@@ -498,7 +518,7 @@ STAmount::zeroed() const
inline STAmount::
operator bool() const noexcept
{
return *this != beast::kZERO;
return *this != beast::kZero;
}
inline STAmount::
@@ -540,7 +560,7 @@ STAmount::fromNumber(A const& a, Number const& number)
return STAmount{asset, intValue, 0, negative};
}
auto const [mantissa, exponent] = working.normalizeToRange(kMIN_VALUE, kMAX_VALUE);
auto const [mantissa, exponent] = working.normalizeToRange(kMinValue, kMaxValue);
return STAmount{asset, mantissa, exponent, negative};
}
@@ -548,7 +568,7 @@ STAmount::fromNumber(A const& a, Number const& number)
inline void
STAmount::negate()
{
if (*this != beast::kZERO)
if (*this != beast::kZero)
isNegative_ = !isNegative_;
}
@@ -575,12 +595,25 @@ STAmount::value() const noexcept
return *this;
}
inline bool
[[nodiscard]] inline bool
isLegalNet(STAmount const& value)
{
return !value.native() || (value.mantissa() <= STAmount::kMAX_NATIVE_N);
return !value.native() || (value.mantissa() <= STAmount::kMaxNativeN);
}
[[nodiscard]] inline bool
isLegalMPT(STAmount const& value)
{
return !value.holds<MPTIssue>() ||
(!value.negative() && value.exponent() == 0 && value.mantissa() <= kMaxMpTokenAmount);
}
/* Check recursively if an object has invalid MPTAmount or XRPAmount in STAmount field.
* Calls isLegalNet() and isLegalMPT().
*/
[[nodiscard]] bool
hasInvalidAmount(STBase const& field, beast::Journal j);
//------------------------------------------------------------------------------
//
// Operators

View File

@@ -18,23 +18,23 @@ 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
KNone = 0b0000'0000,
KIncludeDate = 0b0000'0001,
KDisableApiPriorV2 = 0b0000'0010,
enum class Values : underlying_t {
None = 0b0000'0000,
IncludeDate = 0b0000'0001,
DisableApiPriorV2 = 0b0000'0010,
// IMPORTANT `kALL` must be union of all of the above; see also operator~
KAll = 0b0000'0011
// clang-format on
// IMPORTANT `All` must be union of all of the above; see also operator~
All = IncludeDate | DisableApiPriorV2 // 0b0000'0011
};
constexpr JsonOptions(underlying_t v) noexcept : value(v)
{
}
constexpr JsonOptions(Values v) noexcept : value(static_cast<JsonOptions::underlying_t>(v))
{
}
[[nodiscard]] constexpr explicit
operator underlying_t() const noexcept
{
@@ -65,22 +65,22 @@ struct JsonOptions
}
/// Returns JsonOptions binary negation, can be used with & (above) for set
/// difference e.g. `(options & ~JsonOptions::kINCLUDE_DATE)`
/// difference e.g. `(options & ~JsonOptions::kIncludeDate)`
[[nodiscard]] constexpr JsonOptions friend
operator~(JsonOptions v) noexcept
{
return {~v.value & static_cast<underlying_t>(KAll)};
return {~v.value & static_cast<underlying_t>(Values::All)};
}
};
template <typename T>
requires requires(T const& t) {
{ t.getJson(JsonOptions::KNone) } -> std::convertible_to<json::Value>;
{ t.getJson(JsonOptions::Values::None) } -> std::convertible_to<json::Value>;
}
json::Value
toJson(T const& t)
{
return t.getJson(JsonOptions::KNone);
return t.getJson(JsonOptions::Values::None);
}
namespace detail {
@@ -148,7 +148,7 @@ public:
[[nodiscard]] virtual std::string
getText() const;
[[nodiscard]] virtual json::Value getJson(JsonOptions = JsonOptions::KNone) const;
[[nodiscard]] virtual json::Value getJson(JsonOptions = JsonOptions::Values::None) const;
virtual void
add(Serializer& s) const;

View File

@@ -16,7 +16,7 @@ class STBitString final : public STBase, public CountedObject<STBitString<Bits>>
static_assert(Bits > 0, "Number of bits must be positive");
public:
using value_type = BaseUint<Bits>;
using value_type = BaseUInt<Bits>;
private:
value_type value_{};
@@ -46,7 +46,7 @@ public:
template <typename Tag>
void
setValue(BaseUint<Bits, Tag> const& v);
setValue(BaseUInt<Bits, Tag> const& v);
[[nodiscard]] value_type const&
value() const;
@@ -157,7 +157,7 @@ STBitString<Bits>::add(Serializer& s) const
template <int Bits>
template <typename Tag>
void
STBitString<Bits>::setValue(BaseUint<Bits, Tag> const& v)
STBitString<Bits>::setValue(BaseUInt<Bits, Tag> const& v)
{
value_ = v;
}
@@ -180,7 +180,7 @@ template <int Bits>
bool
STBitString<Bits>::isDefault() const
{
return value_ == beast::kZERO;
return value_ == beast::kZero;
}
} // namespace xrpl

View File

@@ -24,7 +24,7 @@ public:
STBlob(SField const& f, void const* data, std::size_t size);
STBlob(SField const& f, Buffer&& b);
STBlob(SField const& n);
STBlob(SerialIter&, SField const& name = kSF_GENERIC);
STBlob(SerialIter&, SField const& name = sfGeneric);
[[nodiscard]] std::size_t
size() const;

View File

@@ -38,7 +38,7 @@ public:
getText() const override;
[[nodiscard]] json::Value
getJson(JsonOptions options = JsonOptions::KNone) const override;
getJson(JsonOptions options = JsonOptions::Values::None) const override;
/** Returns the 'key' (or 'index') of this item.
The key identifies this entry's position in

View File

@@ -132,7 +132,7 @@ public:
getText() const override;
// TODO(tom): options should be an enum.
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::KNone) const override;
[[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::Values::None) const override;
void
addWithoutSigningFields(Serializer& s) const;
@@ -381,7 +381,7 @@ public:
template <class Tag>
void
setFieldH160(SField const& field, BaseUint<160, Tag> const& v);
setFieldH160(SField const& field, BaseUInt<160, Tag> const& v);
STObject&
peekFieldObject(SField const& field);
@@ -1143,7 +1143,7 @@ STObject::at(OptionaledField<T> const& of) -> OptionalProxy<T>
template <class Tag>
void
STObject::setFieldH160(SField const& field, BaseUint<160, Tag> const& v)
STObject::setFieldH160(SField const& field, BaseUInt<160, Tag> const& v)
{
STBase* rf = getPField(field, true);

View File

@@ -6,6 +6,13 @@
namespace xrpl {
/** Maximum JSON object nesting depth permitted during parsing. */
inline constexpr std::size_t kMaxParsedJsonDepth = 64;
/** Maximum number of elements permitted in any JSON array field during parsing.
Requests exceeding this limit are rejected with an invalidParams error. */
inline constexpr std::size_t kMaxParsedJsonArraySize = 512;
/** Holds the serialized result of parsing an input JSON object.
This does validation and checking on the provided JSON.
*/

View File

@@ -21,8 +21,8 @@ class STPathElement final : public CountedObject<STPathElement>
PathAsset assetID_;
AccountID issuerID_;
bool is_offer_;
std::size_t hash_value_;
bool isOffer_;
std::size_t hashValue_;
public:
// Bitwise values (typeCurrency | typeMPT)
@@ -235,9 +235,9 @@ private:
// ------------ STPathElement ------------
inline STPathElement::STPathElement() : type_(TypeNone), is_offer_(true)
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
{
hash_value_ = getHash(*this);
hashValue_ = getHash(*this);
}
inline STPathElement::STPathElement(
@@ -248,11 +248,11 @@ inline STPathElement::STPathElement(
{
if (!account)
{
is_offer_ = true;
isOffer_ = true;
}
else
{
is_offer_ = false;
isOffer_ = false;
accountID_ = *account;
type_ |= TypeAccount;
XRPL_ASSERT(
@@ -272,7 +272,7 @@ inline STPathElement::STPathElement(
XRPL_ASSERT(issuerID_ != noAccount(), "xrpl::STPathElement::STPathElement : issuer is set");
}
hash_value_ = getHash(*this);
hashValue_ = getHash(*this);
}
inline STPathElement::STPathElement(
@@ -284,9 +284,9 @@ inline STPathElement::STPathElement(
, accountID_(account)
, assetID_(asset)
, issuerID_(issuer)
, is_offer_(isXRP(accountID_))
, isOffer_(isXRP(accountID_))
{
if (!is_offer_)
if (!isOffer_)
type_ |= TypeAccount;
if (forceAsset || !isXRP(assetID_))
@@ -295,7 +295,7 @@ inline STPathElement::STPathElement(
if (!isXRP(issuer))
type_ |= TypeIssuer;
hash_value_ = getHash(*this);
hashValue_ = getHash(*this);
}
inline STPathElement::STPathElement(
@@ -307,12 +307,12 @@ inline STPathElement::STPathElement(
, accountID_(account)
, assetID_(asset)
, issuerID_(issuer)
, is_offer_(isXRP(accountID_))
, isOffer_(isXRP(accountID_))
{
assetID_.visit(
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
hash_value_ = getHash(*this);
hashValue_ = getHash(*this);
}
inline auto
@@ -324,7 +324,7 @@ STPathElement::getNodeType() const
inline bool
STPathElement::isOffer() const
{
return is_offer_;
return isOffer_;
}
inline bool
@@ -404,7 +404,7 @@ STPathElement::getIssuerID() const
inline bool
STPathElement::operator==(STPathElement const& t) const
{
return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hash_value_ == t.hash_value_ &&
return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hashValue_ == t.hashValue_ &&
accountID_ == t.accountID_ && assetID_ == t.assetID_ && issuerID_ == t.issuerID_;
}

View File

@@ -27,11 +27,11 @@ enum class TxnSql : char {
class STTx final : public STObject, public CountedObject<STTx>
{
uint256 tid_;
TxType tx_type_;
TxType txType_;
public:
static constexpr std::size_t kMIN_MULTI_SIGNERS = 1;
static constexpr std::size_t kMAX_MULTI_SIGNERS = 32;
static constexpr std::size_t kMinMultiSigners = 1;
static constexpr std::size_t kMaxMultiSigners = 32;
STTx() = delete;
STTx(STTx const& other) = default;
@@ -187,7 +187,7 @@ inline STTx::STTx(SerialIter&& sit) // NOLINT(cppcoreguidelines-rvalue-referenc
inline TxType
STTx::getTxnType() const
{
return tx_type_;
return txType_;
}
inline Blob

Some files were not shown because too many files have changed in this diff Show More