mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-23 15:10:34 +00:00
Merge branch 'develop' into dangell7/batch-v1
This commit is contained in:
@@ -12,8 +12,8 @@ template <int Window, typename Clock>
|
||||
class DecayingSample
|
||||
{
|
||||
public:
|
||||
using value_type = typename Clock::duration::rep;
|
||||
using time_point = typename Clock::time_point;
|
||||
using value_type = Clock::duration::rep;
|
||||
using time_point = Clock::time_point;
|
||||
|
||||
DecayingSample() = delete;
|
||||
|
||||
@@ -93,7 +93,7 @@ template <int HalfLife, class Clock>
|
||||
class DecayWindow
|
||||
{
|
||||
public:
|
||||
using time_point = typename Clock::time_point;
|
||||
using time_point = Clock::time_point;
|
||||
|
||||
explicit DecayWindow(time_point now) : when_(now)
|
||||
{
|
||||
|
||||
@@ -206,8 +206,7 @@ private:
|
||||
#ifndef JLOG
|
||||
#define JLOG(x) \
|
||||
if (!(x)) \
|
||||
{ \
|
||||
} \
|
||||
; \
|
||||
else \
|
||||
x
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <xrpl/beast/insight/Insight.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
@@ -17,6 +18,22 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Replace-policy tags selecting how TaggedCache::canonicalizeImpl resolves a
|
||||
// collision when the key already exists (defined in TaggedCache.ipp):
|
||||
// - ReplaceCached: always replace the cached value with `data`. `data` is
|
||||
// never written back and may be const.
|
||||
// - ReplaceClient: keep the cached value and write it back into `data` (the
|
||||
// client's pointer), which must therefore be writable.
|
||||
// - ReplaceDynamically: call the supplied callback to decide per call; `data`
|
||||
// is written back when the cached value is kept, so it must be writable.
|
||||
struct ReplaceCached;
|
||||
struct ReplaceClient;
|
||||
struct ReplaceDynamically;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/** Map/cache combination.
|
||||
This class implements a cache and a map. The cache keeps objects alive
|
||||
in the map. The map allows multiple code paths that reference objects
|
||||
@@ -96,6 +113,32 @@ public:
|
||||
bool
|
||||
del(key_type const& key, bool valid);
|
||||
|
||||
private:
|
||||
// Selects the `data` parameter type of canonicalizeImpl from the replace
|
||||
// policy: const for detail::ReplaceCached (never written back), otherwise
|
||||
// writable.
|
||||
template <typename Policy>
|
||||
using CanonicalizeClientPointerType = std::conditional_t<
|
||||
std::is_same_v<detail::ReplaceCached, Policy>,
|
||||
SharedPointerType const&,
|
||||
SharedPointerType&>;
|
||||
|
||||
/** Shared implementation of the canonicalize family.
|
||||
|
||||
`policy` selects how a collision is resolved when `key` already exists:
|
||||
detail::ReplaceCached, detail::ReplaceClient or
|
||||
detail::ReplaceDynamically. For ReplaceDynamically `replaceCallback` is
|
||||
invoked with the existing strong pointer and returns whether to replace
|
||||
the cached value with `data`; for the tag policies it is unused.
|
||||
*/
|
||||
template <class Policy, class Callback = std::nullptr_t>
|
||||
bool
|
||||
canonicalizeImpl(
|
||||
key_type const& key,
|
||||
CanonicalizeClientPointerType<Policy> data,
|
||||
Policy policy,
|
||||
Callback&& replaceCallback = nullptr);
|
||||
|
||||
public:
|
||||
/** Replace aliased objects with originals.
|
||||
|
||||
@@ -104,19 +147,52 @@ public:
|
||||
This routine eliminates the duplicate and performs a replacement
|
||||
on the callers shared pointer if needed.
|
||||
|
||||
`replaceCallback` is a callable taking the existing strong pointer and
|
||||
returning whether to replace the cached value with `data` (true) or to
|
||||
keep the cached value and write it back into `data` (false). Because the
|
||||
write-back case mutates `data`, `data` must be writable.
|
||||
|
||||
@param key The key corresponding to the object
|
||||
@param data A shared pointer to the data corresponding to the object.
|
||||
@param replace Function that decides if cache should be replaced
|
||||
@param replaceCallback A callable (existing strong pointer -> bool).
|
||||
|
||||
@return `true` If the key already existed.
|
||||
*/
|
||||
template <class R>
|
||||
@return `true` if an existing live entry was found and used; `false` if a new entry was
|
||||
inserted or an expired tracked entry was re-cached.
|
||||
**/
|
||||
template <class Callback>
|
||||
bool
|
||||
canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback);
|
||||
canonicalize(key_type const& key, SharedPointerType& data, Callback&& replaceCallback);
|
||||
|
||||
/** Insert/update the canonical entry for `key`, always replacing the
|
||||
cached value with `data`.
|
||||
|
||||
If an entry already exists for `key`, the cached value is unconditionally
|
||||
replaced with `data`; otherwise `data` is inserted. `data` is never
|
||||
written back, so it may be const.
|
||||
|
||||
@param key The key corresponding to the object.
|
||||
@param data A shared pointer to the data corresponding to the object.
|
||||
|
||||
@return `true` if an existing live entry was found and used; `false` if a new entry was
|
||||
inserted or an expired tracked entry was re-cached.
|
||||
**/
|
||||
bool
|
||||
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data);
|
||||
|
||||
/** Insert the canonical entry for `key`, keeping any existing cached value.
|
||||
|
||||
If an entry already exists for `key`, the cached value is kept and
|
||||
written back into `data` so the caller ends up with the canonical
|
||||
object; otherwise `data` is inserted. Because `data` may be overwritten
|
||||
it must be writable.
|
||||
|
||||
@param key The key corresponding to the object.
|
||||
@param data A shared pointer to the data corresponding to the object;
|
||||
updated to the canonical value when one already exists.
|
||||
|
||||
@return `true` if an existing live entry was found and used; `false` if a new entry was
|
||||
inserted or an expired tracked entry was re-cached.
|
||||
**/
|
||||
bool
|
||||
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data);
|
||||
|
||||
@@ -262,7 +338,7 @@ private:
|
||||
sweepHelper(
|
||||
clock_type::time_point const& whenExpire,
|
||||
[[maybe_unused]] clock_type::time_point const& now,
|
||||
typename KeyValueCacheType::map_type& partition,
|
||||
KeyValueCacheType::map_type& partition,
|
||||
SweptPointersVector& stuffToSweep,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
@@ -271,7 +347,7 @@ private:
|
||||
sweepHelper(
|
||||
clock_type::time_point const& whenExpire,
|
||||
clock_type::time_point const& now,
|
||||
typename KeyOnlyCacheType::map_type& partition,
|
||||
KeyOnlyCacheType::map_type& partition,
|
||||
SweptPointersVector&,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&);
|
||||
|
||||
@@ -5,6 +5,30 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Replace-policy tags selecting how TaggedCache::canonicalizeImpl resolves a
|
||||
// collision when the key already exists:
|
||||
// - ReplaceCached: always replace the cached value with `data`. `data` is
|
||||
// never written back and may be const.
|
||||
// - ReplaceClient: keep the cached value and write it back into `data` (the
|
||||
// client's pointer), which must therefore be writable.
|
||||
// - ReplaceDynamically: call the supplied callback to decide per call; `data`
|
||||
// is written back when the cached value is kept, so it must be writable.
|
||||
struct ReplaceCached
|
||||
{
|
||||
};
|
||||
|
||||
struct ReplaceClient
|
||||
{
|
||||
};
|
||||
|
||||
struct ReplaceDynamically
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <
|
||||
class Key,
|
||||
class T,
|
||||
@@ -300,13 +324,29 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Mutex>
|
||||
template <class R>
|
||||
template <class Policy, class Callback>
|
||||
inline bool
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
canonicalize(key_type const& key, SharedPointerType& data, R&& replaceCallback)
|
||||
canonicalizeImpl(
|
||||
key_type const& key,
|
||||
CanonicalizeClientPointerType<Policy> data,
|
||||
[[maybe_unused]] Policy policy,
|
||||
[[maybe_unused]] Callback&& replaceCallback)
|
||||
{
|
||||
// Return canonical value, store if needed, refresh in cache
|
||||
// Return values: true=we had the data already
|
||||
|
||||
// `Policy` is one of:
|
||||
// - detail::ReplaceCached: always replace the cached value with `data`;
|
||||
// `data` is never written back and may be const.
|
||||
// - detail::ReplaceClient: keep the cached value and write it back into
|
||||
// `data` (the client's pointer), which must therefore be writable.
|
||||
// - detail::ReplaceDynamically: call `replaceCallback` to decide at run
|
||||
// time; `data` must be writable.
|
||||
// For the latter two the write-back below requires a mutable `data`, so
|
||||
// passing a const argument is a compile error.
|
||||
constexpr bool replaceCached = std::is_same_v<Policy, detail::ReplaceCached>;
|
||||
|
||||
std::scoped_lock const lock(mutex_);
|
||||
|
||||
auto cit = cache_.find(key);
|
||||
@@ -324,13 +364,14 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
Entry& entry = cit->second;
|
||||
entry.touch(clock_.now());
|
||||
|
||||
auto shouldReplace = [&] {
|
||||
if constexpr (std::is_invocable_r_v<bool, R>)
|
||||
auto shouldReplaceCached = [&] {
|
||||
if constexpr (replaceCached)
|
||||
{
|
||||
// The reason for this extra complexity is for intrusive
|
||||
// strong/weak combo getting a strong is relatively expensive
|
||||
// and not needed for many cases.
|
||||
return replaceCallback();
|
||||
return true;
|
||||
}
|
||||
else if constexpr (std::is_same_v<Policy, detail::ReplaceClient>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -340,11 +381,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
|
||||
if (entry.isCached())
|
||||
{
|
||||
if (shouldReplace())
|
||||
if (shouldReplaceCached())
|
||||
{
|
||||
entry.ptr = data;
|
||||
}
|
||||
else
|
||||
else if constexpr (!replaceCached)
|
||||
{
|
||||
data = entry.ptr.getStrong();
|
||||
}
|
||||
@@ -356,11 +397,11 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
|
||||
if (cachedData)
|
||||
{
|
||||
if (shouldReplace())
|
||||
if (shouldReplaceCached())
|
||||
{
|
||||
entry.ptr = data;
|
||||
}
|
||||
else
|
||||
else if constexpr (!replaceCached)
|
||||
{
|
||||
entry.ptr.convertToStrong();
|
||||
data = cachedData;
|
||||
@@ -376,6 +417,24 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
return false;
|
||||
}
|
||||
|
||||
template <
|
||||
class Key,
|
||||
class T,
|
||||
bool IsKeyCache,
|
||||
class SharedWeakUnionPointer,
|
||||
class SharedPointerType,
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Mutex>
|
||||
template <class Callback>
|
||||
inline bool
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
canonicalize(key_type const& key, SharedPointerType& data, Callback&& replaceCallback)
|
||||
{
|
||||
return canonicalizeImpl(
|
||||
key, data, detail::ReplaceDynamically{}, std::forward<Callback>(replaceCallback));
|
||||
}
|
||||
|
||||
template <
|
||||
class Key,
|
||||
class T,
|
||||
@@ -389,7 +448,7 @@ inline bool
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
canonicalizeReplaceCache(key_type const& key, SharedPointerType const& data)
|
||||
{
|
||||
return canonicalize(key, const_cast<SharedPointerType&>(data), []() { return true; });
|
||||
return canonicalizeImpl(key, data, detail::ReplaceCached{});
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -405,7 +464,7 @@ inline bool
|
||||
TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash, KeyEqual, Mutex>::
|
||||
canonicalizeReplaceClient(key_type const& key, SharedPointerType& data)
|
||||
{
|
||||
return canonicalize(key, data, []() { return false; });
|
||||
return canonicalizeImpl(key, data, detail::ReplaceClient{});
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -676,7 +735,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
sweepHelper(
|
||||
clock_type::time_point const& whenExpire,
|
||||
[[maybe_unused]] clock_type::time_point const& now,
|
||||
typename KeyValueCacheType::map_type& partition,
|
||||
KeyValueCacheType::map_type& partition,
|
||||
SweptPointersVector& stuffToSweep,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&)
|
||||
@@ -756,7 +815,7 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
|
||||
sweepHelper(
|
||||
clock_type::time_point const& whenExpire,
|
||||
clock_type::time_point const& now,
|
||||
typename KeyOnlyCacheType::map_type& partition,
|
||||
KeyOnlyCacheType::map_type& partition,
|
||||
SweptPointersVector&,
|
||||
std::atomic<int>& allRemovals,
|
||||
std::scoped_lock<std::recursive_mutex> const&)
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
detail::seed_pair seeds_{detail::makeSeedPair<>()};
|
||||
|
||||
public:
|
||||
using result_type = typename HashAlgorithm::result_type;
|
||||
using result_type = HashAlgorithm::result_type;
|
||||
|
||||
HardenedHash() = default;
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
{
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
partition_map_type* map{nullptr};
|
||||
typename partition_map_type::iterator ait{};
|
||||
typename map_type::iterator mit;
|
||||
partition_map_type::iterator ait{};
|
||||
map_type::iterator mit;
|
||||
|
||||
Iterator() = default;
|
||||
|
||||
@@ -126,8 +126,8 @@ public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
partition_map_type* map{nullptr};
|
||||
typename partition_map_type::iterator ait{};
|
||||
typename map_type::iterator mit;
|
||||
partition_map_type::iterator ait{};
|
||||
map_type::iterator mit;
|
||||
|
||||
ConstIterator() = default;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ static_assert(
|
||||
namespace detail {
|
||||
|
||||
// Determines if a type can be called like an Engine
|
||||
// NOLINTNEXTLINE(readability-redundant-typename): typename required by MSVC
|
||||
template <class Engine, class Result = typename Engine::result_type>
|
||||
using is_engine = std::is_invocable_r<Result, Engine>;
|
||||
} // namespace detail
|
||||
|
||||
@@ -18,8 +18,8 @@ template <class Clock>
|
||||
class IOLatencyProbe
|
||||
{
|
||||
private:
|
||||
using duration = typename Clock::duration;
|
||||
using time_point = typename Clock::time_point;
|
||||
using duration = Clock::duration;
|
||||
using time_point = Clock::time_point;
|
||||
|
||||
std::recursive_mutex mutex_;
|
||||
std::condition_variable_any cond_;
|
||||
|
||||
@@ -34,10 +34,10 @@ template <class Clock>
|
||||
class AbstractClock
|
||||
{
|
||||
public:
|
||||
using rep = typename Clock::rep;
|
||||
using period = typename Clock::period;
|
||||
using duration = typename Clock::duration;
|
||||
using time_point = typename Clock::time_point;
|
||||
using rep = Clock::rep;
|
||||
using period = Clock::period;
|
||||
using duration = Clock::duration;
|
||||
using time_point = Clock::time_point;
|
||||
using clock_type = Clock;
|
||||
|
||||
static bool const is_steady = Clock::is_steady; // NOLINT(readability-identifier-naming)
|
||||
|
||||
@@ -20,10 +20,10 @@ public:
|
||||
|
||||
explicit BasicSecondsClock() = default;
|
||||
|
||||
using rep = typename Clock::rep;
|
||||
using period = typename Clock::period;
|
||||
using duration = typename Clock::duration;
|
||||
using time_point = typename Clock::time_point;
|
||||
using rep = Clock::rep;
|
||||
using period = Clock::period;
|
||||
using duration = Clock::duration;
|
||||
using time_point = Clock::time_point;
|
||||
|
||||
static bool const is_steady = // NOLINT(readability-identifier-naming)
|
||||
Clock::is_steady;
|
||||
|
||||
@@ -16,15 +16,15 @@ template <bool IsConst, class Iterator>
|
||||
class AgedContainerIterator
|
||||
{
|
||||
public:
|
||||
using iterator_category = typename std::iterator_traits<Iterator>::iterator_category;
|
||||
using iterator_category = std::iterator_traits<Iterator>::iterator_category;
|
||||
using value_type = std::conditional_t<
|
||||
IsConst,
|
||||
typename Iterator::value_type::Stashed::value_type const,
|
||||
typename Iterator::value_type::Stashed::value_type>;
|
||||
using difference_type = typename std::iterator_traits<Iterator>::difference_type;
|
||||
using difference_type = std::iterator_traits<Iterator>::difference_type;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type&;
|
||||
using time_point = typename Iterator::value_type::Stashed::time_point;
|
||||
using time_point = Iterator::value_type::Stashed::time_point;
|
||||
|
||||
AgedContainerIterator() = default;
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ class AgedOrderedContainer
|
||||
{
|
||||
public:
|
||||
using clock_type = AbstractClock<Clock>;
|
||||
using time_point = typename clock_type::time_point;
|
||||
using duration = typename clock_type::duration;
|
||||
using time_point = clock_type::time_point;
|
||||
using duration = clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
@@ -94,8 +94,8 @@ private:
|
||||
{
|
||||
explicit Stashed() = default;
|
||||
|
||||
using value_type = typename AgedOrderedContainer::value_type;
|
||||
using time_point = typename AgedOrderedContainer::time_point;
|
||||
using value_type = AgedOrderedContainer::value_type;
|
||||
using time_point = AgedOrderedContainer::time_point;
|
||||
};
|
||||
|
||||
Element(time_point const& when, value_type const& value) : value(value), when(when)
|
||||
@@ -192,8 +192,8 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<Element, boost::intrusive::constant_time_size<false>>::type;
|
||||
using list_type =
|
||||
boost::intrusive::make_list<Element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
IsMulti,
|
||||
@@ -206,8 +206,7 @@ private:
|
||||
boost::intrusive::constant_time_size<true>,
|
||||
boost::intrusive::compare<KeyValueCompare>>::type>;
|
||||
|
||||
using ElementAllocator =
|
||||
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
using ElementAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
|
||||
using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>;
|
||||
|
||||
@@ -373,8 +372,8 @@ public:
|
||||
using allocator_type = Allocator;
|
||||
using reference = value_type&;
|
||||
using const_reference = value_type const&;
|
||||
using pointer = typename std::allocator_traits<Allocator>::pointer;
|
||||
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer;
|
||||
using pointer = std::allocator_traits<Allocator>::pointer;
|
||||
using const_pointer = std::allocator_traits<Allocator>::const_pointer;
|
||||
|
||||
// A set iterator (IsMap==false) is always const
|
||||
// because the elements of a set are immutable.
|
||||
@@ -617,7 +616,7 @@ public:
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
@@ -1146,7 +1145,7 @@ private:
|
||||
void
|
||||
touch(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
|
||||
typename clock_type::time_point const& now);
|
||||
clock_type::time_point const& now);
|
||||
|
||||
template <
|
||||
bool MaybePropagate = std::allocator_traits<Allocator>::propagate_on_container_swap::value>
|
||||
@@ -1393,7 +1392,7 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K co
|
||||
|
||||
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::at(K const& k) const
|
||||
{
|
||||
auto const iter(cont_.find(k, std::cref(config_.keyCompare())));
|
||||
@@ -1732,7 +1731,7 @@ AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::operato
|
||||
cend(),
|
||||
other.cbegin(),
|
||||
other.cend(),
|
||||
[&eq, &other](value_type const& lhs, typename Other::value_type const& rhs) {
|
||||
[&eq, &other](value_type const& lhs, Other::value_type const& rhs) {
|
||||
return eq(extract(lhs), other.extract(rhs));
|
||||
});
|
||||
}
|
||||
@@ -1744,7 +1743,7 @@ template <bool IsConst, class Iterator, class>
|
||||
void
|
||||
AgedOrderedContainer<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::touch(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
clock_type::time_point const& now)
|
||||
{
|
||||
auto& e(*pos.iterator());
|
||||
e.when = now;
|
||||
|
||||
@@ -67,8 +67,8 @@ class AgedUnorderedContainer
|
||||
{
|
||||
public:
|
||||
using clock_type = AbstractClock<Clock>;
|
||||
using time_point = typename clock_type::time_point;
|
||||
using duration = typename clock_type::duration;
|
||||
using time_point = clock_type::time_point;
|
||||
using duration = clock_type::duration;
|
||||
using key_type = Key;
|
||||
using mapped_type = T;
|
||||
using value_type = std::conditional_t<IsMap, std::pair<Key const, T>, Key>;
|
||||
@@ -99,8 +99,8 @@ private:
|
||||
{
|
||||
explicit Stashed() = default;
|
||||
|
||||
using value_type = typename AgedUnorderedContainer::value_type;
|
||||
using time_point = typename AgedUnorderedContainer::time_point;
|
||||
using value_type = AgedUnorderedContainer::value_type;
|
||||
using time_point = AgedUnorderedContainer::time_point;
|
||||
};
|
||||
|
||||
Element(time_point const& when, value_type const& value) : value(value), when(when)
|
||||
@@ -201,8 +201,8 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
using list_type = typename boost::intrusive::
|
||||
make_list<Element, boost::intrusive::constant_time_size<false>>::type;
|
||||
using list_type =
|
||||
boost::intrusive::make_list<Element, boost::intrusive::constant_time_size<false>>::type;
|
||||
|
||||
using cont_type = std::conditional_t<
|
||||
IsMulti,
|
||||
@@ -219,16 +219,14 @@ private:
|
||||
boost::intrusive::equal<KeyValueEqual>,
|
||||
boost::intrusive::cache_begin<true>>::type>;
|
||||
|
||||
using bucket_type = typename cont_type::bucket_type;
|
||||
using bucket_traits = typename cont_type::bucket_traits;
|
||||
using bucket_type = cont_type::bucket_type;
|
||||
using bucket_traits = cont_type::bucket_traits;
|
||||
|
||||
using ElementAllocator =
|
||||
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
using ElementAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
|
||||
using ElementAllocatorTraits = std::allocator_traits<ElementAllocator>;
|
||||
|
||||
using BucketAllocator =
|
||||
typename std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
using BucketAllocator = std::allocator_traits<Allocator>::template rebind_alloc<Element>;
|
||||
|
||||
using BucketAllocatorTraits = std::allocator_traits<BucketAllocator>;
|
||||
|
||||
@@ -542,8 +540,8 @@ public:
|
||||
using allocator_type = Allocator;
|
||||
using reference = value_type&;
|
||||
using const_reference = value_type const&;
|
||||
using pointer = typename std::allocator_traits<Allocator>::pointer;
|
||||
using const_pointer = typename std::allocator_traits<Allocator>::const_pointer;
|
||||
using pointer = std::allocator_traits<Allocator>::pointer;
|
||||
using const_pointer = std::allocator_traits<Allocator>::const_pointer;
|
||||
|
||||
// A set iterator (IsMap==false) is always const
|
||||
// because the elements of a set are immutable.
|
||||
@@ -850,7 +848,7 @@ public:
|
||||
bool MaybeMulti = IsMulti,
|
||||
bool MaybeMap = IsMap,
|
||||
class = std::enable_if_t<MaybeMap && !MaybeMulti>>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
at(K const& k) const;
|
||||
|
||||
template <
|
||||
@@ -1414,7 +1412,7 @@ private:
|
||||
void
|
||||
touch(
|
||||
beast::detail::AgedContainerIterator<IsConst, Iterator> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
clock_type::time_point const& now)
|
||||
{
|
||||
auto& e(*pos.iterator());
|
||||
e.when = now;
|
||||
@@ -2111,7 +2109,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <class K, bool MaybeMulti, bool MaybeMap, class>
|
||||
typename std::conditional<IsMap, T, void*>::type const&
|
||||
std::conditional<IsMap, T, void*>::type const&
|
||||
AgedUnorderedContainer<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::at(
|
||||
K const& k) const
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ struct CopyConst<T const, U>
|
||||
{
|
||||
explicit CopyConst() = default;
|
||||
|
||||
using type = typename std::remove_const<U>::type const;
|
||||
using type = std::remove_const<U>::type const;
|
||||
};
|
||||
/** @} */
|
||||
|
||||
@@ -56,7 +56,7 @@ class ListIterator
|
||||
{
|
||||
public:
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using value_type = typename beast::detail::CopyConst<N, typename N::value_type>::type;
|
||||
using value_type = beast::detail::CopyConst<N, typename N::value_type>::type;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type&;
|
||||
@@ -259,7 +259,7 @@ template <typename T, typename Tag = void>
|
||||
class List
|
||||
{
|
||||
public:
|
||||
using Node = typename detail::ListNode<T, Tag>;
|
||||
using Node = detail::ListNode<T, Tag>;
|
||||
|
||||
using value_type = T;
|
||||
using pointer = value_type*;
|
||||
|
||||
@@ -12,13 +12,13 @@ template <class Container, bool IsConst>
|
||||
class LockFreeStackIterator
|
||||
{
|
||||
protected:
|
||||
using Node = typename Container::Node;
|
||||
using Node = Container::Node;
|
||||
using NodePtr = std::conditional_t<IsConst, Node const*, Node*>;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = typename Container::value_type;
|
||||
using difference_type = typename Container::difference_type;
|
||||
using value_type = Container::value_type;
|
||||
using difference_type = Container::difference_type;
|
||||
using pointer =
|
||||
std::conditional_t<IsConst, typename Container::const_pointer, typename Container::pointer>;
|
||||
using reference = std::
|
||||
|
||||
@@ -11,7 +11,7 @@ struct Uhash
|
||||
{
|
||||
Uhash() = default;
|
||||
|
||||
using result_type = typename Hasher::result_type;
|
||||
using result_type = Hasher::result_type;
|
||||
|
||||
template <class T>
|
||||
result_type
|
||||
|
||||
@@ -102,7 +102,7 @@ Result
|
||||
split(FwdIt first, FwdIt last, Char delim)
|
||||
{
|
||||
using namespace detail;
|
||||
using string = typename Result::value_type;
|
||||
using string = Result::value_type;
|
||||
|
||||
Result result;
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
using value_type = typename cont_type::value_type;
|
||||
using size_type = typename cont_type::size_type;
|
||||
using difference_type = typename cont_type::difference_type;
|
||||
using iterator = typename cont_type::const_iterator;
|
||||
using const_iterator = typename cont_type::const_iterator;
|
||||
using value_type = cont_type::value_type;
|
||||
using size_type = cont_type::size_type;
|
||||
using difference_type = cont_type::difference_type;
|
||||
using iterator = cont_type::const_iterator;
|
||||
using const_iterator = cont_type::const_iterator;
|
||||
|
||||
/** Returns `true` if the container is empty. */
|
||||
[[nodiscard]] bool
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
std::size_t cases = 0;
|
||||
std::size_t total = 0;
|
||||
std::size_t failed = 0;
|
||||
typename clock_type::time_point start = clock_type::now();
|
||||
clock_type::time_point start = clock_type::now();
|
||||
|
||||
explicit SuiteResults(std::string name = "") : name(std::move(name))
|
||||
{
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
|
||||
struct Results
|
||||
{
|
||||
using run_time = std::pair<std::string, typename clock_type::duration>;
|
||||
using run_time = std::pair<std::string, clock_type::duration>;
|
||||
|
||||
static constexpr auto kMaxTop = 10;
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
std::size_t total = 0;
|
||||
std::size_t failed = 0;
|
||||
std::vector<run_time> top;
|
||||
typename clock_type::time_point start = clock_type::now();
|
||||
clock_type::time_point start = clock_type::now();
|
||||
|
||||
void
|
||||
add(SuiteResults const& r);
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
private:
|
||||
static std::string
|
||||
fmtdur(typename clock_type::duration const& d);
|
||||
fmtdur(clock_type::duration const& d);
|
||||
|
||||
void
|
||||
onSuiteBegin(SuiteInfo const& info) override;
|
||||
@@ -141,9 +141,7 @@ Reporter<Unused>::Results::add(SuiteResults const& r)
|
||||
top.begin(),
|
||||
top.end(),
|
||||
elapsed,
|
||||
[](run_time const& t1, typename clock_type::duration const& t2) {
|
||||
return t1.second > t2;
|
||||
});
|
||||
[](run_time const& t1, clock_type::duration const& t2) { return t1.second > t2; });
|
||||
if (iter != top.end())
|
||||
{
|
||||
if (top.size() == kMaxTop)
|
||||
@@ -181,7 +179,7 @@ Reporter<Unused>::~Reporter()
|
||||
|
||||
template <class Unused>
|
||||
std::string
|
||||
Reporter<Unused>::fmtdur(typename clock_type::duration const& d)
|
||||
Reporter<Unused>::fmtdur(clock_type::duration const& d)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto const ms = duration_cast<milliseconds>(d);
|
||||
|
||||
@@ -411,9 +411,9 @@ class BasicLogstream : public std::basic_ostream<CharT, Traits>
|
||||
{
|
||||
using char_type = CharT;
|
||||
using traits_type = Traits;
|
||||
using int_type = typename traits_type::int_type;
|
||||
using pos_type = typename traits_type::pos_type;
|
||||
using off_type = typename traits_type::off_type;
|
||||
using int_type = traits_type::int_type;
|
||||
using pos_type = traits_type::pos_type;
|
||||
using off_type = traits_type::off_type;
|
||||
|
||||
detail::LogStreamBuf<CharT, Traits> buf_;
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ struct MaybeConst
|
||||
|
||||
/** Alias for omitting `typename`. */
|
||||
template <bool IsConst, class T>
|
||||
using maybe_const_t = typename MaybeConst<IsConst, T>::type;
|
||||
using maybe_const_t = MaybeConst<IsConst, T>::type;
|
||||
|
||||
} // namespace beast
|
||||
|
||||
@@ -13,7 +13,7 @@ template <class Generator>
|
||||
void
|
||||
rngfill(void* const buffer, std::size_t const bytes, Generator& g)
|
||||
{
|
||||
using result_type = typename Generator::result_type;
|
||||
using result_type = Generator::result_type;
|
||||
constexpr std::size_t kResultSize = sizeof(result_type);
|
||||
|
||||
std::uint8_t* const bufferStart = static_cast<std::uint8_t*>(buffer);
|
||||
@@ -42,7 +42,7 @@ template <
|
||||
void
|
||||
rngfill(std::array<std::uint8_t, N>& a, Generator& g)
|
||||
{
|
||||
using result_type = typename Generator::result_type;
|
||||
using result_type = Generator::result_type;
|
||||
auto i = N / sizeof(result_type);
|
||||
result_type* p = reinterpret_cast<result_type*>(a.data());
|
||||
while (i--)
|
||||
|
||||
@@ -566,6 +566,7 @@ public:
|
||||
using SelfType = ValueConstIterator;
|
||||
|
||||
ValueConstIterator() = default;
|
||||
ValueConstIterator(ValueConstIterator const& other) = default;
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
@@ -574,12 +575,12 @@ private:
|
||||
|
||||
public:
|
||||
SelfType&
|
||||
operator=(ValueIteratorBase const& other);
|
||||
operator=(SelfType const& other);
|
||||
|
||||
SelfType
|
||||
operator++(int)
|
||||
{
|
||||
SelfType temp(*this);
|
||||
SelfType const temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
@@ -587,7 +588,7 @@ public:
|
||||
SelfType
|
||||
operator--(int)
|
||||
{
|
||||
SelfType temp(*this);
|
||||
SelfType const temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ escrowUnlockApplyHelper<Issue>(
|
||||
beast::Journal journal)
|
||||
{
|
||||
Issue const& issue = amount.get<Issue>();
|
||||
Keylet const trustLineKey = keylet::line(receiver, issue);
|
||||
Keylet const trustLineKey = keylet::trustLine(receiver, issue);
|
||||
bool const recvLow = issuer > receiver;
|
||||
bool const senderIssuer = issuer == sender;
|
||||
bool const receiverIssuer = issuer == receiver;
|
||||
@@ -175,7 +175,7 @@ escrowUnlockApplyHelper<MPTIssue>(
|
||||
bool const receiverIssuer = issuer == receiver;
|
||||
|
||||
auto const mptID = amount.get<MPTIssue>().getMptID();
|
||||
auto const issuanceKey = keylet::mptIssuance(mptID);
|
||||
auto const issuanceKey = keylet::mptokenIssuance(mptID);
|
||||
if (!view.exists(keylet::mptoken(issuanceKey.key, receiver)) && createAsset && !receiverIssuer)
|
||||
{
|
||||
if (std::uint32_t const ownerCount = {sleDest->at(sfOwnerCount)};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/ledger/View.h>
|
||||
|
||||
namespace xrpl::permissioned_dex {
|
||||
|
||||
@@ -68,21 +68,15 @@ skip(LedgerIndex ledger) noexcept;
|
||||
|
||||
/** The (fixed) index of the object containing the ledger fees. */
|
||||
Keylet const&
|
||||
fees() noexcept;
|
||||
feeSettings() noexcept;
|
||||
|
||||
/** The (fixed) index of the object containing the ledger negativeUNL. */
|
||||
Keylet const&
|
||||
negativeUNL() noexcept;
|
||||
|
||||
/** The beginning of an order book */
|
||||
struct BookT
|
||||
{
|
||||
explicit BookT() = default;
|
||||
|
||||
Keylet
|
||||
operator()(Book const& b) const;
|
||||
};
|
||||
static BookT const kBook{};
|
||||
Keylet
|
||||
book(Book const& b);
|
||||
|
||||
/** The index of a trust line for a given currency
|
||||
|
||||
@@ -93,12 +87,12 @@ static BookT const kBook{};
|
||||
*/
|
||||
/** @{ */
|
||||
Keylet
|
||||
line(AccountID const& id0, AccountID const& id1, Currency const& currency) noexcept;
|
||||
trustLine(AccountID const& id0, AccountID const& id1, Currency const& currency) noexcept;
|
||||
|
||||
inline Keylet
|
||||
line(AccountID const& id, Issue const& issue) noexcept
|
||||
trustLine(AccountID const& id, Issue const& issue) noexcept
|
||||
{
|
||||
return line(id, issue.account, issue.currency);
|
||||
return trustLine(id, issue.account, issue.currency);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
@@ -119,37 +113,27 @@ Keylet
|
||||
quality(Keylet const& k, std::uint64_t q) noexcept;
|
||||
|
||||
/** The directory for the next lower quality */
|
||||
struct NextT
|
||||
{
|
||||
explicit NextT() = default;
|
||||
|
||||
Keylet
|
||||
operator()(Keylet const& k) const;
|
||||
};
|
||||
static NextT const kNext{};
|
||||
Keylet
|
||||
next(Keylet const& k);
|
||||
|
||||
/** A ticket belonging to an account */
|
||||
struct TicketT
|
||||
/** @{ */
|
||||
Keylet
|
||||
ticket(AccountID const& id, std::uint32_t ticketSeq);
|
||||
|
||||
Keylet
|
||||
ticket(AccountID const& id, SeqProxy ticketSeq);
|
||||
|
||||
inline Keylet
|
||||
ticket(uint256 const& key)
|
||||
{
|
||||
explicit TicketT() = default;
|
||||
|
||||
Keylet
|
||||
operator()(AccountID const& id, std::uint32_t ticketSeq) const;
|
||||
|
||||
Keylet
|
||||
operator()(AccountID const& id, SeqProxy ticketSeq) const;
|
||||
|
||||
Keylet
|
||||
operator()(uint256 const& key) const
|
||||
{
|
||||
return {ltTICKET, key};
|
||||
}
|
||||
};
|
||||
static TicketT const kTicket{};
|
||||
return {ltTICKET, key};
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/** A SignerList */
|
||||
Keylet
|
||||
signers(AccountID const& account) noexcept;
|
||||
signerList(AccountID const& account) noexcept;
|
||||
|
||||
/** A Check */
|
||||
/** @{ */
|
||||
@@ -209,7 +193,7 @@ escrow(AccountID const& src, std::uint32_t seq) noexcept;
|
||||
|
||||
/** A PaymentChannel */
|
||||
Keylet
|
||||
payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
|
||||
payChannel(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
|
||||
|
||||
/** NFT page keylets
|
||||
|
||||
@@ -221,22 +205,22 @@ payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
|
||||
/** @{ */
|
||||
/** A keylet for the owner's first possible NFT page. */
|
||||
Keylet
|
||||
nftpageMin(AccountID const& owner);
|
||||
nftokenPageMin(AccountID const& owner);
|
||||
|
||||
/** A keylet for the owner's last possible NFT page. */
|
||||
Keylet
|
||||
nftpageMax(AccountID const& owner);
|
||||
nftokenPageMax(AccountID const& owner);
|
||||
|
||||
Keylet
|
||||
nftpage(Keylet const& k, uint256 const& token);
|
||||
nftokenPage(Keylet const& k, uint256 const& token);
|
||||
/** @} */
|
||||
|
||||
/** An offer from an account to buy or sell an NFT */
|
||||
Keylet
|
||||
nftoffer(AccountID const& owner, std::uint32_t seq);
|
||||
nftokenOffer(AccountID const& owner, std::uint32_t seq);
|
||||
|
||||
inline Keylet
|
||||
nftoffer(uint256 const& offer)
|
||||
nftokenOffer(uint256 const& offer)
|
||||
{
|
||||
return {ltNFTOKEN_OFFER, offer};
|
||||
}
|
||||
@@ -287,13 +271,13 @@ credential(uint256 const& key) noexcept
|
||||
}
|
||||
|
||||
Keylet
|
||||
mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
|
||||
mptokenIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
|
||||
|
||||
Keylet
|
||||
mptIssuance(MPTID const& issuanceID) noexcept;
|
||||
mptokenIssuance(MPTID const& issuanceID) noexcept;
|
||||
|
||||
inline Keylet
|
||||
mptIssuance(uint256 const& issuanceKey)
|
||||
mptokenIssuance(uint256 const& issuanceKey)
|
||||
{
|
||||
return {ltMPTOKEN_ISSUANCE, issuanceKey};
|
||||
}
|
||||
@@ -320,10 +304,10 @@ vault(uint256 const& vaultKey)
|
||||
}
|
||||
|
||||
Keylet
|
||||
loanbroker(AccountID const& owner, std::uint32_t seq) noexcept;
|
||||
loanBroker(AccountID const& owner, std::uint32_t seq) noexcept;
|
||||
|
||||
inline Keylet
|
||||
loanbroker(uint256 const& key)
|
||||
loanBroker(uint256 const& key)
|
||||
{
|
||||
return {ltLOAN_BROKER, key};
|
||||
}
|
||||
@@ -376,11 +360,15 @@ struct KeyletDesc
|
||||
std::array<KeyletDesc<AccountID const&>, 6> const kDirectAccountKeylets{
|
||||
{{.function = &keylet::account, .expectedLEName = jss::AccountRoot, .includeInTests = false},
|
||||
{.function = &keylet::ownerDir, .expectedLEName = jss::DirectoryNode, .includeInTests = true},
|
||||
{.function = &keylet::signers, .expectedLEName = jss::SignerList, .includeInTests = true},
|
||||
{.function = &keylet::signerList, .expectedLEName = jss::SignerList, .includeInTests = true},
|
||||
// It's normally impossible to create an item at nftpage_min, but
|
||||
// test it anyway, since the invariant checks for it.
|
||||
{.function = &keylet::nftpageMin, .expectedLEName = jss::NFTokenPage, .includeInTests = true},
|
||||
{.function = &keylet::nftpageMax, .expectedLEName = jss::NFTokenPage, .includeInTests = true},
|
||||
{.function = &keylet::nftokenPageMin,
|
||||
.expectedLEName = jss::NFTokenPage,
|
||||
.includeInTests = true},
|
||||
{.function = &keylet::nftokenPageMax,
|
||||
.expectedLEName = jss::NFTokenPage,
|
||||
.includeInTests = true},
|
||||
{.function = &keylet::did, .expectedLEName = jss::DID, .includeInTests = true}}};
|
||||
|
||||
MPTID
|
||||
|
||||
@@ -118,13 +118,13 @@ public:
|
||||
}
|
||||
|
||||
// begin() and end() are provided for testing purposes.
|
||||
[[nodiscard]] typename std::forward_list<Item>::const_iterator
|
||||
[[nodiscard]] std::forward_list<Item>::const_iterator
|
||||
begin() const
|
||||
{
|
||||
return formats_.begin();
|
||||
}
|
||||
|
||||
[[nodiscard]] typename std::forward_list<Item>::const_iterator
|
||||
[[nodiscard]] std::forward_list<Item>::const_iterator
|
||||
end() const
|
||||
{
|
||||
return formats_.end();
|
||||
|
||||
@@ -163,7 +163,7 @@ STBitString<Bits>::setValue(BaseUInt<Bits, Tag> const& v)
|
||||
}
|
||||
|
||||
template <int Bits>
|
||||
typename STBitString<Bits>::value_type const&
|
||||
STBitString<Bits>::value_type const&
|
||||
STBitString<Bits>::value() const
|
||||
{
|
||||
return value_;
|
||||
|
||||
@@ -120,7 +120,7 @@ STInteger<Integer>::operator=(value_type const& v)
|
||||
}
|
||||
|
||||
template <typename Integer>
|
||||
inline typename STInteger<Integer>::value_type
|
||||
inline STInteger<Integer>::value_type
|
||||
STInteger<Integer>::value() const noexcept
|
||||
{
|
||||
return value_;
|
||||
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
@throws STObject::FieldErr if the field is not present.
|
||||
*/
|
||||
template <class T>
|
||||
typename T::value_type
|
||||
T::value_type
|
||||
operator[](TypedField<T> const& f) const;
|
||||
|
||||
/** Get the value of a field as a std::optional
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
@throws STObject::FieldErr if the field is not present.
|
||||
*/
|
||||
template <class T>
|
||||
[[nodiscard]] typename T::value_type
|
||||
[[nodiscard]] T::value_type
|
||||
at(TypedField<T> const& f) const;
|
||||
|
||||
/** Get the value of a field as std::optional
|
||||
@@ -478,7 +478,7 @@ template <class T>
|
||||
class STObject::Proxy
|
||||
{
|
||||
public:
|
||||
using value_type = typename T::value_type;
|
||||
using value_type = T::value_type;
|
||||
|
||||
[[nodiscard]] value_type
|
||||
value() const;
|
||||
@@ -513,13 +513,10 @@ protected:
|
||||
template <typename U>
|
||||
concept IsArithmeticNumber =
|
||||
std::is_arithmetic_v<U> || std::is_same_v<U, Number> || std::is_same_v<U, STAmount>;
|
||||
template <
|
||||
typename U,
|
||||
typename Value = typename U::value_type,
|
||||
typename Unit = typename U::unit_type>
|
||||
template <typename U, typename Value = U::value_type, typename Unit = U::unit_type>
|
||||
concept IsArithmeticValueUnit = std::is_same_v<U, unit::ValueUnit<Unit, Value>> &&
|
||||
IsArithmeticNumber<Value> && std::is_class_v<Unit>;
|
||||
template <typename U, typename Value = typename U::value_type>
|
||||
template <typename U, typename Value = U::value_type>
|
||||
concept IsArithmeticST = !IsArithmeticValueUnit<U> && IsArithmeticNumber<Value>;
|
||||
template <typename U>
|
||||
concept IsArithmetic = IsArithmeticNumber<U> || IsArithmeticST<U> || IsArithmeticValueUnit<U>;
|
||||
@@ -534,7 +531,7 @@ template <class T>
|
||||
class STObject::ValueProxy : public Proxy<T>
|
||||
{
|
||||
private:
|
||||
using value_type = typename T::value_type;
|
||||
using value_type = T::value_type;
|
||||
|
||||
public:
|
||||
ValueProxy(ValueProxy const&) = default;
|
||||
@@ -576,7 +573,7 @@ template <class T>
|
||||
class STObject::OptionalProxy : public Proxy<T>
|
||||
{
|
||||
private:
|
||||
using value_type = typename T::value_type;
|
||||
using value_type = T::value_type;
|
||||
|
||||
using optional_type = std::optional<std::decay_t<value_type>>;
|
||||
|
||||
@@ -840,7 +837,7 @@ operator typename STObject::OptionalProxy<T>::optional_type() const
|
||||
}
|
||||
|
||||
template <class T>
|
||||
typename STObject::OptionalProxy<T>::optional_type
|
||||
STObject::OptionalProxy<T>::optional_type
|
||||
STObject::OptionalProxy<T>::operator~() const
|
||||
{
|
||||
return optionalValue();
|
||||
@@ -933,7 +930,7 @@ STObject::OptionalProxy<T>::optionalValue() const -> optional_type
|
||||
}
|
||||
|
||||
template <class T>
|
||||
typename STObject::OptionalProxy<T>::value_type
|
||||
STObject::OptionalProxy<T>::value_type
|
||||
STObject::OptionalProxy<T>::valueOr(value_type val) const
|
||||
{
|
||||
return engaged() ? this->value() : val;
|
||||
@@ -1040,7 +1037,7 @@ STObject::getPIndex(int offset)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
typename T::value_type
|
||||
T::value_type
|
||||
STObject::operator[](TypedField<T> const& f) const
|
||||
{
|
||||
return at(f);
|
||||
@@ -1068,7 +1065,7 @@ STObject::operator[](OptionaledField<T> const& of) -> OptionalProxy<T>
|
||||
}
|
||||
|
||||
template <class T>
|
||||
[[nodiscard]] typename T::value_type
|
||||
[[nodiscard]] T::value_type
|
||||
STObject::at(TypedField<T> const& f) const
|
||||
{
|
||||
auto const b = peekAtPField(f);
|
||||
|
||||
@@ -659,13 +659,13 @@ inline bool
|
||||
isTesSuccess(TER x) noexcept
|
||||
{
|
||||
// Makes use of TERSubset::operator bool()
|
||||
return !(x);
|
||||
return !x;
|
||||
}
|
||||
|
||||
inline bool
|
||||
isTecClaim(TER x) noexcept
|
||||
{
|
||||
return ((x) >= tecCLAIM);
|
||||
return (x >= tecCLAIM);
|
||||
}
|
||||
|
||||
std::unordered_map<TERUnderlyingType, std::pair<char const* const, char const* const>> const&
|
||||
|
||||
@@ -391,7 +391,7 @@ mulDivU(Source1 value, Dest mul, Source2 div)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
using desttype = typename Dest::value_type;
|
||||
using desttype = Dest::value_type;
|
||||
constexpr auto kMax = std::numeric_limits<desttype>::max();
|
||||
|
||||
// Shortcuts, since these happen a lot in the real world
|
||||
|
||||
@@ -379,16 +379,16 @@ public:
|
||||
[[nodiscard]] STArray
|
||||
toSTArray() const;
|
||||
|
||||
[[nodiscard]] typename AttCollection::const_iterator
|
||||
[[nodiscard]] AttCollection::const_iterator
|
||||
begin() const;
|
||||
|
||||
[[nodiscard]] typename AttCollection::const_iterator
|
||||
[[nodiscard]] AttCollection::const_iterator
|
||||
end() const;
|
||||
|
||||
typename AttCollection::iterator
|
||||
AttCollection::iterator
|
||||
begin();
|
||||
|
||||
typename AttCollection::iterator
|
||||
AttCollection::iterator
|
||||
end();
|
||||
|
||||
template <class F>
|
||||
@@ -419,7 +419,7 @@ operator==(
|
||||
}
|
||||
|
||||
template <class TAttestation>
|
||||
inline typename XChainAttestationsBase<TAttestation>::AttCollection const&
|
||||
inline XChainAttestationsBase<TAttestation>::AttCollection const&
|
||||
XChainAttestationsBase<TAttestation>::attestations() const
|
||||
{
|
||||
return attestations_;
|
||||
|
||||
@@ -57,13 +57,11 @@ XRPL_FIX (EmptyDID, Supported::Yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(PriceOracle, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (AMMOverflowOffer, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (InnerObjTemplate, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (NFTokenReserve, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (FillOrKill, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DID, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (DisallowIncomingV1, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMM, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Clawback, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
|
||||
@@ -104,6 +102,7 @@ XRPL_RETIRE_FIX(CheckThreading)
|
||||
XRPL_RETIRE_FIX(MasterKeyAsRegularKey)
|
||||
XRPL_RETIRE_FIX(NonFungibleTokensV1_2)
|
||||
XRPL_RETIRE_FIX(NFTokenRemint)
|
||||
XRPL_RETIRE_FIX(NFTokenReserve)
|
||||
XRPL_RETIRE_FIX(PayChanRecipientOwnerDir)
|
||||
XRPL_RETIRE_FIX(QualityUpperBound)
|
||||
XRPL_RETIRE_FIX(ReducedOffersV1)
|
||||
@@ -115,6 +114,7 @@ XRPL_RETIRE_FIX(UniversalNumber)
|
||||
|
||||
XRPL_RETIRE_FEATURE(Checks)
|
||||
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
|
||||
XRPL_RETIRE_FEATURE(Clawback)
|
||||
XRPL_RETIRE_FEATURE(CryptoConditions)
|
||||
XRPL_RETIRE_FEATURE(CryptoConditionsSuite)
|
||||
XRPL_RETIRE_FEATURE(DeletableAccounts)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
/** A ledger object which identifies an offer to buy or sell an NFT.
|
||||
|
||||
\sa keylet::nftoffer
|
||||
\sa keylet::nftokenOffer
|
||||
*/
|
||||
LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, nft_offer, ({
|
||||
{sfOwner, SoeRequired},
|
||||
@@ -84,7 +84,7 @@ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({
|
||||
|
||||
/** A ledger object which contains a list of NFTs
|
||||
|
||||
\sa keylet::nftpageMin, keylet::nftpageMax, keylet::nftpage
|
||||
\sa keylet::nftokenPageMin, keylet::nftokenPageMax, keylet::nftokenPage
|
||||
*/
|
||||
LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({
|
||||
{sfPreviousPageMin, SoeOptional},
|
||||
@@ -96,7 +96,7 @@ LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({
|
||||
|
||||
/** A ledger object which contains a signer list for an account.
|
||||
|
||||
\sa keylet::signers
|
||||
\sa keylet::signerList
|
||||
*/
|
||||
// All fields are SoeRequired because there is always a SignerEntries.
|
||||
// If there are no SignerEntries the node is deleted.
|
||||
@@ -112,7 +112,7 @@ LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({
|
||||
|
||||
/** A ledger object which describes a ticket.
|
||||
|
||||
\sa keylet::kTicket
|
||||
\sa keylet::ticket
|
||||
*/
|
||||
LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({
|
||||
{sfAccount, SoeRequired},
|
||||
@@ -272,7 +272,7 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, xchain_owned_c
|
||||
|
||||
@note Per Vinnie Falco this should be renamed to ltTRUST_LINE
|
||||
|
||||
\sa keylet::line
|
||||
\sa keylet::trustLine
|
||||
*/
|
||||
LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({
|
||||
{sfBalance, SoeRequired},
|
||||
@@ -292,7 +292,7 @@ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({
|
||||
|
||||
\note This is a singleton: only one such object exists in the ledger.
|
||||
|
||||
\sa keylet::fees
|
||||
\sa keylet::feeSettings
|
||||
*/
|
||||
LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({
|
||||
// Old version uses raw numbers
|
||||
@@ -346,7 +346,7 @@ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({
|
||||
|
||||
/** A ledger object describing a single unidirectional XRP payment channel.
|
||||
|
||||
\sa keylet::payChan
|
||||
\sa keylet::payChannel
|
||||
*/
|
||||
LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, payment_channel, ({
|
||||
{sfAccount, SoeRequired},
|
||||
@@ -384,7 +384,7 @@ LEDGER_ENTRY(ltAMM, 0x0079, AMM, amm, ({
|
||||
}))
|
||||
|
||||
/** A ledger object which tracks MPTokenIssuance
|
||||
\sa keylet::mptIssuance
|
||||
\sa keylet::mptokenIssuance
|
||||
*/
|
||||
LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, mpt_issuance, ({
|
||||
{sfIssuer, SoeRequired},
|
||||
@@ -499,7 +499,7 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({
|
||||
|
||||
/** A ledger object representing a loan broker
|
||||
|
||||
\sa keylet::loanbroker
|
||||
\sa keylet::loanBroker
|
||||
*/
|
||||
LEDGER_ENTRY(ltLOAN_BROKER, 0x0088, LoanBroker, loan_broker, ({
|
||||
{sfPreviousTxnID, SoeRequired},
|
||||
|
||||
@@ -395,7 +395,7 @@ TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer,
|
||||
#endif
|
||||
TRANSACTION(ttCLAWBACK, 30, Clawback,
|
||||
Delegation::Delegable,
|
||||
featureClawback,
|
||||
uint256{},
|
||||
NoPriv,
|
||||
({
|
||||
{sfAmount, SoeRequired, SoeMptSupported},
|
||||
|
||||
@@ -206,7 +206,7 @@ sha512Half(Args const&... args)
|
||||
sha512_half_hasher h;
|
||||
using beast::hash_append;
|
||||
hash_append(h, args...);
|
||||
return static_cast<typename sha512_half_hasher::result_type>(h);
|
||||
return static_cast<sha512_half_hasher::result_type>(h);
|
||||
}
|
||||
|
||||
/** Returns the SHA512-Half of a series of objects.
|
||||
@@ -222,7 +222,7 @@ sha512HalfS(Args const&... args)
|
||||
sha512_half_hasher_s h;
|
||||
using beast::hash_append;
|
||||
hash_append(h, args...);
|
||||
return static_cast<typename sha512_half_hasher_s::result_type>(h);
|
||||
return static_cast<sha512_half_hasher_s::result_type>(h);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -52,7 +52,7 @@ getTransferFee(uint256 const& id)
|
||||
}
|
||||
|
||||
inline std::uint32_t
|
||||
getSerial(uint256 const& id)
|
||||
getSequence(uint256 const& id)
|
||||
{
|
||||
std::uint32_t seq = 0;
|
||||
memcpy(&seq, id.begin() + 28, 4);
|
||||
@@ -92,7 +92,7 @@ getTaxon(uint256 const& id)
|
||||
|
||||
// The taxon cipher is just an XOR, so it is reversible by applying the
|
||||
// XOR a second time.
|
||||
return cipheredTaxon(getSerial(id), toTaxon(taxon));
|
||||
return cipheredTaxon(getSequence(id), toTaxon(taxon));
|
||||
}
|
||||
|
||||
inline AccountID
|
||||
|
||||
@@ -20,7 +20,7 @@ class ClawbackBuilder;
|
||||
*
|
||||
* Type: ttCLAWBACK (30)
|
||||
* Delegable: Delegation::Delegable
|
||||
* Amendment: featureClawback
|
||||
* Amendment: uint256{}
|
||||
* Privileges: NoPriv
|
||||
*
|
||||
* Immutable wrapper around STTx providing type-safe field access.
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
static constexpr auto kDefaultCacheTargetSize = 0;
|
||||
|
||||
using key_type = uint256;
|
||||
using clock_type = typename CacheType::clock_type;
|
||||
using clock_type = CacheType::clock_type;
|
||||
|
||||
/** Construct the cache.
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpl/ledger/PaymentSandbox.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/tx/paths/detail/AmountSpec.h>
|
||||
|
||||
#include <boost/container/flat_map.hpp>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ checkFreeze(
|
||||
}
|
||||
}
|
||||
|
||||
if (auto sle = view.read(keylet::line(src, dst, currency)))
|
||||
if (auto sle = view.read(keylet::trustLine(src, dst, currency)))
|
||||
{
|
||||
if (sle->isFlag((dst > src) ? lsfHighFreeze : lsfLowFreeze))
|
||||
{
|
||||
@@ -71,8 +71,8 @@ checkNoRipple(
|
||||
beast::Journal j)
|
||||
{
|
||||
// fetch the ripple lines into and out of this node
|
||||
auto sleIn = view.read(keylet::line(prev, cur, currency));
|
||||
auto sleOut = view.read(keylet::line(cur, next, currency));
|
||||
auto sleIn = view.read(keylet::trustLine(prev, cur, currency));
|
||||
auto sleOut = view.read(keylet::trustLine(cur, next, currency));
|
||||
|
||||
if (!sleIn || !sleOut)
|
||||
return terNO_LINE;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
#include <xrpl/tx/paths/Flow.h>
|
||||
#include <xrpl/tx/paths/detail/AmountSpec.h>
|
||||
#include <xrpl/tx/paths/detail/FlatSets.h>
|
||||
#include <xrpl/tx/paths/detail/FlowDebugInfo.h>
|
||||
#include <xrpl/tx/paths/detail/Steps.h>
|
||||
|
||||
Reference in New Issue
Block a user