mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-07 02:36:47 +00:00
Merge remote-tracking branch 'upstream/develop' into sponsor
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
extractTarLz4(
|
||||
@@ -99,4 +99,4 @@ extractTarLz4(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Section::Section(std::string const& name) : name_(name)
|
||||
{
|
||||
@@ -183,4 +183,4 @@ operator<<(std::ostream& ss, BasicConfig const& c)
|
||||
return ss;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
CountedObjects&
|
||||
CountedObjects::getInstance() noexcept
|
||||
@@ -36,4 +36,4 @@ CountedObjects::getCounts(int minimumThreshold) const
|
||||
return counts;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
getFileContents(
|
||||
@@ -85,4 +85,4 @@ writeFileContents(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Logs::Sink::Sink(
|
||||
std::string const& partition,
|
||||
@@ -222,7 +222,7 @@ Logs::fromSeverity(beast::severities::Severity level)
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
UNREACHABLE("ripple::Logs::fromSeverity : invalid severity");
|
||||
UNREACHABLE("xrpl::Logs::fromSeverity : invalid severity");
|
||||
[[fallthrough]];
|
||||
// LCOV_EXCL_STOP
|
||||
case kFatal:
|
||||
@@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level)
|
||||
return kError;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
UNREACHABLE("ripple::Logs::toSeverity : invalid severity");
|
||||
UNREACHABLE("xrpl::Logs::toSeverity : invalid severity");
|
||||
[[fallthrough]];
|
||||
// LCOV_EXCL_STOP
|
||||
case lsFATAL:
|
||||
@@ -279,7 +279,7 @@ Logs::toString(LogSeverity s)
|
||||
return "Fatal";
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
UNREACHABLE("ripple::Logs::toString : invalid severity");
|
||||
UNREACHABLE("xrpl::Logs::toString : invalid severity");
|
||||
return "Unknown";
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -345,7 +345,7 @@ Logs::format(
|
||||
break;
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
UNREACHABLE("ripple::Logs::format : invalid severity");
|
||||
UNREACHABLE("xrpl::Logs::format : invalid severity");
|
||||
[[fallthrough]];
|
||||
// LCOV_EXCL_STOP
|
||||
case kFatal:
|
||||
@@ -459,4 +459,4 @@ debugLog()
|
||||
return beast::Journal(debugSink().get());
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -20,7 +20,7 @@ using uint128_t = boost::multiprecision::uint128_t;
|
||||
using uint128_t = __uint128_t;
|
||||
#endif // !defined(_MSC_VER)
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
thread_local Number::rounding_mode Number::mode_ = Number::to_nearest;
|
||||
|
||||
@@ -74,6 +74,18 @@ public:
|
||||
// tie, round towards even.
|
||||
int
|
||||
round() noexcept;
|
||||
|
||||
// Modify the result to the correctly rounded value
|
||||
void
|
||||
doRoundUp(rep& mantissa, int& exponent, std::string location);
|
||||
|
||||
// Modify the result to the correctly rounded value
|
||||
void
|
||||
doRoundDown(rep& mantissa, int& exponent);
|
||||
|
||||
// Modify the result to the correctly rounded value
|
||||
void
|
||||
doRound(rep& drops);
|
||||
};
|
||||
|
||||
inline void
|
||||
@@ -151,6 +163,61 @@ Number::Guard::round() noexcept
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Number::Guard::doRoundUp(rep& mantissa, int& exponent, std::string location)
|
||||
{
|
||||
auto r = round();
|
||||
if (r == 1 || (r == 0 && (mantissa & 1) == 1))
|
||||
{
|
||||
++mantissa;
|
||||
if (mantissa > maxMantissa)
|
||||
{
|
||||
mantissa /= 10;
|
||||
++exponent;
|
||||
}
|
||||
}
|
||||
if (exponent < minExponent)
|
||||
{
|
||||
mantissa = 0;
|
||||
exponent = Number{}.exponent_;
|
||||
}
|
||||
if (exponent > maxExponent)
|
||||
throw std::overflow_error(location);
|
||||
}
|
||||
|
||||
void
|
||||
Number::Guard::doRoundDown(rep& mantissa, int& exponent)
|
||||
{
|
||||
auto r = round();
|
||||
if (r == 1 || (r == 0 && (mantissa & 1) == 1))
|
||||
{
|
||||
--mantissa;
|
||||
if (mantissa < minMantissa)
|
||||
{
|
||||
mantissa *= 10;
|
||||
--exponent;
|
||||
}
|
||||
}
|
||||
if (exponent < minExponent)
|
||||
{
|
||||
mantissa = 0;
|
||||
exponent = Number{}.exponent_;
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the result to the correctly rounded value
|
||||
void
|
||||
Number::Guard::doRound(rep& drops)
|
||||
{
|
||||
auto r = round();
|
||||
if (r == 1 || (r == 0 && (drops & 1) == 1))
|
||||
{
|
||||
++drops;
|
||||
}
|
||||
if (is_negative())
|
||||
drops = -drops;
|
||||
}
|
||||
|
||||
// Number
|
||||
|
||||
constexpr Number one{1000000000000000, -15, Number::unchecked{}};
|
||||
@@ -190,18 +257,7 @@ Number::normalize()
|
||||
return;
|
||||
}
|
||||
|
||||
auto r = g.round();
|
||||
if (r == 1 || (r == 0 && (mantissa_ & 1) == 1))
|
||||
{
|
||||
++mantissa_;
|
||||
if (mantissa_ > maxMantissa)
|
||||
{
|
||||
mantissa_ /= 10;
|
||||
++exponent_;
|
||||
}
|
||||
}
|
||||
if (exponent_ > maxExponent)
|
||||
throw std::overflow_error("Number::normalize 2");
|
||||
g.doRoundUp(mantissa_, exponent_, "Number::normalize 2");
|
||||
|
||||
if (negative)
|
||||
mantissa_ = -mantissa_;
|
||||
@@ -224,7 +280,7 @@ Number::operator+=(Number const& y)
|
||||
}
|
||||
XRPL_ASSERT(
|
||||
isnormal() && y.isnormal(),
|
||||
"ripple::Number::operator+=(Number) : is normal");
|
||||
"xrpl::Number::operator+=(Number) : is normal");
|
||||
auto xm = mantissa();
|
||||
auto xe = exponent();
|
||||
int xn = 1;
|
||||
@@ -273,18 +329,7 @@ Number::operator+=(Number const& y)
|
||||
xm /= 10;
|
||||
++xe;
|
||||
}
|
||||
auto r = g.round();
|
||||
if (r == 1 || (r == 0 && (xm & 1) == 1))
|
||||
{
|
||||
++xm;
|
||||
if (xm > maxMantissa)
|
||||
{
|
||||
xm /= 10;
|
||||
++xe;
|
||||
}
|
||||
}
|
||||
if (xe > maxExponent)
|
||||
throw std::overflow_error("Number::addition overflow");
|
||||
g.doRoundUp(xm, xe, "Number::addition overflow");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -304,21 +349,7 @@ Number::operator+=(Number const& y)
|
||||
xm -= g.pop();
|
||||
--xe;
|
||||
}
|
||||
auto r = g.round();
|
||||
if (r == 1 || (r == 0 && (xm & 1) == 1))
|
||||
{
|
||||
--xm;
|
||||
if (xm < minMantissa)
|
||||
{
|
||||
xm *= 10;
|
||||
--xe;
|
||||
}
|
||||
}
|
||||
if (xe < minExponent)
|
||||
{
|
||||
xm = 0;
|
||||
xe = Number{}.exponent_;
|
||||
}
|
||||
g.doRoundDown(xm, xe);
|
||||
}
|
||||
mantissa_ = xm * xn;
|
||||
exponent_ = xe;
|
||||
@@ -365,7 +396,7 @@ Number::operator*=(Number const& y)
|
||||
}
|
||||
XRPL_ASSERT(
|
||||
isnormal() && y.isnormal(),
|
||||
"ripple::Number::operator*=(Number) : is normal");
|
||||
"xrpl::Number::operator*=(Number) : is normal");
|
||||
auto xm = mantissa();
|
||||
auto xe = exponent();
|
||||
int xn = 1;
|
||||
@@ -398,30 +429,15 @@ Number::operator*=(Number const& y)
|
||||
}
|
||||
xm = static_cast<rep>(zm);
|
||||
xe = ze;
|
||||
auto r = g.round();
|
||||
if (r == 1 || (r == 0 && (xm & 1) == 1))
|
||||
{
|
||||
++xm;
|
||||
if (xm > maxMantissa)
|
||||
{
|
||||
xm /= 10;
|
||||
++xe;
|
||||
}
|
||||
}
|
||||
if (xe < minExponent)
|
||||
{
|
||||
xm = 0;
|
||||
xe = Number{}.exponent_;
|
||||
}
|
||||
if (xe > maxExponent)
|
||||
throw std::overflow_error(
|
||||
"Number::multiplication overflow : exponent is " +
|
||||
std::to_string(xe));
|
||||
g.doRoundUp(
|
||||
xm,
|
||||
xe,
|
||||
"Number::multiplication overflow : exponent is " + std::to_string(xe));
|
||||
mantissa_ = xm * zn;
|
||||
exponent_ = xe;
|
||||
XRPL_ASSERT(
|
||||
isnormal() || *this == Number{},
|
||||
"ripple::Number::operator*=(Number) : result is normal");
|
||||
"xrpl::Number::operator*=(Number) : result is normal");
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -481,17 +497,29 @@ Number::operator rep() const
|
||||
throw std::overflow_error("Number::operator rep() overflow");
|
||||
drops *= 10;
|
||||
}
|
||||
auto r = g.round();
|
||||
if (r == 1 || (r == 0 && (drops & 1) == 1))
|
||||
{
|
||||
++drops;
|
||||
}
|
||||
if (g.is_negative())
|
||||
drops = -drops;
|
||||
g.doRound(drops);
|
||||
}
|
||||
return drops;
|
||||
}
|
||||
|
||||
Number
|
||||
Number::truncate() const noexcept
|
||||
{
|
||||
if (exponent_ >= 0 || mantissa_ == 0)
|
||||
return *this;
|
||||
|
||||
Number ret = *this;
|
||||
while (ret.exponent_ < 0 && ret.mantissa_ != 0)
|
||||
{
|
||||
ret.exponent_ += 1;
|
||||
ret.mantissa_ /= rep(10);
|
||||
}
|
||||
// We are guaranteed that normalize() will never throw an exception
|
||||
// because exponent is either negative or zero at this point.
|
||||
ret.normalize();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string
|
||||
to_string(Number const& amount)
|
||||
{
|
||||
@@ -520,7 +548,7 @@ to_string(Number const& amount)
|
||||
}
|
||||
|
||||
XRPL_ASSERT(
|
||||
exponent + 43 > 0, "ripple::to_string(Number) : minimum exponent");
|
||||
exponent + 43 > 0, "xrpl::to_string(Number) : minimum exponent");
|
||||
|
||||
ptrdiff_t const pad_prefix = 27;
|
||||
ptrdiff_t const pad_suffix = 23;
|
||||
@@ -547,8 +575,7 @@ to_string(Number const& amount)
|
||||
pre_from += pad_prefix;
|
||||
|
||||
XRPL_ASSERT(
|
||||
post_to >= post_from,
|
||||
"ripple::to_string(Number) : first distance check");
|
||||
post_to >= post_from, "xrpl::to_string(Number) : first distance check");
|
||||
|
||||
pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; });
|
||||
|
||||
@@ -559,7 +586,7 @@ to_string(Number const& amount)
|
||||
|
||||
XRPL_ASSERT(
|
||||
post_to >= post_from,
|
||||
"ripple::to_string(Number) : second distance check");
|
||||
"xrpl::to_string(Number) : second distance check");
|
||||
|
||||
post_to = std::find_if(
|
||||
std::make_reverse_iterator(post_to),
|
||||
@@ -744,4 +771,4 @@ power(Number const& f, unsigned n, unsigned d)
|
||||
return root(power(f, n), d);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
/** Mix-in to track when all pending I/O is complete.
|
||||
Derived classes must be callable with this signature:
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
// Destroying the object with I/O pending? Not a clean exit!
|
||||
XRPL_ASSERT(
|
||||
m_pending.load() == 0,
|
||||
"ripple::AsyncObject::~AsyncObject : nothing pending");
|
||||
"xrpl::AsyncObject::~AsyncObject : nothing pending");
|
||||
}
|
||||
|
||||
/** RAII container that maintains the count of pending I/O.
|
||||
@@ -153,9 +153,9 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_work.empty(),
|
||||
"ripple::ResolverAsioImpl::~ResolverAsioImpl : no pending work");
|
||||
"xrpl::ResolverAsioImpl::~ResolverAsioImpl : no pending work");
|
||||
XRPL_ASSERT(
|
||||
m_stopped, "ripple::ResolverAsioImpl::~ResolverAsioImpl : stopped");
|
||||
m_stopped, "xrpl::ResolverAsioImpl::~ResolverAsioImpl : stopped");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -178,10 +178,10 @@ public:
|
||||
start() override
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_stopped == true, "ripple::ResolverAsioImpl::start : stopped");
|
||||
m_stopped == true, "xrpl::ResolverAsioImpl::start : stopped");
|
||||
XRPL_ASSERT(
|
||||
m_stop_called == false,
|
||||
"ripple::ResolverAsioImpl::start : not stopping");
|
||||
"xrpl::ResolverAsioImpl::start : not stopping");
|
||||
|
||||
if (m_stopped.exchange(false) == true)
|
||||
{
|
||||
@@ -229,10 +229,10 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_stop_called == false,
|
||||
"ripple::ResolverAsioImpl::resolve : not stopping");
|
||||
"xrpl::ResolverAsioImpl::resolve : not stopping");
|
||||
XRPL_ASSERT(
|
||||
!names.empty(),
|
||||
"ripple::ResolverAsioImpl::resolve : names non-empty");
|
||||
"xrpl::ResolverAsioImpl::resolve : names non-empty");
|
||||
|
||||
// TODO NIKB use rvalue references to construct and move
|
||||
// reducing cost.
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_stop_called == true,
|
||||
"ripple::ResolverAsioImpl::do_stop : stopping");
|
||||
"xrpl::ResolverAsioImpl::do_stop : stopping");
|
||||
|
||||
if (m_stopped.exchange(true) == false)
|
||||
{
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!names.empty(),
|
||||
"ripple::ResolverAsioImpl::do_resolve : names non-empty");
|
||||
"xrpl::ResolverAsioImpl::do_resolve : names non-empty");
|
||||
|
||||
if (m_stop_called == false)
|
||||
{
|
||||
@@ -450,4 +450,4 @@ ResolverAsio::New(boost::asio::io_context& io_context, beast::Journal journal)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Resolver::~Resolver() = default;
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
sqlBlobLiteral(Blob const& blob)
|
||||
@@ -136,4 +136,4 @@ isProperlyFormedTomlDomain(std::string_view domain)
|
||||
return boost::regex_match(domain.begin(), domain.end(), re);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::atomic<UptimeClock::rep> UptimeClock::now_{0}; // seconds since start
|
||||
std::atomic<bool> UptimeClock::stop_{false}; // stop update thread
|
||||
@@ -54,4 +54,4 @@ UptimeClock::now()
|
||||
return time_point{duration{now_}};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace base64 {
|
||||
|
||||
@@ -232,4 +232,4 @@ base64_decode(std::string_view data)
|
||||
return dest;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
LogThrow(std::string const& title)
|
||||
@@ -30,4 +30,4 @@ LogicError(std::string const& s) noexcept
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace openssl {
|
||||
namespace detail {
|
||||
|
||||
@@ -385,4 +385,4 @@ make_SSLContextAuthed(
|
||||
return context;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::optional<std::uint64_t>
|
||||
mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
|
||||
@@ -17,10 +17,10 @@ mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
|
||||
|
||||
result /= div;
|
||||
|
||||
if (result > ripple::muldiv_max)
|
||||
if (result > xrpl::muldiv_max)
|
||||
return std::nullopt;
|
||||
|
||||
return static_cast<std::uint64_t>(result);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include <xrpld/core/Job.h>
|
||||
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
#include <xrpl/core/Job.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Job::Job() : mType(jtINVALID), mJobIndex(0)
|
||||
{
|
||||
@@ -101,4 +100,4 @@ Job::operator<=(Job const& j) const
|
||||
return mJobIndex <= j.mJobIndex;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
@@ -1,11 +1,10 @@
|
||||
#include <xrpld/core/JobQueue.h>
|
||||
#include <xrpld/perflog/PerfLog.h>
|
||||
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/core/JobQueue.h>
|
||||
#include <xrpl/core/PerfLog.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
JobQueue::JobQueue(
|
||||
int threadCount,
|
||||
@@ -39,8 +38,7 @@ JobQueue::JobQueue(
|
||||
std::forward_as_tuple(jt.type()),
|
||||
std::forward_as_tuple(jt, m_collector, logs)));
|
||||
XRPL_ASSERT(
|
||||
result.second == true,
|
||||
"ripple::JobQueue::JobQueue : jobs added");
|
||||
result.second == true, "xrpl::JobQueue::JobQueue : jobs added");
|
||||
(void)result.second;
|
||||
}
|
||||
}
|
||||
@@ -67,12 +65,12 @@ JobQueue::addRefCountedJob(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
type != jtINVALID,
|
||||
"ripple::JobQueue::addRefCountedJob : valid input job type");
|
||||
"xrpl::JobQueue::addRefCountedJob : valid input job type");
|
||||
|
||||
auto iter(m_jobData.find(type));
|
||||
XRPL_ASSERT(
|
||||
iter != m_jobData.end(),
|
||||
"ripple::JobQueue::addRefCountedJob : job type found in jobs");
|
||||
"xrpl::JobQueue::addRefCountedJob : job type found in jobs");
|
||||
if (iter == m_jobData.end())
|
||||
return false;
|
||||
|
||||
@@ -85,7 +83,7 @@ JobQueue::addRefCountedJob(
|
||||
XRPL_ASSERT(
|
||||
(type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) ||
|
||||
m_workers.getNumberOfThreads() > 0,
|
||||
"ripple::JobQueue::addRefCountedJob : threads available or job "
|
||||
"xrpl::JobQueue::addRefCountedJob : threads available or job "
|
||||
"requires no threads");
|
||||
|
||||
{
|
||||
@@ -97,10 +95,10 @@ JobQueue::addRefCountedJob(
|
||||
JobType const type(job.getType());
|
||||
XRPL_ASSERT(
|
||||
type != jtINVALID,
|
||||
"ripple::JobQueue::addRefCountedJob : has valid job type");
|
||||
"xrpl::JobQueue::addRefCountedJob : has valid job type");
|
||||
XRPL_ASSERT(
|
||||
m_jobSet.find(job) != m_jobSet.end(),
|
||||
"ripple::JobQueue::addRefCountedJob : job found");
|
||||
"xrpl::JobQueue::addRefCountedJob : job found");
|
||||
perfLog_.jobQueue(type);
|
||||
|
||||
JobTypeData& data(getJobTypeData(type));
|
||||
@@ -162,7 +160,7 @@ JobQueue::makeLoadEvent(JobType t, std::string const& name)
|
||||
JobDataMap::iterator iter(m_jobData.find(t));
|
||||
XRPL_ASSERT(
|
||||
iter != m_jobData.end(),
|
||||
"ripple::JobQueue::makeLoadEvent : valid job type input");
|
||||
"xrpl::JobQueue::makeLoadEvent : valid job type input");
|
||||
|
||||
if (iter == m_jobData.end())
|
||||
return {};
|
||||
@@ -179,7 +177,7 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed)
|
||||
JobDataMap::iterator iter(m_jobData.find(t));
|
||||
XRPL_ASSERT(
|
||||
iter != m_jobData.end(),
|
||||
"ripple::JobQueue::addLoadEvents : valid job type input");
|
||||
"xrpl::JobQueue::addLoadEvents : valid job type input");
|
||||
iter->second.load().addSamples(count, elapsed);
|
||||
}
|
||||
|
||||
@@ -206,7 +204,7 @@ JobQueue::getJson(int c)
|
||||
for (auto& x : m_jobData)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
x.first != jtINVALID, "ripple::JobQueue::getJson : valid job type");
|
||||
x.first != jtINVALID, "xrpl::JobQueue::getJson : valid job type");
|
||||
|
||||
if (x.first == jtGENERIC)
|
||||
continue;
|
||||
@@ -263,7 +261,7 @@ JobQueue::getJobTypeData(JobType type)
|
||||
JobDataMap::iterator c(m_jobData.find(type));
|
||||
XRPL_ASSERT(
|
||||
c != m_jobData.end(),
|
||||
"ripple::JobQueue::getJobTypeData : valid job type input");
|
||||
"xrpl::JobQueue::getJobTypeData : valid job type input");
|
||||
|
||||
// NIKB: This is ugly and I hate it. We must remove jtINVALID completely
|
||||
// and use something sane.
|
||||
@@ -290,11 +288,11 @@ JobQueue::stop()
|
||||
lock, [this] { return m_processCount == 0 && m_jobSet.empty(); });
|
||||
XRPL_ASSERT(
|
||||
m_processCount == 0,
|
||||
"ripple::JobQueue::stop : all processes completed");
|
||||
"xrpl::JobQueue::stop : all processes completed");
|
||||
XRPL_ASSERT(
|
||||
m_jobSet.empty(), "ripple::JobQueue::stop : all jobs completed");
|
||||
m_jobSet.empty(), "xrpl::JobQueue::stop : all jobs completed");
|
||||
XRPL_ASSERT(
|
||||
nSuspend_ == 0, "ripple::JobQueue::stop : no coros suspended");
|
||||
nSuspend_ == 0, "xrpl::JobQueue::stop : no coros suspended");
|
||||
stopped_ = true;
|
||||
}
|
||||
}
|
||||
@@ -309,26 +307,26 @@ void
|
||||
JobQueue::getNextJob(Job& job)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!m_jobSet.empty(), "ripple::JobQueue::getNextJob : non-empty jobs");
|
||||
!m_jobSet.empty(), "xrpl::JobQueue::getNextJob : non-empty jobs");
|
||||
|
||||
std::set<Job>::const_iterator iter;
|
||||
for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter)
|
||||
{
|
||||
JobType const type = iter->getType();
|
||||
XRPL_ASSERT(
|
||||
type != jtINVALID, "ripple::JobQueue::getNextJob : valid job type");
|
||||
type != jtINVALID, "xrpl::JobQueue::getNextJob : valid job type");
|
||||
|
||||
JobTypeData& data(getJobTypeData(type));
|
||||
XRPL_ASSERT(
|
||||
data.running <= getJobLimit(type),
|
||||
"ripple::JobQueue::getNextJob : maximum jobs running");
|
||||
"xrpl::JobQueue::getNextJob : maximum jobs running");
|
||||
|
||||
// Run this job if we're running below the limit.
|
||||
if (data.running < getJobLimit(data.type()))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
data.waiting > 0,
|
||||
"ripple::JobQueue::getNextJob : positive data waiting");
|
||||
"xrpl::JobQueue::getNextJob : positive data waiting");
|
||||
--data.waiting;
|
||||
++data.running;
|
||||
break;
|
||||
@@ -336,8 +334,7 @@ JobQueue::getNextJob(Job& job)
|
||||
}
|
||||
|
||||
XRPL_ASSERT(
|
||||
iter != m_jobSet.end(),
|
||||
"ripple::JobQueue::getNextJob : found next job");
|
||||
iter != m_jobSet.end(), "xrpl::JobQueue::getNextJob : found next job");
|
||||
job = *iter;
|
||||
m_jobSet.erase(iter);
|
||||
}
|
||||
@@ -346,8 +343,7 @@ void
|
||||
JobQueue::finishJob(JobType type)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
type != jtINVALID,
|
||||
"ripple::JobQueue::finishJob : valid input job type");
|
||||
type != jtINVALID, "xrpl::JobQueue::finishJob : valid input job type");
|
||||
|
||||
JobTypeData& data = getJobTypeData(type);
|
||||
|
||||
@@ -356,7 +352,7 @@ JobQueue::finishJob(JobType type)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
data.running + data.waiting >= getJobLimit(type),
|
||||
"ripple::JobQueue::finishJob : job limit");
|
||||
"xrpl::JobQueue::finishJob : job limit");
|
||||
|
||||
--data.deferred;
|
||||
m_workers.addTask();
|
||||
@@ -423,10 +419,9 @@ JobQueue::getJobLimit(JobType type)
|
||||
{
|
||||
JobTypeInfo const& j(JobTypes::instance().get(type));
|
||||
XRPL_ASSERT(
|
||||
j.type() != jtINVALID,
|
||||
"ripple::JobQueue::getJobLimit : valid job type");
|
||||
j.type() != jtINVALID, "xrpl::JobQueue::getJobLimit : valid job type");
|
||||
|
||||
return j.limit();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <xrpld/core/LoadEvent.h>
|
||||
#include <xrpld/core/LoadMonitor.h>
|
||||
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/core/LoadEvent.h>
|
||||
#include <xrpl/core/LoadMonitor.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
LoadEvent::LoadEvent(
|
||||
LoadMonitor& monitor,
|
||||
@@ -64,7 +63,7 @@ LoadEvent::start()
|
||||
void
|
||||
LoadEvent::stop()
|
||||
{
|
||||
XRPL_ASSERT(running_, "ripple::LoadEvent::stop : is running");
|
||||
XRPL_ASSERT(running_, "xrpl::LoadEvent::stop : is running");
|
||||
|
||||
auto const now = std::chrono::steady_clock::now();
|
||||
|
||||
@@ -75,4 +74,4 @@ LoadEvent::stop()
|
||||
monitor_.addLoadSample(*this);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <xrpld/core/LoadMonitor.h>
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/UptimeClock.h>
|
||||
#include <xrpl/core/LoadMonitor.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
/*
|
||||
|
||||
@@ -183,4 +182,4 @@ LoadMonitor::getStats()
|
||||
return stats;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <xrpld/core/detail/Workers.h>
|
||||
#include <xrpld/perflog/PerfLog.h>
|
||||
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/core/PerfLog.h>
|
||||
#include <xrpl/core/detail/Workers.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Workers::Workers(
|
||||
Callback& callback,
|
||||
@@ -103,7 +102,7 @@ Workers::stop()
|
||||
|
||||
XRPL_ASSERT(
|
||||
numberOfCurrentlyRunningTasks() == 0,
|
||||
"ripple::Workers::stop : zero running tasks");
|
||||
"xrpl::Workers::stop : zero running tasks");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -261,4 +260,4 @@ Workers::Worker::run()
|
||||
} while (!shouldExit);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
//
|
||||
// RFC 1751 code converted to C++/Boost.
|
||||
@@ -260,12 +260,12 @@ RFC1751::extract(char const* s, int start, int length)
|
||||
unsigned char cr;
|
||||
unsigned long x;
|
||||
|
||||
XRPL_ASSERT(length <= 11, "ripple::RFC1751::extract : maximum length");
|
||||
XRPL_ASSERT(start >= 0, "ripple::RFC1751::extract : minimum start");
|
||||
XRPL_ASSERT(length >= 0, "ripple::RFC1751::extract : minimum length");
|
||||
XRPL_ASSERT(length <= 11, "xrpl::RFC1751::extract : maximum length");
|
||||
XRPL_ASSERT(start >= 0, "xrpl::RFC1751::extract : minimum start");
|
||||
XRPL_ASSERT(length >= 0, "xrpl::RFC1751::extract : minimum length");
|
||||
XRPL_ASSERT(
|
||||
start + length <= 66,
|
||||
"ripple::RFC1751::extract : maximum start + length");
|
||||
"xrpl::RFC1751::extract : maximum start + length");
|
||||
|
||||
int const shiftR = 24 - (length + (start % 8));
|
||||
cl = s[start / 8]; // get components
|
||||
@@ -312,12 +312,11 @@ RFC1751::insert(char* s, int x, int start, int length)
|
||||
unsigned long y;
|
||||
int shift;
|
||||
|
||||
XRPL_ASSERT(length <= 11, "ripple::RFC1751::insert : maximum length");
|
||||
XRPL_ASSERT(start >= 0, "ripple::RFC1751::insert : minimum start");
|
||||
XRPL_ASSERT(length >= 0, "ripple::RFC1751::insert : minimum length");
|
||||
XRPL_ASSERT(length <= 11, "xrpl::RFC1751::insert : maximum length");
|
||||
XRPL_ASSERT(start >= 0, "xrpl::RFC1751::insert : minimum start");
|
||||
XRPL_ASSERT(length >= 0, "xrpl::RFC1751::insert : minimum length");
|
||||
XRPL_ASSERT(
|
||||
start + length <= 66,
|
||||
"ripple::RFC1751::insert : maximum start + length");
|
||||
start + length <= 66, "xrpl::RFC1751::insert : maximum start + length");
|
||||
|
||||
shift = ((8 - ((start + length) % 8)) % 8);
|
||||
y = (long)x << shift;
|
||||
@@ -508,4 +507,4 @@ RFC1751::getWordFromBlob(void const* blob, size_t bytes)
|
||||
[hash % (sizeof(s_dictionary) / sizeof(s_dictionary[0]))];
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <random>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
csprng_engine::csprng_engine()
|
||||
{
|
||||
@@ -87,4 +87,4 @@ crypto_prng()
|
||||
return engine;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
secure_erase(void* dest, std::size_t bytes)
|
||||
@@ -12,4 +12,4 @@ secure_erase(void* dest, std::size_t bytes)
|
||||
OPENSSL_cleanse(dest, bytes);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
JsonPropertyStream::JsonPropertyStream() : m_top(Json::objectValue)
|
||||
{
|
||||
@@ -161,4 +161,4 @@ JsonPropertyStream::add(std::string const& v)
|
||||
m_stack.back()->append(v);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/json/Object.h>
|
||||
#include <xrpl/json/Output.h>
|
||||
#include <xrpl/json/Writer.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace Json {
|
||||
|
||||
Collection::Collection(Collection* parent, Writer* writer)
|
||||
: parent_(parent), writer_(writer), enabled_(true)
|
||||
{
|
||||
checkWritable("Collection::Collection()");
|
||||
if (parent_)
|
||||
{
|
||||
check(parent_->enabled_, "Parent not enabled in constructor");
|
||||
parent_->enabled_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
Collection::~Collection()
|
||||
{
|
||||
if (writer_)
|
||||
writer_->finish();
|
||||
if (parent_)
|
||||
parent_->enabled_ = true;
|
||||
}
|
||||
|
||||
Collection&
|
||||
Collection::operator=(Collection&& that) noexcept
|
||||
{
|
||||
parent_ = that.parent_;
|
||||
writer_ = that.writer_;
|
||||
enabled_ = that.enabled_;
|
||||
|
||||
that.parent_ = nullptr;
|
||||
that.writer_ = nullptr;
|
||||
that.enabled_ = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Collection::Collection(Collection&& that) noexcept
|
||||
{
|
||||
*this = std::move(that);
|
||||
}
|
||||
|
||||
void
|
||||
Collection::checkWritable(std::string const& label)
|
||||
{
|
||||
if (!enabled_)
|
||||
ripple::Throw<std::logic_error>(label + ": not enabled");
|
||||
if (!writer_)
|
||||
ripple::Throw<std::logic_error>(label + ": not writable");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Object::Root::Root(Writer& w) : Object(nullptr, &w)
|
||||
{
|
||||
writer_->startRoot(Writer::object);
|
||||
}
|
||||
|
||||
Object
|
||||
Object::setObject(std::string const& key)
|
||||
{
|
||||
checkWritable("Object::setObject");
|
||||
if (writer_)
|
||||
writer_->startSet(Writer::object, key);
|
||||
return Object(this, writer_);
|
||||
}
|
||||
|
||||
Array
|
||||
Object::setArray(std::string const& key)
|
||||
{
|
||||
checkWritable("Object::setArray");
|
||||
if (writer_)
|
||||
writer_->startSet(Writer::array, key);
|
||||
return Array(this, writer_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Object
|
||||
Array::appendObject()
|
||||
{
|
||||
checkWritable("Array::appendObject");
|
||||
if (writer_)
|
||||
writer_->startAppend(Writer::object);
|
||||
return Object(this, writer_);
|
||||
}
|
||||
|
||||
Array
|
||||
Array::appendArray()
|
||||
{
|
||||
checkWritable("Array::makeArray");
|
||||
if (writer_)
|
||||
writer_->startAppend(Writer::array);
|
||||
return Array(this, writer_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Object::Proxy::Proxy(Object& object, std::string const& key)
|
||||
: object_(object), key_(key)
|
||||
{
|
||||
}
|
||||
|
||||
Object::Proxy
|
||||
Object::operator[](std::string const& key)
|
||||
{
|
||||
return Proxy(*this, key);
|
||||
}
|
||||
|
||||
Object::Proxy
|
||||
Object::operator[](Json::StaticString const& key)
|
||||
{
|
||||
return Proxy(*this, std::string(key));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
Array::append(Json::Value const& v)
|
||||
{
|
||||
auto t = v.type();
|
||||
switch (t)
|
||||
{
|
||||
case Json::nullValue:
|
||||
return append(nullptr);
|
||||
case Json::intValue:
|
||||
return append(v.asInt());
|
||||
case Json::uintValue:
|
||||
return append(v.asUInt());
|
||||
case Json::realValue:
|
||||
return append(v.asDouble());
|
||||
case Json::stringValue:
|
||||
return append(v.asString());
|
||||
case Json::booleanValue:
|
||||
return append(v.asBool());
|
||||
|
||||
case Json::objectValue: {
|
||||
auto object = appendObject();
|
||||
copyFrom(object, v);
|
||||
return;
|
||||
}
|
||||
|
||||
case Json::arrayValue: {
|
||||
auto array = appendArray();
|
||||
for (auto& item : v)
|
||||
array.append(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Json::Array::append : invalid type"); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
void
|
||||
Object::set(std::string const& k, Json::Value const& v)
|
||||
{
|
||||
auto t = v.type();
|
||||
switch (t)
|
||||
{
|
||||
case Json::nullValue:
|
||||
return set(k, nullptr);
|
||||
case Json::intValue:
|
||||
return set(k, v.asInt());
|
||||
case Json::uintValue:
|
||||
return set(k, v.asUInt());
|
||||
case Json::realValue:
|
||||
return set(k, v.asDouble());
|
||||
case Json::stringValue:
|
||||
return set(k, v.asString());
|
||||
case Json::booleanValue:
|
||||
return set(k, v.asBool());
|
||||
|
||||
case Json::objectValue: {
|
||||
auto object = setObject(k);
|
||||
copyFrom(object, v);
|
||||
return;
|
||||
}
|
||||
|
||||
case Json::arrayValue: {
|
||||
auto array = setArray(k);
|
||||
for (auto& item : v)
|
||||
array.append(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
UNREACHABLE("Json::Object::set : invalid type"); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
template <class Object>
|
||||
void
|
||||
doCopyFrom(Object& to, Json::Value const& from)
|
||||
{
|
||||
XRPL_ASSERT(from.isObjectOrNull(), "Json::doCopyFrom : valid input type");
|
||||
auto members = from.getMemberNames();
|
||||
for (auto& m : members)
|
||||
to[m] = from[m];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void
|
||||
copyFrom(Json::Value& to, Json::Value const& from)
|
||||
{
|
||||
if (!to) // Short circuit this very common case.
|
||||
to = from;
|
||||
else
|
||||
doCopyFrom(to, from);
|
||||
}
|
||||
|
||||
void
|
||||
copyFrom(Object& to, Json::Value const& from)
|
||||
{
|
||||
doCopyFrom(to, from);
|
||||
}
|
||||
|
||||
WriterObject
|
||||
stringWriterObject(std::string& s)
|
||||
{
|
||||
return WriterObject(stringOutput(s));
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
@@ -263,14 +263,14 @@ Writer::output(Json::Value const& value)
|
||||
void
|
||||
Writer::output(float f)
|
||||
{
|
||||
auto s = ripple::to_string(f);
|
||||
auto s = xrpl::to_string(f);
|
||||
impl_->output({s.data(), lengthWithoutTrailingZeros(s)});
|
||||
}
|
||||
|
||||
void
|
||||
Writer::output(double f)
|
||||
{
|
||||
auto s = ripple::to_string(f);
|
||||
auto s = xrpl::to_string(f);
|
||||
impl_->output({s.data(), lengthWithoutTrailingZeros(s)});
|
||||
}
|
||||
|
||||
|
||||
@@ -941,7 +941,7 @@ operator>>(std::istream& sin, Value& root)
|
||||
|
||||
// XRPL_ASSERT(ok, "Json::operator>>() : parse succeeded");
|
||||
if (!ok)
|
||||
ripple::Throw<std::runtime_error>(reader.getFormatedErrorMessages());
|
||||
xrpl::Throw<std::runtime_error>(reader.getFormatedErrorMessages());
|
||||
|
||||
return sin;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ Value::Value(char const* value) : type_(stringValue), allocated_(true)
|
||||
value_.string_ = valueAllocator()->duplicateStringValue(value);
|
||||
}
|
||||
|
||||
Value::Value(ripple::Number const& value) : type_(stringValue), allocated_(true)
|
||||
Value::Value(xrpl::Number const& value) : type_(stringValue), allocated_(true)
|
||||
{
|
||||
auto const tmp = to_string(value);
|
||||
value_.string_ =
|
||||
@@ -1042,6 +1042,12 @@ Value::isMember(std::string const& key) const
|
||||
return isMember(key.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
Value::isMember(StaticString const& key) const
|
||||
{
|
||||
return isMember(key.c_str());
|
||||
}
|
||||
|
||||
Value::Members
|
||||
Value::getMemberNames() const
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/st.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
void
|
||||
@@ -143,7 +143,7 @@ ApplyStateTable::apply(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
origNode && curNode,
|
||||
"ripple::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"xrpl::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"deletion");
|
||||
threadOwners(to, meta, origNode, newMod, j);
|
||||
|
||||
@@ -178,7 +178,7 @@ ApplyStateTable::apply(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
curNode && origNode,
|
||||
"ripple::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"xrpl::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"modification");
|
||||
|
||||
if (curNode->isThreadedType(
|
||||
@@ -216,7 +216,7 @@ ApplyStateTable::apply(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
curNode && !origNode,
|
||||
"ripple::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"xrpl::detail::ApplyStateTable::apply : valid nodes for "
|
||||
"creation");
|
||||
threadOwners(to, meta, curNode, newMod, j);
|
||||
|
||||
@@ -242,7 +242,7 @@ ApplyStateTable::apply(
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::detail::ApplyStateTable::apply : unsupported "
|
||||
"xrpl::detail::ApplyStateTable::apply : unsupported "
|
||||
"operation type");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -547,7 +547,7 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr<SLE> const& sle)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
node.getFieldIndex(sfPreviousTxnLgrSeq) == -1,
|
||||
"ripple::ApplyStateTable::threadItem : previous ledger is not "
|
||||
"xrpl::ApplyStateTable::threadItem : previous ledger is not "
|
||||
"set");
|
||||
node.setFieldH256(sfPreviousTxnID, prevTxID);
|
||||
node.setFieldU32(sfPreviousTxnLgrSeq, prevLgrID);
|
||||
@@ -555,11 +555,11 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr<SLE> const& sle)
|
||||
|
||||
XRPL_ASSERT(
|
||||
node.getFieldH256(sfPreviousTxnID) == prevTxID,
|
||||
"ripple::ApplyStateTable::threadItem : previous transaction is a "
|
||||
"xrpl::ApplyStateTable::threadItem : previous transaction is a "
|
||||
"match");
|
||||
XRPL_ASSERT(
|
||||
node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID,
|
||||
"ripple::ApplyStateTable::threadItem : previous ledger is a match");
|
||||
"xrpl::ApplyStateTable::threadItem : previous ledger is a match");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ ApplyStateTable::getForMod(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
miter->second,
|
||||
"ripple::ApplyStateTable::getForMod : non-null result");
|
||||
"xrpl::ApplyStateTable::getForMod : non-null result");
|
||||
return miter->second;
|
||||
}
|
||||
}
|
||||
@@ -634,7 +634,7 @@ ApplyStateTable::threadTx(
|
||||
// threadItem only applied to AccountRoot
|
||||
XRPL_ASSERT(
|
||||
sle->isThreadedType(base.rules()),
|
||||
"ripple::ApplyStateTable::threadTx : SLE is threaded");
|
||||
"xrpl::ApplyStateTable::threadTx : SLE is threaded");
|
||||
threadItem(meta, sle);
|
||||
}
|
||||
|
||||
@@ -671,4 +671,4 @@ ApplyStateTable::threadOwners(
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -6,75 +6,97 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::optional<std::uint64_t>
|
||||
ApplyView::dirAdd(
|
||||
bool preserveOrder,
|
||||
namespace directory {
|
||||
|
||||
std::uint64_t
|
||||
createRoot(
|
||||
ApplyView& view,
|
||||
Keylet const& directory,
|
||||
uint256 const& key,
|
||||
std::function<void(std::shared_ptr<SLE> const&)> const& describe)
|
||||
{
|
||||
auto root = peek(directory);
|
||||
auto newRoot = std::make_shared<SLE>(directory);
|
||||
newRoot->setFieldH256(sfRootIndex, directory.key);
|
||||
describe(newRoot);
|
||||
|
||||
if (!root)
|
||||
{
|
||||
// No root, make it.
|
||||
root = std::make_shared<SLE>(directory);
|
||||
root->setFieldH256(sfRootIndex, directory.key);
|
||||
describe(root);
|
||||
STVector256 v;
|
||||
v.push_back(key);
|
||||
newRoot->setFieldV256(sfIndexes, v);
|
||||
|
||||
STVector256 v;
|
||||
v.push_back(key);
|
||||
root->setFieldV256(sfIndexes, v);
|
||||
view.insert(newRoot);
|
||||
return std::uint64_t{0};
|
||||
}
|
||||
|
||||
insert(root);
|
||||
return std::uint64_t{0};
|
||||
}
|
||||
auto
|
||||
findPreviousPage(ApplyView& view, Keylet const& directory, SLE::ref start)
|
||||
{
|
||||
std::uint64_t page = start->getFieldU64(sfIndexPrevious);
|
||||
|
||||
std::uint64_t page = root->getFieldU64(sfIndexPrevious);
|
||||
|
||||
auto node = root;
|
||||
auto node = start;
|
||||
|
||||
if (page)
|
||||
{
|
||||
node = peek(keylet::page(directory, page));
|
||||
node = view.peek(keylet::page(directory, page));
|
||||
if (!node)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: root back-pointer broken.");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
|
||||
auto indexes = node->getFieldV256(sfIndexes);
|
||||
return std::make_tuple(page, node, indexes);
|
||||
}
|
||||
|
||||
// If there's space, we use it:
|
||||
if (indexes.size() < dirNodeMaxEntries)
|
||||
std::uint64_t
|
||||
insertKey(
|
||||
ApplyView& view,
|
||||
SLE::ref node,
|
||||
std::uint64_t page,
|
||||
bool preserveOrder,
|
||||
STVector256& indexes,
|
||||
uint256 const& key)
|
||||
{
|
||||
if (preserveOrder)
|
||||
{
|
||||
if (preserveOrder)
|
||||
{
|
||||
if (std::find(indexes.begin(), indexes.end(), key) != indexes.end())
|
||||
LogicError("dirInsert: double insertion");
|
||||
if (std::find(indexes.begin(), indexes.end(), key) != indexes.end())
|
||||
LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE
|
||||
|
||||
indexes.push_back(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can't be sure if this page is already sorted because
|
||||
// it may be a legacy page we haven't yet touched. Take
|
||||
// the time to sort it.
|
||||
std::sort(indexes.begin(), indexes.end());
|
||||
indexes.push_back(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can't be sure if this page is already sorted because
|
||||
// it may be a legacy page we haven't yet touched. Take
|
||||
// the time to sort it.
|
||||
std::sort(indexes.begin(), indexes.end());
|
||||
|
||||
auto pos = std::lower_bound(indexes.begin(), indexes.end(), key);
|
||||
auto pos = std::lower_bound(indexes.begin(), indexes.end(), key);
|
||||
|
||||
if (pos != indexes.end() && key == *pos)
|
||||
LogicError("dirInsert: double insertion");
|
||||
if (pos != indexes.end() && key == *pos)
|
||||
LogicError("dirInsert: double insertion"); // LCOV_EXCL_LINE
|
||||
|
||||
indexes.insert(pos, key);
|
||||
}
|
||||
|
||||
node->setFieldV256(sfIndexes, indexes);
|
||||
update(node);
|
||||
return page;
|
||||
indexes.insert(pos, key);
|
||||
}
|
||||
|
||||
node->setFieldV256(sfIndexes, indexes);
|
||||
view.update(node);
|
||||
return page;
|
||||
}
|
||||
|
||||
std::optional<std::uint64_t>
|
||||
insertPage(
|
||||
ApplyView& view,
|
||||
std::uint64_t page,
|
||||
SLE::pointer node,
|
||||
std::uint64_t nextPage,
|
||||
SLE::ref next,
|
||||
uint256 const& key,
|
||||
Keylet const& directory,
|
||||
std::function<void(std::shared_ptr<SLE> const&)> const& describe)
|
||||
{
|
||||
// We rely on modulo arithmetic of unsigned integers (guaranteed in
|
||||
// [basic.fundamental] paragraph 2) to detect page representation overflow.
|
||||
// For signed integers this would be UB, hence static_assert here.
|
||||
@@ -88,20 +110,20 @@ ApplyView::dirAdd(
|
||||
// Check whether we're out of pages.
|
||||
if (page == 0)
|
||||
return std::nullopt;
|
||||
if (!rules().enabled(fixDirectoryLimit) &&
|
||||
if (!view.rules().enabled(fixDirectoryLimit) &&
|
||||
page >= dirNodeMaxPages) // Old pages limit
|
||||
return std::nullopt;
|
||||
|
||||
// We are about to create a new node; we'll link it to
|
||||
// the chain first:
|
||||
node->setFieldU64(sfIndexNext, page);
|
||||
update(node);
|
||||
view.update(node);
|
||||
|
||||
root->setFieldU64(sfIndexPrevious, page);
|
||||
update(root);
|
||||
next->setFieldU64(sfIndexPrevious, page);
|
||||
view.update(next);
|
||||
|
||||
// Insert the new key:
|
||||
indexes.clear();
|
||||
STVector256 indexes;
|
||||
indexes.push_back(key);
|
||||
|
||||
node = std::make_shared<SLE>(keylet::page(directory, page));
|
||||
@@ -112,12 +134,50 @@ ApplyView::dirAdd(
|
||||
// it's the default.
|
||||
if (page != 1)
|
||||
node->setFieldU64(sfIndexPrevious, page - 1);
|
||||
XRPL_ASSERT_PARTS(
|
||||
!nextPage, "xrpl::directory::insertPage", "nextPage has default value");
|
||||
/* Reserved for future use when directory pages may be inserted in
|
||||
* between two other pages instead of only at the end of the chain.
|
||||
if (nextPage)
|
||||
node->setFieldU64(sfIndexNext, nextPage);
|
||||
*/
|
||||
describe(node);
|
||||
insert(node);
|
||||
view.insert(node);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
} // namespace directory
|
||||
|
||||
std::optional<std::uint64_t>
|
||||
ApplyView::dirAdd(
|
||||
bool preserveOrder,
|
||||
Keylet const& directory,
|
||||
uint256 const& key,
|
||||
std::function<void(std::shared_ptr<SLE> const&)> const& describe)
|
||||
{
|
||||
auto root = peek(directory);
|
||||
|
||||
if (!root)
|
||||
{
|
||||
// No root, make it.
|
||||
return directory::createRoot(*this, directory, key, describe);
|
||||
}
|
||||
|
||||
auto [page, node, indexes] =
|
||||
directory::findPreviousPage(*this, directory, root);
|
||||
|
||||
// If there's space, we use it:
|
||||
if (indexes.size() < dirNodeMaxEntries)
|
||||
{
|
||||
return directory::insertKey(
|
||||
*this, node, page, preserveOrder, indexes, key);
|
||||
}
|
||||
|
||||
return directory::insertPage(
|
||||
*this, page, node, 0, root, key, directory, describe);
|
||||
}
|
||||
|
||||
bool
|
||||
ApplyView::emptyDirDelete(Keylet const& directory)
|
||||
{
|
||||
@@ -131,7 +191,7 @@ ApplyView::emptyDirDelete(Keylet const& directory)
|
||||
node->getFieldH256(sfRootIndex) != directory.key)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::ApplyView::emptyDirDelete : invalid node type");
|
||||
UNREACHABLE("xrpl::ApplyView::emptyDirDelete : invalid node type");
|
||||
return false;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -145,10 +205,10 @@ ApplyView::emptyDirDelete(Keylet const& directory)
|
||||
auto nextPage = node->getFieldU64(sfIndexNext);
|
||||
|
||||
if (nextPage == rootPage && prevPage != rootPage)
|
||||
LogicError("Directory chain: fwd link broken");
|
||||
LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
|
||||
|
||||
if (prevPage == rootPage && nextPage != rootPage)
|
||||
LogicError("Directory chain: rev link broken");
|
||||
LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE
|
||||
|
||||
// Older versions of the code would, in some cases, allow the last
|
||||
// page to be empty. Remove such pages:
|
||||
@@ -157,7 +217,10 @@ ApplyView::emptyDirDelete(Keylet const& directory)
|
||||
auto last = peek(keylet::page(directory, nextPage));
|
||||
|
||||
if (!last)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: fwd link broken.");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (!last->getFieldV256(sfIndexes).empty())
|
||||
return false;
|
||||
@@ -229,10 +292,16 @@ ApplyView::dirRemove(
|
||||
if (page == rootPage)
|
||||
{
|
||||
if (nextPage == page && prevPage != page)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: fwd link broken");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (prevPage == page && nextPage != page)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: rev link broken");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
// Older versions of the code would, in some cases,
|
||||
// allow the last page to be empty. Remove such
|
||||
@@ -241,7 +310,10 @@ ApplyView::dirRemove(
|
||||
{
|
||||
auto last = peek(keylet::page(directory, nextPage));
|
||||
if (!last)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: fwd link broken.");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
if (last->getFieldV256(sfIndexes).empty())
|
||||
{
|
||||
@@ -273,10 +345,10 @@ ApplyView::dirRemove(
|
||||
|
||||
// This can never happen for nodes other than the root:
|
||||
if (nextPage == page)
|
||||
LogicError("Directory chain: fwd link broken");
|
||||
LogicError("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
|
||||
|
||||
if (prevPage == page)
|
||||
LogicError("Directory chain: rev link broken");
|
||||
LogicError("Directory chain: rev link broken"); // LCOV_EXCL_LINE
|
||||
|
||||
// This node isn't the root, so it can either be in the
|
||||
// middle of the list, or at the end. Unlink it first
|
||||
@@ -284,14 +356,14 @@ ApplyView::dirRemove(
|
||||
// root:
|
||||
auto prev = peek(keylet::page(directory, prevPage));
|
||||
if (!prev)
|
||||
LogicError("Directory chain: fwd link broken.");
|
||||
LogicError("Directory chain: fwd link broken."); // LCOV_EXCL_LINE
|
||||
// Fix previous to point to its new next.
|
||||
prev->setFieldU64(sfIndexNext, nextPage);
|
||||
update(prev);
|
||||
|
||||
auto next = peek(keylet::page(directory, nextPage));
|
||||
if (!next)
|
||||
LogicError("Directory chain: rev link broken.");
|
||||
LogicError("Directory chain: rev link broken."); // LCOV_EXCL_LINE
|
||||
// Fix next to point to its new previous.
|
||||
next->setFieldU64(sfIndexPrevious, prevPage);
|
||||
update(next);
|
||||
@@ -315,7 +387,10 @@ ApplyView::dirRemove(
|
||||
// And the root points to the last page:
|
||||
auto root = peek(keylet::page(directory, rootPage));
|
||||
if (!root)
|
||||
{ // LCOV_EXCL_START
|
||||
LogicError("Directory chain: root link broken.");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
root->setFieldU64(sfIndexPrevious, prevPage);
|
||||
update(root);
|
||||
|
||||
@@ -358,4 +433,4 @@ ApplyView::dirDelete(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/ledger/detail/ApplyViewBase.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
ApplyViewBase::ApplyViewBase(ReadView const* base, ApplyFlags flags)
|
||||
@@ -16,10 +16,10 @@ ApplyViewBase::open() const
|
||||
return base_->open();
|
||||
}
|
||||
|
||||
LedgerInfo const&
|
||||
ApplyViewBase::info() const
|
||||
LedgerHeader const&
|
||||
ApplyViewBase::header() const
|
||||
{
|
||||
return base_->info();
|
||||
return base_->header();
|
||||
}
|
||||
|
||||
Fees const&
|
||||
@@ -155,4 +155,4 @@ ApplyViewBase::rawDestroyXRP(XRPAmount const& fee)
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/ledger/ApplyViewImpl.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
ApplyViewImpl::ApplyViewImpl(ReadView const* base, ApplyFlags flags)
|
||||
: ApplyViewBase(base, flags)
|
||||
@@ -37,4 +37,4 @@ ApplyViewImpl::visit(
|
||||
items_.visit(to, func);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
BookDirs::BookDirs(ReadView const& view, Book const& book)
|
||||
: view_(&view)
|
||||
@@ -11,13 +11,13 @@ BookDirs::BookDirs(ReadView const& view, Book const& book)
|
||||
, key_(view_->succ(root_, next_quality_).value_or(beast::zero))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
root_ != beast::zero, "ripple::BookDirs::BookDirs : nonzero root");
|
||||
root_ != beast::zero, "xrpl::BookDirs::BookDirs : nonzero root");
|
||||
if (key_ != beast::zero)
|
||||
{
|
||||
if (!cdirFirst(*view_, key_, sle_, entry_, index_))
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::BookDirs::BookDirs : directory is empty");
|
||||
UNREACHABLE("xrpl::BookDirs::BookDirs : directory is empty");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ BookDirs::const_iterator::operator==(
|
||||
|
||||
XRPL_ASSERT(
|
||||
view_ == other.view_ && root_ == other.root_,
|
||||
"ripple::BookDirs::const_iterator::operator== : views and roots are "
|
||||
"xrpl::BookDirs::const_iterator::operator== : views and roots are "
|
||||
"matching");
|
||||
return entry_ == other.entry_ && cur_key_ == other.cur_key_ &&
|
||||
index_ == other.index_;
|
||||
@@ -66,7 +66,7 @@ BookDirs::const_iterator::operator*() const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
index_ != beast::zero,
|
||||
"ripple::BookDirs::const_iterator::operator* : nonzero index");
|
||||
"xrpl::BookDirs::const_iterator::operator* : nonzero index");
|
||||
if (!cache_)
|
||||
cache_ = view_->read(keylet::offer(index_));
|
||||
return *cache_;
|
||||
@@ -79,7 +79,7 @@ BookDirs::const_iterator::operator++()
|
||||
|
||||
XRPL_ASSERT(
|
||||
index_ != zero,
|
||||
"ripple::BookDirs::const_iterator::operator++ : nonzero index");
|
||||
"xrpl::BookDirs::const_iterator::operator++ : nonzero index");
|
||||
if (!cdirNext(*view_, cur_key_, sle_, entry_, index_))
|
||||
{
|
||||
if (index_ != 0 ||
|
||||
@@ -94,7 +94,7 @@ BookDirs::const_iterator::operator++()
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::BookDirs::const_iterator::operator++ : directory is "
|
||||
"xrpl::BookDirs::const_iterator::operator++ : directory is "
|
||||
"empty");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -109,10 +109,10 @@ BookDirs::const_iterator::operator++(int)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
index_ != beast::zero,
|
||||
"ripple::BookDirs::const_iterator::operator++(int) : nonzero index");
|
||||
"xrpl::BookDirs::const_iterator::operator++(int) : nonzero index");
|
||||
const_iterator tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <xrpl/basics/TaggedCache.ipp>
|
||||
#include <xrpl/ledger/CachedView.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
bool
|
||||
@@ -39,8 +39,7 @@ CachedViewImpl::read(Keylet const& k) const
|
||||
});
|
||||
// If the sle is null, then a failure must have occurred in base_.read()
|
||||
XRPL_ASSERT(
|
||||
sle || baseRead,
|
||||
"ripple::CachedView::read : null SLE result from base");
|
||||
sle || baseRead, "xrpl::CachedView::read : null SLE result from base");
|
||||
if (cacheHit && baseRead)
|
||||
hitsexpired.increment();
|
||||
else if (cacheHit)
|
||||
@@ -62,4 +61,4 @@ CachedViewImpl::read(Keylet const& k) const
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace credentials {
|
||||
|
||||
bool
|
||||
@@ -22,7 +22,7 @@ checkExpired(
|
||||
bool
|
||||
removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j)
|
||||
{
|
||||
auto const closeTime = view.info().parentCloseTime;
|
||||
auto const closeTime = view.header().parentCloseTime;
|
||||
bool foundExpired = false;
|
||||
|
||||
for (auto const& h : arr)
|
||||
@@ -185,7 +185,7 @@ validDomain(ReadView const& view, uint256 domainID, AccountID const& subject)
|
||||
if (!slePD)
|
||||
return tecOBJECT_NOT_FOUND;
|
||||
|
||||
auto const closeTime = view.info().parentCloseTime;
|
||||
auto const closeTime = view.header().parentCloseTime;
|
||||
bool foundExpired = false;
|
||||
for (auto const& h : slePD->getFieldArray(sfAcceptedCredentials))
|
||||
{
|
||||
@@ -378,4 +378,4 @@ verifyDepositPreauth(
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/ledger/Dir.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
using const_iterator = Dir::const_iterator;
|
||||
|
||||
@@ -43,7 +43,7 @@ const_iterator::operator==(const_iterator const& other) const
|
||||
|
||||
XRPL_ASSERT(
|
||||
view_ == other.view_ && root_.key == other.root_.key,
|
||||
"ripple::const_iterator::operator== : views and roots are matching");
|
||||
"xrpl::const_iterator::operator== : views and roots are matching");
|
||||
return page_.key == other.page_.key && index_ == other.index_;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ const_iterator::operator*() const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
index_ != beast::zero,
|
||||
"ripple::const_iterator::operator* : nonzero index");
|
||||
"xrpl::const_iterator::operator* : nonzero index");
|
||||
if (!cache_)
|
||||
cache_ = view_->read(keylet::child(index_));
|
||||
return *cache_;
|
||||
@@ -63,7 +63,7 @@ const_iterator::operator++()
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
index_ != beast::zero,
|
||||
"ripple::const_iterator::operator++ : nonzero index");
|
||||
"xrpl::const_iterator::operator++ : nonzero index");
|
||||
if (++it_ != std::end(*indexes_))
|
||||
{
|
||||
index_ = *it_;
|
||||
@@ -79,7 +79,7 @@ const_iterator::operator++(int)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
index_ != beast::zero,
|
||||
"ripple::const_iterator::operator++(int) : nonzero index");
|
||||
"xrpl::const_iterator::operator++(int) : nonzero index");
|
||||
const_iterator tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
@@ -98,7 +98,7 @@ const_iterator::next_page()
|
||||
{
|
||||
page_ = keylet::page(root_, next);
|
||||
sle_ = view_->read(page_);
|
||||
XRPL_ASSERT(sle_, "ripple::const_iterator::next_page : non-null SLE");
|
||||
XRPL_ASSERT(sle_, "xrpl::const_iterator::next_page : non-null SLE");
|
||||
indexes_ = &sle_->getFieldV256(sfIndexes);
|
||||
if (indexes_->empty())
|
||||
{
|
||||
@@ -120,4 +120,4 @@ const_iterator::page_size()
|
||||
return indexes_->size();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/ledger/OpenView.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
class OpenView::txs_iter_impl : public txs_type::iter_base
|
||||
{
|
||||
@@ -61,7 +61,7 @@ OpenView::OpenView(OpenView const& rhs)
|
||||
boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
|
||||
, txs_{rhs.txs_, monotonic_resource_.get()}
|
||||
, rules_{rhs.rules_}
|
||||
, info_{rhs.info_}
|
||||
, header_{rhs.header_}
|
||||
, base_{rhs.base_}
|
||||
, items_{rhs.items_}
|
||||
, hold_{rhs.hold_}
|
||||
@@ -76,15 +76,15 @@ OpenView::OpenView(
|
||||
boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
|
||||
, txs_{monotonic_resource_.get()}
|
||||
, rules_(rules)
|
||||
, info_(base->info())
|
||||
, header_(base->header())
|
||||
, base_(base)
|
||||
, hold_(std::move(hold))
|
||||
{
|
||||
info_.validated = false;
|
||||
info_.accepted = false;
|
||||
info_.seq = base_->info().seq + 1;
|
||||
info_.parentCloseTime = base_->info().closeTime;
|
||||
info_.parentHash = base_->info().hash;
|
||||
header_.validated = false;
|
||||
header_.accepted = false;
|
||||
header_.seq = base_->header().seq + 1;
|
||||
header_.parentCloseTime = base_->header().closeTime;
|
||||
header_.parentHash = base_->header().hash;
|
||||
}
|
||||
|
||||
OpenView::OpenView(ReadView const* base, std::shared_ptr<void const> hold)
|
||||
@@ -92,7 +92,7 @@ OpenView::OpenView(ReadView const* base, std::shared_ptr<void const> hold)
|
||||
boost::container::pmr::monotonic_buffer_resource>(initialBufferSize)}
|
||||
, txs_{monotonic_resource_.get()}
|
||||
, rules_(base->rules())
|
||||
, info_(base->info())
|
||||
, header_(base->header())
|
||||
, base_(base)
|
||||
, hold_(std::move(hold))
|
||||
, open_(base->open())
|
||||
@@ -115,10 +115,10 @@ OpenView::apply(TxsRawView& to) const
|
||||
|
||||
//---
|
||||
|
||||
LedgerInfo const&
|
||||
OpenView::info() const
|
||||
LedgerHeader const&
|
||||
OpenView::header() const
|
||||
{
|
||||
return info_;
|
||||
return header_;
|
||||
}
|
||||
|
||||
Fees const&
|
||||
@@ -230,7 +230,7 @@ void
|
||||
OpenView::rawDestroyXRP(XRPAmount const& fee)
|
||||
{
|
||||
items_.destroyXRP(fee);
|
||||
// VFALCO Deduct from info_.totalDrops ?
|
||||
// VFALCO Deduct from header_.totalDrops ?
|
||||
// What about child views?
|
||||
}
|
||||
|
||||
@@ -250,4 +250,4 @@ OpenView::rawTxInsert(
|
||||
LogicError("rawTxInsert: duplicate TX id: " + to_string(key));
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -28,10 +28,10 @@ DeferredCredits::credit(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sender != receiver,
|
||||
"ripple::detail::DeferredCredits::credit : sender is not receiver");
|
||||
"xrpl::detail::DeferredCredits::credit : sender is not receiver");
|
||||
XRPL_ASSERT(
|
||||
!amount.negative(),
|
||||
"ripple::detail::DeferredCredits::credit : positive amount");
|
||||
"xrpl::detail::DeferredCredits::credit : positive amount");
|
||||
|
||||
auto const k = makeKey(sender, receiver, amount.getCurrency());
|
||||
auto i = credits_.find(k);
|
||||
@@ -234,14 +234,14 @@ PaymentSandbox::adjustOwnerCountHook(
|
||||
void
|
||||
PaymentSandbox::apply(RawView& to)
|
||||
{
|
||||
XRPL_ASSERT(!ps_, "ripple::PaymentSandbox::apply : non-null sandbox");
|
||||
XRPL_ASSERT(!ps_, "xrpl::PaymentSandbox::apply : non-null sandbox");
|
||||
items_.apply(to);
|
||||
}
|
||||
|
||||
void
|
||||
PaymentSandbox::apply(PaymentSandbox& to)
|
||||
{
|
||||
XRPL_ASSERT(ps_ == &to, "ripple::PaymentSandbox::apply : matching sandbox");
|
||||
XRPL_ASSERT(ps_ == &to, "xrpl::PaymentSandbox::apply : matching sandbox");
|
||||
items_.apply(to);
|
||||
tab_.apply(to.tab_);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ PaymentSandbox::balanceChanges(ReadView const& view) const
|
||||
auto const at = after->getType();
|
||||
XRPL_ASSERT(
|
||||
at == before->getType(),
|
||||
"ripple::PaymentSandbox::balanceChanges : after and before "
|
||||
"xrpl::PaymentSandbox::balanceChanges : after and before "
|
||||
"types matching");
|
||||
switch (at)
|
||||
{
|
||||
@@ -377,4 +377,4 @@ PaymentSandbox::xrpDestroyed() const
|
||||
return items_.dropsDestroyed();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/ledger/detail/RawStateTable.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
end1_ == p->end1_ && end0_ == p->end0_,
|
||||
"ripple::detail::RawStateTable::equal : matching end "
|
||||
"xrpl::detail::RawStateTable::equal : matching end "
|
||||
"iterators");
|
||||
return iter1_ == p->iter1_ && iter0_ == p->iter0_;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sle1_ || sle0_,
|
||||
"ripple::detail::RawStateTable::increment : either SLE is "
|
||||
"xrpl::detail::RawStateTable::increment : either SLE is "
|
||||
"non-null");
|
||||
|
||||
if (sle1_ && !sle0_)
|
||||
@@ -167,8 +167,7 @@ bool
|
||||
RawStateTable::exists(ReadView const& base, Keylet const& k) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
k.key.isNonZero(),
|
||||
"ripple::detail::RawStateTable::exists : nonzero key");
|
||||
k.key.isNonZero(), "xrpl::detail::RawStateTable::exists : nonzero key");
|
||||
auto const iter = items_.find(k.key);
|
||||
if (iter == items_.end())
|
||||
return base.exists(k);
|
||||
@@ -339,4 +338,4 @@ RawStateTable::slesUpperBound(ReadView const& base, uint256 const& key) const
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
ReadView::sles_type::sles_type(ReadView const& view) : ReadViewFwdRange(view)
|
||||
{
|
||||
@@ -68,4 +68,4 @@ makeRulesGivenLedger(
|
||||
return Rules(presets);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
static std::optional<HTTPClientSSLContext> httpClientSSLContext;
|
||||
|
||||
@@ -605,4 +605,4 @@ HTTPClient::request(
|
||||
client->request(bSSL, deqSites, setRequest, timeout, complete);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
registerSSLCerts(
|
||||
@@ -89,7 +89,7 @@ registerSSLCerts(
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
// There is a very unpleasant interaction between <wincrypt> and
|
||||
// openssl x509 types (namely the former has macros that stomp
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/nodestore/detail/BatchWriter.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
BatchWriter::BatchWriter(Callback& callback, Scheduler& scheduler)
|
||||
@@ -66,7 +66,7 @@ BatchWriter::writeBatch()
|
||||
mWriteSet.swap(set);
|
||||
XRPL_ASSERT(
|
||||
mWriteSet.empty(),
|
||||
"ripple::NodeStore::BatchWriter::writeBatch : writes not set");
|
||||
"xrpl::NodeStore::BatchWriter::writeBatch : writes not set");
|
||||
mWriteLoad = set.size();
|
||||
|
||||
if (set.empty())
|
||||
@@ -102,4 +102,4 @@ BatchWriter::waitForWriting()
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
Database::Database(
|
||||
@@ -24,7 +24,7 @@ Database::Database(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
readThreads,
|
||||
"ripple::NodeStore::Database::Database : nonzero threads input");
|
||||
"xrpl::NodeStore::Database::Database : nonzero threads input");
|
||||
|
||||
if (earliestLedgerSeq_ < 1)
|
||||
Throw<std::runtime_error>("Invalid earliest_seq");
|
||||
@@ -73,7 +73,7 @@ Database::Database(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!it->second.empty(),
|
||||
"ripple::NodeStore::Database::Database : non-empty "
|
||||
"xrpl::NodeStore::Database::Database : non-empty "
|
||||
"data");
|
||||
|
||||
auto const& hash = it->first;
|
||||
@@ -150,7 +150,7 @@ Database::stop()
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
steady_clock::now() - start < 30s,
|
||||
"ripple::NodeStore::Database::stop : maximum stop duration");
|
||||
"xrpl::NodeStore::Database::stop : maximum stop duration");
|
||||
std::this_thread::yield();
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ Database::importInternal(Backend& dstBackend, Database& srcDB)
|
||||
srcDB.for_each([&](std::shared_ptr<NodeObject> nodeObject) {
|
||||
XRPL_ASSERT(
|
||||
nodeObject,
|
||||
"ripple::NodeStore::Database::importInternal : non-null node");
|
||||
"xrpl::NodeStore::Database::importInternal : non-null node");
|
||||
if (!nodeObject) // This should never happen
|
||||
return;
|
||||
|
||||
@@ -249,7 +249,7 @@ Database::getCountsJson(Json::Value& obj)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
obj.isObject(),
|
||||
"ripple::NodeStore::Database::getCountsJson : valid input type");
|
||||
"xrpl::NodeStore::Database::getCountsJson : valid input type");
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(readLock_);
|
||||
@@ -269,4 +269,4 @@ Database::getCountsJson(Json::Value& obj)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/nodestore/detail/DatabaseNodeImp.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
void
|
||||
@@ -194,4 +194,4 @@ DatabaseNodeImp::fetchBatch(std::vector<uint256> const& hashes)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
DatabaseRotatingImp::DatabaseRotatingImp(
|
||||
@@ -192,4 +192,4 @@ DatabaseRotatingImp::for_each(
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
|
||||
@@ -56,7 +56,7 @@ DecodedBlob::createObject()
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_success,
|
||||
"ripple::NodeStore::DecodedBlob::createObject : valid object type");
|
||||
"xrpl::NodeStore::DecodedBlob::createObject : valid object type");
|
||||
|
||||
std::shared_ptr<NodeObject> object;
|
||||
|
||||
@@ -72,4 +72,4 @@ DecodedBlob::createObject()
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/nodestore/DummyScheduler.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
void
|
||||
@@ -21,4 +21,4 @@ DummyScheduler::onBatchWrite(BatchWriteReport const& report)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace NodeStore {
|
||||
|
||||
@@ -95,7 +95,7 @@ ManagerImp::erase(Factory& factory)
|
||||
});
|
||||
XRPL_ASSERT(
|
||||
iter != list_.end(),
|
||||
"ripple::NodeStore::ManagerImp::erase : valid input");
|
||||
"xrpl::NodeStore::ManagerImp::erase : valid input");
|
||||
list_.erase(iter);
|
||||
}
|
||||
|
||||
@@ -121,4 +121,4 @@ Manager::instance()
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -40,4 +40,4 @@ NodeObject::getData() const
|
||||
return mData;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
struct MemoryDB
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
fetch(void const* key, std::shared_ptr<NodeObject>* pObject) override
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
db_, "ripple::NodeStore::MemoryBackend::fetch : non-null database");
|
||||
db_, "xrpl::NodeStore::MemoryBackend::fetch : non-null database");
|
||||
uint256 const hash(uint256::fromVoid(key));
|
||||
|
||||
std::lock_guard _(db_->mutex);
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
store(std::shared_ptr<NodeObject> const& object) override
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
db_, "ripple::NodeStore::MemoryBackend::store : non-null database");
|
||||
db_, "xrpl::NodeStore::MemoryBackend::store : non-null database");
|
||||
std::lock_guard _(db_->mutex);
|
||||
db_->table.emplace(object->getHash(), object);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
db_,
|
||||
"ripple::NodeStore::MemoryBackend::for_each : non-null database");
|
||||
"xrpl::NodeStore::MemoryBackend::for_each : non-null database");
|
||||
for (auto const& e : db_->table)
|
||||
f(e.second);
|
||||
}
|
||||
@@ -229,4 +229,4 @@ MemoryFactory::createInstance(
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
class NuDBBackend : public Backend
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::NodeStore::NuDBBackend::open : database is already "
|
||||
"xrpl::NodeStore::NuDBBackend::open : database is already "
|
||||
"open");
|
||||
JLOG(j_.error()) << "database is already open";
|
||||
return;
|
||||
@@ -455,4 +455,4 @@ registerNuDBFactory(Manager& manager)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
class NullBackend : public Backend
|
||||
@@ -126,4 +126,4 @@ registerNullFactory(Manager& manager)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace NodeStore {
|
||||
|
||||
class RocksDBEnv : public rocksdb::EnvWrapper
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::NodeStore::RocksDBBackend::open : database is already "
|
||||
"xrpl::NodeStore::RocksDBBackend::open : database is already "
|
||||
"open");
|
||||
JLOG(m_journal.error()) << "database is already open";
|
||||
return;
|
||||
@@ -261,8 +261,7 @@ public:
|
||||
fetch(void const* key, std::shared_ptr<NodeObject>* pObject) override
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_db,
|
||||
"ripple::NodeStore::RocksDBBackend::fetch : non-null database");
|
||||
m_db, "xrpl::NodeStore::RocksDBBackend::fetch : non-null database");
|
||||
pObject->reset();
|
||||
|
||||
Status status(ok);
|
||||
@@ -340,7 +339,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_db,
|
||||
"ripple::NodeStore::RocksDBBackend::storeBatch : non-null "
|
||||
"xrpl::NodeStore::RocksDBBackend::storeBatch : non-null "
|
||||
"database");
|
||||
rocksdb::WriteBatch wb;
|
||||
|
||||
@@ -375,7 +374,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_db,
|
||||
"ripple::NodeStore::RocksDBBackend::for_each : non-null database");
|
||||
"xrpl::NodeStore::RocksDBBackend::for_each : non-null database");
|
||||
rocksdb::ReadOptions const options;
|
||||
|
||||
std::unique_ptr<rocksdb::Iterator> it(m_db->NewIterator(options));
|
||||
@@ -477,6 +476,6 @@ registerRocksDBFactory(Manager& manager)
|
||||
}
|
||||
|
||||
} // namespace NodeStore
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Currency
|
||||
ammLPTCurrency(Currency const& cur1, Currency const& cur2)
|
||||
@@ -93,7 +93,7 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot)
|
||||
auto const expiration = auctionSlot[sfExpiration];
|
||||
XRPL_ASSERT(
|
||||
expiration >= TOTAL_TIME_SLOT_SECS,
|
||||
"ripple::ammAuctionTimeSlot : minimum expiration");
|
||||
"xrpl::ammAuctionTimeSlot : minimum expiration");
|
||||
if (expiration >= TOTAL_TIME_SLOT_SECS)
|
||||
{
|
||||
if (auto const start = expiration - TOTAL_TIME_SLOT_SECS;
|
||||
@@ -112,4 +112,4 @@ ammEnabled(Rules const& rules)
|
||||
return rules.enabled(featureAMM) && rules.enabled(fixUniversalNumber);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
XRPL_ASSERT(
|
||||
ret.size() <= 38,
|
||||
"ripple::detail::AccountIdCache : maximum result size");
|
||||
"xrpl::detail::AccountIdCache : maximum result size");
|
||||
|
||||
{
|
||||
std::lock_guard lock(sl);
|
||||
@@ -181,4 +181,4 @@ to_issuer(AccountID& issuer, std::string const& s)
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
AccountID const&
|
||||
Asset::getIssuer() const
|
||||
@@ -66,4 +66,4 @@ assetFromJson(Json::Value const& v)
|
||||
return mptIssueFromJson(v);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
bool
|
||||
isConsistent(Book const& book)
|
||||
@@ -32,4 +32,4 @@ reversed(Book const& book)
|
||||
return Book(book.out, book.in, book.domain);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace BuildInfo {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BuildInfo {
|
||||
// and follow the format described at http://semver.org/
|
||||
//------------------------------------------------------------------------------
|
||||
// clang-format off
|
||||
char const* const versionString = "3.1.0-b0"
|
||||
char const* const versionString = "3.2.0-b0"
|
||||
// clang-format on
|
||||
|
||||
#if defined(DEBUG) || defined(SANITIZER)
|
||||
@@ -159,4 +159,4 @@ isNewerVersion(std::uint64_t version)
|
||||
|
||||
} // namespace BuildInfo
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace RPC {
|
||||
|
||||
namespace detail {
|
||||
@@ -160,6 +160,24 @@ constexpr ErrorInfo unknownError;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
inject_error(error_code_i code, Json::Value& json)
|
||||
{
|
||||
ErrorInfo const& info(get_error_info(code));
|
||||
json[jss::error] = info.token;
|
||||
json[jss::error_code] = info.code;
|
||||
json[jss::error_message] = info.message;
|
||||
}
|
||||
|
||||
void
|
||||
inject_error(error_code_i code, std::string const& message, Json::Value& json)
|
||||
{
|
||||
ErrorInfo const& info(get_error_info(code));
|
||||
json[jss::error] = info.token;
|
||||
json[jss::error_code] = info.code;
|
||||
json[jss::error_message] = message;
|
||||
}
|
||||
|
||||
ErrorInfo const&
|
||||
get_error_info(error_code_i code)
|
||||
{
|
||||
@@ -205,8 +223,8 @@ rpcErrorString(Json::Value const& jv)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
RPC::contains_error(jv),
|
||||
"ripple::RPC::rpcErrorString : input contains an error");
|
||||
"xrpl::RPC::rpcErrorString : input contains an error");
|
||||
return jv[jss::error].asString() + jv[jss::error_message].asString();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
inline std::size_t
|
||||
hash_value(ripple::uint256 const& feature)
|
||||
hash_value(xrpl::uint256 const& feature)
|
||||
{
|
||||
std::size_t seed = 0;
|
||||
using namespace boost;
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
|
||||
FeatureCollections::FeatureCollections()
|
||||
{
|
||||
features.reserve(ripple::detail::numFeatures);
|
||||
features.reserve(xrpl::detail::numFeatures);
|
||||
}
|
||||
|
||||
std::optional<uint256>
|
||||
@@ -213,7 +213,7 @@ FeatureCollections::getRegisteredFeature(std::string const& name) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
readOnly.load(),
|
||||
"ripple::FeatureCollections::getRegisteredFeature : startup completed");
|
||||
"xrpl::FeatureCollections::getRegisteredFeature : startup completed");
|
||||
Feature const* feature = getByName(name);
|
||||
if (feature)
|
||||
return feature->feature;
|
||||
@@ -294,7 +294,7 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
readOnly.load(),
|
||||
"ripple::FeatureCollections::featureToBitsetIndex : startup completed");
|
||||
"xrpl::FeatureCollections::featureToBitsetIndex : startup completed");
|
||||
|
||||
Feature const* feature = getByFeature(f);
|
||||
if (!feature)
|
||||
@@ -308,7 +308,7 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
readOnly.load(),
|
||||
"ripple::FeatureCollections::bitsetIndexToFeature : startup completed");
|
||||
"xrpl::FeatureCollections::bitsetIndexToFeature : startup completed");
|
||||
Feature const& feature = getByIndex(i);
|
||||
return feature.feature;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ FeatureCollections::featureToName(uint256 const& f) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
readOnly.load(),
|
||||
"ripple::FeatureCollections::featureToName : startup completed");
|
||||
"xrpl::FeatureCollections::featureToName : startup completed");
|
||||
Feature const* feature = getByFeature(f);
|
||||
return feature ? feature->name : to_string(f);
|
||||
}
|
||||
@@ -452,4 +452,4 @@ featureToName(uint256 const& f)
|
||||
[[maybe_unused]] static bool const readOnlySet =
|
||||
featureCollections.registrationIsDone();
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -303,4 +303,4 @@ mulRatio(
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
/** Type-specific prefix for calculating ledger indices.
|
||||
|
||||
@@ -77,6 +77,8 @@ enum class LedgerNameSpace : std::uint16_t {
|
||||
PERMISSIONED_DOMAIN = 'm',
|
||||
DELEGATE = 'E',
|
||||
VAULT = 'V',
|
||||
LOAN_BROKER = 'l', // lower-case L
|
||||
LOAN = 'L',
|
||||
SPONSORSHIP = '>',
|
||||
|
||||
// No longer used or supported. Left here to reserve the space
|
||||
@@ -96,8 +98,7 @@ indexHash(LedgerNameSpace space, Args const&... args)
|
||||
uint256
|
||||
getBookBase(Book const& book)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
isConsistent(book), "ripple::getBookBase : input is consistent");
|
||||
XRPL_ASSERT(isConsistent(book), "xrpl::getBookBase : input is consistent");
|
||||
|
||||
auto const index = book.domain ? indexHash(
|
||||
LedgerNameSpace::BOOK_DIR,
|
||||
@@ -144,7 +145,7 @@ getTicketIndex(AccountID const& account, std::uint32_t ticketSeq)
|
||||
uint256
|
||||
getTicketIndex(AccountID const& account, SeqProxy ticketSeq)
|
||||
{
|
||||
XRPL_ASSERT(ticketSeq.isTicket(), "ripple::getTicketIndex : valid input");
|
||||
XRPL_ASSERT(ticketSeq.isTicket(), "xrpl::getTicketIndex : valid input");
|
||||
return getTicketIndex(account, ticketSeq.value());
|
||||
}
|
||||
|
||||
@@ -231,7 +232,7 @@ line(
|
||||
// There is code in SetTrust that calls us with id0 == id1, to allow users
|
||||
// to locate and delete such "weird" trustlines. If we remove that code, we
|
||||
// could enable this assert:
|
||||
// XRPL_ASSERT(id0 != id1, "ripple::keylet::line : accounts must be
|
||||
// XRPL_ASSERT(id0 != id1, "xrpl::keylet::line : accounts must be
|
||||
// different");
|
||||
|
||||
// A trust line is shared between two accounts; while we typically think
|
||||
@@ -262,7 +263,7 @@ Keylet
|
||||
quality(Keylet const& k, std::uint64_t q) noexcept
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
k.type == ltDIR_NODE, "ripple::keylet::quality : valid input type");
|
||||
k.type == ltDIR_NODE, "xrpl::keylet::quality : valid input type");
|
||||
|
||||
// Indexes are stored in big endian format: they print as hex as stored.
|
||||
// Most significant bytes are first and the least significant bytes
|
||||
@@ -282,7 +283,7 @@ next_t::operator()(Keylet const& k) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
k.type == ltDIR_NODE,
|
||||
"ripple::keylet::next_t::operator() : valid input type");
|
||||
"xrpl::keylet::next_t::operator() : valid input type");
|
||||
return {ltDIR_NODE, getQualityNext(k.key)};
|
||||
}
|
||||
|
||||
@@ -409,7 +410,7 @@ Keylet
|
||||
nftpage(Keylet const& k, uint256 const& token)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
k.type == ltNFTOKEN_PAGE, "ripple::keylet::nftpage : valid input type");
|
||||
k.type == ltNFTOKEN_PAGE, "xrpl::keylet::nftpage : valid input type");
|
||||
return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)};
|
||||
}
|
||||
|
||||
@@ -556,6 +557,18 @@ vault(AccountID const& owner, std::uint32_t seq) noexcept
|
||||
return vault(indexHash(LedgerNameSpace::VAULT, owner, seq));
|
||||
}
|
||||
|
||||
Keylet
|
||||
loanbroker(AccountID const& owner, std::uint32_t seq) noexcept
|
||||
{
|
||||
return loanbroker(indexHash(LedgerNameSpace::LOAN_BROKER, owner, seq));
|
||||
}
|
||||
|
||||
Keylet
|
||||
loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept
|
||||
{
|
||||
return loan(indexHash(LedgerNameSpace::LOAN, loanBrokerID, loanSeq));
|
||||
}
|
||||
|
||||
Keylet
|
||||
permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept
|
||||
{
|
||||
@@ -572,4 +585,4 @@ permissionedDomain(uint256 const& domainID) noexcept
|
||||
|
||||
} // namespace keylet
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/SOTemplate.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
InnerObjectFormats::InnerObjectFormats()
|
||||
{
|
||||
@@ -154,6 +154,14 @@ InnerObjectFormats::InnerObjectFormats()
|
||||
{sfBookNode, soeREQUIRED},
|
||||
});
|
||||
|
||||
add(sfCounterpartySignature.jsonName,
|
||||
sfCounterpartySignature.getCode(),
|
||||
{
|
||||
{sfSigningPubKey, soeOPTIONAL},
|
||||
{sfTxnSignature, soeOPTIONAL},
|
||||
{sfSigners, soeOPTIONAL},
|
||||
});
|
||||
|
||||
add(sfSponsor.jsonName.c_str(),
|
||||
sfSponsor.getCode(),
|
||||
{
|
||||
@@ -187,4 +195,4 @@ InnerObjectFormats::findSOTemplateBySField(SField const& sField) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::string
|
||||
Issue::getText() const
|
||||
@@ -132,4 +132,4 @@ operator<<(std::ostream& os, Issue const& x)
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include <xrpl/protocol/LedgerFormats.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
bool
|
||||
Keylet::check(STLedgerEntry const& sle) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sle.getType() != ltANY || sle.getType() != ltCHILD,
|
||||
"ripple::Keylet::check : valid input type");
|
||||
"xrpl::Keylet::check : valid input type");
|
||||
|
||||
if (type == ltANY)
|
||||
return true;
|
||||
@@ -21,4 +21,4 @@ Keylet::check(STLedgerEntry const& sle) const
|
||||
return sle.getType() == type && sle.key() == key;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
LedgerFormats::LedgerFormats()
|
||||
{
|
||||
@@ -41,4 +41,4 @@ LedgerFormats::getInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <xrpl/protocol/LedgerHeader.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
addRaw(LedgerHeader const& info, Serializer& s, bool includeHash)
|
||||
@@ -52,4 +52,4 @@ deserializePrefixedHeader(Slice data, bool hasHash)
|
||||
return deserializeHeader(data + 4, hasHash);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/protocol/MPTAmount.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
MPTAmount&
|
||||
MPTAmount::operator+=(MPTAmount const& other)
|
||||
@@ -46,4 +46,4 @@ MPTAmount::minPositiveAmount()
|
||||
return MPTAmount{1};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
MPTIssue::MPTIssue(MPTID const& issuanceID) : mptID_(issuanceID)
|
||||
{
|
||||
@@ -88,4 +88,4 @@ mptIssueFromJson(Json::Value const& v)
|
||||
return MPTIssue{id};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace RPC {
|
||||
|
||||
void
|
||||
@@ -22,4 +22,4 @@ insertNFTSyntheticInJson(
|
||||
}
|
||||
|
||||
} // namespace RPC
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
bool
|
||||
canHaveNFTokenID(
|
||||
@@ -184,4 +184,4 @@ insertNFTokenID(
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
bool
|
||||
canHaveNFTokenOfferID(
|
||||
@@ -64,4 +64,4 @@ insertNFTokenOfferID(
|
||||
response[jss::offer_id] = to_string(result.value());
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <xrpl/protocol/Permissions.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Permission::Permission()
|
||||
{
|
||||
@@ -71,7 +71,7 @@ Permission::Permission()
|
||||
for ([[maybe_unused]] auto const& permission : granularPermissionMap_)
|
||||
XRPL_ASSERT(
|
||||
permission.second > UINT16_MAX,
|
||||
"ripple::Permission::granularPermissionMap_ : granular permission "
|
||||
"xrpl::Permission::granularPermissionMap_ : granular permission "
|
||||
"value must not exceed the maximum uint16_t value.");
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ Permission::getTxFeature(TxType txType) const
|
||||
auto const txFeaturesIt = txFeatureMap_.find(txType);
|
||||
XRPL_ASSERT(
|
||||
txFeaturesIt != txFeatureMap_.end(),
|
||||
"ripple::Permissions::getTxFeature : tx exists in txFeatureMap_");
|
||||
"xrpl::Permissions::getTxFeature : tx exists in txFeatureMap_");
|
||||
|
||||
if (txFeaturesIt->second == uint256{})
|
||||
return std::nullopt;
|
||||
@@ -161,7 +161,7 @@ Permission::isDelegatable(
|
||||
auto const txFeaturesIt = txFeatureMap_.find(txType);
|
||||
XRPL_ASSERT(
|
||||
txFeaturesIt != txFeatureMap_.end(),
|
||||
"ripple::Permissions::isDelegatable : tx exists in txFeatureMap_");
|
||||
"xrpl::Permissions::isDelegatable : tx exists in txFeatureMap_");
|
||||
|
||||
// Delegation is only allowed if the required amendment for the transaction
|
||||
// is enabled. For transactions that do not require an amendment, delegation
|
||||
@@ -188,4 +188,4 @@ Permission::permissionToTxType(uint32_t const& value) const
|
||||
return static_cast<TxType>(value - 1);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <boost/multiprecision/number.hpp>
|
||||
|
||||
#include <ed25519.h>
|
||||
#include <secp256k1.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
@@ -22,7 +21,7 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, PublicKey const& pk)
|
||||
@@ -302,4 +301,4 @@ calcNodeID(PublicKey const& pk)
|
||||
return NodeID{static_cast<ripesha_hasher::result_type>(h)};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Quality::Quality(std::uint64_t value) : m_value(value)
|
||||
{
|
||||
@@ -21,7 +21,7 @@ Quality::Quality(Amounts const& amount)
|
||||
Quality&
|
||||
Quality::operator++()
|
||||
{
|
||||
XRPL_ASSERT(m_value > 0, "ripple::Quality::operator++() : minimum value");
|
||||
XRPL_ASSERT(m_value > 0, "xrpl::Quality::operator++() : minimum value");
|
||||
--m_value;
|
||||
return *this;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ Quality::operator--()
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
m_value < std::numeric_limits<value_type>::max(),
|
||||
"ripple::Quality::operator--() : maximum value");
|
||||
"xrpl::Quality::operator--() : maximum value");
|
||||
++m_value;
|
||||
return *this;
|
||||
}
|
||||
@@ -70,11 +70,10 @@ ceil_in_impl(
|
||||
if (result.out > amount.out)
|
||||
result.out = amount.out;
|
||||
XRPL_ASSERT(
|
||||
result.in == limit, "ripple::ceil_in_impl : result matches limit");
|
||||
result.in == limit, "xrpl::ceil_in_impl : result matches limit");
|
||||
return result;
|
||||
}
|
||||
XRPL_ASSERT(
|
||||
amount.in <= limit, "ripple::ceil_in_impl : result inside limit");
|
||||
XRPL_ASSERT(amount.in <= limit, "xrpl::ceil_in_impl : result inside limit");
|
||||
return amount;
|
||||
}
|
||||
|
||||
@@ -111,12 +110,11 @@ ceil_out_impl(
|
||||
if (result.in > amount.in)
|
||||
result.in = amount.in;
|
||||
XRPL_ASSERT(
|
||||
result.out == limit,
|
||||
"ripple::ceil_out_impl : result matches limit");
|
||||
result.out == limit, "xrpl::ceil_out_impl : result matches limit");
|
||||
return result;
|
||||
}
|
||||
XRPL_ASSERT(
|
||||
amount.out <= limit, "ripple::ceil_out_impl : result inside limit");
|
||||
amount.out <= limit, "xrpl::ceil_out_impl : result inside limit");
|
||||
return amount;
|
||||
}
|
||||
|
||||
@@ -140,13 +138,12 @@ composed_quality(Quality const& lhs, Quality const& rhs)
|
||||
{
|
||||
STAmount const lhs_rate(lhs.rate());
|
||||
XRPL_ASSERT(
|
||||
lhs_rate != beast::zero,
|
||||
"ripple::composed_quality : nonzero left input");
|
||||
lhs_rate != beast::zero, "xrpl::composed_quality : nonzero left input");
|
||||
|
||||
STAmount const rhs_rate(rhs.rate());
|
||||
XRPL_ASSERT(
|
||||
rhs_rate != beast::zero,
|
||||
"ripple::composed_quality : nonzero right input");
|
||||
"xrpl::composed_quality : nonzero right input");
|
||||
|
||||
STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.asset(), true));
|
||||
|
||||
@@ -155,7 +152,7 @@ composed_quality(Quality const& lhs, Quality const& rhs)
|
||||
|
||||
XRPL_ASSERT(
|
||||
(stored_exponent > 0) && (stored_exponent <= 255),
|
||||
"ripple::composed_quality : valid exponent");
|
||||
"xrpl::composed_quality : valid exponent");
|
||||
|
||||
return Quality((stored_exponent << (64 - 8)) | stored_mantissa);
|
||||
}
|
||||
@@ -192,4 +189,4 @@ Quality::round(int digits) const
|
||||
return Quality{(exponent << (64 - 8)) | mantissa};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
QualityFunction::QualityFunction(
|
||||
Quality const& quality,
|
||||
@@ -42,4 +42,4 @@ QualityFunction::outFromAvgQ(Quality const& quality)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <xrpl/protocol/RPCErr.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
struct RPCErr;
|
||||
|
||||
// VFALCO NOTE Deprecated function
|
||||
Json::Value
|
||||
rpcError(int iError)
|
||||
rpcError(error_code_i iError)
|
||||
{
|
||||
Json::Value jvResult(Json::objectValue);
|
||||
RPC::inject_error(iError, jvResult);
|
||||
@@ -23,4 +23,4 @@ isRpcError(Json::Value jvResult)
|
||||
return jvResult.isObject() && jvResult.isMember(jss::error);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
Rate const parityRate(QUALITY_ONE);
|
||||
|
||||
@@ -33,7 +33,7 @@ transferFeeAsRate(std::uint16_t fee)
|
||||
STAmount
|
||||
multiply(STAmount const& amount, Rate const& rate)
|
||||
{
|
||||
XRPL_ASSERT(rate.value, "ripple::nft::multiply : nonzero rate input");
|
||||
XRPL_ASSERT(rate.value, "xrpl::nft::multiply : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
return amount;
|
||||
@@ -44,7 +44,7 @@ multiply(STAmount const& amount, Rate const& rate)
|
||||
STAmount
|
||||
multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp)
|
||||
{
|
||||
XRPL_ASSERT(rate.value, "ripple::nft::multiplyRound : nonzero rate input");
|
||||
XRPL_ASSERT(rate.value, "xrpl::nft::multiplyRound : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
return amount;
|
||||
@@ -60,7 +60,7 @@ multiplyRound(
|
||||
bool roundUp)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
rate.value, "ripple::nft::multiplyRound(Issue) : nonzero rate input");
|
||||
rate.value, "xrpl::nft::multiplyRound(Issue) : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ multiplyRound(
|
||||
STAmount
|
||||
divide(STAmount const& amount, Rate const& rate)
|
||||
{
|
||||
XRPL_ASSERT(rate.value, "ripple::nft::divide : nonzero rate input");
|
||||
XRPL_ASSERT(rate.value, "xrpl::nft::divide : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
return amount;
|
||||
@@ -84,7 +84,7 @@ divide(STAmount const& amount, Rate const& rate)
|
||||
STAmount
|
||||
divideRound(STAmount const& amount, Rate const& rate, bool roundUp)
|
||||
{
|
||||
XRPL_ASSERT(rate.value, "ripple::nft::divideRound : nonzero rate input");
|
||||
XRPL_ASSERT(rate.value, "xrpl::nft::divideRound : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
return amount;
|
||||
@@ -100,7 +100,7 @@ divideRound(
|
||||
bool roundUp)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
rate.value, "ripple::nft::divideRound(Issue) : nonzero rate input");
|
||||
rate.value, "xrpl::nft::divideRound(Issue) : nonzero rate input");
|
||||
|
||||
if (rate == parityRate)
|
||||
return amount;
|
||||
@@ -108,4 +108,4 @@ divideRound(
|
||||
return divRound(amount, detail::as_amount(rate), asset, roundUp);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
// Use a static inside a function to help prevent order-of-initialization issues
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
return false;
|
||||
XRPL_ASSERT(
|
||||
presets_ == other.presets_,
|
||||
"ripple::Rules::Impl::operator==(Impl) const : input presets do "
|
||||
"xrpl::Rules::Impl::operator==(Impl) const : input presets do "
|
||||
"match");
|
||||
return *digest_ == *other.digest_;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ Rules::presets() const
|
||||
bool
|
||||
Rules::enabled(uint256 const& feature) const
|
||||
{
|
||||
XRPL_ASSERT(impl_, "ripple::Rules::enabled : initialized");
|
||||
XRPL_ASSERT(impl_, "xrpl::Rules::enabled : initialized");
|
||||
|
||||
return impl_->enabled(feature);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ Rules::operator==(Rules const& other) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
impl_ && other.impl_,
|
||||
"ripple::Rules::operator==(Rules) const : both initialized");
|
||||
"xrpl::Rules::operator==(Rules) const : both initialized");
|
||||
if (impl_.get() == other.impl_.get())
|
||||
return true;
|
||||
return *impl_ == *other.impl_;
|
||||
@@ -139,4 +139,4 @@ isFeatureEnabled(uint256 const& feature)
|
||||
return rules && rules->enabled(feature);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
// Storage for static const members.
|
||||
SField::IsSigning const SField::notSigning;
|
||||
@@ -84,10 +84,10 @@ SField::SField(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!knownCodeToField.contains(fieldCode),
|
||||
"ripple::SField::SField(tid,fv,fn,meta,signing) : fieldCode is unique");
|
||||
"xrpl::SField::SField(tid,fv,fn,meta,signing) : fieldCode is unique");
|
||||
XRPL_ASSERT(
|
||||
!knownNameToField.contains(fieldName),
|
||||
"ripple::SField::SField(tid,fv,fn,meta,signing) : fieldName is unique");
|
||||
"xrpl::SField::SField(tid,fv,fn,meta,signing) : fieldName is unique");
|
||||
knownCodeToField[fieldCode] = this;
|
||||
knownNameToField[fieldName] = this;
|
||||
}
|
||||
@@ -104,10 +104,10 @@ SField::SField(private_access_tag_t, int fc, char const* fn)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!knownCodeToField.contains(fieldCode),
|
||||
"ripple::SField::SField(fc,fn) : fieldCode is unique");
|
||||
"xrpl::SField::SField(fc,fn) : fieldCode is unique");
|
||||
XRPL_ASSERT(
|
||||
!knownNameToField.contains(fieldName),
|
||||
"ripple::SField::SField(fc,fn) : fieldName is unique");
|
||||
"xrpl::SField::SField(fc,fn) : fieldName is unique");
|
||||
knownCodeToField[fieldCode] = this;
|
||||
knownNameToField[fieldName] = this;
|
||||
}
|
||||
@@ -152,4 +152,4 @@ SField::getField(std::string const& fieldName)
|
||||
return sfInvalid;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <initializer_list>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
SOTemplate::SOTemplate(
|
||||
std::initializer_list<SOElement> uniqueFields,
|
||||
@@ -50,4 +50,4 @@ SOTemplate::getIndex(SField const& sField) const
|
||||
return indices_[sField.getNum()];
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STAccount::STAccount() : STBase(), value_(beast::zero), default_(true)
|
||||
{
|
||||
@@ -74,10 +74,10 @@ void
|
||||
STAccount::add(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
getFName().isBinary(), "ripple::STAccount::add : field is binary");
|
||||
getFName().isBinary(), "xrpl::STAccount::add : field is binary");
|
||||
XRPL_ASSERT(
|
||||
getFName().fieldType == STI_ACCOUNT,
|
||||
"ripple::STAccount::add : valid field type");
|
||||
"xrpl::STAccount::add : valid field type");
|
||||
|
||||
// Preserve the serialization behavior of an STBlob:
|
||||
// o If we are default (all zeros) serialize as an empty blob.
|
||||
@@ -107,4 +107,4 @@ STAccount::getText() const
|
||||
return toBase58(value());
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
static std::uint64_t const tenTo14 = 100000000000000ull;
|
||||
static std::uint64_t const tenTo14m1 = tenTo14 - 1;
|
||||
@@ -60,13 +60,13 @@ getInt64Value(STAmount const& amount, bool valid, char const* error)
|
||||
if (!valid)
|
||||
Throw<std::runtime_error>(error);
|
||||
XRPL_ASSERT(
|
||||
amount.exponent() == 0, "ripple::getInt64Value : exponent is zero");
|
||||
amount.exponent() == 0, "xrpl::getInt64Value : exponent is zero");
|
||||
|
||||
auto ret = static_cast<std::int64_t>(amount.mantissa());
|
||||
|
||||
XRPL_ASSERT(
|
||||
static_cast<std::uint64_t>(ret) == amount.mantissa(),
|
||||
"ripple::getInt64Value : mantissa must roundtrip");
|
||||
"xrpl::getInt64Value : mantissa must roundtrip");
|
||||
|
||||
if (amount.negative())
|
||||
ret = -ret;
|
||||
@@ -195,7 +195,7 @@ STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
mValue <= std::numeric_limits<std::int64_t>::max(),
|
||||
"ripple::STAmount::STAmount(SField, std::uint64_t, bool) : maximum "
|
||||
"xrpl::STAmount::STAmount(SField, std::uint64_t, bool) : maximum "
|
||||
"mantissa input");
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ STAmount::STAmount(SField const& name, STAmount const& from)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
mValue <= std::numeric_limits<std::int64_t>::max(),
|
||||
"ripple::STAmount::STAmount(SField, STAmount) : maximum input");
|
||||
"xrpl::STAmount::STAmount(SField, STAmount) : maximum input");
|
||||
canonicalize();
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
mValue <= std::numeric_limits<std::int64_t>::max(),
|
||||
"ripple::STAmount::STAmount(std::uint64_t, bool) : maximum mantissa "
|
||||
"xrpl::STAmount::STAmount(std::uint64_t, bool) : maximum mantissa "
|
||||
"input");
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ STAmount::xrp() const
|
||||
"Cannot return non-native STAmount as XRPAmount");
|
||||
|
||||
auto drops = static_cast<XRPAmount::value_type>(mValue);
|
||||
XRPL_ASSERT(mOffset == 0, "ripple::STAmount::xrp : amount is canonical");
|
||||
XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::xrp : amount is canonical");
|
||||
|
||||
if (mIsNegative)
|
||||
drops = -drops;
|
||||
@@ -279,7 +279,7 @@ STAmount::xrp() const
|
||||
IOUAmount
|
||||
STAmount::iou() const
|
||||
{
|
||||
if (native() || !holds<Issue>())
|
||||
if (integral())
|
||||
Throw<std::logic_error>("Cannot return non-IOU STAmount as IOUAmount");
|
||||
|
||||
auto mantissa = static_cast<std::int64_t>(mValue);
|
||||
@@ -298,7 +298,7 @@ STAmount::mpt() const
|
||||
Throw<std::logic_error>("Cannot return STAmount as MPTAmount");
|
||||
|
||||
auto value = static_cast<MPTAmount::value_type>(mValue);
|
||||
XRPL_ASSERT(mOffset == 0, "ripple::STAmount::mpt : amount is canonical");
|
||||
XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::mpt : amount is canonical");
|
||||
|
||||
if (mIsNegative)
|
||||
value = -value;
|
||||
@@ -310,8 +310,7 @@ STAmount&
|
||||
STAmount::operator=(IOUAmount const& iou)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
native() == false,
|
||||
"ripple::STAmount::operator=(IOUAmount) : is not XRP");
|
||||
native() == false, "xrpl::STAmount::operator=(IOUAmount) : is not XRP");
|
||||
mOffset = iou.exponent();
|
||||
mIsNegative = iou < beast::zero;
|
||||
if (mIsNegative)
|
||||
@@ -452,7 +451,7 @@ getRate(STAmount const& offerOut, STAmount const& offerIn)
|
||||
return 0;
|
||||
XRPL_ASSERT(
|
||||
(r.exponent() >= -100) && (r.exponent() <= 155),
|
||||
"ripple::getRate : exponent inside range");
|
||||
"xrpl::getRate : exponent inside range");
|
||||
std::uint64_t ret = r.exponent() + 100;
|
||||
return (ret << (64 - 8)) | r.mantissa();
|
||||
}
|
||||
@@ -689,7 +688,7 @@ STAmount::getText() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
XRPL_ASSERT(mOffset + 43 > 0, "ripple::STAmount::getText : minimum offset");
|
||||
XRPL_ASSERT(mOffset + 43 > 0, "xrpl::STAmount::getText : minimum offset");
|
||||
|
||||
size_t const pad_prefix = 27;
|
||||
size_t const pad_suffix = 23;
|
||||
@@ -714,8 +713,7 @@ STAmount::getText() const
|
||||
pre_from += pad_prefix;
|
||||
|
||||
XRPL_ASSERT(
|
||||
post_to >= post_from,
|
||||
"ripple::STAmount::getText : first distance check");
|
||||
post_to >= post_from, "xrpl::STAmount::getText : first distance check");
|
||||
|
||||
pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; });
|
||||
|
||||
@@ -726,7 +724,7 @@ STAmount::getText() const
|
||||
|
||||
XRPL_ASSERT(
|
||||
post_to >= post_from,
|
||||
"ripple::STAmount::getText : second distance check");
|
||||
"xrpl::STAmount::getText : second distance check");
|
||||
|
||||
post_to = std::find_if(
|
||||
std::make_reverse_iterator(post_to),
|
||||
@@ -762,7 +760,7 @@ STAmount::add(Serializer& s) const
|
||||
{
|
||||
if (native())
|
||||
{
|
||||
XRPL_ASSERT(mOffset == 0, "ripple::STAmount::add : zero offset");
|
||||
XRPL_ASSERT(mOffset == 0, "xrpl::STAmount::add : zero offset");
|
||||
|
||||
if (!mIsNegative)
|
||||
s.add64(mValue | cPositive);
|
||||
@@ -830,7 +828,7 @@ STAmount::isDefault() const
|
||||
void
|
||||
STAmount::canonicalize()
|
||||
{
|
||||
if (native() || mAsset.holds<MPTIssue>())
|
||||
if (integral())
|
||||
{
|
||||
// native and MPT currency amounts should always have an offset of zero
|
||||
// log(2^64,10) ~ 19.2
|
||||
@@ -859,8 +857,10 @@ STAmount::canonicalize()
|
||||
};
|
||||
if (native())
|
||||
set(XRPAmount{num});
|
||||
else
|
||||
else if (mAsset.holds<MPTIssue>())
|
||||
set(MPTAmount{num});
|
||||
else
|
||||
Throw<std::runtime_error>("Unknown integral asset type");
|
||||
mOffset = 0;
|
||||
}
|
||||
else
|
||||
@@ -935,13 +935,13 @@ STAmount::canonicalize()
|
||||
|
||||
XRPL_ASSERT(
|
||||
(mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)),
|
||||
"ripple::STAmount::canonicalize : value inside range");
|
||||
"xrpl::STAmount::canonicalize : value inside range");
|
||||
XRPL_ASSERT(
|
||||
(mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)),
|
||||
"ripple::STAmount::canonicalize : offset inside range");
|
||||
"xrpl::STAmount::canonicalize : offset inside range");
|
||||
XRPL_ASSERT(
|
||||
(mValue != 0) || (mOffset != -100),
|
||||
"ripple::STAmount::canonicalize : value or offset set");
|
||||
"xrpl::STAmount::canonicalize : value or offset set");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1461,6 +1461,33 @@ canonicalizeRoundStrict(
|
||||
}
|
||||
}
|
||||
|
||||
STAmount
|
||||
roundToScale(
|
||||
STAmount const& value,
|
||||
std::int32_t scale,
|
||||
Number::rounding_mode rounding)
|
||||
{
|
||||
// Nothing to do for integral types.
|
||||
if (value.integral())
|
||||
return value;
|
||||
|
||||
// If the value's exponent is greater than or equal to the scale, then
|
||||
// rounding will do nothing, and might even lose precision, so just return
|
||||
// the value.
|
||||
if (value.exponent() >= scale)
|
||||
return value;
|
||||
|
||||
STAmount const referenceValue{
|
||||
value.asset(), STAmount::cMinValue, scale, value.negative()};
|
||||
|
||||
NumberRoundModeGuard mg(rounding);
|
||||
// With an IOU, the the result of addition will be truncated to the
|
||||
// precision of the larger value, which in this case is referenceValue. Then
|
||||
// remove the reference value via subtraction, and we're left with the
|
||||
// rounded value.
|
||||
return (value + referenceValue) - referenceValue;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// We need a class that has an interface similar to NumberRoundModeGuard
|
||||
@@ -1719,4 +1746,4 @@ divRoundStrict(
|
||||
return divRoundImpl<NumberRoundModeGuard>(num, den, asset, roundUp);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STArray::STArray(STArray&& other)
|
||||
: STBase(other.getFName()), v_(std::move(other.v_))
|
||||
@@ -180,4 +180,4 @@ STArray::sort(bool (*compare)(STObject const&, STObject const&))
|
||||
std::sort(v_.begin(), v_.end(), compare);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STBase::STBase() : fName(&sfGeneric)
|
||||
{
|
||||
@@ -17,7 +17,7 @@ STBase::STBase() : fName(&sfGeneric)
|
||||
|
||||
STBase::STBase(SField const& n) : fName(&n)
|
||||
{
|
||||
XRPL_ASSERT(fName, "ripple::STBase::STBase : field is set");
|
||||
XRPL_ASSERT(fName, "xrpl::STBase::STBase : field is set");
|
||||
}
|
||||
|
||||
STBase&
|
||||
@@ -94,7 +94,7 @@ STBase::add(Serializer& s) const
|
||||
{
|
||||
// Should never be called
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::STBase::add : not implemented");
|
||||
UNREACHABLE("xrpl::STBase::add : not implemented");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ STBase::isEquivalent(STBase const& t) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
getSType() == STI_NOTPRESENT,
|
||||
"ripple::STBase::isEquivalent : type not present");
|
||||
"xrpl::STBase::isEquivalent : type not present");
|
||||
return t.getSType() == STI_NOTPRESENT;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ void
|
||||
STBase::setFName(SField const& n)
|
||||
{
|
||||
fName = &n;
|
||||
XRPL_ASSERT(fName, "ripple::STBase::setFName : field is set");
|
||||
XRPL_ASSERT(fName, "xrpl::STBase::setFName : field is set");
|
||||
}
|
||||
|
||||
SField const&
|
||||
@@ -130,7 +130,7 @@ void
|
||||
STBase::addFieldID(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
fName->isBinary(), "ripple::STBase::addFieldID : field is binary");
|
||||
fName->isBinary(), "xrpl::STBase::addFieldID : field is binary");
|
||||
s.addFieldID(fName->fieldType, fName->fieldValue);
|
||||
}
|
||||
|
||||
@@ -142,4 +142,4 @@ operator<<(std::ostream& out, STBase const& t)
|
||||
return out << t.getFullText();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STBlob::STBlob(SerialIter& st, SField const& name)
|
||||
: STBase(name), value_(st.getVLBuffer())
|
||||
@@ -43,11 +43,11 @@ STBlob::getText() const
|
||||
void
|
||||
STBlob::add(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(getFName().isBinary(), "ripple::STBlob::add : field is binary");
|
||||
XRPL_ASSERT(getFName().isBinary(), "xrpl::STBlob::add : field is binary");
|
||||
XRPL_ASSERT(
|
||||
(getFName().fieldType == STI_VL) ||
|
||||
(getFName().fieldType == STI_ACCOUNT),
|
||||
"ripple::STBlob::add : valid field type");
|
||||
"xrpl::STBlob::add : valid field type");
|
||||
s.addVL(value_.data(), value_.size());
|
||||
}
|
||||
|
||||
@@ -64,4 +64,4 @@ STBlob::isDefault() const
|
||||
return value_.empty();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STCurrency::STCurrency(SField const& name) : STBase{name}
|
||||
{
|
||||
@@ -102,4 +102,4 @@ currencyFromJson(SField const& name, Json::Value const& v)
|
||||
return STCurrency{name, currency};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
template <>
|
||||
STInteger<unsigned char>::STInteger(SerialIter& sit, SField const& name)
|
||||
@@ -210,14 +210,14 @@ STUInt64::getJson(JsonOptions) const
|
||||
auto convertToString = [](uint64_t const value, int const base) {
|
||||
XRPL_ASSERT(
|
||||
base == 10 || base == 16,
|
||||
"ripple::STUInt64::getJson : base 10 or 16");
|
||||
"xrpl::STUInt64::getJson : base 10 or 16");
|
||||
std::string str(
|
||||
base == 10 ? 20 : 16, 0); // Allocate space depending on base
|
||||
auto ret =
|
||||
std::to_chars(str.data(), str.data() + str.size(), value, base);
|
||||
XRPL_ASSERT(
|
||||
ret.ec == std::errc(),
|
||||
"ripple::STUInt64::getJson : to_chars succeeded");
|
||||
"xrpl::STUInt64::getJson : to_chars succeeded");
|
||||
str.resize(std::distance(str.data(), ret.ptr));
|
||||
return str;
|
||||
};
|
||||
@@ -259,4 +259,4 @@ STInt32::getJson(JsonOptions) const
|
||||
return value_;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STIssue::STIssue(SField const& name) : STBase{name}
|
||||
{
|
||||
@@ -139,4 +139,4 @@ issueFromJson(SField const& name, Json::Value const& v)
|
||||
return STIssue{name, assetFromJson(v)};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STLedgerEntry::STLedgerEntry(Keylet const& k)
|
||||
: STObject(sfLedgerEntry), key_(k.key), type_(k.type)
|
||||
@@ -157,7 +157,7 @@ STLedgerEntry::thread(
|
||||
// this transaction is already threaded
|
||||
XRPL_ASSERT(
|
||||
getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq,
|
||||
"ripple::STLedgerEntry::thread : ledger sequence match");
|
||||
"xrpl::STLedgerEntry::thread : ledger sequence match");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -168,4 +168,4 @@ STLedgerEntry::thread(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STNumber::STNumber(SField const& field, Number const& value)
|
||||
: STBase(field), value_(value)
|
||||
@@ -45,11 +45,10 @@ STNumber::getText() const
|
||||
void
|
||||
STNumber::add(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
getFName().isBinary(), "ripple::STNumber::add : field is binary");
|
||||
XRPL_ASSERT(getFName().isBinary(), "xrpl::STNumber::add : field is binary");
|
||||
XRPL_ASSERT(
|
||||
getFName().fieldType == getSType(),
|
||||
"ripple::STNumber::add : field type match");
|
||||
"xrpl::STNumber::add : field type match");
|
||||
s.add64(value_.mantissa());
|
||||
s.add32(value_.exponent());
|
||||
}
|
||||
@@ -83,7 +82,7 @@ STNumber::isEquivalent(STBase const& t) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
t.getSType() == this->getSType(),
|
||||
"ripple::STNumber::isEquivalent : field type match");
|
||||
"xrpl::STNumber::isEquivalent : field type match");
|
||||
STNumber const& v = dynamic_cast<STNumber const&>(t);
|
||||
return value_ == v;
|
||||
}
|
||||
@@ -196,4 +195,4 @@ numberFromJson(SField const& field, Json::Value const& value)
|
||||
return STNumber{field, Number{mantissa, parts.exponent}};
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STObject::STObject(STObject&& other)
|
||||
: STBase(other.getFName()), v_(std::move(other.v_)), mType(other.mType)
|
||||
@@ -904,7 +904,7 @@ STObject::add(Serializer& s, WhichFields whichFields) const
|
||||
XRPL_ASSERT(
|
||||
(sType != STI_OBJECT) ||
|
||||
(field->getFName().fieldType == STI_OBJECT),
|
||||
"ripple::STObject::add : valid field type");
|
||||
"xrpl::STObject::add : valid field type");
|
||||
field->addFieldID(s);
|
||||
field->add(s);
|
||||
if (sType == STI_ARRAY || sType == STI_OBJECT)
|
||||
@@ -937,4 +937,4 @@ STObject::getSortedFields(STObject const& objToSort, WhichFields whichFields)
|
||||
return sf;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace STParsedJSONDetail {
|
||||
template <typename U, typename S>
|
||||
@@ -1190,4 +1190,4 @@ STParsedJSONObject::STParsedJSONObject(
|
||||
object = parseObject(name, json, sfGeneric, 0, error);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::size_t
|
||||
STPathElement::get_hash(STPathElement const& element)
|
||||
@@ -201,10 +201,10 @@ void
|
||||
STPathSet::add(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
getFName().isBinary(), "ripple::STPathSet::add : field is binary");
|
||||
getFName().isBinary(), "xrpl::STPathSet::add : field is binary");
|
||||
XRPL_ASSERT(
|
||||
getFName().fieldType == STI_PATHSET,
|
||||
"ripple::STPathSet::add : valid field type");
|
||||
"xrpl::STPathSet::add : valid field type");
|
||||
bool first = true;
|
||||
|
||||
for (auto const& spPath : value)
|
||||
@@ -234,4 +234,4 @@ STPathSet::add(Serializer& s) const
|
||||
s.add8(STPathElement::typeNone);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
static auto
|
||||
getTxFormat(TxType type)
|
||||
@@ -150,7 +150,7 @@ STTx::getMentionedAccounts() const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!sacc->isDefault(),
|
||||
"ripple::STTx::getMentionedAccounts : account is set");
|
||||
"xrpl::STTx::getMentionedAccounts : account is set");
|
||||
if (!sacc->isDefault())
|
||||
list.insert(sacc->value());
|
||||
}
|
||||
@@ -222,7 +222,7 @@ STTx::sign(
|
||||
{
|
||||
auto const data = getSigningData(*this);
|
||||
|
||||
auto const sig = ripple::sign(publicKey, secretKey, makeSlice(data));
|
||||
auto const sig = xrpl::sign(publicKey, secretKey, makeSlice(data));
|
||||
|
||||
if (signatureTarget)
|
||||
{
|
||||
@@ -261,15 +261,12 @@ STTx::checkSign(Rules const& rules) const
|
||||
if (auto const ret = checkSign(rules, *this); !ret)
|
||||
return ret;
|
||||
|
||||
/* Placeholder for field that will be added by Lending Protocol
|
||||
if (isFieldPresent(sfCounterpartySignature))
|
||||
{
|
||||
auto const counterSig = getFieldObject(sfCounterpartySignature);
|
||||
if (auto const ret = checkSign(rules, counterSig);
|
||||
!ret)
|
||||
if (auto const ret = checkSign(rules, counterSig); !ret)
|
||||
return Unexpected("Counterparty: " + ret.error());
|
||||
}
|
||||
*/
|
||||
|
||||
if (isFieldPresent(sfSponsorSignature))
|
||||
{
|
||||
@@ -386,7 +383,7 @@ STTx::getMetaSQL(
|
||||
std::string rTxn = sqlBlobLiteral(rawTxn.peekData());
|
||||
|
||||
auto format = TxFormats::getInstance().findByType(tx_type_);
|
||||
XRPL_ASSERT(format, "ripple::STTx::getMetaSQL : non-null type format");
|
||||
XRPL_ASSERT(format, "xrpl::STTx::getMetaSQL : non-null type format");
|
||||
|
||||
return str(
|
||||
boost::format(bfTrans) % to_string(getTransactionID()) %
|
||||
@@ -830,4 +827,4 @@ isPseudoTx(STObject const& tx)
|
||||
return tt == ttAMENDMENT || tt == ttFEE || tt == ttUNL_MODIFY;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STBase*
|
||||
STValidation::copy(std::size_t n, void* buf) const
|
||||
@@ -101,7 +101,7 @@ STValidation::isValid() const noexcept
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
publicKeyType(getSignerPublic()) == KeyType::secp256k1,
|
||||
"ripple::STValidation::isValid : valid key type");
|
||||
"xrpl::STValidation::isValid : valid key type");
|
||||
|
||||
valid_ = verifyDigest(
|
||||
getSignerPublic(),
|
||||
@@ -133,4 +133,4 @@ STValidation::getSerialized() const
|
||||
return s.peekData();
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
defaultObject_t defaultObject;
|
||||
@@ -109,7 +109,7 @@ STVar::STVar(SerializedTypeID id, SField const& name)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
(id == STI_NOTPRESENT) || (id == name.fieldType),
|
||||
"ripple::detail::STVar::STVar(SerializedTypeID) : valid type input");
|
||||
"xrpl::detail::STVar::STVar(SerializedTypeID) : valid type input");
|
||||
constructST(id, 0, name);
|
||||
}
|
||||
|
||||
@@ -225,4 +225,4 @@ STVar::constructST(SerializedTypeID id, int depth, Args&&... args)
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STVector256::STVector256(SerialIter& sit, SField const& name) : STBase(name)
|
||||
{
|
||||
@@ -59,10 +59,10 @@ void
|
||||
STVector256::add(Serializer& s) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
getFName().isBinary(), "ripple::STVector256::add : field is binary");
|
||||
getFName().isBinary(), "xrpl::STVector256::add : field is binary");
|
||||
XRPL_ASSERT(
|
||||
getFName().fieldType == STI_VECTOR256,
|
||||
"ripple::STVector256::add : valid field type");
|
||||
"xrpl::STVector256::add : valid field type");
|
||||
s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8));
|
||||
}
|
||||
|
||||
@@ -84,4 +84,4 @@ STVector256::getJson(JsonOptions) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STXChainBridge::STXChainBridge() : STBase{sfXChainBridge}
|
||||
{
|
||||
@@ -66,7 +66,7 @@ STXChainBridge::STXChainBridge(SField const& name, Json::Value const& v)
|
||||
|
||||
auto checkExtra = [](Json::Value const& v) {
|
||||
static auto const jbridge =
|
||||
ripple::STXChainBridge().getJson(ripple::JsonOptions::none);
|
||||
xrpl::STXChainBridge().getJson(xrpl::JsonOptions::none);
|
||||
for (auto it = v.begin(); it != v.end(); ++it)
|
||||
{
|
||||
std::string const name = it.memberName();
|
||||
@@ -207,4 +207,4 @@ STXChainBridge::move(std::size_t n, void* buf)
|
||||
{
|
||||
return emplace(n, buf, std::move(*this));
|
||||
}
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
#include <ed25519.h>
|
||||
#include <secp256k1.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -27,7 +26,7 @@
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
SecretKey::~SecretKey()
|
||||
{
|
||||
@@ -382,4 +381,4 @@ parseBase58(TokenType type, std::string const& s)
|
||||
return SecretKey(makeSlice(result));
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user