mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-06 02:07:07 +00:00
Merge commit '92046785d1fea5f9efe5a770d636792ea6cab78b' into ct-merge-develop-new
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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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,11 +24,11 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
namespace openssl {
|
||||
namespace detail {
|
||||
|
||||
/** The default strength of self-signed RSA certifices.
|
||||
/** The default strength of self-signed RSA certificates.
|
||||
|
||||
Per NIST Special Publication 800-57 Part 3, 2048-bit RSA is still
|
||||
considered acceptably secure. Generally, we would want to go above
|
||||
@@ -131,7 +131,7 @@ initAnonymous(boost::asio::ssl::context& context)
|
||||
LogicError("X509_new failed");
|
||||
|
||||
// According to the standards (X.509 et al), the value should be one
|
||||
// less than the actualy certificate version we want. Since we want
|
||||
// less than the actually certificate version we want. Since we want
|
||||
// version 3, we must use a 2.
|
||||
X509_set_version(x509, 2);
|
||||
|
||||
@@ -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,6 +1,5 @@
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
|
||||
#include <boost/predef.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -73,12 +72,37 @@ setCurrentThreadNameImpl(std::string_view name)
|
||||
#if BOOST_OS_LINUX
|
||||
#include <pthread.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace beast::detail {
|
||||
|
||||
inline void
|
||||
setCurrentThreadNameImpl(std::string_view name)
|
||||
{
|
||||
pthread_setname_np(pthread_self(), name.data());
|
||||
// truncate and set the thread name.
|
||||
char boundedName[maxThreadNameLength + 1];
|
||||
std::snprintf(
|
||||
boundedName,
|
||||
sizeof(boundedName),
|
||||
"%.*s",
|
||||
static_cast<int>(maxThreadNameLength),
|
||||
name.data());
|
||||
|
||||
pthread_setname_np(pthread_self(), boundedName);
|
||||
|
||||
#ifdef TRUNCATED_THREAD_NAME_LOGS
|
||||
if (name.size() > maxThreadNameLength)
|
||||
{
|
||||
std::cerr << "WARNING: Thread name \"" << name << "\" (length "
|
||||
<< name.size() << ") exceeds maximum of "
|
||||
<< maxThreadNameLength << " characters on Linux.\n";
|
||||
|
||||
XRPL_ASSERT(
|
||||
false,
|
||||
"beast::detail::setCurrentThreadNameImpl : Thread name exceeds "
|
||||
"maximum length for Linux");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace beast::detail
|
||||
|
||||
@@ -24,7 +24,7 @@ is_public(AddressV4 const& addr)
|
||||
char
|
||||
get_class(AddressV4 const& addr)
|
||||
{
|
||||
static char const* table = "AAAABBCD";
|
||||
static char const* table = "AAAABBCD"; // cspell:disable-line
|
||||
return table[(addr.to_uint() & 0xE0000000) >> 29];
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -42,7 +41,7 @@ Job::queue_time() const
|
||||
void
|
||||
Job::doJob()
|
||||
{
|
||||
beast::setCurrentThreadName("doJob: " + mName);
|
||||
beast::setCurrentThreadName("j:" + mName);
|
||||
m_loadEvent->start();
|
||||
m_loadEvent->setName(mName);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
/*
|
||||
|
||||
@@ -67,7 +66,7 @@ LoadMonitor::update()
|
||||
|
||||
"Imagine if you add 10 to something every second. And you
|
||||
also reduce it by 1/4 every second. It will "idle" at 40,
|
||||
correponding to 10 counts per second."
|
||||
corresponding to 10 counts per second."
|
||||
*/
|
||||
do
|
||||
{
|
||||
@@ -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
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// JSON collections are either arrrays, or objects.
|
||||
// JSON collections are either arrays, or objects.
|
||||
struct Collection
|
||||
{
|
||||
explicit Collection() = default;
|
||||
@@ -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)});
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ Reader::readToken(Token& token)
|
||||
|
||||
case 'f':
|
||||
token.type_ = tokenFalse;
|
||||
ok = match("alse", 4);
|
||||
ok = match("alse", 4); // cspell:disable-line
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
@@ -912,7 +912,7 @@ Reader::getLocationLineAndColumn(Location location) const
|
||||
}
|
||||
|
||||
std::string
|
||||
Reader::getFormatedErrorMessages() const
|
||||
Reader::getFormattedErrorMessages() const
|
||||
{
|
||||
std::string formattedMessage;
|
||||
|
||||
@@ -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.getFormattedErrorMessages());
|
||||
|
||||
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_ =
|
||||
|
||||
@@ -89,26 +89,26 @@ ValueIteratorBase::copy(SelfType const& other)
|
||||
Value
|
||||
ValueIteratorBase::key() const
|
||||
{
|
||||
Value::CZString const czstring = (*current_).first;
|
||||
Value::CZString const czString = (*current_).first;
|
||||
|
||||
if (czstring.c_str())
|
||||
if (czString.c_str())
|
||||
{
|
||||
if (czstring.isStaticString())
|
||||
return Value(StaticString(czstring.c_str()));
|
||||
if (czString.isStaticString())
|
||||
return Value(StaticString(czString.c_str()));
|
||||
|
||||
return Value(czstring.c_str());
|
||||
return Value(czString.c_str());
|
||||
}
|
||||
|
||||
return Value(czstring.index());
|
||||
return Value(czString.index());
|
||||
}
|
||||
|
||||
UInt
|
||||
ValueIteratorBase::index() const
|
||||
{
|
||||
Value::CZString const czstring = (*current_).first;
|
||||
Value::CZString const czString = (*current_).first;
|
||||
|
||||
if (!czstring.c_str())
|
||||
return czstring.index();
|
||||
if (!czString.c_str())
|
||||
return czString.index();
|
||||
|
||||
return Value::UInt(-1);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ valueToString(double value)
|
||||
// of precision requested below.
|
||||
char buffer[32];
|
||||
// Print into the buffer. We need not request the alternative representation
|
||||
// that always has a decimal point because JSON doesn't distingish the
|
||||
// that always has a decimal point because JSON doesn't distinguish the
|
||||
// concepts of reals and integers.
|
||||
#if defined(_MSC_VER) && \
|
||||
defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005
|
||||
@@ -108,7 +108,7 @@ valueToQuotedString(char const* value)
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to std::string is not efficient, but this should be rare.
|
||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
||||
unsigned maxsize = strlen(value) * 2 + 3; // allescaped+quotes+NULL
|
||||
unsigned maxsize = strlen(value) * 2 + 3; // all-escaped+quotes+NULL
|
||||
std::string result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
@@ -347,7 +347,7 @@ StyledWriter::writeArrayValue(Value const& value)
|
||||
pushValue("[]");
|
||||
else
|
||||
{
|
||||
bool isArrayMultiLine = isMultineArray(value);
|
||||
bool isArrayMultiLine = isMultilineArray(value);
|
||||
|
||||
if (isArrayMultiLine)
|
||||
{
|
||||
@@ -398,7 +398,7 @@ StyledWriter::writeArrayValue(Value const& value)
|
||||
}
|
||||
|
||||
bool
|
||||
StyledWriter::isMultineArray(Value const& value)
|
||||
StyledWriter::isMultilineArray(Value const& value)
|
||||
{
|
||||
int size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
@@ -573,7 +573,7 @@ StyledStreamWriter::writeArrayValue(Value const& value)
|
||||
pushValue("[]");
|
||||
else
|
||||
{
|
||||
bool isArrayMultiLine = isMultineArray(value);
|
||||
bool isArrayMultiLine = isMultilineArray(value);
|
||||
|
||||
if (isArrayMultiLine)
|
||||
{
|
||||
@@ -624,7 +624,7 @@ StyledStreamWriter::writeArrayValue(Value const& value)
|
||||
}
|
||||
|
||||
bool
|
||||
StyledStreamWriter::isMultineArray(Value const& value)
|
||||
StyledStreamWriter::isMultilineArray(Value const& value)
|
||||
{
|
||||
int size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
|
||||
@@ -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,7 +6,7 @@
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace directory {
|
||||
|
||||
@@ -135,9 +135,7 @@ insertPage(
|
||||
if (page != 1)
|
||||
node->setFieldU64(sfIndexPrevious, page - 1);
|
||||
XRPL_ASSERT_PARTS(
|
||||
!nextPage,
|
||||
"ripple::directory::insertPage",
|
||||
"nextPage has default value");
|
||||
!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)
|
||||
@@ -193,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
|
||||
}
|
||||
@@ -435,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)
|
||||
@@ -181,7 +181,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))
|
||||
{
|
||||
@@ -290,7 +290,7 @@ checkArray(STArray const& credentials, unsigned maxSize, beast::Journal j)
|
||||
if (!ins)
|
||||
{
|
||||
JLOG(j.trace()) << "Malformed transaction: "
|
||||
"duplicates in credenentials.";
|
||||
"duplicates in credentials.";
|
||||
return temMALFORMED;
|
||||
}
|
||||
}
|
||||
@@ -374,4 +374,4 @@ verifyDepositPreauth(
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STAmount
|
||||
creditLimit(
|
||||
@@ -25,10 +25,10 @@ creditLimit(
|
||||
|
||||
XRPL_ASSERT(
|
||||
result.getIssuer() == account,
|
||||
"ripple::creditLimit : result issuer match");
|
||||
"xrpl::creditLimit : result issuer match");
|
||||
XRPL_ASSERT(
|
||||
result.getCurrency() == currency,
|
||||
"ripple::creditLimit : result currency match");
|
||||
"xrpl::creditLimit : result currency match");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ creditBalance(
|
||||
|
||||
XRPL_ASSERT(
|
||||
result.getIssuer() == account,
|
||||
"ripple::creditBalance : result issuer match");
|
||||
"xrpl::creditBalance : result issuer match");
|
||||
XRPL_ASSERT(
|
||||
result.getCurrency() == currency,
|
||||
"ripple::creditBalance : result currency match");
|
||||
"xrpl::creditBalance : result currency match");
|
||||
return result;
|
||||
}
|
||||
|
||||
} // 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
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <xrpl/basics/chrono.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/ledger/CredentialHelpers.h>
|
||||
#include <xrpl/ledger/Credit.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
@@ -19,7 +20,7 @@
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -40,7 +41,7 @@ internalDirNext(
|
||||
auto const& svIndexes = page->getFieldV256(sfIndexes);
|
||||
XRPL_ASSERT(
|
||||
index <= svIndexes.size(),
|
||||
"ripple::detail::internalDirNext : index inside range");
|
||||
"xrpl::detail::internalDirNext : index inside range");
|
||||
|
||||
if (index >= svIndexes.size())
|
||||
{
|
||||
@@ -57,7 +58,7 @@ internalDirNext(
|
||||
else
|
||||
page = view.peek(keylet::page(root, next));
|
||||
|
||||
XRPL_ASSERT(page, "ripple::detail::internalDirNext : non-null root");
|
||||
XRPL_ASSERT(page, "xrpl::detail::internalDirNext : non-null root");
|
||||
|
||||
if (!page)
|
||||
return false;
|
||||
@@ -307,7 +308,7 @@ isVaultPseudoAccountFrozen(
|
||||
if (mptIssuer == nullptr)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::isVaultPseudoAccountFrozen : null MPToken issuer");
|
||||
UNREACHABLE("xrpl::isVaultPseudoAccountFrozen : null MPToken issuer");
|
||||
return false;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -319,7 +320,7 @@ isVaultPseudoAccountFrozen(
|
||||
view.read(keylet::vault(mptIssuer->getFieldH256(sfVaultID)));
|
||||
if (vault == nullptr)
|
||||
{ // LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::isVaultPseudoAccountFrozen : null vault");
|
||||
UNREACHABLE("xrpl::isVaultPseudoAccountFrozen : null vault");
|
||||
return false;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -450,9 +451,8 @@ getTrustLineBalance(
|
||||
amount.clear(Issue{currency, issuer});
|
||||
}
|
||||
|
||||
JLOG(j.trace()) << "getTrustLineBalance:"
|
||||
<< " account=" << to_string(account)
|
||||
<< " amount=" << amount.getFullText();
|
||||
JLOG(j.trace()) << "getTrustLineBalance:" << " account="
|
||||
<< to_string(account) << " amount=" << amount.getFullText();
|
||||
|
||||
return view.balanceHook(account, issuer, amount);
|
||||
}
|
||||
@@ -464,7 +464,8 @@ accountHolds(
|
||||
Currency const& currency,
|
||||
AccountID const& issuer,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j)
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance)
|
||||
{
|
||||
STAmount amount;
|
||||
if (isXRP(currency))
|
||||
@@ -472,11 +473,19 @@ accountHolds(
|
||||
return {xrpLiquid(view, account, 0, j)};
|
||||
}
|
||||
|
||||
bool const returnSpendable = (includeFullBalance == shFULL_BALANCE);
|
||||
if (returnSpendable && account == issuer)
|
||||
// If the account is the issuer, then their limit is effectively
|
||||
// infinite
|
||||
return STAmount{
|
||||
Issue{currency, issuer}, STAmount::cMaxValue, STAmount::cMaxOffset};
|
||||
|
||||
// IOU: Return balance on trust line modulo freeze
|
||||
SLE::const_pointer const sle =
|
||||
getLineIfUsable(view, account, currency, issuer, zeroIfFrozen, j);
|
||||
|
||||
return getTrustLineBalance(view, sle, account, currency, issuer, false, j);
|
||||
return getTrustLineBalance(
|
||||
view, sle, account, currency, issuer, returnSpendable, j);
|
||||
}
|
||||
|
||||
STAmount
|
||||
@@ -485,10 +494,17 @@ accountHolds(
|
||||
AccountID const& account,
|
||||
Issue const& issue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j)
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance)
|
||||
{
|
||||
return accountHolds(
|
||||
view, account, issue.currency, issue.account, zeroIfFrozen, j);
|
||||
view,
|
||||
account,
|
||||
issue.currency,
|
||||
issue.account,
|
||||
zeroIfFrozen,
|
||||
j,
|
||||
includeFullBalance);
|
||||
}
|
||||
|
||||
STAmount
|
||||
@@ -498,8 +514,28 @@ accountHolds(
|
||||
MPTIssue const& mptIssue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j)
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance)
|
||||
{
|
||||
bool const returnSpendable = (includeFullBalance == shFULL_BALANCE);
|
||||
|
||||
if (returnSpendable && account == mptIssue.getIssuer())
|
||||
{
|
||||
// if the account is the issuer, and the issuance exists, their limit is
|
||||
// the issuance limit minus the outstanding value
|
||||
auto const issuance =
|
||||
view.read(keylet::mptIssuance(mptIssue.getMptID()));
|
||||
|
||||
if (!issuance)
|
||||
{
|
||||
return STAmount{mptIssue};
|
||||
}
|
||||
return STAmount{
|
||||
mptIssue,
|
||||
issuance->at(~sfMaximumAmount).value_or(maxMPTokenAmount) -
|
||||
issuance->at(sfOutstandingAmount)};
|
||||
}
|
||||
|
||||
STAmount amount;
|
||||
|
||||
auto const sleMpt =
|
||||
@@ -548,108 +584,27 @@ accountHolds(
|
||||
Asset const& asset,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j)
|
||||
beast::Journal j,
|
||||
SpendableHandling includeFullBalance)
|
||||
{
|
||||
return std::visit(
|
||||
[&](auto const& value) {
|
||||
if constexpr (std::is_same_v<
|
||||
std::remove_cvref_t<decltype(value)>,
|
||||
Issue>)
|
||||
[&]<ValidIssueType TIss>(TIss const& value) {
|
||||
if constexpr (std::is_same_v<TIss, Issue>)
|
||||
{
|
||||
return accountHolds(view, account, value, zeroIfFrozen, j);
|
||||
return accountHolds(
|
||||
view, account, value, zeroIfFrozen, j, includeFullBalance);
|
||||
}
|
||||
return accountHolds(
|
||||
view, account, value, zeroIfFrozen, zeroIfUnauthorized, j);
|
||||
},
|
||||
asset.value());
|
||||
}
|
||||
|
||||
STAmount
|
||||
accountSpendable(
|
||||
ReadView const& view,
|
||||
AccountID const& account,
|
||||
Currency const& currency,
|
||||
AccountID const& issuer,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j)
|
||||
{
|
||||
if (isXRP(currency))
|
||||
return accountHolds(view, account, currency, issuer, zeroIfFrozen, j);
|
||||
|
||||
if (account == issuer)
|
||||
// If the account is the issuer, then their limit is effectively
|
||||
// infinite
|
||||
return STAmount{
|
||||
Issue{currency, issuer}, STAmount::cMaxValue, STAmount::cMaxOffset};
|
||||
|
||||
// IOU: Return balance on trust line modulo freeze
|
||||
SLE::const_pointer const sle =
|
||||
getLineIfUsable(view, account, currency, issuer, zeroIfFrozen, j);
|
||||
|
||||
return getTrustLineBalance(view, sle, account, currency, issuer, true, j);
|
||||
}
|
||||
|
||||
STAmount
|
||||
accountSpendable(
|
||||
ReadView const& view,
|
||||
AccountID const& account,
|
||||
Issue const& issue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
beast::Journal j)
|
||||
{
|
||||
return accountSpendable(
|
||||
view, account, issue.currency, issue.account, zeroIfFrozen, j);
|
||||
}
|
||||
|
||||
STAmount
|
||||
accountSpendable(
|
||||
ReadView const& view,
|
||||
AccountID const& account,
|
||||
MPTIssue const& mptIssue,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j)
|
||||
{
|
||||
if (account == mptIssue.getIssuer())
|
||||
{
|
||||
// if the account is the issuer, and the issuance exists, their limit is
|
||||
// the issuance limit minus the outstanding value
|
||||
auto const issuance =
|
||||
view.read(keylet::mptIssuance(mptIssue.getMptID()));
|
||||
|
||||
if (!issuance)
|
||||
{
|
||||
return STAmount{mptIssue};
|
||||
}
|
||||
return STAmount{
|
||||
mptIssue,
|
||||
issuance->at(~sfMaximumAmount).value_or(maxMPTokenAmount) -
|
||||
issuance->at(sfOutstandingAmount)};
|
||||
}
|
||||
|
||||
return accountHolds(
|
||||
view, account, mptIssue, zeroIfFrozen, zeroIfUnauthorized, j);
|
||||
}
|
||||
|
||||
[[nodiscard]] STAmount
|
||||
accountSpendable(
|
||||
ReadView const& view,
|
||||
AccountID const& account,
|
||||
Asset const& asset,
|
||||
FreezeHandling zeroIfFrozen,
|
||||
AuthHandling zeroIfUnauthorized,
|
||||
beast::Journal j)
|
||||
{
|
||||
return std::visit(
|
||||
[&](auto const& value) {
|
||||
if constexpr (std::is_same_v<
|
||||
std::remove_cvref_t<decltype(value)>,
|
||||
Issue>)
|
||||
else if constexpr (std::is_same_v<TIss, MPTIssue>)
|
||||
{
|
||||
return accountSpendable(view, account, value, zeroIfFrozen, j);
|
||||
return accountHolds(
|
||||
view,
|
||||
account,
|
||||
value,
|
||||
zeroIfFrozen,
|
||||
zeroIfUnauthorized,
|
||||
j,
|
||||
includeFullBalance);
|
||||
}
|
||||
return accountSpendable(
|
||||
view, account, value, zeroIfFrozen, zeroIfUnauthorized, j);
|
||||
},
|
||||
asset.value());
|
||||
}
|
||||
@@ -712,7 +667,7 @@ confineOwnerCount(
|
||||
<< "Account " << *id << " owner count set below 0!";
|
||||
}
|
||||
adjusted = 0;
|
||||
XRPL_ASSERT(!id, "ripple::confineOwnerCount : id is not set");
|
||||
XRPL_ASSERT(!id, "xrpl::confineOwnerCount : id is not set");
|
||||
}
|
||||
}
|
||||
return adjusted;
|
||||
@@ -745,8 +700,7 @@ xrpLiquid(
|
||||
STAmount const amount =
|
||||
(balance < reserve) ? STAmount{0} : balance - reserve;
|
||||
|
||||
JLOG(j.trace()) << "accountHolds:"
|
||||
<< " account=" << to_string(id)
|
||||
JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(id)
|
||||
<< " amount=" << amount.getFullText()
|
||||
<< " fullBalance=" << fullBalance.getFullText()
|
||||
<< " balance=" << balance.getFullText()
|
||||
@@ -762,8 +716,7 @@ forEachItem(
|
||||
Keylet const& root,
|
||||
std::function<void(std::shared_ptr<SLE const> const&)> const& f)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
root.type == ltDIR_NODE, "ripple::forEachItem : valid root type");
|
||||
XRPL_ASSERT(root.type == ltDIR_NODE, "xrpl::forEachItem : valid root type");
|
||||
|
||||
if (root.type != ltDIR_NODE)
|
||||
return;
|
||||
@@ -794,7 +747,7 @@ forEachItemAfter(
|
||||
std::function<bool(std::shared_ptr<SLE const> const&)> const& f)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
root.type == ltDIR_NODE, "ripple::forEachItemAfter : valid root type");
|
||||
root.type == ltDIR_NODE, "xrpl::forEachItemAfter : valid root type");
|
||||
|
||||
if (root.type != ltDIR_NODE)
|
||||
return false;
|
||||
@@ -908,14 +861,14 @@ areCompatible(
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
if (validLedger.info().seq < testLedger.info().seq)
|
||||
if (validLedger.header().seq < testLedger.header().seq)
|
||||
{
|
||||
// valid -> ... -> test
|
||||
auto hash = hashOfSeq(
|
||||
testLedger,
|
||||
validLedger.info().seq,
|
||||
validLedger.header().seq,
|
||||
beast::Journal{beast::Journal::getNullSink()});
|
||||
if (hash && (*hash != validLedger.info().hash))
|
||||
if (hash && (*hash != validLedger.header().hash))
|
||||
{
|
||||
JLOG(s) << reason << " incompatible with valid ledger";
|
||||
|
||||
@@ -924,14 +877,14 @@ areCompatible(
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else if (validLedger.info().seq > testLedger.info().seq)
|
||||
else if (validLedger.header().seq > testLedger.header().seq)
|
||||
{
|
||||
// test -> ... -> valid
|
||||
auto hash = hashOfSeq(
|
||||
validLedger,
|
||||
testLedger.info().seq,
|
||||
testLedger.header().seq,
|
||||
beast::Journal{beast::Journal::getNullSink()});
|
||||
if (hash && (*hash != testLedger.info().hash))
|
||||
if (hash && (*hash != testLedger.header().hash))
|
||||
{
|
||||
JLOG(s) << reason << " incompatible preceding ledger";
|
||||
|
||||
@@ -941,8 +894,8 @@ areCompatible(
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(validLedger.info().seq == testLedger.info().seq) &&
|
||||
(validLedger.info().hash != testLedger.info().hash))
|
||||
(validLedger.header().seq == testLedger.header().seq) &&
|
||||
(validLedger.header().hash != testLedger.header().hash))
|
||||
{
|
||||
// Same sequence number, different hash
|
||||
JLOG(s) << reason << " incompatible ledger";
|
||||
@@ -952,11 +905,11 @@ areCompatible(
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
JLOG(s) << "Val: " << validLedger.info().seq << " "
|
||||
<< to_string(validLedger.info().hash);
|
||||
JLOG(s) << "Val: " << validLedger.header().seq << " "
|
||||
<< to_string(validLedger.header().hash);
|
||||
|
||||
JLOG(s) << "New: " << testLedger.info().seq << " "
|
||||
<< to_string(testLedger.info().hash);
|
||||
JLOG(s) << "New: " << testLedger.header().seq << " "
|
||||
<< to_string(testLedger.header().hash);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -972,7 +925,7 @@ areCompatible(
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
if (testLedger.info().seq > validIndex)
|
||||
if (testLedger.header().seq > validIndex)
|
||||
{
|
||||
// Ledger we are testing follows last valid ledger
|
||||
auto hash = hashOfSeq(
|
||||
@@ -988,8 +941,8 @@ areCompatible(
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(validIndex == testLedger.info().seq) &&
|
||||
(testLedger.info().hash != validHash))
|
||||
(validIndex == testLedger.header().seq) &&
|
||||
(testLedger.header().hash != validHash))
|
||||
{
|
||||
JLOG(s) << reason << " incompatible ledger";
|
||||
|
||||
@@ -1000,8 +953,8 @@ areCompatible(
|
||||
{
|
||||
JLOG(s) << "Val: " << validIndex << " " << to_string(validHash);
|
||||
|
||||
JLOG(s) << "New: " << testLedger.info().seq << " "
|
||||
<< to_string(testLedger.info().hash);
|
||||
JLOG(s) << "New: " << testLedger.header().seq << " "
|
||||
<< to_string(testLedger.header().hash);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1072,9 +1025,9 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal)
|
||||
return std::nullopt;
|
||||
}
|
||||
if (seq == ledger.seq())
|
||||
return ledger.info().hash;
|
||||
return ledger.header().hash;
|
||||
if (seq == (ledger.seq() - 1))
|
||||
return ledger.info().parentHash;
|
||||
return ledger.header().parentHash;
|
||||
|
||||
if (int diff = ledger.seq() - seq; diff <= 256)
|
||||
{
|
||||
@@ -1085,7 +1038,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal)
|
||||
XRPL_ASSERT(
|
||||
hashIndex->getFieldU32(sfLastLedgerSequence) ==
|
||||
(ledger.seq() - 1),
|
||||
"ripple::hashOfSeq : matching ledger sequence");
|
||||
"xrpl::hashOfSeq : matching ledger sequence");
|
||||
STVector256 vec = hashIndex->getFieldV256(sfHashes);
|
||||
if (vec.size() >= diff)
|
||||
return vec[vec.size() - diff];
|
||||
@@ -1096,7 +1049,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal)
|
||||
else
|
||||
{
|
||||
JLOG(journal.warn())
|
||||
<< "Ledger " << ledger.seq() << ":" << ledger.info().hash
|
||||
<< "Ledger " << ledger.seq() << ":" << ledger.header().hash
|
||||
<< " missing normal list";
|
||||
}
|
||||
}
|
||||
@@ -1113,9 +1066,9 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal)
|
||||
if (hashIndex)
|
||||
{
|
||||
auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence);
|
||||
XRPL_ASSERT(lastSeq >= seq, "ripple::hashOfSeq : minimum last ledger");
|
||||
XRPL_ASSERT(lastSeq >= seq, "xrpl::hashOfSeq : minimum last ledger");
|
||||
XRPL_ASSERT(
|
||||
(lastSeq & 0xff) == 0, "ripple::hashOfSeq : valid last ledger");
|
||||
(lastSeq & 0xff) == 0, "xrpl::hashOfSeq : valid last ledger");
|
||||
auto const diff = (lastSeq - seq) >> 8;
|
||||
STVector256 vec = hashIndex->getFieldV256(sfHashes);
|
||||
if (vec.size() > diff)
|
||||
@@ -1141,7 +1094,7 @@ adjustOwnerCount(
|
||||
{
|
||||
if (!sle)
|
||||
return;
|
||||
XRPL_ASSERT(amount, "ripple::adjustOwnerCount : nonzero amount input");
|
||||
XRPL_ASSERT(amount, "xrpl::adjustOwnerCount : nonzero amount input");
|
||||
std::uint32_t const current{sle->getFieldU32(sfOwnerCount)};
|
||||
AccountID const id = (*sle)[sfAccount];
|
||||
std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j);
|
||||
@@ -1153,7 +1106,7 @@ adjustOwnerCount(
|
||||
std::function<void(SLE::ref)>
|
||||
describeOwnerDir(AccountID const& account)
|
||||
{
|
||||
return [&account](std::shared_ptr<SLE> const& sle) {
|
||||
return [account](std::shared_ptr<SLE> const& sle) {
|
||||
(*sle)[sfOwner] = account;
|
||||
};
|
||||
}
|
||||
@@ -1181,7 +1134,8 @@ pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey)
|
||||
for (std::uint16_t i = 0; i < maxAccountAttempts; ++i)
|
||||
{
|
||||
ripesha_hasher rsh;
|
||||
auto const hash = sha512Half(i, view.info().parentHash, pseudoOwnerKey);
|
||||
auto const hash =
|
||||
sha512Half(i, view.header().parentHash, pseudoOwnerKey);
|
||||
rsh(hash.data(), hash.size());
|
||||
AccountID const ret{static_cast<ripesha_hasher::result_type>(rsh)};
|
||||
if (!view.read(keylet::account(ret)))
|
||||
@@ -1205,9 +1159,8 @@ getPseudoAccountFields()
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
LogicError(
|
||||
"ripple::getPseudoAccountFields : unable to find account root "
|
||||
"ledger "
|
||||
"format");
|
||||
"xrpl::getPseudoAccountFields : unable to find account root "
|
||||
"ledger format");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
auto const& soTemplate = ar->getSOTemplate();
|
||||
@@ -1258,7 +1211,7 @@ createPseudoAccount(
|
||||
[&ownerField](SField const* sf) -> bool {
|
||||
return *sf == ownerField;
|
||||
}) == 1,
|
||||
"ripple::createPseudoAccount : valid owner field");
|
||||
"xrpl::createPseudoAccount : valid owner field");
|
||||
|
||||
auto const accountId = pseudoAccountAddress(view, pseudoOwnerKey);
|
||||
if (accountId == beast::zero)
|
||||
@@ -1343,12 +1296,58 @@ checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag)
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if a withdrawal amount into the destination account exceeds
|
||||
* any applicable receiving limit.
|
||||
* Called by VaultWithdraw and LoanBrokerCoverWithdraw.
|
||||
*
|
||||
* IOU : Performs the trustline check against the destination account's
|
||||
* credit limit to ensure the account's trust maximum is not exceeded.
|
||||
*
|
||||
* MPT: The limit check is effectively skipped (returns true). This is
|
||||
* because MPT MaximumAmount relates to token supply, and withdrawal does not
|
||||
* involve minting new tokens that could exceed the global cap.
|
||||
* On withdrawal, tokens are simply transferred from the vault's pseudo-account
|
||||
* to the destination account. Since no new MPT tokens are minted during this
|
||||
* transfer, the withdrawal cannot violate the MPT MaximumAmount/supply cap
|
||||
* even if `from` is the issuer.
|
||||
*/
|
||||
static TER
|
||||
withdrawToDestExceedsLimit(
|
||||
ReadView const& view,
|
||||
AccountID const& from,
|
||||
AccountID const& to,
|
||||
STAmount const& amount)
|
||||
{
|
||||
auto const& issuer = amount.getIssuer();
|
||||
if (from == to || to == issuer || isXRP(issuer))
|
||||
return tesSUCCESS;
|
||||
|
||||
return std::visit(
|
||||
[&]<ValidIssueType TIss>(TIss const& issue) -> TER {
|
||||
if constexpr (std::is_same_v<TIss, Issue>)
|
||||
{
|
||||
auto const& currency = issue.currency;
|
||||
auto const owed = creditBalance(view, to, issuer, currency);
|
||||
if (owed <= beast::zero)
|
||||
{
|
||||
auto const limit = creditLimit(view, to, issuer, currency);
|
||||
if (-owed >= limit || amount > (limit + owed))
|
||||
return tecNO_LINE;
|
||||
}
|
||||
}
|
||||
return tesSUCCESS;
|
||||
},
|
||||
amount.asset().value());
|
||||
}
|
||||
|
||||
[[nodiscard]] TER
|
||||
canWithdraw(
|
||||
AccountID const& from,
|
||||
ReadView const& view,
|
||||
AccountID const& from,
|
||||
AccountID const& to,
|
||||
SLE::const_ref toSle,
|
||||
STAmount const& amount,
|
||||
bool hasDestinationTag)
|
||||
{
|
||||
if (auto const ret = checkDestinationAndTag(toSle, hasDestinationTag))
|
||||
@@ -1363,19 +1362,20 @@ canWithdraw(
|
||||
return tecNO_PERMISSION;
|
||||
}
|
||||
|
||||
return tesSUCCESS;
|
||||
return withdrawToDestExceedsLimit(view, from, to, amount);
|
||||
}
|
||||
|
||||
[[nodiscard]] TER
|
||||
canWithdraw(
|
||||
AccountID const& from,
|
||||
ReadView const& view,
|
||||
AccountID const& from,
|
||||
AccountID const& to,
|
||||
STAmount const& amount,
|
||||
bool hasDestinationTag)
|
||||
{
|
||||
auto const toSle = view.read(keylet::account(to));
|
||||
|
||||
return canWithdraw(from, view, to, toSle, hasDestinationTag);
|
||||
return canWithdraw(view, from, to, toSle, amount, hasDestinationTag);
|
||||
}
|
||||
|
||||
[[nodiscard]] TER
|
||||
@@ -1384,7 +1384,8 @@ canWithdraw(ReadView const& view, STTx const& tx)
|
||||
auto const from = tx[sfAccount];
|
||||
auto const to = tx[~sfDestination].value_or(from);
|
||||
|
||||
return canWithdraw(from, view, to, tx.isFieldPresent(sfDestinationTag));
|
||||
return canWithdraw(
|
||||
view, from, to, tx[sfAmount], tx.isFieldPresent(sfDestinationTag));
|
||||
}
|
||||
|
||||
TER
|
||||
@@ -1577,7 +1578,7 @@ authorizeMPToken(
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::authorizeMPToken : invalid issuance or issuers token");
|
||||
"xrpl::authorizeMPToken : invalid issuance or issuers token");
|
||||
if (view.rules().enabled(featureLendingProtocol))
|
||||
return tecINTERNAL;
|
||||
// LCOV_EXCL_STOP
|
||||
@@ -1661,7 +1662,7 @@ trustCreate(
|
||||
if (uLowAccountID == uHighAccountID)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("ripple::trustCreate : trust line to self");
|
||||
UNREACHABLE("xrpl::trustCreate : trust line to self");
|
||||
if (view.rules().enabled(featureLendingProtocol))
|
||||
return tecINTERNAL;
|
||||
// LCOV_EXCL_STOP
|
||||
@@ -1689,14 +1690,14 @@ trustCreate(
|
||||
bool const bSetDst = saLimit.getIssuer() == uDstAccountID;
|
||||
bool const bSetHigh = bSrcHigh ^ bSetDst;
|
||||
|
||||
XRPL_ASSERT(sleAccount, "ripple::trustCreate : non-null SLE");
|
||||
XRPL_ASSERT(sleAccount, "xrpl::trustCreate : non-null SLE");
|
||||
if (!sleAccount)
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
XRPL_ASSERT(
|
||||
sleAccount->getAccountID(sfAccount) ==
|
||||
(bSetHigh ? uHighAccountID : uLowAccountID),
|
||||
"ripple::trustCreate : matching account ID");
|
||||
"xrpl::trustCreate : matching account ID");
|
||||
auto const slePeer =
|
||||
view.peek(keylet::account(bSetHigh ? uLowAccountID : uHighAccountID));
|
||||
if (!slePeer)
|
||||
@@ -1933,7 +1934,7 @@ offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sle->isFlag(lsfHybrid) && sle->isFieldPresent(sfDomainID),
|
||||
"ripple::offerDelete : should be a hybrid domain offer");
|
||||
"xrpl::offerDelete : should be a hybrid domain offer");
|
||||
|
||||
auto const& additionalBookDirs = sle->getFieldArray(sfAdditionalBooks);
|
||||
|
||||
@@ -1976,23 +1977,23 @@ rippleCreditIOU(
|
||||
// Make sure issuer is involved.
|
||||
XRPL_ASSERT(
|
||||
!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer,
|
||||
"ripple::rippleCreditIOU : matching issuer or don't care");
|
||||
"xrpl::rippleCreditIOU : matching issuer or don't care");
|
||||
(void)issuer;
|
||||
|
||||
// Disallow sending to self.
|
||||
XRPL_ASSERT(
|
||||
uSenderID != uReceiverID,
|
||||
"ripple::rippleCreditIOU : sender is not receiver");
|
||||
"xrpl::rippleCreditIOU : sender is not receiver");
|
||||
|
||||
bool const bSenderHigh = uSenderID > uReceiverID;
|
||||
auto const index = keylet::line(uSenderID, uReceiverID, currency);
|
||||
|
||||
XRPL_ASSERT(
|
||||
!isXRP(uSenderID) && uSenderID != noAccount(),
|
||||
"ripple::rippleCreditIOU : sender is not XRP");
|
||||
"xrpl::rippleCreditIOU : sender is not XRP");
|
||||
XRPL_ASSERT(
|
||||
!isXRP(uReceiverID) && uReceiverID != noAccount(),
|
||||
"ripple::rippleCreditIOU : receiver is not XRP");
|
||||
"xrpl::rippleCreditIOU : receiver is not XRP");
|
||||
|
||||
// If the line exists, modify it accordingly.
|
||||
if (auto const sleRippleState = view.peek(index))
|
||||
@@ -2129,10 +2130,10 @@ rippleSendIOU(
|
||||
|
||||
XRPL_ASSERT(
|
||||
!isXRP(uSenderID) && !isXRP(uReceiverID),
|
||||
"ripple::rippleSendIOU : neither sender nor receiver is XRP");
|
||||
"xrpl::rippleSendIOU : neither sender nor receiver is XRP");
|
||||
XRPL_ASSERT(
|
||||
uSenderID != uReceiverID,
|
||||
"ripple::rippleSendIOU : sender is not receiver");
|
||||
"xrpl::rippleSendIOU : sender is not receiver");
|
||||
|
||||
if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount())
|
||||
{
|
||||
@@ -2183,7 +2184,7 @@ rippleSendMultiIOU(
|
||||
auto const& issuer = issue.getIssuer();
|
||||
|
||||
XRPL_ASSERT(
|
||||
!isXRP(senderID), "ripple::rippleSendMultiIOU : sender is not XRP");
|
||||
!isXRP(senderID), "xrpl::rippleSendMultiIOU : sender is not XRP");
|
||||
|
||||
// These may diverge
|
||||
STAmount takeFromSender{issue};
|
||||
@@ -2203,7 +2204,7 @@ rippleSendMultiIOU(
|
||||
|
||||
XRPL_ASSERT(
|
||||
!isXRP(receiverID),
|
||||
"ripple::rippleSendMultiIOU : receiver is not XRP");
|
||||
"xrpl::rippleSendMultiIOU : receiver is not XRP");
|
||||
|
||||
if (senderID == issuer || receiverID == issuer || issuer == noAccount())
|
||||
{
|
||||
@@ -2269,7 +2270,7 @@ accountSendIOU(
|
||||
// LCOV_EXCL_START
|
||||
XRPL_ASSERT(
|
||||
saAmount >= beast::zero && !saAmount.holds<MPTIssue>(),
|
||||
"ripple::accountSendIOU : minimum amount and not MPT");
|
||||
"xrpl::accountSendIOU : minimum amount and not MPT");
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -2383,7 +2384,7 @@ accountSendMultiIOU(
|
||||
{
|
||||
XRPL_ASSERT_PARTS(
|
||||
receivers.size() > 1,
|
||||
"ripple::accountSendMultiIOU",
|
||||
"xrpl::accountSendMultiIOU",
|
||||
"multiple recipients provided");
|
||||
|
||||
if (!issue.native())
|
||||
@@ -2584,7 +2585,7 @@ rippleSendMPT(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
uSenderID != uReceiverID,
|
||||
"ripple::rippleSendMPT : sender is not receiver");
|
||||
"xrpl::rippleSendMPT : sender is not receiver");
|
||||
|
||||
// Safe to get MPT since rippleSendMPT is only called by accountSendMPT
|
||||
auto const& issuer = saAmount.getIssuer();
|
||||
@@ -2745,7 +2746,7 @@ accountSendMPT(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
saAmount >= beast::zero && saAmount.holds<MPTIssue>(),
|
||||
"ripple::accountSendMPT : minimum amount and MPT");
|
||||
"xrpl::accountSendMPT : minimum amount and MPT");
|
||||
|
||||
/* If we aren't sending anything or if the sender is the same as the
|
||||
* receiver then we don't need to do anything.
|
||||
@@ -2806,7 +2807,7 @@ accountSendMulti(
|
||||
{
|
||||
XRPL_ASSERT_PARTS(
|
||||
receivers.size() > 1,
|
||||
"ripple::accountSendMulti",
|
||||
"xrpl::accountSendMulti",
|
||||
"multiple recipients provided");
|
||||
return std::visit(
|
||||
[&]<ValidIssueType TIss>(TIss const& issue) {
|
||||
@@ -2883,14 +2884,14 @@ issueIOU(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!isXRP(account) && !isXRP(issue.account),
|
||||
"ripple::issueIOU : neither account nor issuer is XRP");
|
||||
"xrpl::issueIOU : neither account nor issuer is XRP");
|
||||
|
||||
// Consistency check
|
||||
XRPL_ASSERT(issue == amount.issue(), "ripple::issueIOU : matching issue");
|
||||
XRPL_ASSERT(issue == amount.issue(), "xrpl::issueIOU : matching issue");
|
||||
|
||||
// Can't send to self!
|
||||
XRPL_ASSERT(
|
||||
issue.account != account, "ripple::issueIOU : not issuer account");
|
||||
issue.account != account, "xrpl::issueIOU : not issuer account");
|
||||
|
||||
JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": "
|
||||
<< amount.getFullText();
|
||||
@@ -2983,14 +2984,14 @@ redeemIOU(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!isXRP(account) && !isXRP(issue.account),
|
||||
"ripple::redeemIOU : neither account nor issuer is XRP");
|
||||
"xrpl::redeemIOU : neither account nor issuer is XRP");
|
||||
|
||||
// Consistency check
|
||||
XRPL_ASSERT(issue == amount.issue(), "ripple::redeemIOU : matching issue");
|
||||
XRPL_ASSERT(issue == amount.issue(), "xrpl::redeemIOU : matching issue");
|
||||
|
||||
// Can't send to self!
|
||||
XRPL_ASSERT(
|
||||
issue.account != account, "ripple::redeemIOU : not issuer account");
|
||||
issue.account != account, "xrpl::redeemIOU : not issuer account");
|
||||
|
||||
JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": "
|
||||
<< amount.getFullText();
|
||||
@@ -3057,10 +3058,10 @@ transferXRP(
|
||||
beast::Journal j)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
from != beast::zero, "ripple::transferXRP : nonzero from account");
|
||||
XRPL_ASSERT(to != beast::zero, "ripple::transferXRP : nonzero to account");
|
||||
XRPL_ASSERT(from != to, "ripple::transferXRP : sender is not receiver");
|
||||
XRPL_ASSERT(amount.native(), "ripple::transferXRP : amount is XRP");
|
||||
from != beast::zero, "xrpl::transferXRP : nonzero from account");
|
||||
XRPL_ASSERT(to != beast::zero, "xrpl::transferXRP : nonzero to account");
|
||||
XRPL_ASSERT(from != to, "xrpl::transferXRP : sender is not receiver");
|
||||
XRPL_ASSERT(amount.native(), "xrpl::transferXRP : amount is XRP");
|
||||
|
||||
SLE::pointer const sender = view.peek(keylet::account(from));
|
||||
SLE::pointer const receiver = view.peek(keylet::account(to));
|
||||
@@ -3194,7 +3195,7 @@ requireAuth(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
sleIssuance->getFieldU32(sfFlags) & lsfMPTRequireAuth,
|
||||
"ripple::requireAuth : issuance requires authorization");
|
||||
"xrpl::requireAuth : issuance requires authorization");
|
||||
// ter = tefINTERNAL | tecOBJECT_NOT_FOUND | tecNO_AUTH | tecEXPIRED
|
||||
if (auto const ter =
|
||||
credentials::validDomain(view, *maybeDomainID, account);
|
||||
@@ -3235,7 +3236,7 @@ enforceMPTokenAuthorization(
|
||||
|
||||
XRPL_ASSERT(
|
||||
sleIssuance->isFlag(lsfMPTRequireAuth),
|
||||
"ripple::enforceMPTokenAuthorization : authorization required");
|
||||
"xrpl::enforceMPTokenAuthorization : authorization required");
|
||||
|
||||
if (account == sleIssuance->at(sfIssuer))
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
@@ -3245,7 +3246,7 @@ enforceMPTokenAuthorization(
|
||||
auto const maybeDomainID = sleIssuance->at(~sfDomainID);
|
||||
bool expired = false;
|
||||
bool const authorizedByDomain = [&]() -> bool {
|
||||
// NOTE: defensive here, shuld be checked in preclaim
|
||||
// NOTE: defensive here, should be checked in preclaim
|
||||
if (!maybeDomainID.has_value())
|
||||
return false; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -3281,7 +3282,7 @@ enforceMPTokenAuthorization(
|
||||
// MPToken which requires authorization by the token issuer.
|
||||
XRPL_ASSERT(
|
||||
sleToken != nullptr && !maybeDomainID.has_value(),
|
||||
"ripple::enforceMPTokenAuthorization : found MPToken");
|
||||
"xrpl::enforceMPTokenAuthorization : found MPToken");
|
||||
if (sleToken->isFlag(lsfMPTAuthorized))
|
||||
return tesSUCCESS;
|
||||
|
||||
@@ -3293,7 +3294,7 @@ enforceMPTokenAuthorization(
|
||||
// lsfMPTAuthorized because it is meaningless. Return tesSUCCESS
|
||||
XRPL_ASSERT(
|
||||
maybeDomainID.has_value(),
|
||||
"ripple::enforceMPTokenAuthorization : found MPToken for domain");
|
||||
"xrpl::enforceMPTokenAuthorization : found MPToken for domain");
|
||||
return tesSUCCESS;
|
||||
}
|
||||
else if (authorizedByDomain)
|
||||
@@ -3302,7 +3303,7 @@ enforceMPTokenAuthorization(
|
||||
// authorized by domain. Proceed to create it, then return tesSUCCESS
|
||||
XRPL_ASSERT(
|
||||
maybeDomainID.has_value() && sleToken == nullptr,
|
||||
"ripple::enforceMPTokenAuthorization : new MPToken for domain");
|
||||
"xrpl::enforceMPTokenAuthorization : new MPToken for domain");
|
||||
if (auto const err = authorizeMPToken(
|
||||
view,
|
||||
priorBalance, // priorBalance
|
||||
@@ -3317,7 +3318,7 @@ enforceMPTokenAuthorization(
|
||||
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE(
|
||||
"ripple::enforceMPTokenAuthorization : condition list is incomplete");
|
||||
"xrpl::enforceMPTokenAuthorization : condition list is incomplete");
|
||||
return tefINTERNAL;
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
@@ -3441,7 +3442,7 @@ cleanupOnAccountDelete(
|
||||
// back to 'it' to "un-invalidate" the iterator.
|
||||
XRPL_ASSERT(
|
||||
uDirEntry >= 1,
|
||||
"ripple::cleanupOnAccountDelete : minimum dir entries");
|
||||
"xrpl::cleanupOnAccountDelete : minimum dir entries");
|
||||
if (uDirEntry == 0)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
@@ -3529,8 +3530,7 @@ rippleCredit(
|
||||
else
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!bCheckIssuer,
|
||||
"ripple::rippleCredit : not checking issuer");
|
||||
!bCheckIssuer, "xrpl::rippleCredit : not checking issuer");
|
||||
return rippleCreditMPT(
|
||||
view, uSenderID, uReceiverID, saAmount, j);
|
||||
}
|
||||
@@ -3546,10 +3546,10 @@ assetsToSharesDeposit(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!assets.negative(),
|
||||
"ripple::assetsToSharesDeposit : non-negative assets");
|
||||
"xrpl::assetsToSharesDeposit : non-negative assets");
|
||||
XRPL_ASSERT(
|
||||
assets.asset() == vault->at(sfAsset),
|
||||
"ripple::assetsToSharesDeposit : assets and vault match");
|
||||
"xrpl::assetsToSharesDeposit : assets and vault match");
|
||||
if (assets.negative() || assets.asset() != vault->at(sfAsset))
|
||||
return std::nullopt; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -3574,10 +3574,10 @@ sharesToAssetsDeposit(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!shares.negative(),
|
||||
"ripple::sharesToAssetsDeposit : non-negative shares");
|
||||
"xrpl::sharesToAssetsDeposit : non-negative shares");
|
||||
XRPL_ASSERT(
|
||||
shares.asset() == vault->at(sfShareMPTID),
|
||||
"ripple::sharesToAssetsDeposit : shares and vault match");
|
||||
"xrpl::sharesToAssetsDeposit : shares and vault match");
|
||||
if (shares.negative() || shares.asset() != vault->at(sfShareMPTID))
|
||||
return std::nullopt; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -3604,10 +3604,10 @@ assetsToSharesWithdraw(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!assets.negative(),
|
||||
"ripple::assetsToSharesDeposit : non-negative assets");
|
||||
"xrpl::assetsToSharesDeposit : non-negative assets");
|
||||
XRPL_ASSERT(
|
||||
assets.asset() == vault->at(sfAsset),
|
||||
"ripple::assetsToSharesWithdraw : assets and vault match");
|
||||
"xrpl::assetsToSharesWithdraw : assets and vault match");
|
||||
if (assets.negative() || assets.asset() != vault->at(sfAsset))
|
||||
return std::nullopt; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -3632,10 +3632,10 @@ sharesToAssetsWithdraw(
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
!shares.negative(),
|
||||
"ripple::sharesToAssetsDeposit : non-negative shares");
|
||||
"xrpl::sharesToAssetsDeposit : non-negative shares");
|
||||
XRPL_ASSERT(
|
||||
shares.asset() == vault->at(sfShareMPTID),
|
||||
"ripple::sharesToAssetsWithdraw : shares and vault match");
|
||||
"xrpl::sharesToAssetsWithdraw : shares and vault match");
|
||||
if (shares.negative() || shares.asset() != vault->at(sfShareMPTID))
|
||||
return std::nullopt; // LCOV_EXCL_LINE
|
||||
|
||||
@@ -3758,7 +3758,7 @@ rippleUnlockEscrowMPT(
|
||||
if (!view.rules().enabled(fixTokenEscrowV1))
|
||||
XRPL_ASSERT(
|
||||
netAmount == grossAmount,
|
||||
"ripple::rippleUnlockEscrowMPT : netAmount == grossAmount");
|
||||
"xrpl::rippleUnlockEscrowMPT : netAmount == grossAmount");
|
||||
|
||||
auto const& issuer = netAmount.getIssuer();
|
||||
auto const& mptIssue = netAmount.get<MPTIssue>();
|
||||
@@ -3926,4 +3926,4 @@ after(NetClock::time_point now, std::uint32_t mark)
|
||||
return now.time_since_epoch().count() > mark;
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -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(
|
||||
@@ -49,11 +49,11 @@ registerSSLCerts(
|
||||
return;
|
||||
}
|
||||
|
||||
auto warn = [&](std::string const& mesg) {
|
||||
auto warn = [&](std::string const& msg) {
|
||||
// Buffer based on asio recommended size
|
||||
char buf[256];
|
||||
::ERR_error_string_n(ec.value(), buf, sizeof(buf));
|
||||
JLOG(j.warn()) << mesg << " " << buf;
|
||||
JLOG(j.warn()) << msg << " " << buf;
|
||||
::ERR_clear_error();
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ Database::stop()
|
||||
<< duration_cast<std::chrono::milliseconds>(
|
||||
steady_clock::now() - start)
|
||||
.count()
|
||||
<< " millseconds";
|
||||
<< " milliseconds";
|
||||
}
|
||||
|
||||
void
|
||||
@@ -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 {
|
||||
|
||||
@@ -18,8 +18,8 @@ void
|
||||
ManagerImp::missing_backend()
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
"Your rippled.cfg is missing a [node_db] entry, "
|
||||
"please see the rippled-example.cfg file!");
|
||||
"Your xrpld.cfg is missing a [node_db] entry, "
|
||||
"please see the xrpld-example.cfg file!");
|
||||
}
|
||||
|
||||
// We shouldn't rely on global variables for lifetime management because their
|
||||
@@ -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
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
#include <xrpl/beast/core/SemanticVersion.h>
|
||||
#include <xrpl/protocol/BuildInfo.h>
|
||||
|
||||
#include <boost/preprocessor/stringize.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace BuildInfo {
|
||||
|
||||
@@ -17,10 +19,10 @@ 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)
|
||||
#if defined(DEBUG) || defined(SANITIZERS)
|
||||
"+"
|
||||
#ifdef GIT_COMMIT_HASH
|
||||
GIT_COMMIT_HASH
|
||||
@@ -28,13 +30,13 @@ char const* const versionString = "3.1.0-b0"
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
"DEBUG"
|
||||
#ifdef SANITIZER
|
||||
#ifdef SANITIZERS
|
||||
"."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SANITIZER
|
||||
BOOST_PP_STRINGIZE(SANITIZER)
|
||||
#ifdef SANITIZERS
|
||||
BOOST_PP_STRINGIZE(SANITIZERS) // cspell: disable-line
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -159,4 +161,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
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
// Do not remove. Forces IOUAmount.h to stay first, to verify it can compile
|
||||
// without any hidden dependencies
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
@@ -14,11 +17,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
|
||||
// Use a static inside a function to help prevent order-of-initialzation issues
|
||||
// Use a static inside a function to help prevent order-of-initialization issues
|
||||
LocalValue<bool>&
|
||||
getStaticSTNumberSwitchover()
|
||||
{
|
||||
@@ -40,11 +43,24 @@ setSTNumberSwitchover(bool v)
|
||||
}
|
||||
|
||||
/* The range for the mantissa when normalized */
|
||||
static std::int64_t constexpr minMantissa = 1000000000000000ull;
|
||||
static std::int64_t constexpr maxMantissa = 9999999999999999ull;
|
||||
// log(2^63,10) ~ 18.96
|
||||
//
|
||||
static std::int64_t constexpr minMantissa = STAmount::cMinValue;
|
||||
static std::int64_t constexpr maxMantissa = STAmount::cMaxValue;
|
||||
/* The range for the exponent when normalized */
|
||||
static int constexpr minExponent = -96;
|
||||
static int constexpr maxExponent = 80;
|
||||
static int constexpr minExponent = STAmount::cMinOffset;
|
||||
static int constexpr maxExponent = STAmount::cMaxOffset;
|
||||
|
||||
IOUAmount
|
||||
IOUAmount::fromNumber(Number const& number)
|
||||
{
|
||||
// Need to create a default IOUAmount and assign directly so it doesn't try
|
||||
// to normalize, which calls fromNumber
|
||||
IOUAmount result{};
|
||||
std::tie(result.mantissa_, result.exponent_) =
|
||||
number.normalizeToRange(minMantissa, maxMantissa);
|
||||
return result;
|
||||
}
|
||||
|
||||
IOUAmount
|
||||
IOUAmount::minPositiveAmount()
|
||||
@@ -64,8 +80,7 @@ IOUAmount::normalize()
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
Number const v{mantissa_, exponent_};
|
||||
mantissa_ = v.mantissa();
|
||||
exponent_ = v.exponent();
|
||||
*this = fromNumber(v);
|
||||
if (exponent_ > maxExponent)
|
||||
Throw<std::overflow_error>("value overflow");
|
||||
if (exponent_ < minExponent)
|
||||
@@ -106,8 +121,7 @@ IOUAmount::normalize()
|
||||
mantissa_ = -mantissa_;
|
||||
}
|
||||
|
||||
IOUAmount::IOUAmount(Number const& other)
|
||||
: mantissa_(other.mantissa()), exponent_(other.exponent())
|
||||
IOUAmount::IOUAmount(Number const& other) : IOUAmount(fromNumber(other))
|
||||
{
|
||||
if (exponent_ > maxExponent)
|
||||
Throw<std::overflow_error>("value overflow");
|
||||
@@ -303,4 +317,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.
|
||||
|
||||
@@ -97,8 +97,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,
|
||||
@@ -123,9 +122,9 @@ getBookBase(Book const& book)
|
||||
uint256
|
||||
getQualityNext(uint256 const& uBase)
|
||||
{
|
||||
static constexpr uint256 nextq(
|
||||
static constexpr uint256 nextQuality(
|
||||
"0000000000000000000000000000000000000000000000010000000000000000");
|
||||
return uBase + nextq;
|
||||
return uBase + nextQuality;
|
||||
}
|
||||
|
||||
std::uint64_t
|
||||
@@ -145,7 +144,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());
|
||||
}
|
||||
|
||||
@@ -232,7 +231,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
|
||||
@@ -263,7 +262,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
|
||||
@@ -283,7 +282,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)};
|
||||
}
|
||||
|
||||
@@ -402,7 +401,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)};
|
||||
}
|
||||
|
||||
@@ -577,4 +576,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()
|
||||
{
|
||||
@@ -180,4 +180,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
|
||||
@@ -49,6 +49,12 @@ Issue::native() const
|
||||
return *this == xrpIssue();
|
||||
}
|
||||
|
||||
bool
|
||||
Issue::integral() const
|
||||
{
|
||||
return native();
|
||||
}
|
||||
|
||||
bool
|
||||
isConsistent(Issue const& ac)
|
||||
{
|
||||
@@ -132,4 +138,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()
|
||||
{
|
||||
@@ -40,4 +40,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()
|
||||
{
|
||||
@@ -11,7 +11,7 @@ Permission::Permission()
|
||||
#pragma push_macro("TRANSACTION")
|
||||
#undef TRANSACTION
|
||||
|
||||
#define TRANSACTION(tag, value, name, delegatable, amendment, ...) \
|
||||
#define TRANSACTION(tag, value, name, delegable, amendment, ...) \
|
||||
{value, amendment},
|
||||
|
||||
#include <xrpl/protocol/detail/transactions.macro>
|
||||
@@ -20,11 +20,11 @@ Permission::Permission()
|
||||
#pragma pop_macro("TRANSACTION")
|
||||
};
|
||||
|
||||
delegatableTx_ = {
|
||||
delegableTx_ = {
|
||||
#pragma push_macro("TRANSACTION")
|
||||
#undef TRANSACTION
|
||||
|
||||
#define TRANSACTION(tag, value, name, delegatable, ...) {value, delegatable},
|
||||
#define TRANSACTION(tag, value, name, delegable, ...) {value, delegable},
|
||||
|
||||
#include <xrpl/protocol/detail/transactions.macro>
|
||||
|
||||
@@ -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;
|
||||
@@ -142,7 +142,7 @@ Permission::getTxFeature(TxType txType) const
|
||||
}
|
||||
|
||||
bool
|
||||
Permission::isDelegatable(
|
||||
Permission::isDelegable(
|
||||
std::uint32_t const& permissionValue,
|
||||
Rules const& rules) const
|
||||
{
|
||||
@@ -153,15 +153,15 @@ Permission::isDelegatable(
|
||||
return true;
|
||||
|
||||
auto const txType = permissionToTxType(permissionValue);
|
||||
auto const it = delegatableTx_.find(txType);
|
||||
auto const it = delegableTx_.find(txType);
|
||||
|
||||
if (it == delegatableTx_.end())
|
||||
if (it == delegableTx_.end())
|
||||
return false;
|
||||
|
||||
auto const txFeaturesIt = txFeatureMap_.find(txType);
|
||||
XRPL_ASSERT(
|
||||
txFeaturesIt != txFeatureMap_.end(),
|
||||
"ripple::Permissions::isDelegatable : tx exists in txFeatureMap_");
|
||||
"xrpl::Permissions::isDelegable : 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
|
||||
@@ -170,7 +170,7 @@ Permission::isDelegatable(
|
||||
!rules.enabled(txFeaturesIt->second))
|
||||
return false;
|
||||
|
||||
if (it->second == Delegation::notDelegatable)
|
||||
if (it->second == Delegation::notDelegable)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -188,4 +188,4 @@ Permission::permissionToTxType(uint32_t const& value) const
|
||||
return static_cast<TxType>(value - 1);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, PublicKey const& pk)
|
||||
@@ -301,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
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
// Do not remove. Forces Rules.h to stay first, to verify it can compile
|
||||
// without any hidden dependencies
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/hardened_hash.h>
|
||||
#include <xrpl/beast/hash/uhash.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/STVector256.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -12,7 +15,7 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
// Use a static inside a function to help prevent order-of-initialization issues
|
||||
@@ -33,6 +36,15 @@ getCurrentTransactionRules()
|
||||
void
|
||||
setCurrentTransactionRules(std::optional<Rules> r)
|
||||
{
|
||||
// Make global changes associated with the rules before the value is moved.
|
||||
// Push the appropriate setting, instead of having the class pull every time
|
||||
// the value is needed. That could get expensive fast.
|
||||
bool enableLargeNumbers = !r ||
|
||||
(r->enabled(featureSingleAssetVault) ||
|
||||
r->enabled(featureLendingProtocol));
|
||||
Number::setMantissaScale(
|
||||
enableLargeNumbers ? MantissaRange::large : MantissaRange::small);
|
||||
|
||||
*getCurrentTransactionRulesRef() = std::move(r);
|
||||
}
|
||||
|
||||
@@ -82,7 +94,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 +122,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 +132,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 +151,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
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Asset.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/MPTAmount.h>
|
||||
#include <xrpl/protocol/MPTIssue.h>
|
||||
#include <xrpl/protocol/Protocol.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
@@ -47,7 +49,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 +62,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;
|
||||
@@ -98,6 +100,8 @@ areComparable(STAmount const& v1, STAmount const& v2)
|
||||
return false;
|
||||
}
|
||||
|
||||
static_assert(INITIAL_XRP.drops() == STAmount::cMaxNativeN);
|
||||
|
||||
STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name)
|
||||
{
|
||||
std::uint64_t value = sit.get64();
|
||||
@@ -195,7 +199,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 +212,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 +226,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 +272,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;
|
||||
@@ -298,7 +302,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 +314,8 @@ STAmount&
|
||||
STAmount::operator=(IOUAmount const& iou)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
native() == false,
|
||||
"ripple::STAmount::operator=(IOUAmount) : is not XRP");
|
||||
integral() == false,
|
||||
"xrpl::STAmount::operator=(IOUAmount) : is not integral");
|
||||
mOffset = iou.exponent();
|
||||
mIsNegative = iou < beast::zero;
|
||||
if (mIsNegative)
|
||||
@@ -321,6 +325,26 @@ STAmount::operator=(IOUAmount const& iou)
|
||||
return *this;
|
||||
}
|
||||
|
||||
STAmount&
|
||||
STAmount::operator=(Number const& number)
|
||||
{
|
||||
if (!getCurrentTransactionRules() ||
|
||||
isFeatureEnabled(featureSingleAssetVault) ||
|
||||
isFeatureEnabled(featureLendingProtocol))
|
||||
{
|
||||
*this = fromNumber(mAsset, number);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const originalMantissa = number.mantissa();
|
||||
mIsNegative = originalMantissa < 0;
|
||||
mValue = mIsNegative ? -originalMantissa : originalMantissa;
|
||||
mOffset = number.exponent();
|
||||
}
|
||||
canonicalize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Operators
|
||||
@@ -452,7 +476,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();
|
||||
}
|
||||
@@ -663,7 +687,7 @@ STAmount::getFullText() const
|
||||
std::string
|
||||
STAmount::getText() const
|
||||
{
|
||||
// keep full internal accuracy, but make more human friendly if posible
|
||||
// keep full internal accuracy, but make more human friendly if possible
|
||||
if (*this == beast::zero)
|
||||
return "0";
|
||||
|
||||
@@ -689,7 +713,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 +738,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 +749,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 +785,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);
|
||||
@@ -851,11 +874,11 @@ STAmount::canonicalize()
|
||||
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
Number num(
|
||||
mIsNegative ? -mValue : mValue, mOffset, Number::unchecked{});
|
||||
Number num(mIsNegative, mValue, mOffset, Number::unchecked{});
|
||||
auto set = [&](auto const& val) {
|
||||
mIsNegative = val.value() < 0;
|
||||
mValue = mIsNegative ? -val.value() : val.value();
|
||||
auto const value = val.value();
|
||||
mIsNegative = value < 0;
|
||||
mValue = mIsNegative ? -value : value;
|
||||
};
|
||||
if (native())
|
||||
set(XRPAmount{num});
|
||||
@@ -937,13 +960,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
|
||||
@@ -1325,7 +1348,7 @@ multiply(STAmount const& v1, STAmount const& v2, Asset const& asset)
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
auto const r = Number{v1} * Number{v2};
|
||||
return STAmount{asset, r.mantissa(), r.exponent()};
|
||||
return STAmount{asset, r};
|
||||
}
|
||||
|
||||
std::uint64_t value1 = v1.mantissa();
|
||||
@@ -1473,6 +1496,10 @@ roundToScale(
|
||||
if (value.integral())
|
||||
return value;
|
||||
|
||||
// Nothing to do for zero.
|
||||
if (value == beast::zero)
|
||||
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.
|
||||
@@ -1748,4 +1775,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
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include <xrpl/protocol/STNumber.h>
|
||||
// Do not remove. Keep STNumber.h first
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/beast/core/LexicalCast.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/SField.h>
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
#include <xrpl/protocol/STNumber.h>
|
||||
#include <xrpl/protocol/STIssue.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@@ -14,14 +18,14 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace ripple {
|
||||
namespace xrpl {
|
||||
|
||||
STNumber::STNumber(SField const& field, Number const& value)
|
||||
: STBase(field), value_(value)
|
||||
: STTakesAsset(field), value_(value)
|
||||
{
|
||||
}
|
||||
|
||||
STNumber::STNumber(SerialIter& sit, SField const& field) : STBase(field)
|
||||
STNumber::STNumber(SerialIter& sit, SField const& field) : STTakesAsset(field)
|
||||
{
|
||||
// We must call these methods in separate statements
|
||||
// to guarantee their order of execution.
|
||||
@@ -42,16 +46,69 @@ STNumber::getText() const
|
||||
return to_string(value_);
|
||||
}
|
||||
|
||||
void
|
||||
STNumber::associateAsset(Asset const& a)
|
||||
{
|
||||
STTakesAsset::associateAsset(a);
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
getFName().shouldMeta(SField::sMD_NeedsAsset),
|
||||
"STNumber::associateAsset",
|
||||
"field needs asset");
|
||||
|
||||
roundToAsset(a, value_);
|
||||
}
|
||||
|
||||
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");
|
||||
s.add64(value_.mantissa());
|
||||
s.add32(value_.exponent());
|
||||
"xrpl::STNumber::add : field type match");
|
||||
|
||||
auto value = value_;
|
||||
auto const mantissa = value.mantissa();
|
||||
auto const exponent = value.exponent();
|
||||
|
||||
SField const& field = getFName();
|
||||
if (field.shouldMeta(SField::sMD_NeedsAsset))
|
||||
{
|
||||
// asset is defined in the STTakesAsset base class
|
||||
if (asset_)
|
||||
{
|
||||
// The number should be rounded to the asset's precision, but round
|
||||
// it here if it has an asset assigned.
|
||||
roundToAsset(*asset_, value);
|
||||
XRPL_ASSERT_PARTS(
|
||||
value_ == value,
|
||||
"xrpl::STNumber::add",
|
||||
"value is already rounded");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !NDEBUG
|
||||
// There are circumstances where an already-rounded Number is
|
||||
// serialized without being touched by a transactor, and thus
|
||||
// without an asset. We can't know if it's rounded, because it could
|
||||
// represent _anything_, particularly when serializing user-provided
|
||||
// Json. Regardless, the only time we should be serializing an
|
||||
// STNumber is when the scale is large.
|
||||
XRPL_ASSERT_PARTS(
|
||||
Number::getMantissaScale() == MantissaRange::large,
|
||||
"xrpl::STNumber::add",
|
||||
"STNumber only used with large mantissa scale");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
mantissa <= std::numeric_limits<std::int64_t>::max() &&
|
||||
mantissa >= std::numeric_limits<std::int64_t>::min(),
|
||||
"xrpl::STNumber::add",
|
||||
"mantissa in valid range");
|
||||
s.add64(mantissa);
|
||||
s.add32(exponent);
|
||||
}
|
||||
|
||||
Number const&
|
||||
@@ -83,7 +140,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;
|
||||
}
|
||||
@@ -180,20 +237,30 @@ numberFromJson(SField const& field, Json::Value const& value)
|
||||
else if (value.isString())
|
||||
{
|
||||
parts = partsFromString(value.asString());
|
||||
// Only strings can represent out-of-range values.
|
||||
if (parts.mantissa > std::numeric_limits<std::int64_t>::max())
|
||||
Throw<std::range_error>("too high");
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
!getCurrentTransactionRules(),
|
||||
"xrpld::numberFromJson",
|
||||
"Not in a Transactor context");
|
||||
|
||||
// Number mantissas are much bigger than the allowable parsed values, so
|
||||
// it can't be out of range.
|
||||
static_assert(
|
||||
std::numeric_limits<std::uint64_t>::max() >=
|
||||
std::numeric_limits<decltype(parts.mantissa)>::max());
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw<std::runtime_error>("not a number");
|
||||
}
|
||||
|
||||
std::int64_t mantissa = parts.mantissa;
|
||||
if (parts.negative)
|
||||
mantissa = -mantissa;
|
||||
|
||||
return STNumber{field, Number{mantissa, parts.exponent}};
|
||||
return STNumber{
|
||||
field,
|
||||
Number{
|
||||
parts.negative,
|
||||
parts.mantissa,
|
||||
parts.exponent,
|
||||
Number::normalized{}}};
|
||||
}
|
||||
|
||||
} // 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)
|
||||
@@ -580,6 +580,12 @@ STObject::delField(int index)
|
||||
v_.erase(v_.begin() + index);
|
||||
}
|
||||
|
||||
SOEStyle
|
||||
STObject::getStyle(SField const& field) const
|
||||
{
|
||||
return mType ? mType->style(field) : soeINVALID;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
STObject::getFieldU8(SField const& field) const
|
||||
{
|
||||
@@ -904,7 +910,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 +943,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
|
||||
|
||||
47
src/libxrpl/protocol/STTakesAsset.cpp
Normal file
47
src/libxrpl/protocol/STTakesAsset.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <xrpl/protocol/STTakesAsset.h>
|
||||
// Do not remove. Force STTakesAsset.h first
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
void
|
||||
associateAsset(SLE& sle, Asset const& asset)
|
||||
{
|
||||
// Iterating by offset is the only way to get non-const references
|
||||
for (int i = 0; i < sle.getCount(); ++i)
|
||||
{
|
||||
STBase& entry = sle.getIndex(i);
|
||||
SField const& field = entry.getFName();
|
||||
if (field.shouldMeta(SField::sMD_NeedsAsset))
|
||||
{
|
||||
auto const type = entry.getSType();
|
||||
// If the field is not set or present, skip it.
|
||||
if (type == STI_NOTPRESENT)
|
||||
continue;
|
||||
|
||||
// If the type doesn't downcast, then the flag shouldn't be on the
|
||||
// SField
|
||||
auto& ta = entry.downcast<STTakesAsset>();
|
||||
auto const style = sle.getStyle(ta.getFName());
|
||||
XRPL_ASSERT_PARTS(
|
||||
style != soeINVALID,
|
||||
"xrpl::associateAsset",
|
||||
"valid template element style");
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
style != soeDEFAULT || !ta.isDefault(),
|
||||
"xrpl::associateAsset",
|
||||
"non-default value");
|
||||
ta.associateAsset(asset);
|
||||
|
||||
// associateAsset in derived classes may change the underlying
|
||||
// value, but it won't know anything about how the value relates to
|
||||
// the SLE. If the template element is soeDEFAULT, and the value
|
||||
// changed to the default value, remove the field.
|
||||
if (style == soeDEFAULT && ta.isDefault())
|
||||
sle.makeFieldAbsent(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // 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