mirror of
https://github.com/XRPLF/rippled.git
synced 2026-10-22 11:37:07 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5aa162322 | ||
|
|
82421bc2a1 | ||
|
|
969d9035aa |
No files matched your search
@@ -0,0 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/**
|
||||
* Opt-in bitwise operators for scoped enumerations.
|
||||
*
|
||||
* Provides `&`, `|`, `^`, `~` and the corresponding compound assignment forms
|
||||
* for any scoped enumeration with an unsigned underlying type that opts in by
|
||||
* specializing @ref OptIn:
|
||||
*
|
||||
* @code
|
||||
* namespace xrpl {
|
||||
*
|
||||
* enum class MyFlags : std::uint32_t { a = 1, b = 2, c = 4 };
|
||||
*
|
||||
* template <>
|
||||
* struct enum_bitops::OptIn<MyFlags> : std::true_type {};
|
||||
*
|
||||
* } // namespace xrpl
|
||||
* @endcode
|
||||
*
|
||||
* The operators are constexpr and noexcept, and return the enumeration type.
|
||||
*
|
||||
* @par Where the specialization may be declared
|
||||
* In namespace xrpl, or at global scope with full qualification, and after
|
||||
* the enumeration is defined but before the operators are first used. This
|
||||
* cannot be done in a nested namespace or at class scope; for enumerations
|
||||
* nested in a class this means after the class definition.
|
||||
*
|
||||
* @par Where the operators are found
|
||||
* The operators are declared in namespace xrpl, so argument-dependent lookup
|
||||
* will find them only for enumerations declared in xrpl or nested in a class
|
||||
* declared directly in xrpl. Enumerations in a nested namespace will only be
|
||||
* found from code inside xrpl, and only if no enclosing scope declares an
|
||||
* operator of the same name; elsewhere they require using-declarations.
|
||||
*/
|
||||
namespace enum_bitops {
|
||||
|
||||
/**
|
||||
* Types that may be opted in to the bitwise operators.
|
||||
*
|
||||
* Satisfied by a scoped enumeration whose underlying type is an unsigned
|
||||
* integer type.
|
||||
*
|
||||
* @tparam T The type to test.
|
||||
*/
|
||||
template <typename T>
|
||||
concept Eligible = std::is_scoped_enum_v<T> && std::unsigned_integral<std::underlying_type_t<T>>;
|
||||
|
||||
/**
|
||||
* Opt-in switch for the bitwise operators.
|
||||
*
|
||||
* The primary template derives from std::false_type. Specialize it to derive
|
||||
* from std::true_type to enable the operators for an @ref Eligible enumeration.
|
||||
*
|
||||
* @tparam T The scoped enumeration to opt in.
|
||||
*/
|
||||
template <Eligible T>
|
||||
struct OptIn : std::false_type
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumerations for which the bitwise operators are enabled.
|
||||
*
|
||||
* Satisfied when @p T satisfies @ref Eligible and @ref OptIn has been
|
||||
* specialized for it to derive from std::true_type.
|
||||
*
|
||||
* @tparam T The type to test.
|
||||
*/
|
||||
template <typename T>
|
||||
concept Candidate = Eligible<T> && OptIn<T>::value;
|
||||
|
||||
} // namespace enum_bitops
|
||||
|
||||
// These are declared in xrpl, not in enum_bitops, so that argument-dependent
|
||||
// lookup finds them for enumerations whose associated namespace is xrpl.
|
||||
|
||||
/**
|
||||
* @name Bitwise operators for opted-in scoped enumerations
|
||||
*
|
||||
* Each operator applies the corresponding built-in operator to the
|
||||
* underlying values and converts the result back to the enumeration type.
|
||||
* Both operands must have the same enumeration type; there is no implicit
|
||||
* conversion to or from the underlying type.
|
||||
*/
|
||||
/** @{ */
|
||||
|
||||
/**
|
||||
* Bitwise AND.
|
||||
*
|
||||
* @param lhs The left operand.
|
||||
* @param rhs The right operand.
|
||||
* @return The bits set in both @p lhs and @p rhs.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T
|
||||
operator&(T lhs, T rhs) noexcept
|
||||
{
|
||||
return static_cast<T>(std::to_underlying(lhs) & std::to_underlying(rhs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise OR.
|
||||
*
|
||||
* @param lhs The left operand.
|
||||
* @param rhs The right operand.
|
||||
* @return The bits set in @p lhs, in @p rhs, or in both.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T
|
||||
operator|(T lhs, T rhs) noexcept
|
||||
{
|
||||
return static_cast<T>(std::to_underlying(lhs) | std::to_underlying(rhs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise exclusive OR.
|
||||
*
|
||||
* @param lhs The left operand.
|
||||
* @param rhs The right operand.
|
||||
* @return The bits set in exactly one of @p lhs and @p rhs.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T
|
||||
operator^(T lhs, T rhs) noexcept
|
||||
{
|
||||
return static_cast<T>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise complement.
|
||||
*
|
||||
* The result has every bit of the underlying type that is clear in
|
||||
* @p val, including bits that no enumerator names. It is intended for
|
||||
* clearing flags, as in `flags & ~flag`.
|
||||
*
|
||||
* @param val The operand.
|
||||
* @return The complement of @p val.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T
|
||||
operator~(T val) noexcept
|
||||
{
|
||||
return static_cast<T>(~std::to_underlying(val));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise AND assignment.
|
||||
*
|
||||
* @param lhs The value to modify.
|
||||
* @param rhs The right operand.
|
||||
* @return A reference to @p lhs.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T&
|
||||
operator&=(T& lhs, T rhs) noexcept
|
||||
{
|
||||
lhs = lhs & rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise OR assignment.
|
||||
*
|
||||
* @param lhs The value to modify.
|
||||
* @param rhs The right operand.
|
||||
* @return A reference to @p lhs.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T&
|
||||
operator|=(T& lhs, T rhs) noexcept
|
||||
{
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise exclusive OR assignment.
|
||||
*
|
||||
* @param lhs The value to modify.
|
||||
* @param rhs The right operand.
|
||||
* @return A reference to @p lhs.
|
||||
*/
|
||||
template <enum_bitops::Candidate T>
|
||||
constexpr T&
|
||||
operator^=(T& lhs, T rhs) noexcept
|
||||
{
|
||||
lhs = lhs ^ rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/safe_cast.h>
|
||||
#include <xrpl/basics/enum_bitops.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/ledger/OwnerCounts.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
@@ -22,80 +22,39 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// Bitwise flag enum with existing operator overloads
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum ApplyFlags : std::uint32_t {
|
||||
TapNone = 0x00,
|
||||
enum class ApplyFlags : std::uint32_t {
|
||||
None = 0x00,
|
||||
|
||||
// This is a local transaction with the
|
||||
// fail_hard flag set.
|
||||
TapFailHard = 0x10,
|
||||
FailHard = 0x10,
|
||||
|
||||
// This is not the transaction's last pass
|
||||
// Transaction can be retried, soft failures allowed
|
||||
TapRetry = 0x20,
|
||||
Retry = 0x20,
|
||||
|
||||
// Transaction came from a privileged source
|
||||
TapUnlimited = 0x400,
|
||||
Unlimited = 0x400,
|
||||
|
||||
// Transaction is executing as part of a batch
|
||||
TapBatch = 0x800,
|
||||
Batch = 0x800,
|
||||
|
||||
// Transaction shouldn't be applied
|
||||
// Signatures shouldn't be checked
|
||||
TapDryRun = 0x1000,
|
||||
DryRun = 0x1000,
|
||||
|
||||
// Transaction is being preflighted as the payload of a
|
||||
// TransactionProposalCreate. Its signatures are collected on-ledger
|
||||
// afterward, so signature-presence checks (e.g. Batch signer matching)
|
||||
// are skipped at proposal-creation time (On-Chain Cosigner spec
|
||||
// §5.3.1.2).
|
||||
TapProposal = 0x2000,
|
||||
Proposal = 0x2000,
|
||||
};
|
||||
|
||||
constexpr ApplyFlags
|
||||
operator|(ApplyFlags const& lhs, ApplyFlags const& rhs)
|
||||
template <>
|
||||
struct enum_bitops::OptIn<ApplyFlags> : std::true_type
|
||||
{
|
||||
return safeCast<ApplyFlags>(
|
||||
safeCast<std::underlying_type_t<ApplyFlags>>(lhs) |
|
||||
safeCast<std::underlying_type_t<ApplyFlags>>(rhs));
|
||||
}
|
||||
|
||||
static_assert((TapFailHard | TapRetry) == safeCast<ApplyFlags>(0x30u), "ApplyFlags operator |");
|
||||
static_assert((TapRetry | TapFailHard) == safeCast<ApplyFlags>(0x30u), "ApplyFlags operator |");
|
||||
|
||||
constexpr ApplyFlags
|
||||
operator&(ApplyFlags const& lhs, ApplyFlags const& rhs)
|
||||
{
|
||||
return safeCast<ApplyFlags>(
|
||||
safeCast<std::underlying_type_t<ApplyFlags>>(lhs) &
|
||||
safeCast<std::underlying_type_t<ApplyFlags>>(rhs));
|
||||
}
|
||||
|
||||
static_assert((TapFailHard & TapRetry) == TapNone, "ApplyFlags operator &");
|
||||
static_assert((TapRetry & TapFailHard) == TapNone, "ApplyFlags operator &");
|
||||
|
||||
constexpr ApplyFlags
|
||||
operator~(ApplyFlags const& flags)
|
||||
{
|
||||
return safeCast<ApplyFlags>(~safeCast<std::underlying_type_t<ApplyFlags>>(flags));
|
||||
}
|
||||
|
||||
static_assert(~TapRetry == safeCast<ApplyFlags>(0xFFFFFFDFu), "ApplyFlags operator ~");
|
||||
|
||||
inline ApplyFlags
|
||||
operator|=(ApplyFlags& lhs, ApplyFlags const& rhs)
|
||||
{
|
||||
lhs = lhs | rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline ApplyFlags
|
||||
operator&=(ApplyFlags& lhs, ApplyFlags const& rhs)
|
||||
{
|
||||
lhs = lhs & rhs;
|
||||
return lhs;
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <xrpl/basics/CountedObject.h>
|
||||
#include <xrpl/basics/UnorderedContainers.h>
|
||||
#include <xrpl/basics/enum_bitops.h>
|
||||
#include <xrpl/beast/hash/hash_append.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
@@ -15,37 +17,43 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
enum class STPathElementType : std::uint8_t {
|
||||
// clang-format off
|
||||
|
||||
None = 0x00, ///< No element; also terminates the serialized path set.
|
||||
Account = 0x01, ///< Rippling through an account (vs taking an offer).
|
||||
Currency = 0x10, ///< Currency follows.
|
||||
Issuer = 0x20, ///< Issuer follows.
|
||||
Mpt = 0x40, ///< MPT follows.
|
||||
Boundary = 0xFF, ///< Boundary between alternate paths.
|
||||
|
||||
Asset = Currency | Mpt, ///< Either asset kind.
|
||||
All = Account | Currency | Issuer | Mpt, ///< Every value-carrying bit.
|
||||
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
template <>
|
||||
struct enum_bitops::OptIn<STPathElementType> : std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
class STPathElement final : public CountedObject<STPathElement>
|
||||
{
|
||||
unsigned int type_;
|
||||
STPathElementType type_ = STPathElementType::None;
|
||||
bool isOffer_ = true;
|
||||
AccountID accountID_;
|
||||
PathAsset assetID_;
|
||||
AccountID issuerID_;
|
||||
|
||||
bool isOffer_;
|
||||
std::size_t hashValue_;
|
||||
|
||||
public:
|
||||
// Bitwise values (typeCurrency | typeMPT)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-use-enum-class)
|
||||
enum Type {
|
||||
TypeNone = 0x00,
|
||||
TypeAccount = 0x01, // Rippling through an account (vs taking an offer).
|
||||
TypeCurrency = 0x10, // Currency follows.
|
||||
TypeIssuer = 0x20, // Issuer follows.
|
||||
TypeMpt = 0x40, // MPT follows.
|
||||
TypeBoundary = 0xFF, // Boundary between alternate paths.
|
||||
TypeAsset = TypeCurrency | TypeMpt,
|
||||
TypeAll = TypeAccount | TypeCurrency | TypeIssuer | TypeMpt,
|
||||
// Combination of all types.
|
||||
};
|
||||
|
||||
STPathElement();
|
||||
STPathElement() = default;
|
||||
STPathElement(STPathElement const&) = default;
|
||||
STPathElement&
|
||||
operator=(STPathElement const&) = default;
|
||||
@@ -62,42 +70,42 @@ public:
|
||||
bool forceAsset = false);
|
||||
|
||||
STPathElement(
|
||||
unsigned int uType,
|
||||
STPathElementType type,
|
||||
AccountID const& account,
|
||||
PathAsset const& asset,
|
||||
AccountID const& issuer);
|
||||
|
||||
[[nodiscard]] std::uint32_t
|
||||
getNodeType() const;
|
||||
[[nodiscard]] STPathElementType
|
||||
getNodeType() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isOffer() const;
|
||||
isOffer() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isAccount() const;
|
||||
isAccount() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
hasIssuer() const;
|
||||
hasIssuer() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
hasCurrency() const;
|
||||
hasCurrency() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
hasMPT() const;
|
||||
hasMPT() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
hasAsset() const;
|
||||
hasAsset() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isNone() const;
|
||||
isNone() const noexcept;
|
||||
|
||||
// Nodes are either an account ID or a offer prefix. Offer prefixs denote a
|
||||
// class of offers.
|
||||
[[nodiscard]] AccountID const&
|
||||
getAccountID() const;
|
||||
getAccountID() const noexcept;
|
||||
|
||||
[[nodiscard]] PathAsset const&
|
||||
getPathAsset() const;
|
||||
getPathAsset() const noexcept;
|
||||
|
||||
[[nodiscard]] Currency const&
|
||||
getCurrency() const;
|
||||
@@ -106,17 +114,18 @@ public:
|
||||
getMPTID() const;
|
||||
|
||||
[[nodiscard]] AccountID const&
|
||||
getIssuerID() const;
|
||||
getIssuerID() const noexcept;
|
||||
|
||||
[[nodiscard]] bool
|
||||
isType(Type const& pe) const;
|
||||
isType(STPathElementType pe) const noexcept;
|
||||
|
||||
bool
|
||||
operator==(STPathElement const& t) const;
|
||||
|
||||
private:
|
||||
static std::size_t
|
||||
getHash(STPathElement const& element);
|
||||
friend bool
|
||||
operator==(STPathElement const& lhs, STPathElement const& rhs) noexcept
|
||||
{
|
||||
return lhs.isType(STPathElementType::Account) == rhs.isType(STPathElementType::Account) &&
|
||||
lhs.accountID_ == rhs.accountID_ && lhs.assetID_ == rhs.assetID_ &&
|
||||
lhs.issuerID_ == rhs.issuerID_;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Hasher>
|
||||
@@ -124,7 +133,7 @@ void
|
||||
hash_append(Hasher& h, STPathElement const& e) noexcept
|
||||
{
|
||||
using beast::hash_append;
|
||||
hash_append(h, (e.getNodeType() & STPathElement::TypeAccount) != 0u);
|
||||
hash_append(h, e.isType(STPathElementType::Account));
|
||||
hash_append(h, e.getAccountID());
|
||||
hash_append(h, e.getPathAsset());
|
||||
hash_append(h, e.getIssuerID());
|
||||
@@ -337,29 +346,16 @@ private:
|
||||
|
||||
// ------------ STPathElement ------------
|
||||
|
||||
inline STPathElement::STPathElement() : type_(TypeNone), isOffer_(true)
|
||||
{
|
||||
// hashValue_ is derived from the whole object, so it is computed in the body
|
||||
// once every other member is initialized (as in the other constructors).
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
std::optional<AccountID> const& account,
|
||||
std::optional<PathAsset> const& asset,
|
||||
std::optional<AccountID> const& issuer)
|
||||
: type_(TypeNone)
|
||||
{
|
||||
if (!account)
|
||||
{
|
||||
isOffer_ = true;
|
||||
}
|
||||
else
|
||||
if (account)
|
||||
{
|
||||
isOffer_ = false;
|
||||
accountID_ = *account;
|
||||
type_ |= TypeAccount;
|
||||
type_ |= STPathElementType::Account;
|
||||
XRPL_ASSERT(
|
||||
accountID_ != noAccount(), "xrpl::STPathElement::STPathElement : account is set");
|
||||
}
|
||||
@@ -367,17 +363,15 @@ inline STPathElement::STPathElement(
|
||||
if (asset)
|
||||
{
|
||||
assetID_ = *asset;
|
||||
type_ |= assetID_.holds<Currency>() ? TypeCurrency : TypeMpt;
|
||||
type_ |= assetID_.holds<Currency>() ? STPathElementType::Currency : STPathElementType::Mpt;
|
||||
}
|
||||
|
||||
if (issuer)
|
||||
{
|
||||
issuerID_ = *issuer;
|
||||
type_ |= TypeIssuer;
|
||||
type_ |= STPathElementType::Issuer;
|
||||
XRPL_ASSERT(issuerID_ != noAccount(), "xrpl::STPathElement::STPathElement : issuer is set");
|
||||
}
|
||||
|
||||
hashValue_ = getHash(*this);
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
@@ -385,108 +379,94 @@ inline STPathElement::STPathElement(
|
||||
PathAsset const& asset,
|
||||
AccountID const& issuer,
|
||||
bool forceAsset)
|
||||
: type_(TypeNone)
|
||||
, accountID_(account)
|
||||
, assetID_(asset)
|
||||
, issuerID_(issuer)
|
||||
, isOffer_(isXRP(accountID_))
|
||||
: isOffer_(isXRP(account)), accountID_(account), assetID_(asset), issuerID_(issuer)
|
||||
{
|
||||
if (!isOffer_)
|
||||
type_ |= TypeAccount;
|
||||
type_ |= STPathElementType::Account;
|
||||
|
||||
if (forceAsset || !isXRP(assetID_))
|
||||
type_ |= asset.holds<Currency>() ? TypeCurrency : TypeMpt;
|
||||
type_ |= asset.holds<Currency>() ? STPathElementType::Currency : STPathElementType::Mpt;
|
||||
|
||||
if (!isXRP(issuer))
|
||||
type_ |= TypeIssuer;
|
||||
|
||||
hashValue_ = getHash(*this);
|
||||
type_ |= STPathElementType::Issuer;
|
||||
}
|
||||
|
||||
inline STPathElement::STPathElement(
|
||||
unsigned int uType,
|
||||
STPathElementType type,
|
||||
AccountID const& account,
|
||||
PathAsset const& asset,
|
||||
AccountID const& issuer)
|
||||
: type_(uType)
|
||||
, accountID_(account)
|
||||
, assetID_(asset)
|
||||
, issuerID_(issuer)
|
||||
, isOffer_(isXRP(accountID_))
|
||||
: type_(type), isOffer_(isXRP(account)), accountID_(account), assetID_(asset), issuerID_(issuer)
|
||||
{
|
||||
assetID_.visit(
|
||||
[&](Currency const&) { type_ = type_ & (~Type::TypeMpt); },
|
||||
[&](MPTID const&) { type_ = type_ & (~Type::TypeCurrency); });
|
||||
// hashValue_ must be computed after type_ is adjusted above, so this cannot
|
||||
// be a member initializer.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
||||
hashValue_ = getHash(*this);
|
||||
[&](Currency const&) { type_ &= ~STPathElementType::Mpt; },
|
||||
[&](MPTID const&) { type_ &= ~STPathElementType::Currency; });
|
||||
}
|
||||
|
||||
inline std::uint32_t
|
||||
STPathElement::getNodeType() const
|
||||
inline STPathElementType
|
||||
STPathElement::getNodeType() const noexcept
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::isOffer() const
|
||||
STPathElement::isOffer() const noexcept
|
||||
{
|
||||
return isOffer_;
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::isAccount() const
|
||||
STPathElement::isAccount() const noexcept
|
||||
{
|
||||
return !isOffer();
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::isType(Type const& pe) const
|
||||
STPathElement::isType(STPathElementType pe) const noexcept
|
||||
{
|
||||
return (type_ & pe) != 0u;
|
||||
return (type_ & pe) != STPathElementType::None;
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::hasIssuer() const
|
||||
STPathElement::hasIssuer() const noexcept
|
||||
{
|
||||
return isType(STPathElement::TypeIssuer);
|
||||
return isType(STPathElementType::Issuer);
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::hasCurrency() const
|
||||
STPathElement::hasCurrency() const noexcept
|
||||
{
|
||||
return isType(STPathElement::TypeCurrency);
|
||||
return isType(STPathElementType::Currency);
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::hasMPT() const
|
||||
STPathElement::hasMPT() const noexcept
|
||||
{
|
||||
return isType(STPathElement::TypeMpt);
|
||||
return isType(STPathElementType::Mpt);
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::hasAsset() const
|
||||
STPathElement::hasAsset() const noexcept
|
||||
{
|
||||
return isType(STPathElement::TypeAsset);
|
||||
return isType(STPathElementType::Asset);
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::isNone() const
|
||||
STPathElement::isNone() const noexcept
|
||||
{
|
||||
return getNodeType() == STPathElement::TypeNone;
|
||||
return getNodeType() == STPathElementType::None;
|
||||
}
|
||||
|
||||
// Nodes are either an account ID or a offer prefix. Offer prefixs denote a
|
||||
// class of offers.
|
||||
inline AccountID const&
|
||||
STPathElement::getAccountID() const
|
||||
STPathElement::getAccountID() const noexcept
|
||||
{
|
||||
return accountID_;
|
||||
}
|
||||
|
||||
inline PathAsset const&
|
||||
STPathElement::getPathAsset() const
|
||||
STPathElement::getPathAsset() const noexcept
|
||||
{
|
||||
return assetID_;
|
||||
}
|
||||
@@ -504,18 +484,11 @@ STPathElement::getMPTID() const
|
||||
}
|
||||
|
||||
inline AccountID const&
|
||||
STPathElement::getIssuerID() const
|
||||
STPathElement::getIssuerID() const noexcept
|
||||
{
|
||||
return issuerID_;
|
||||
}
|
||||
|
||||
inline bool
|
||||
STPathElement::operator==(STPathElement const& t) const
|
||||
{
|
||||
return (type_ & TypeAccount) == (t.type_ & TypeAccount) && hashValue_ == t.hashValue_ &&
|
||||
accountID_ == t.accountID_ && assetID_ == t.assetID_ && issuerID_ == t.issuerID_;
|
||||
}
|
||||
|
||||
// ------------ STPath ------------
|
||||
|
||||
inline STPath::STPath(std::vector<STPathElement> p) : path_(std::move(p))
|
||||
|
||||
@@ -51,7 +51,8 @@ public:
|
||||
beast::Journal journal = beast::Journal{beast::Journal::getNullSink()})
|
||||
: ApplyContext(registry, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal)
|
||||
{
|
||||
XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set");
|
||||
XRPL_ASSERT(
|
||||
(flags & ApplyFlags::Batch) == ApplyFlags::None, "Batch apply flag should not be set");
|
||||
}
|
||||
|
||||
std::reference_wrapper<ServiceRegistry> registry;
|
||||
|
||||
@@ -59,10 +59,11 @@ public:
|
||||
, parentBatchId(parentBatchId)
|
||||
, j(j)
|
||||
{
|
||||
XRPL_ASSERT((flags & TapBatch) == TapBatch, "Batch apply flag should be set");
|
||||
XRPL_ASSERT(
|
||||
(flags & ApplyFlags::Batch) == ApplyFlags::Batch, "Batch apply flag should be set");
|
||||
XRPL_ASSERT_IF(
|
||||
(flags & TapProposal) != TapNone,
|
||||
(flags & TapDryRun) != TapNone,
|
||||
(flags & ApplyFlags::Proposal) != ApplyFlags::None,
|
||||
(flags & ApplyFlags::DryRun) != ApplyFlags::None,
|
||||
"xrpl::PreflightContext : proposal preflight implies dry run");
|
||||
}
|
||||
|
||||
@@ -74,10 +75,11 @@ public:
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
: registry(registry), tx(tx), rules(std::move(rules)), flags(flags), j(j)
|
||||
{
|
||||
XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set");
|
||||
XRPL_ASSERT(
|
||||
(flags & ApplyFlags::Batch) == ApplyFlags::None, "Batch apply flag should not be set");
|
||||
XRPL_ASSERT_IF(
|
||||
(flags & TapProposal) != TapNone,
|
||||
(flags & TapDryRun) != TapNone,
|
||||
(flags & ApplyFlags::Proposal) != ApplyFlags::None,
|
||||
(flags & ApplyFlags::DryRun) != ApplyFlags::None,
|
||||
"xrpl::PreflightContext : proposal preflight implies dry run");
|
||||
}
|
||||
|
||||
@@ -116,7 +118,7 @@ public:
|
||||
, j(j)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
parentBatchId.has_value() == ((flags & TapBatch) == TapBatch),
|
||||
parentBatchId.has_value() == ((flags & ApplyFlags::Batch) == ApplyFlags::Batch),
|
||||
"Parent Batch ID should be set if batch apply flag is set");
|
||||
}
|
||||
|
||||
@@ -129,7 +131,8 @@ public:
|
||||
beast::Journal j = beast::Journal{beast::Journal::getNullSink()})
|
||||
: PreclaimContext(registry, view, preflightResult, tx, flags, std::nullopt, j)
|
||||
{
|
||||
XRPL_ASSERT((flags & TapBatch) == 0, "Batch apply flag should not be set");
|
||||
XRPL_ASSERT(
|
||||
(flags & ApplyFlags::Batch) == ApplyFlags::None, "Batch apply flag should not be set");
|
||||
}
|
||||
|
||||
PreclaimContext&
|
||||
|
||||
@@ -41,7 +41,7 @@ struct ApplyResult
|
||||
inline bool
|
||||
isTecClaimHardFail(TER ter, ApplyFlags flags)
|
||||
{
|
||||
return isTecClaim(ter) && ((flags & TapRetry) == 0u);
|
||||
return isTecClaim(ter) && ((flags & ApplyFlags::Retry) == ApplyFlags::None);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include <xrpl/protocol/STPathSet.h>
|
||||
|
||||
#include <xrpl/basics/CountedObject.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/UnorderedContainers.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/hash/uhash.h>
|
||||
#include <xrpl/basics/safe_cast.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
@@ -17,7 +16,9 @@
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <concepts>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
@@ -25,41 +26,6 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
std::size_t
|
||||
STPathElement::getHash(STPathElement const& element)
|
||||
{
|
||||
std::size_t hashAccount = 2654435761;
|
||||
std::size_t hashCurrency = 2654435761;
|
||||
std::size_t hashIssuer = 2654435761;
|
||||
|
||||
// NIKB NOTE: This doesn't have to be a secure hash as speed is more
|
||||
// important. We don't even really need to fully hash the whole
|
||||
// base_uint here, as a few bytes would do for our use.
|
||||
//
|
||||
// The note above is only true because the result of this function reaches
|
||||
// nothing but STPathElement::operator==, where it is a fast-reject
|
||||
// prefilter ahead of the field comparisons that decide the answer. Do not
|
||||
// use it to key a container.
|
||||
|
||||
for (auto const x : element.getAccountID())
|
||||
hashAccount += (hashAccount * 257) ^ x;
|
||||
|
||||
// Check pathAsset type instead of element's type_
|
||||
// In some cases type_ might be account but the asset
|
||||
// is still set to either MPT or currency (see Pathfinder::addLink())
|
||||
element.getPathAsset().visit(
|
||||
[&](MPTID const& mpt) { hashCurrency += beast::Uhash<>{}(mpt); },
|
||||
[&](Currency const& currency) {
|
||||
for (auto const x : currency)
|
||||
hashCurrency += (hashCurrency * 509) ^ x;
|
||||
});
|
||||
|
||||
for (auto const x : element.getIssuerID())
|
||||
hashIssuer += (hashIssuer * 911) ^ x;
|
||||
|
||||
return (hashAccount ^ hashCurrency ^ hashIssuer);
|
||||
}
|
||||
|
||||
// For guidance on deciding which option to pursue:
|
||||
// 1. Try to decrease the size of the STPathSet first. For instance, if a std::optional was
|
||||
// injected into the type, could you get the same functionality using a std::unique_ptr instead?
|
||||
@@ -108,62 +74,57 @@ STPathSet::operator=(STPathSet const& other)
|
||||
STPathSet::STPathSet(SerialIter& sit, SField const& name) : STBase(name)
|
||||
{
|
||||
std::vector<STPathElement> path;
|
||||
for (;;)
|
||||
{
|
||||
int const iType = sit.get8();
|
||||
|
||||
if (iType == STPathElement::TypeNone || iType == STPathElement::TypeBoundary)
|
||||
STPathElementType type = STPathElementType::None;
|
||||
|
||||
do
|
||||
{
|
||||
type = safeCast<STPathElementType>(sit.get8());
|
||||
|
||||
if (type == STPathElementType::None || type == STPathElementType::Boundary)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
JLOG(debugLog().error()) << "Empty path in pathset";
|
||||
Throw<std::runtime_error>("empty path");
|
||||
}
|
||||
Throw<std::runtime_error>("bad path element: empty path");
|
||||
|
||||
// Move rather than converting the vector to an STPath by copy.
|
||||
value_.emplace_back(std::move(path));
|
||||
path.clear();
|
||||
|
||||
if (iType == STPathElement::TypeNone)
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
else if ((iType & ~STPathElement::TypeAll) != 0)
|
||||
{
|
||||
JLOG(debugLog().error()) << "Bad path element " << iType << " in pathset";
|
||||
Throw<std::runtime_error>("bad path element");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const hasAccount = (iType & STPathElement::TypeAccount) != 0u;
|
||||
auto const hasCurrency = (iType & STPathElement::TypeCurrency) != 0u;
|
||||
auto const hasIssuer = (iType & STPathElement::TypeIssuer) != 0u;
|
||||
auto const hasMPT = (iType & STPathElement::TypeMpt) != 0u;
|
||||
|
||||
AccountID account;
|
||||
PathAsset asset;
|
||||
AccountID issuer;
|
||||
if ((type & ~STPathElementType::All) != STPathElementType::None)
|
||||
Throw<std::runtime_error>(
|
||||
std::format("bad path element: <{:#04x}>", std::to_underlying(type)));
|
||||
|
||||
if (hasAccount)
|
||||
account = sit.get160();
|
||||
bool const hasAccount = (type & STPathElementType::Account) == STPathElementType::Account;
|
||||
bool const hasCurrency =
|
||||
(type & STPathElementType::Currency) == STPathElementType::Currency;
|
||||
bool const hasMPT = (type & STPathElementType::Mpt) == STPathElementType::Mpt;
|
||||
bool const hasIssuer = (type & STPathElementType::Issuer) == STPathElementType::Issuer;
|
||||
|
||||
if (hasCurrency && hasMPT)
|
||||
{
|
||||
JLOG(debugLog().error()) << "Bad path element MPT and Currency in pathset";
|
||||
Throw<std::runtime_error>("bad path element: MPT and Currency");
|
||||
}
|
||||
if (hasCurrency && hasMPT)
|
||||
Throw<std::runtime_error>("bad path element: MPT and Currency");
|
||||
|
||||
if (hasCurrency)
|
||||
asset = Currency::fromRaw(sit.get160());
|
||||
AccountID account;
|
||||
PathAsset asset;
|
||||
AccountID issuer;
|
||||
|
||||
if (hasMPT)
|
||||
asset = sit.get192();
|
||||
if (hasAccount)
|
||||
account = sit.get160();
|
||||
|
||||
if (hasIssuer)
|
||||
issuer = sit.get160();
|
||||
if (hasCurrency)
|
||||
asset = Currency::fromRaw(sit.get160());
|
||||
|
||||
path.emplace_back(account, asset, issuer, hasCurrency || hasMPT);
|
||||
}
|
||||
}
|
||||
if (hasMPT)
|
||||
asset = sit.get192();
|
||||
|
||||
if (hasIssuer)
|
||||
issuer = sit.get160();
|
||||
|
||||
path.emplace_back(account, asset, issuer, hasCurrency || hasMPT);
|
||||
|
||||
} while (type != STPathElementType::None);
|
||||
}
|
||||
|
||||
STBase*
|
||||
@@ -217,24 +178,22 @@ STPath::getJson(JsonOptions) const
|
||||
for (auto const& it : path_)
|
||||
{
|
||||
json::Value elem(json::ValueType::Object);
|
||||
auto const iType = it.getNodeType();
|
||||
|
||||
elem[jss::type] = iType;
|
||||
elem[jss::type] = safeCast<std::uint32_t>(it.getNodeType());
|
||||
|
||||
if ((iType & STPathElement::TypeAccount) != 0u)
|
||||
if (it.isType(STPathElementType::Account))
|
||||
elem[jss::account] = to_string(it.getAccountID());
|
||||
|
||||
XRPL_ASSERT(
|
||||
((iType & STPathElement::TypeCurrency) == 0u) ||
|
||||
((iType & STPathElement::TypeMpt) == 0u),
|
||||
!(it.hasCurrency() && it.hasMPT()),
|
||||
"xrpl::STPath::getJson : not type Currency and MPT");
|
||||
if ((iType & STPathElement::TypeCurrency) != 0u)
|
||||
if (it.hasCurrency())
|
||||
elem[jss::currency] = to_string(it.getCurrency());
|
||||
|
||||
if ((iType & STPathElement::TypeMpt) != 0u)
|
||||
if (it.hasMPT())
|
||||
elem[jss::mpt_issuance_id] = to_string(it.getMPTID());
|
||||
|
||||
if ((iType & STPathElement::TypeIssuer) != 0u)
|
||||
if (it.hasIssuer())
|
||||
elem[jss::issuer] = to_string(it.getIssuerID());
|
||||
|
||||
ret.append(elem);
|
||||
@@ -266,34 +225,42 @@ STPathSet::add(Serializer& s) const
|
||||
XRPL_ASSERT(getFName().fieldType == STI_PATHSET, "xrpl::STPathSet::add : valid field type");
|
||||
bool first = true;
|
||||
|
||||
// Workaround, since `Serializer` does not accept strongly-typed enums
|
||||
// yet. When support is added, the static_assert will trigger, and the
|
||||
// lambda can be removed entirely.
|
||||
auto const toByte = [](std::same_as<STPathElementType> auto t) noexcept {
|
||||
static_assert(
|
||||
!requires(Serializer& ser) { ser.add8(t); },
|
||||
"Serializer::add8 now accepts STPathElementType directly; remove toByte.");
|
||||
return std::to_underlying(t);
|
||||
};
|
||||
|
||||
for (auto const& spPath : value_)
|
||||
{
|
||||
if (!first)
|
||||
s.add8(STPathElement::TypeBoundary);
|
||||
s.add8(toByte(STPathElementType::Boundary));
|
||||
|
||||
for (auto const& speElement : spPath)
|
||||
{
|
||||
int const iType = speElement.getNodeType();
|
||||
s.add8(toByte(speElement.getNodeType()));
|
||||
|
||||
s.add8(iType);
|
||||
|
||||
if ((iType & STPathElement::TypeAccount) != 0u)
|
||||
if (speElement.isType(STPathElementType::Account))
|
||||
s.addBitString(speElement.getAccountID());
|
||||
|
||||
if ((iType & STPathElement::TypeMpt) != 0u)
|
||||
if (speElement.hasMPT())
|
||||
s.addBitString(speElement.getMPTID());
|
||||
|
||||
if ((iType & STPathElement::TypeCurrency) != 0u)
|
||||
if (speElement.hasCurrency())
|
||||
s.addBitString(speElement.getCurrency());
|
||||
|
||||
if ((iType & STPathElement::TypeIssuer) != 0u)
|
||||
if (speElement.hasIssuer())
|
||||
s.addBitString(speElement.getIssuerID());
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
s.add8(STPathElement::TypeNone);
|
||||
s.add8(toByte(STPathElementType::None));
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -38,7 +38,7 @@ ApplyContext::ApplyContext(
|
||||
, parentBatchId_(parentBatchId)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
parentBatchId.has_value() == ((flags_ & TapBatch) == TapBatch),
|
||||
parentBatchId.has_value() == ((flags_ & ApplyFlags::Batch) == ApplyFlags::Batch),
|
||||
"Parent Batch ID should be set if batch apply flag is set");
|
||||
view_.emplace(&base_, flags_);
|
||||
}
|
||||
@@ -53,13 +53,14 @@ std::optional<TxMeta>
|
||||
ApplyContext::apply(TER ter)
|
||||
{
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access) view_ emplaced in constructor
|
||||
return view_->apply(base_, tx, ter, parentBatchId_, (flags_ & TapDryRun) != 0u, journal);
|
||||
return view_->apply(
|
||||
base_, tx, ter, parentBatchId_, (flags_ & ApplyFlags::DryRun) != ApplyFlags::None, journal);
|
||||
}
|
||||
|
||||
void
|
||||
ApplyContext::addOrderBook(Book const& book)
|
||||
{
|
||||
if ((flags_ & TapDryRun) == TapNone)
|
||||
if ((flags_ & ApplyFlags::DryRun) == ApplyFlags::None)
|
||||
registry.get().getOrderBookDB().addOrderBook(book);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ preflightCheckSigningKey(STObject const& sigObject, beast::Journal j)
|
||||
std::optional<NotTEC>
|
||||
preflightCheckSimulateKeys(ApplyFlags flags, STObject const& sigObject, beast::Journal j)
|
||||
{
|
||||
if ((flags & TapDryRun) != 0u) // simulation
|
||||
if ((flags & ApplyFlags::DryRun) != ApplyFlags::None) // simulation
|
||||
{
|
||||
std::optional<Slice> const signature = sigObject[~sfTxnSignature];
|
||||
if (signature && !signature->empty())
|
||||
@@ -510,7 +510,8 @@ Transactor::minimumFee(
|
||||
Fees const& fees,
|
||||
ApplyFlags flags)
|
||||
{
|
||||
return scaleFeeLoad(baseFee, registry.getFeeTrack(), fees, (flags & TapUnlimited) != 0u);
|
||||
return scaleFeeLoad(
|
||||
baseFee, registry.getFeeTrack(), fees, (flags & ApplyFlags::Unlimited) != ApplyFlags::None);
|
||||
}
|
||||
|
||||
TER
|
||||
@@ -521,7 +522,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee)
|
||||
|
||||
auto const feePaid = ctx.tx[sfFee].xrp();
|
||||
|
||||
if ((ctx.flags & TapBatch) != 0u)
|
||||
if ((ctx.flags & ApplyFlags::Batch) != ApplyFlags::None)
|
||||
{
|
||||
if (feePaid == beast::kZero)
|
||||
return tesSUCCESS;
|
||||
@@ -984,7 +985,8 @@ Transactor::checkSign(
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
if (((flags & TapDryRun) != 0u) && pkSigner.empty() && !sigObject.isFieldPresent(sfSigners))
|
||||
if (((flags & ApplyFlags::DryRun) != ApplyFlags::None) && pkSigner.empty() &&
|
||||
!sigObject.isFieldPresent(sfSigners))
|
||||
{
|
||||
// simulate: skip signature validation when neither SigningPubKey nor
|
||||
// Signers are provided
|
||||
@@ -1155,7 +1157,7 @@ Transactor::checkMultiSign(
|
||||
}
|
||||
|
||||
XRPL_ASSERT(
|
||||
(flags & TapDryRun) || !spk.empty(),
|
||||
(flags & ApplyFlags::DryRun) != ApplyFlags::None || !spk.empty(),
|
||||
"xrpl::Transactor::checkMultiSign : non-empty signer or "
|
||||
"simulation");
|
||||
AccountID const signingAcctIDFromPubKey =
|
||||
@@ -1643,7 +1645,7 @@ Transactor::operator()()
|
||||
if (ctx_.size() > kOversizeMetaDataCap)
|
||||
result = tecOVERSIZE;
|
||||
|
||||
if (isTecClaim(result) && ((view().flags() & TapFailHard) != 0u))
|
||||
if (isTecClaim(result) && ((view().flags() & ApplyFlags::FailHard) != ApplyFlags::None))
|
||||
{
|
||||
// If the TapFailHard flag is set, a tec result
|
||||
// must not do anything
|
||||
@@ -1723,7 +1725,7 @@ Transactor::operator()()
|
||||
// Once we call apply, we will no longer be able to look at view()
|
||||
metadata = ctx_.apply(result);
|
||||
|
||||
if ((ctx_.flags() & TapDryRun) != 0u)
|
||||
if ((ctx_.flags() & ApplyFlags::DryRun) != ApplyFlags::None)
|
||||
return logger(result, false, std::move(metadata));
|
||||
|
||||
return logger(result, canApply, std::move(metadata));
|
||||
|
||||
@@ -215,7 +215,7 @@ applyBatchTransactions(
|
||||
auto const applyOneTransaction = [®istry, &j, &parentBatchId, &batchView](STTx const& tx) {
|
||||
OpenView perTxBatchView(kBatchView, batchView);
|
||||
|
||||
auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, TapBatch, j);
|
||||
auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, ApplyFlags::Batch, j);
|
||||
XRPL_ASSERT(
|
||||
ret.applied == (isTesSuccess(ret.ter) || isTecClaim(ret.ter)),
|
||||
"Inner transaction should not be applied");
|
||||
@@ -274,7 +274,7 @@ applyTransaction(
|
||||
{
|
||||
// Returns false if the transaction has need not be retried.
|
||||
if (retryAssured)
|
||||
flags = flags | TapRetry;
|
||||
flags = flags | ApplyFlags::Retry;
|
||||
|
||||
JLOG(j.debug()) << "TXN " << txn.getTransactionID() << (retryAssured ? "/retry" : "/final");
|
||||
|
||||
|
||||
@@ -348,7 +348,8 @@ preflight(
|
||||
// builds; re-check the same invariant here so a release build can't
|
||||
// silently skip a proposed transaction's signature-presence checks
|
||||
// outside of a dry run.
|
||||
if ((flags & TapProposal) != TapNone && (flags & TapDryRun) == TapNone)
|
||||
if ((flags & ApplyFlags::Proposal) != ApplyFlags::None &&
|
||||
(flags & ApplyFlags::DryRun) == ApplyFlags::None)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "apply (preflight): TapProposal set without TapDryRun.";
|
||||
@@ -379,7 +380,8 @@ preflight(
|
||||
PreflightContext const pfCtx(registry, tx, parentBatchId, rules, flags, j);
|
||||
|
||||
// See the comment in the other preflight() overload above.
|
||||
if ((flags & TapProposal) != TapNone && (flags & TapDryRun) == TapNone)
|
||||
if ((flags & ApplyFlags::Proposal) != ApplyFlags::None &&
|
||||
(flags & ApplyFlags::DryRun) == ApplyFlags::None)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.fatal()) << "apply (preflight): TapProposal set without TapDryRun.";
|
||||
|
||||
@@ -1101,7 +1101,7 @@ std::optional<std::variant<Quality, AMMOffer<TIn, TOut>>>
|
||||
BookStep<TIn, TOut, TDerived>::tip(ReadView const& view) const
|
||||
{
|
||||
// This can be simplified (and sped up) if directories are never empty.
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
BookTip bt(sb, book_);
|
||||
auto const lobQuality = bt.step(j_) ? std::optional<Quality>(bt.quality()) : std::nullopt;
|
||||
// Multi-path offer generates an offer with the quality
|
||||
|
||||
@@ -57,10 +57,8 @@ checkNear(IOUAmount const& expected, IOUAmount const& actual)
|
||||
static bool
|
||||
isXRPAccount(STPathElement const& pe)
|
||||
{
|
||||
if (pe.getNodeType() != STPathElement::TypeAccount)
|
||||
return false;
|
||||
return isXRP(pe.getAccountID());
|
||||
};
|
||||
return pe.getNodeType() == STPathElementType::Account && isXRP(pe.getAccountID());
|
||||
}
|
||||
|
||||
static std::pair<TER, std::unique_ptr<Step>>
|
||||
toStep(
|
||||
@@ -71,11 +69,8 @@ toStep(
|
||||
{
|
||||
auto& j = ctx.j;
|
||||
|
||||
if (ctx.isFirst && e1->isAccount() &&
|
||||
((e1->getNodeType() & STPathElement::TypeCurrency) != 0u) && e1->getPathAsset().isXRP())
|
||||
{
|
||||
if (ctx.isFirst && e1->isAccount() && e1->hasCurrency() && e1->getPathAsset().isXRP())
|
||||
return makeXrpEndpointStep(ctx, e1->getAccountID());
|
||||
}
|
||||
|
||||
if (ctx.isLast && isXRPAccount(*e1) && e2->isAccount())
|
||||
return makeXrpEndpointStep(ctx, e2->getAccountID());
|
||||
@@ -117,15 +112,9 @@ toStep(
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
XRPL_ASSERT(
|
||||
(e2->getNodeType() & STPathElement::TypeAsset) ||
|
||||
(e2->getNodeType() & STPathElement::TypeIssuer),
|
||||
"xrpl::toStep : currency or issuer");
|
||||
PathAsset const outAsset =
|
||||
((e2->getNodeType() & STPathElement::TypeAsset) != 0u) ? e2->getPathAsset() : curAsset;
|
||||
auto const outIssuer = ((e2->getNodeType() & STPathElement::TypeIssuer) != 0u)
|
||||
? e2->getIssuerID()
|
||||
: curAsset.getIssuer();
|
||||
XRPL_ASSERT(e2->hasAsset() || e2->hasIssuer(), "xrpl::toStep : currency or issuer");
|
||||
PathAsset const outAsset = e2->hasAsset() ? e2->getPathAsset() : curAsset;
|
||||
auto const outIssuer = e2->hasIssuer() ? e2->getIssuerID() : curAsset.getIssuer();
|
||||
|
||||
if (isXRP(curAsset) && outAsset.isXRP())
|
||||
{
|
||||
@@ -197,16 +186,15 @@ toStrand(
|
||||
for (std::size_t i = 0; i < path.size(); ++i)
|
||||
{
|
||||
auto const& pe = path[i];
|
||||
auto const t = pe.getNodeType();
|
||||
|
||||
if (((t & ~STPathElement::TypeAll) != 0u) || (t == 0u))
|
||||
if ((pe.getNodeType() & ~STPathElementType::All) != STPathElementType::None || pe.isNone())
|
||||
return {temBAD_PATH, Strand{}};
|
||||
|
||||
bool const hasAccount = (t & STPathElement::TypeAccount) != 0u;
|
||||
bool const hasIssuer = (t & STPathElement::TypeIssuer) != 0u;
|
||||
bool const hasCurrency = (t & STPathElement::TypeCurrency) != 0u;
|
||||
bool const hasMPT = (t & STPathElement::TypeMpt) != 0u;
|
||||
bool const hasAsset = (t & STPathElement::TypeAsset) != 0u;
|
||||
bool const hasAccount = pe.isType(STPathElementType::Account);
|
||||
bool const hasIssuer = pe.hasIssuer();
|
||||
bool const hasCurrency = pe.hasCurrency();
|
||||
bool const hasMPT = pe.hasMPT();
|
||||
bool const hasAsset = pe.hasAsset();
|
||||
|
||||
if (hasAccount && (hasIssuer || hasCurrency))
|
||||
return {temBAD_PATH, Strand{}};
|
||||
@@ -250,9 +238,7 @@ toStrand(
|
||||
}();
|
||||
|
||||
// Currency or MPT
|
||||
auto const hasAsset = [](STPathElement const pe) {
|
||||
return pe.getNodeType() & STPathElement::TypeAsset;
|
||||
};
|
||||
auto const hasAsset = [](STPathElement const& pe) { return pe.hasAsset(); };
|
||||
|
||||
std::vector<STPathElement> normPath;
|
||||
// reserve enough for the path, the implied source, destination,
|
||||
@@ -263,10 +249,10 @@ toStrand(
|
||||
// transaction, as defined by the transaction's Account field. The Asset
|
||||
// is either SendMax or Deliver.
|
||||
auto const t = [&] {
|
||||
auto const t = STPathElement::TypeAccount | STPathElement::TypeIssuer;
|
||||
auto const t = STPathElementType::Account | STPathElementType::Issuer;
|
||||
return curAsset.visit(
|
||||
[&](MPTIssue const&) { return t | STPathElement::TypeMpt; },
|
||||
[&](Issue const&) { return t | STPathElement::TypeCurrency; });
|
||||
[&](MPTIssue const&) { return t | STPathElementType::Mpt; },
|
||||
[&](Issue const&) { return t | STPathElementType::Currency; });
|
||||
}();
|
||||
// If MPT then the issuer is the actual issuer, it is never the source
|
||||
// account.
|
||||
@@ -435,7 +421,7 @@ toStrand(
|
||||
return {msr.first, Strand{}};
|
||||
result.push_back(std::move(msr.second));
|
||||
impliedPE.emplace(
|
||||
STPathElement::TypeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount());
|
||||
STPathElementType::Account, curAsset.getIssuer(), xrpCurrency(), xrpAccount());
|
||||
cur = &*impliedPE;
|
||||
}
|
||||
}
|
||||
@@ -450,7 +436,7 @@ toStrand(
|
||||
return {msr.first, Strand{}};
|
||||
result.push_back(std::move(msr.second));
|
||||
impliedPE.emplace(
|
||||
STPathElement::TypeAccount, curAsset.getIssuer(), xrpCurrency(), xrpAccount());
|
||||
STPathElementType::Account, curAsset.getIssuer(), xrpCurrency(), xrpAccount());
|
||||
cur = &*impliedPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,8 @@ AccountSet::preclaim(PreclaimContext const& ctx)
|
||||
if (!dirIsEmpty(ctx.view, keylet::ownerDir(id)))
|
||||
{
|
||||
JLOG(ctx.j.trace()) << "Retry: Owner directory not empty.";
|
||||
return ((ctx.flags & TapRetry) != 0u) ? TER{terOWNERS} : TER{tecOWNERS};
|
||||
return ((ctx.flags & ApplyFlags::Retry) != ApplyFlags::None) ? TER{terOWNERS}
|
||||
: TER{tecOWNERS};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,8 @@ OfferCreate::checkAcceptAsset(
|
||||
JLOG(j.debug()) << "delay: can't receive IOUs from non-existent issuer: "
|
||||
<< to_string(asset.getIssuer());
|
||||
|
||||
return ((flags & TapRetry) != 0u) ? TER{terNO_ACCOUNT} : TER{tecNO_ISSUER};
|
||||
return ((flags & ApplyFlags::Retry) != ApplyFlags::None) ? TER{terNO_ACCOUNT}
|
||||
: TER{tecNO_ISSUER};
|
||||
}
|
||||
|
||||
// An account cannot create a trustline to itself, so no line can exist
|
||||
@@ -320,7 +321,8 @@ OfferCreate::checkAcceptAsset(
|
||||
{
|
||||
JLOG(j.debug()) << "delay: can't receive IOUs from issuer with "
|
||||
"DisallowIncomingTrustline set";
|
||||
return ((flags & TapRetry) != 0u) ? TER{terNO_LINE} : TER{tecNO_LINE};
|
||||
return ((flags & ApplyFlags::Retry) != ApplyFlags::None) ? TER{terNO_LINE}
|
||||
: TER{tecNO_LINE};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +330,8 @@ OfferCreate::checkAcceptAsset(
|
||||
{
|
||||
if (!trustLine)
|
||||
{
|
||||
return ((flags & TapRetry) != 0u) ? TER{terNO_LINE} : TER{tecNO_LINE};
|
||||
return ((flags & ApplyFlags::Retry) != ApplyFlags::None) ? TER{terNO_LINE}
|
||||
: TER{tecNO_LINE};
|
||||
}
|
||||
|
||||
// Entries have a canonical representation, determined by a
|
||||
@@ -344,7 +347,8 @@ OfferCreate::checkAcceptAsset(
|
||||
JLOG(j.debug()) << "delay: can't receive IOUs from "
|
||||
"issuer without auth.";
|
||||
|
||||
return ((flags & TapRetry) != 0u) ? TER{terNO_AUTH} : TER{tecNO_AUTH};
|
||||
return ((flags & ApplyFlags::Retry) != ApplyFlags::None) ? TER{terNO_AUTH}
|
||||
: TER{tecNO_AUTH};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,8 @@ LoanSet::preflight(PreflightContext const& ctx)
|
||||
// A proposed LoanSet is stored unsigned; its CounterpartySignature is
|
||||
// collected on-ledger afterward, so its absence here is expected, not an
|
||||
// error (On-Chain Cosigner spec §5.3.1.2).
|
||||
if (!tx.isFlag(tfInnerBatchTxn) && !counterPartySig && (ctx.flags & TapProposal) == 0)
|
||||
if (!tx.isFlag(tfInnerBatchTxn) && !counterPartySig &&
|
||||
(ctx.flags & ApplyFlags::Proposal) == ApplyFlags::None)
|
||||
{
|
||||
JLOG(ctx.j.warn()) << "LoanSet transaction must have a CounterpartySignature.";
|
||||
return temBAD_SIGNER;
|
||||
|
||||
@@ -54,8 +54,8 @@ TransactionProposalCreate::preflight(PreflightContext const& ctx)
|
||||
try
|
||||
{
|
||||
STTx const stx{STObject{proposedTx}};
|
||||
auto const inner =
|
||||
xrpl::preflight(ctx.registry, ctx.rules, stx, TapDryRun | TapProposal, ctx.j);
|
||||
auto const inner = xrpl::preflight(
|
||||
ctx.registry, ctx.rules, stx, ApplyFlags::DryRun | ApplyFlags::Proposal, ctx.j);
|
||||
if (!isTesSuccess(inner.ter))
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "TransactionProposalCreate: proposed txn "
|
||||
|
||||
@@ -205,7 +205,7 @@ SponsorshipTransfer::preflight(PreflightContext const& ctx)
|
||||
// is collected on-ledger afterward, so its absence here is expected, not
|
||||
// an error (On-Chain Cosigner spec §5.3.1.2).
|
||||
if (isAccountReserveSponsorship && !ctx.tx.isFieldPresent(sfSponsorSignature) &&
|
||||
(ctx.flags & TapProposal) == 0)
|
||||
(ctx.flags & ApplyFlags::Proposal) == ApplyFlags::None)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "preflight: account sponsorship requires sfSponsorSignature";
|
||||
return temMALFORMED;
|
||||
|
||||
@@ -371,7 +371,8 @@ Batch::preflight(PreflightContext const& ctx)
|
||||
// TapBatch — PreflightContext with a parentBatchId requires it.
|
||||
// LoanSet already short-circuits on tfInnerBatchTxn; it is also in
|
||||
// kDisabledTxTypes, so it never reaches this call.
|
||||
ApplyFlags const innerFlags = TapBatch | (ctx.flags & (TapProposal | TapDryRun));
|
||||
ApplyFlags const innerFlags =
|
||||
ApplyFlags::Batch | (ctx.flags & (ApplyFlags::Proposal | ApplyFlags::DryRun));
|
||||
if (auto const preflightResult =
|
||||
xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, innerFlags, ctx.j);
|
||||
!isTesSuccess(preflightResult.ter))
|
||||
@@ -443,7 +444,7 @@ Batch::preflightSigValidated(PreflightContext const& ctx)
|
||||
// A proposed Batch is stored unsigned; its BatchSigners are collected
|
||||
// on-ledger afterward, so the signer-presence match belongs to submission
|
||||
// time, not proposal creation (On-Chain Cosigner spec §5.3.1.2).
|
||||
if ((ctx.flags & TapProposal) != 0)
|
||||
if ((ctx.flags & ApplyFlags::Proposal) != ApplyFlags::None)
|
||||
return tesSUCCESS;
|
||||
|
||||
auto const parentBatchId = ctx.tx.getTransactionID();
|
||||
|
||||
@@ -1941,11 +1941,11 @@ private:
|
||||
auto const flowResult = [&] {
|
||||
STAmount const deliver(eth(51'000'000));
|
||||
STAmount smax(btc(61'000'000));
|
||||
PaymentSandbox sb(env.current().get(), TapNone);
|
||||
PaymentSandbox sb(env.current().get(), ApplyFlags::None);
|
||||
STPathSet paths;
|
||||
auto const ipe = [](MPTTester const& iss) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeMpt | STPathElement::TypeIssuer,
|
||||
STPathElementType::Mpt | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
PathAsset{iss.issuanceID()},
|
||||
iss.issuer());
|
||||
@@ -1979,7 +1979,7 @@ private:
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
if (flowResult.removableOffers.empty())
|
||||
return false;
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
for (auto const& o : flowResult.removableOffers)
|
||||
{
|
||||
if (auto const ok = sb.peek(keylet::offer(o)))
|
||||
|
||||
@@ -2015,11 +2015,11 @@ private:
|
||||
auto const flowResult = [&] {
|
||||
STAmount const deliver(USD(51));
|
||||
STAmount smax(BTC(61));
|
||||
PaymentSandbox sb(env.current().get(), TapNone);
|
||||
PaymentSandbox sb(env.current().get(), ApplyFlags::None);
|
||||
STPathSet paths;
|
||||
auto const ipe = [](Issue const& iss) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeCurrency | STPathElement::TypeIssuer,
|
||||
STPathElementType::Currency | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
iss.currency,
|
||||
iss.account);
|
||||
@@ -2053,7 +2053,7 @@ private:
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
if (flowResult.removableOffers.empty())
|
||||
return false;
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
for (auto const& o : flowResult.removableOffers)
|
||||
{
|
||||
if (auto const ok = sb.peek(keylet::offer(o)))
|
||||
|
||||
@@ -4207,7 +4207,7 @@ private:
|
||||
auto const jtx = env.jt(tx, Seq(1), Fee(10));
|
||||
env.app().config().features.erase(featureMPTokensV2);
|
||||
PreflightContext const ctx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = AMMBid::checkExtraFeatures(ctx);
|
||||
BEAST_EXPECT(pf == false);
|
||||
env.app().config().features.insert(featureMPTokensV2);
|
||||
@@ -4219,7 +4219,7 @@ private:
|
||||
jtx.jv["Asset2"].removeMember("mpt_issuance_id");
|
||||
jtx.stx = env.ust(jtx);
|
||||
PreflightContext const ctx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = AMMBid::preflight(ctx);
|
||||
BEAST_EXPECT(pf == temBAD_AMM_TOKENS);
|
||||
}
|
||||
|
||||
@@ -3194,7 +3194,7 @@ private:
|
||||
auto const jtx = env.jt(tx, Seq(1), Fee(baseFee));
|
||||
env.app().config().features.erase(featureAMM);
|
||||
PreflightContext const pfCtx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = Transactor::invokePreflight<AMMBid>(pfCtx);
|
||||
BEAST_EXPECT(pf == temDISABLED);
|
||||
env.app().config().features.insert(featureAMM);
|
||||
@@ -3205,7 +3205,7 @@ private:
|
||||
jtx.jv["TxnSignature"] = "deadbeef";
|
||||
jtx.stx = env.ust(jtx);
|
||||
PreflightContext const pfCtx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = Transactor::invokePreflight<AMMBid>(pfCtx);
|
||||
BEAST_EXPECT(!isTesSuccess(pf));
|
||||
}
|
||||
@@ -3216,7 +3216,7 @@ private:
|
||||
jtx.jv["Asset2"].removeMember("issuer");
|
||||
jtx.stx = env.ust(jtx);
|
||||
PreflightContext const pfCtx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = Transactor::invokePreflight<AMMBid>(pfCtx);
|
||||
BEAST_EXPECT(pf == temBAD_AMM_TOKENS);
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ public:
|
||||
stx->at(sfSigningPubKey) = makeSlice(std::string("badkey"));
|
||||
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(result.ter == temBAD_SIGNATURE);
|
||||
BEAST_EXPECT(!result.applied);
|
||||
return result.applied;
|
||||
|
||||
@@ -432,7 +432,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const jtx = env.jt(pay(alice, bob, XRP(1)), Txflags(tfInnerBatchTxn));
|
||||
PreflightContext const pfCtx(
|
||||
env.app(), *jtx.stx, env.current()->rules(), TapNone, env.journal);
|
||||
env.app(), *jtx.stx, env.current()->rules(), ApplyFlags::None, env.journal);
|
||||
auto const pf = Transactor::invokePreflight<Payment>(pfCtx);
|
||||
BEAST_EXPECT(pf == temINVALID_INNER_BATCH);
|
||||
}
|
||||
@@ -447,7 +447,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
disabledEnv.app(),
|
||||
*jtx.stx,
|
||||
disabledEnv.current()->rules(),
|
||||
TapNone,
|
||||
ApplyFlags::None,
|
||||
disabledEnv.journal);
|
||||
auto const pf = Transactor::invokePreflight<Payment>(pfCtx);
|
||||
BEAST_EXPECT(pf == temINVALID_FLAG);
|
||||
@@ -458,7 +458,12 @@ class Batch_test : public beast::unit_test::Suite
|
||||
{
|
||||
auto const jtx = env.jt(pay(alice, bob, XRP(1)));
|
||||
PreflightContext const pfCtx(
|
||||
env.app(), *jtx.stx, UInt256{1}, env.current()->rules(), TapBatch, env.journal);
|
||||
env.app(),
|
||||
*jtx.stx,
|
||||
UInt256{1},
|
||||
env.current()->rules(),
|
||||
ApplyFlags::Batch,
|
||||
env.journal);
|
||||
auto const pf = Transactor::invokePreflight<Payment>(pfCtx);
|
||||
BEAST_EXPECT(pf == temINVALID_INNER_BATCH);
|
||||
}
|
||||
@@ -1596,7 +1601,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
batch::Sig(std::vector<Reg>(kMaxBatchSigners + 1, bob)));
|
||||
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *jt.stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(!result.applied && result.ter == temARRAY_TOO_LARGE);
|
||||
return result.applied;
|
||||
});
|
||||
@@ -4716,7 +4721,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(!passesLocalChecks(stx, reason));
|
||||
BEAST_EXPECT(reason == "Cannot submit pseudo transactions.");
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(!result.applied && result.ter == temINVALID_FLAG);
|
||||
return result.applied;
|
||||
});
|
||||
@@ -6016,7 +6021,7 @@ class Batch_test : public beast::unit_test::Suite
|
||||
obj.setFieldU32(sfFlags, tfInnerBatchTxn);
|
||||
});
|
||||
|
||||
auto const result = xrpl::apply(env.app(), view, stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, stx, ApplyFlags::None, j);
|
||||
// Must NOT be applied — signature was never checked
|
||||
BEAST_EXPECT(!result.applied);
|
||||
return false;
|
||||
|
||||
@@ -1748,7 +1748,8 @@ class ConfidentialTransfer_test : public ConfidentialTransferTestBase
|
||||
(*sle)[sfConfidentialBalanceVersion] = wrappedFrom;
|
||||
view.rawReplace(sle);
|
||||
|
||||
auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, env.journal);
|
||||
auto const result =
|
||||
xrpl::apply(env.app(), view, *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(result.ter == tesSUCCESS);
|
||||
return result.applied;
|
||||
}));
|
||||
|
||||
@@ -909,7 +909,7 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
{
|
||||
testcase("deleteSLE fail, bad SLE.");
|
||||
auto const view =
|
||||
std::make_shared<ApplyViewImpl>(env.current().get(), ApplyFlags::TapNone);
|
||||
std::make_shared<ApplyViewImpl>(env.current().get(), ApplyFlags::None);
|
||||
auto const ter = xrpl::credentials::deleteSLE(*view, {}, env.journal);
|
||||
BEAST_EXPECT(ter == tecNO_ENTRY);
|
||||
}
|
||||
@@ -1132,7 +1132,7 @@ struct Credentials_test : public beast::unit_test::Suite
|
||||
// Create an ApplyViewImpl on top of the current closed ledger
|
||||
// and corrupt it by erasing the issuer's account SLE
|
||||
auto const open = env.current();
|
||||
ApplyViewImpl av(&*open, TapNone);
|
||||
ApplyViewImpl av(&*open, ApplyFlags::None);
|
||||
|
||||
// Erase the issuer's account to simulate ledger corruption
|
||||
auto const sleIssuer = av.peek(keylet::account(issuer.id()));
|
||||
|
||||
@@ -2773,7 +2773,7 @@ struct EscrowToken_test : public beast::unit_test::Suite
|
||||
|
||||
auto const seq1 = env.seq(alice);
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
auto const sleNew =
|
||||
std::make_shared<SLE>(keylet::escrow(alice, SeqProxy::rawSequence(seq1)));
|
||||
MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}};
|
||||
@@ -3003,7 +3003,7 @@ struct EscrowToken_test : public beast::unit_test::Suite
|
||||
|
||||
auto const seq1 = env.seq(alice);
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
auto const sleNew =
|
||||
std::make_shared<SLE>(keylet::escrow(alice, SeqProxy::rawSequence(seq1)));
|
||||
MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}};
|
||||
|
||||
@@ -1126,8 +1126,8 @@ struct Escrow_test : public beast::unit_test::Suite
|
||||
env(jt, Ter(fixEnabled ? TER{temMALFORMED} : TER{tecCRYPTOCONDITION_ERROR}));
|
||||
// Run preflight on the same transaction again, now with the
|
||||
// HashRouter flag cached. The result must not change.
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jt.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(pf.ter == (fixEnabled ? TER{temMALFORMED} : TER{tesSUCCESS}));
|
||||
env.close();
|
||||
|
||||
@@ -1344,8 +1344,8 @@ struct Escrow_test : public beast::unit_test::Suite
|
||||
escrow::kFinishTime(env.now() + 1s),
|
||||
Seq(1),
|
||||
Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
@@ -1354,8 +1354,8 @@ struct Escrow_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
auto const jtx = env.jt(escrow::cancel("bob", "alice", 3), Seq(1), Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
@@ -1364,8 +1364,8 @@ struct Escrow_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
auto const jtx = env.jt(escrow::finish("bob", "alice", 3), Seq(1), Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
|
||||
@@ -160,7 +160,7 @@ createInvalidFeeTx(
|
||||
TER
|
||||
applyFeeAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx)
|
||||
{
|
||||
auto const res = apply(env.app(), view, tx, ApplyFlags::TapNone, env.journal);
|
||||
auto const res = apply(env.app(), view, tx, ApplyFlags::None, env.journal);
|
||||
return res.ter;
|
||||
}
|
||||
|
||||
@@ -1473,8 +1473,7 @@ class FeeVote_test : public beast::unit_test::Suite
|
||||
OpenView accum(ledger.get());
|
||||
BEAST_EXPECT(!accum.open());
|
||||
|
||||
auto const result =
|
||||
apply(env.app(), accum, amendTx, ApplyFlags::TapNone, env.journal);
|
||||
auto const result = apply(env.app(), accum, amendTx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECTS(result.applied && isTesSuccess(result.ter), transToken(result.ter));
|
||||
accum.apply(*ledger);
|
||||
}
|
||||
|
||||
@@ -338,11 +338,11 @@ struct FlowMPT_test : public beast::unit_test::Suite
|
||||
auto const flowResult = [&] {
|
||||
STAmount const deliver(usd(5'100));
|
||||
STAmount smax(btc(61));
|
||||
PaymentSandbox sb(env.current().get(), TapNone);
|
||||
PaymentSandbox sb(env.current().get(), ApplyFlags::None);
|
||||
STPathSet paths;
|
||||
auto const ipe = [](Asset const& asset) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeAsset | STPathElement::TypeIssuer,
|
||||
STPathElementType::Asset | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
asset,
|
||||
asset.getIssuer());
|
||||
@@ -376,7 +376,7 @@ struct FlowMPT_test : public beast::unit_test::Suite
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
if (flowResult.removableOffers.empty())
|
||||
return false;
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
for (auto const& o : flowResult.removableOffers)
|
||||
{
|
||||
if (auto const ok = sb.peek(keylet::offer(o)))
|
||||
|
||||
@@ -476,11 +476,11 @@ struct Flow_test : public beast::unit_test::Suite
|
||||
auto const flowResult = [&] {
|
||||
STAmount const deliver(usd(51));
|
||||
STAmount smax(btc(61));
|
||||
PaymentSandbox sb(env.current().get(), TapNone);
|
||||
PaymentSandbox sb(env.current().get(), ApplyFlags::None);
|
||||
STPathSet paths;
|
||||
auto const ipe = [](Issue const& iss) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeCurrency | STPathElement::TypeIssuer,
|
||||
STPathElementType::Currency | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
iss.currency,
|
||||
iss.account);
|
||||
@@ -514,7 +514,7 @@ struct Flow_test : public beast::unit_test::Suite
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
if (flowResult.removableOffers.empty())
|
||||
return false;
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
for (auto const& o : flowResult.removableOffers)
|
||||
{
|
||||
if (auto const ok = sb.peek(keylet::offer(o)))
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
if (stx)
|
||||
{
|
||||
OpenView accum(&*res);
|
||||
applyTransaction(env.app(), accum, *stx, false, TapNone, env.journal);
|
||||
applyTransaction(env.app(), accum, *stx, false, ApplyFlags::None, env.journal);
|
||||
accum.apply(*res);
|
||||
}
|
||||
res->updateSkipList();
|
||||
|
||||
@@ -90,7 +90,7 @@ struct LedgerReplay_test : public beast::unit_test::Suite
|
||||
auto const lastClosedParent = ledgerMaster.getLedgerByHash(lastClosed->header().parentHash);
|
||||
|
||||
auto const replayed = buildLedger(
|
||||
LedgerReplay(lastClosedParent, lastClosed), TapNone, env.app(), env.journal);
|
||||
LedgerReplay(lastClosedParent, lastClosed), ApplyFlags::None, env.app(), env.journal);
|
||||
|
||||
BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ struct LedgerReplay_test : public beast::unit_test::Suite
|
||||
auto const lastClosedParent = ledgerMaster.getLedgerByHash(lastClosed->header().parentHash);
|
||||
|
||||
auto const replayed = buildLedger(
|
||||
LedgerReplay(lastClosedParent, lastClosed), TapNone, env.app(), env.journal);
|
||||
LedgerReplay(lastClosedParent, lastClosed), ApplyFlags::None, env.app(), env.journal);
|
||||
|
||||
BEAST_EXPECT(replayed->header().hash == lastClosed->header().hash);
|
||||
}
|
||||
|
||||
@@ -4118,7 +4118,7 @@ class MPToken_test : public beast::unit_test::Suite
|
||||
TER expectedTer,
|
||||
std::optional<std::uint64_t> expectedOutstanding,
|
||||
std::string const& label) {
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
auto const ter =
|
||||
accountSendMulti(av, issuer.id(), asset, receivers, env.app().getJournal("View"));
|
||||
BEAST_EXPECTS(ter == expectedTer, label);
|
||||
|
||||
@@ -777,7 +777,13 @@ class NFTokenBurn_test : public beast::unit_test::Suite
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
|
||||
// Verify that the last page is present and contains one NFT.
|
||||
auto const lastNFTokenPage = ac.view().peek(keylet::nftokenPageMax(alice));
|
||||
@@ -809,7 +815,13 @@ class NFTokenBurn_test : public beast::unit_test::Suite
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
|
||||
// Verify that the middle page is present.
|
||||
auto const lastNFTokenPage = ac.view().peek(keylet::nftokenPageMax(alice));
|
||||
|
||||
@@ -1964,9 +1964,9 @@ public:
|
||||
auto const createPathElements = [](auto const& account1, auto const& account2) {
|
||||
auto base = STPath{};
|
||||
base.pushBack(
|
||||
STPathElement{STPathElement::TypeAccount, account1, xrpCurrency(), account1});
|
||||
STPathElement{STPathElementType::Account, account1, xrpCurrency(), account1});
|
||||
auto const tail =
|
||||
STPathElement{STPathElement::TypeAccount, account2, xrpCurrency(), account2};
|
||||
STPathElement{STPathElementType::Account, account2, xrpCurrency(), account2};
|
||||
return std::make_pair(base, tail);
|
||||
};
|
||||
|
||||
@@ -2050,7 +2050,7 @@ public:
|
||||
|
||||
auto const makePath = [](AccountID const& account) {
|
||||
auto p = STPath{};
|
||||
p.pushBack(STPathElement{STPathElement::TypeAccount, account, xrpCurrency(), account});
|
||||
p.pushBack(STPathElement{STPathElementType::Account, account, xrpCurrency(), account});
|
||||
return p;
|
||||
};
|
||||
|
||||
@@ -2174,7 +2174,7 @@ public:
|
||||
},
|
||||
// An explicit type mask vs. one derived from the populated fields.
|
||||
{
|
||||
STPathElement{STPathElement::TypeAccount, kAccount, xrpCurrency(), kIssuer},
|
||||
STPathElement{STPathElementType::Account, kAccount, xrpCurrency(), kIssuer},
|
||||
STPathElement{kAccount, PathAsset{xrpCurrency()}, kIssuer, false},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -256,7 +256,7 @@ struct PayStrandMPT_test : public beast::unit_test::Suite
|
||||
usd,
|
||||
STPath({
|
||||
STPathElement{
|
||||
STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()},
|
||||
STPathElementType::Currency, xrpAccount(), xrpCurrency(), xrpAccount()},
|
||||
}),
|
||||
tesSUCCESS,
|
||||
makeEndpointStep(alice, gw, usd),
|
||||
@@ -583,7 +583,7 @@ struct PayStrandMPT_test : public beast::unit_test::Suite
|
||||
inputs.defaultPathsAllowed = true;
|
||||
try
|
||||
{
|
||||
PaymentSandbox sb{env.current().get(), TapNone};
|
||||
PaymentSandbox sb{env.current().get(), ApplyFlags::None};
|
||||
{
|
||||
auto const r = ::xrpl::path::RippleCalc::rippleCalculate(
|
||||
sb,
|
||||
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
else
|
||||
{
|
||||
col.emplace_back(
|
||||
STPathElement::Type::TypeBoundary,
|
||||
STPathElementType::Boundary,
|
||||
acc.value_or(AccountID{}),
|
||||
cur.value_or(Currency{}),
|
||||
iss.value_or(AccountID{}));
|
||||
@@ -684,7 +684,7 @@ struct PayStrand_test : public beast::unit_test::Suite
|
||||
usd,
|
||||
STPath({
|
||||
STPathElement{
|
||||
STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount()},
|
||||
STPathElementType::Currency, xrpAccount(), xrpCurrency(), xrpAccount()},
|
||||
}),
|
||||
tesSUCCESS,
|
||||
D{.src = alice, .dst = gw, .currency = usdC},
|
||||
@@ -770,7 +770,8 @@ struct PayStrand_test : public beast::unit_test::Suite
|
||||
env,
|
||||
usd,
|
||||
std::nullopt,
|
||||
STPath({STPathElement(0, xrpAccount(), xrpCurrency(), xrpAccount())}),
|
||||
STPath({STPathElement(
|
||||
STPathElementType::None, xrpAccount(), xrpCurrency(), xrpAccount())}),
|
||||
temBAD_PATH);
|
||||
|
||||
// The same account can't appear more than once on a path
|
||||
@@ -1078,7 +1079,7 @@ struct PayStrand_test : public beast::unit_test::Suite
|
||||
inputs.defaultPathsAllowed = true;
|
||||
try
|
||||
{
|
||||
PaymentSandbox sb{env.current().get(), TapNone};
|
||||
PaymentSandbox sb{env.current().get(), ApplyFlags::None};
|
||||
{
|
||||
auto const r = ::xrpl::path::RippleCalc::rippleCalculate(
|
||||
sb,
|
||||
|
||||
@@ -88,7 +88,7 @@ struct PseudoTx_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(!passesLocalChecks(stx, reason));
|
||||
BEAST_EXPECT(reason == "Cannot submit pseudo transactions.");
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(!result.applied && result.ter == temINVALID);
|
||||
return result.applied;
|
||||
});
|
||||
|
||||
@@ -103,7 +103,8 @@ struct Regression_test : public beast::unit_test::Suite
|
||||
auto const jt = env.jt(pay(env.master, "alice", aliceAmount));
|
||||
OpenView accum(&*next);
|
||||
|
||||
auto const result = xrpl::apply(env.app(), accum, *jt.stx, TapNone, env.journal);
|
||||
auto const result =
|
||||
xrpl::apply(env.app(), accum, *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(result.ter));
|
||||
BEAST_EXPECT(result.applied);
|
||||
|
||||
@@ -126,7 +127,8 @@ struct Regression_test : public beast::unit_test::Suite
|
||||
|
||||
OpenView accum(&*next);
|
||||
|
||||
auto const result = xrpl::apply(env.app(), accum, *jt.stx, TapNone, env.journal);
|
||||
auto const result =
|
||||
xrpl::apply(env.app(), accum, *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(result.ter == tecINSUFF_FEE);
|
||||
BEAST_EXPECT(result.applied);
|
||||
|
||||
|
||||
@@ -990,8 +990,8 @@ public:
|
||||
sponsor::SponseeAcc(alice),
|
||||
Seq(1),
|
||||
Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jt.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
@@ -1006,8 +1006,8 @@ public:
|
||||
sponsor::SponseeAcc(alice),
|
||||
Seq(1),
|
||||
Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jt.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
@@ -1021,8 +1021,8 @@ public:
|
||||
sponsor::SponseeAcc(alice),
|
||||
Seq(1),
|
||||
Fee(baseFee));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jt.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(baseFee));
|
||||
@@ -2318,7 +2318,8 @@ public:
|
||||
Seq(env.seq(alice)),
|
||||
sponsor::As(carol, spfSponsorFee));
|
||||
|
||||
auto const result = xrpl::apply(env.app(), overlay, *jt.stx, TapNone, env.journal);
|
||||
auto const result =
|
||||
xrpl::apply(env.app(), overlay, *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(result.ter == tecINSUFF_FEE);
|
||||
BEAST_EXPECT(result.applied);
|
||||
|
||||
@@ -2371,7 +2372,8 @@ public:
|
||||
Fee(fixFee),
|
||||
sponsor::As(sponsor, spfSponsorFee));
|
||||
|
||||
auto const pf = preflight(env.app(), overlay.rules(), *jt.stx, TapNone, env.journal);
|
||||
auto const pf =
|
||||
preflight(env.app(), overlay.rules(), *jt.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
auto const pc = preclaim(pf, env.app(), overlay);
|
||||
BEAST_EXPECT(isTesSuccess(pc.ter));
|
||||
|
||||
@@ -252,7 +252,7 @@ class TheoreticalQuality_test : public beast::unit_test::Suite
|
||||
std::shared_ptr<ReadView const> closed,
|
||||
std::optional<Quality> const& expectedQ = {})
|
||||
{
|
||||
PaymentSandbox const sb(closed.get(), TapNone);
|
||||
PaymentSandbox const sb(closed.get(), ApplyFlags::None);
|
||||
AMMContext ammContext(rcp.srcAccount, false);
|
||||
|
||||
auto const sendMaxIssue = [&rcp] -> std::optional<Asset> {
|
||||
|
||||
@@ -1603,7 +1603,7 @@ struct TransactionProposalReservedTicket_test : public beast::unit_test::Suite
|
||||
auto const stx = rebuilt(mutated);
|
||||
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(result.ter == temBAD_SIGNATURE);
|
||||
BEAST_EXPECT(!result.applied);
|
||||
return result.applied;
|
||||
@@ -1639,7 +1639,7 @@ struct TransactionProposalReservedTicket_test : public beast::unit_test::Suite
|
||||
auto const stx = rebuilt(mutated);
|
||||
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, TapNone, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *stx, ApplyFlags::None, j);
|
||||
BEAST_EXPECT(result.ter == temINVALID);
|
||||
BEAST_EXPECT(!result.applied);
|
||||
return result.applied;
|
||||
|
||||
@@ -989,7 +989,8 @@ public:
|
||||
Env::ParsedResult parsed;
|
||||
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const result = xrpl::apply(env.app(), view, *jt.stx, TapNone, env.journal);
|
||||
auto const result =
|
||||
xrpl::apply(env.app(), view, *jt.stx, ApplyFlags::None, env.journal);
|
||||
parsed.ter = result.ter;
|
||||
return result.applied;
|
||||
});
|
||||
@@ -2428,8 +2429,8 @@ public:
|
||||
env.memoize("carol");
|
||||
{
|
||||
auto const jtx = env.jt(offerCancel(alice, 3), Seq(5), Fee(10));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(10));
|
||||
@@ -2440,8 +2441,8 @@ public:
|
||||
auto const usd = alice["USD"];
|
||||
|
||||
auto const jtx = env.jt(trust("carol", usd(50000000)), Seq(1), Fee(10));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(10));
|
||||
@@ -2450,8 +2451,8 @@ public:
|
||||
|
||||
{
|
||||
auto const jtx = env.jt(ticket::create(alice, 1), Seq(1), Fee(10));
|
||||
auto const pf =
|
||||
preflight(env.app(), env.current()->rules(), *jtx.stx, TapNone, env.journal);
|
||||
auto const pf = preflight(
|
||||
env.app(), env.current()->rules(), *jtx.stx, ApplyFlags::None, env.journal);
|
||||
BEAST_EXPECT(isTesSuccess(pf.ter));
|
||||
BEAST_EXPECT(!pf.consequences.isBlocker());
|
||||
BEAST_EXPECT(pf.consequences.fee() == drops(10));
|
||||
@@ -4010,7 +4011,7 @@ public:
|
||||
// be callable via RPC.)
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const tx = env.jt(noop(alice), Seq(aliceSeq), Fee(openLedgerCost(env)));
|
||||
auto const result = xrpl::apply(env.app(), view, *tx.stx, TapUnlimited, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *tx.stx, ApplyFlags::Unlimited, j);
|
||||
BEAST_EXPECT(isTesSuccess(result.ter) && result.applied);
|
||||
return result.applied;
|
||||
});
|
||||
@@ -4078,7 +4079,7 @@ public:
|
||||
// be callable via RPC.)
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
auto const tx = env.jt(noop(alice), ticket::Use(tktSeq0 + 1), Fee(openLedgerCost(env)));
|
||||
auto const result = xrpl::apply(env.app(), view, *tx.stx, TapUnlimited, j);
|
||||
auto const result = xrpl::apply(env.app(), view, *tx.stx, ApplyFlags::Unlimited, j);
|
||||
BEAST_EXPECT(isTesSuccess(result.ter) && result.applied);
|
||||
return result.applied;
|
||||
});
|
||||
|
||||
@@ -122,7 +122,8 @@ InvariantsBase::doInvariantCheck(
|
||||
OpenView ov{*env.current()};
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
|
||||
// Invariants normally run in the Transaction's "apply" (operator()) context, and can always
|
||||
// access global Rules.
|
||||
|
||||
@@ -845,7 +845,13 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -900,7 +906,13 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1023,7 +1035,13 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1507,7 +1525,7 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sle = ac.view().peek(vaultKeylet);
|
||||
@@ -1574,7 +1592,7 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
// visitEntry only runs for entries the transaction touched, so
|
||||
@@ -1631,7 +1649,8 @@ class InvariantsMisc_test : public InvariantsBase
|
||||
STTx const tx{ttACCOUNT_SET, [](STObject&) {}};
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
FailingTxInvariantCheck failing;
|
||||
|
||||
@@ -681,7 +681,7 @@ class InvariantsPseudoAccount_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleBroker = ac.view().peek(brokerKeylet);
|
||||
@@ -733,7 +733,7 @@ class InvariantsPseudoAccount_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleBroker = ac.view().peek(brokerKeylet);
|
||||
@@ -781,7 +781,7 @@ class InvariantsPseudoAccount_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleBroker = ac.view().peek(brokerKeylet);
|
||||
|
||||
@@ -1131,7 +1131,13 @@ class InvariantsVault_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1183,7 +1189,7 @@ class InvariantsVault_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1360,7 +1366,13 @@ class InvariantsVault_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1415,7 +1427,13 @@ class InvariantsVault_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(),
|
||||
ov,
|
||||
tx,
|
||||
tesSUCCESS,
|
||||
env.current()->fees().base,
|
||||
ApplyFlags::None,
|
||||
jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
auto const sleLoan = ac.view().peek(loanKeylet);
|
||||
@@ -1519,7 +1537,7 @@ class InvariantsVault_test : public InvariantsBase
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
CurrentTransactionRulesGuard const rulesGuard(ov.rules());
|
||||
|
||||
{
|
||||
|
||||
@@ -1271,7 +1271,8 @@ class LoanBroker_test : public beast::unit_test::Suite
|
||||
OpenView ov{*env.current()};
|
||||
test::StreamSink sink{beast::Severity::Warning};
|
||||
beast::Journal const jlog{sink};
|
||||
ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, TapNone, jlog};
|
||||
ApplyContext ac{
|
||||
env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, ApplyFlags::None, jlog};
|
||||
|
||||
if (auto const sleBroker = ac.view().peek(keylet::loanBroker(brokerKeylet.key)))
|
||||
{
|
||||
@@ -1284,7 +1285,7 @@ class LoanBroker_test : public beast::unit_test::Suite
|
||||
|
||||
// Invoke preclaim against the mutated (ApplyView) view; triggers
|
||||
// nullptr deref
|
||||
PreclaimContext const pctx{env.app(), ac.view(), tesSUCCESS, tx, TapNone, jlog};
|
||||
PreclaimContext const pctx{env.app(), ac.view(), tesSUCCESS, tx, ApplyFlags::None, jlog};
|
||||
(void)LoanBrokerCoverDeposit::preclaim(pctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
auto const peek = [keylet, &env, this](std::function<bool(SLE&, SLE&)> fn) -> bool {
|
||||
return env.app().getOpenLedger().modify(
|
||||
[&](OpenView& view, beast::Journal j) -> bool {
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
auto const vault = sb.peek(keylet::vault(keylet.key));
|
||||
if (!BEAST_EXPECT(vault))
|
||||
return false;
|
||||
|
||||
@@ -304,7 +304,7 @@ private:
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
for (auto const field : encryptedBalanceFields)
|
||||
{
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
auto const token = sb.peek(tokenKeylet);
|
||||
if (!BEAST_EXPECT(token))
|
||||
return false;
|
||||
|
||||
@@ -1939,7 +1939,7 @@ negUnlSizeTest(
|
||||
bool
|
||||
applyAndTestResult(jtx::Env& env, OpenView& view, STTx const& tx, bool pass)
|
||||
{
|
||||
auto const res = apply(env.app(), view, tx, ApplyFlags::TapNone, env.journal);
|
||||
auto const res = apply(env.app(), view, tx, ApplyFlags::None, env.journal);
|
||||
if (pass)
|
||||
{
|
||||
return isTesSuccess(res.ter);
|
||||
|
||||
@@ -125,7 +125,7 @@ inline TestPath&
|
||||
TestPath::pushBack(Issue const& iss)
|
||||
{
|
||||
path.emplaceBack(
|
||||
STPathElement::TypeCurrency | STPathElement::TypeIssuer,
|
||||
STPathElementType::Currency | STPathElementType::Issuer,
|
||||
beast::kZero,
|
||||
iss.currency,
|
||||
iss.account);
|
||||
@@ -136,7 +136,7 @@ inline TestPath&
|
||||
TestPath::pushBack(MPTIssue const& iss)
|
||||
{
|
||||
path.emplaceBack(
|
||||
STPathElement::TypeMpt | STPathElement::TypeIssuer,
|
||||
STPathElementType::Mpt | STPathElementType::Issuer,
|
||||
beast::kZero,
|
||||
iss.getMptID(),
|
||||
iss.getIssuer());
|
||||
|
||||
@@ -570,10 +570,10 @@ cpe(PathAsset const& pa)
|
||||
{
|
||||
return pa.visit(
|
||||
[](Currency const& currency) {
|
||||
return STPathElement(STPathElement::TypeCurrency, xrpAccount(), currency, xrpAccount());
|
||||
return STPathElement(STPathElementType::Currency, xrpAccount(), currency, xrpAccount());
|
||||
},
|
||||
[](MPTID const& mpt) {
|
||||
return STPathElement(STPathElement::TypeMpt, xrpAccount(), mpt, xrpAccount());
|
||||
return STPathElement(STPathElementType::Mpt, xrpAccount(), mpt, xrpAccount());
|
||||
});
|
||||
};
|
||||
|
||||
@@ -590,14 +590,14 @@ ipe(Asset const& asset)
|
||||
return asset.visit(
|
||||
[](Issue const& issue) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeCurrency | STPathElement::TypeIssuer,
|
||||
STPathElementType::Currency | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
issue.currency,
|
||||
issue.account);
|
||||
},
|
||||
[](MPTIssue const& issue) {
|
||||
return STPathElement(
|
||||
STPathElement::TypeMpt | STPathElement::TypeIssuer,
|
||||
STPathElementType::Mpt | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
issue.getMptID(),
|
||||
issue.getIssuer());
|
||||
@@ -608,14 +608,14 @@ ipe(Asset const& asset)
|
||||
STPathElement
|
||||
iape(AccountID const& account)
|
||||
{
|
||||
return STPathElement(STPathElement::TypeIssuer, xrpAccount(), xrpCurrency(), account);
|
||||
return STPathElement(STPathElementType::Issuer, xrpAccount(), xrpCurrency(), account);
|
||||
};
|
||||
|
||||
// Account path element
|
||||
STPathElement
|
||||
ape(AccountID const& a)
|
||||
{
|
||||
return STPathElement(STPathElement::TypeAccount, a, xrpCurrency(), xrpAccount());
|
||||
return STPathElement(STPathElementType::Account, a, xrpCurrency(), xrpAccount());
|
||||
};
|
||||
|
||||
bool
|
||||
|
||||
@@ -32,7 +32,7 @@ bumpLastPage(
|
||||
{
|
||||
std::expected<void, Error> res{};
|
||||
env.app().getOpenLedger().modify([&](OpenView& view, beast::Journal j) -> bool {
|
||||
Sandbox sb(&view, TapNone);
|
||||
Sandbox sb(&view, ApplyFlags::None);
|
||||
|
||||
// Find the root page
|
||||
auto const sleRoot = sb.peek(directory);
|
||||
|
||||
@@ -313,7 +313,7 @@ struct Directory_test : public beast::unit_test::Suite
|
||||
// All the offers have been cancelled, so the book
|
||||
// should have no entries and be empty:
|
||||
{
|
||||
Sandbox const sb(env.closed().get(), TapNone);
|
||||
Sandbox const sb(env.closed().get(), ApplyFlags::None);
|
||||
UInt256 const bookBase = getBookBase({xrpIssue(), usd, std::nullopt});
|
||||
|
||||
BEAST_EXPECT(dirIsEmpty(sb, keylet::page(bookBase)));
|
||||
@@ -352,7 +352,7 @@ struct Directory_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// Create a chain of three pages:
|
||||
Sandbox sb(env.closed().get(), TapNone);
|
||||
Sandbox sb(env.closed().get(), ApplyFlags::None);
|
||||
makePages(sb, kBase, 3);
|
||||
|
||||
// Insert an item in the middle page:
|
||||
@@ -376,7 +376,7 @@ struct Directory_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// Create a chain of four pages:
|
||||
Sandbox sb(env.closed().get(), TapNone);
|
||||
Sandbox sb(env.closed().get(), ApplyFlags::None);
|
||||
makePages(sb, kBase, 4);
|
||||
|
||||
// Now add items on pages 1 and 2:
|
||||
|
||||
@@ -131,7 +131,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
STAmount const toDebit(usdGw1(20));
|
||||
{
|
||||
// accountSend, no deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
auto const startingAmount =
|
||||
@@ -156,7 +156,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// directSendNoFee, no deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
auto const startingAmount =
|
||||
@@ -177,7 +177,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// accountSend, w/ deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
@@ -205,7 +205,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// directSendNoFee, w/ deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
@@ -221,7 +221,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// redeemIOU, w/ deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
@@ -237,7 +237,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// issueIOU, w/ deferredCredits
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
@@ -253,7 +253,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
|
||||
{
|
||||
// accountSend, w/ deferredCredits and stacked views
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
|
||||
auto const iss = usdGw1;
|
||||
@@ -319,7 +319,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
STAmount const hugeAmt(
|
||||
issue, STAmount::kMaxValue, STAmount::kMaxOffset - 1, false, STAmount::Unchecked{});
|
||||
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox pv(&av);
|
||||
pv.creditHookIOU(gw, alice, hugeAmt, -tinyAmt);
|
||||
BEAST_EXPECT(pv.balanceHookIOU(alice, gw, hugeAmt) == tinyAmt);
|
||||
@@ -347,7 +347,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
env.fund(reserve(env, 1), alice);
|
||||
|
||||
env.close();
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox sb(&av);
|
||||
{
|
||||
// Send alice an amount and spend it. The deferredCredits will cause
|
||||
@@ -380,7 +380,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
auto const usd = gw["USD"];
|
||||
Account const alice("alice");
|
||||
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox sb(&av);
|
||||
|
||||
// The currency we pass for the last argument mimics the currency that
|
||||
@@ -412,7 +412,7 @@ class PaymentSandbox_test : public beast::unit_test::Suite
|
||||
env.fund(XRP(10000), alice, sponsor);
|
||||
env.close();
|
||||
|
||||
ApplyViewImpl av(&*env.current(), TapNone);
|
||||
ApplyViewImpl av(&*env.current(), ApplyFlags::None);
|
||||
PaymentSandbox sb(&av);
|
||||
|
||||
// Test basic owner count hook without sponsor
|
||||
|
||||
@@ -189,7 +189,7 @@ class View_test : public beast::unit_test::Suite
|
||||
Env env(*this);
|
||||
wipe(env.app().getOpenLedger());
|
||||
auto const open = env.current();
|
||||
ApplyViewImpl v(&*open, TapNone);
|
||||
ApplyViewImpl v(&*open, ApplyFlags::None);
|
||||
succ(v, 0, std::nullopt);
|
||||
v.insert(sle(1));
|
||||
BEAST_EXPECT(v.exists(k(1)));
|
||||
@@ -222,7 +222,7 @@ class View_test : public beast::unit_test::Suite
|
||||
Env env(*this);
|
||||
wipe(env.app().getOpenLedger());
|
||||
auto const open = env.current();
|
||||
ApplyViewImpl v0(&*open, TapNone);
|
||||
ApplyViewImpl v0(&*open, ApplyFlags::None);
|
||||
v0.insert(sle(1));
|
||||
v0.insert(sle(2));
|
||||
v0.insert(sle(4));
|
||||
@@ -288,7 +288,7 @@ class View_test : public beast::unit_test::Suite
|
||||
Env env(*this);
|
||||
wipe(env.app().getOpenLedger());
|
||||
auto const open = env.current();
|
||||
ApplyViewImpl v0(&*open, TapNone);
|
||||
ApplyViewImpl v0(&*open, ApplyFlags::None);
|
||||
v0.rawInsert(sle(1, 1));
|
||||
v0.rawInsert(sle(2, 2));
|
||||
v0.rawInsert(sle(4, 4));
|
||||
@@ -368,22 +368,22 @@ class View_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(v1.seq() == v0.seq());
|
||||
BEAST_EXPECT(v1.parentCloseTime() == v1.parentCloseTime());
|
||||
|
||||
ApplyViewImpl v2(&v1, TapRetry);
|
||||
ApplyViewImpl v2(&v1, ApplyFlags::Retry);
|
||||
BEAST_EXPECT(v2.parentCloseTime() == v1.parentCloseTime());
|
||||
BEAST_EXPECT(v2.seq() == v1.seq());
|
||||
BEAST_EXPECT(v2.flags() == TapRetry);
|
||||
BEAST_EXPECT(v2.flags() == ApplyFlags::Retry);
|
||||
|
||||
Sandbox const v3(&v2);
|
||||
BEAST_EXPECT(v3.seq() == v2.seq());
|
||||
BEAST_EXPECT(v3.parentCloseTime() == v2.parentCloseTime());
|
||||
BEAST_EXPECT(v3.flags() == TapRetry);
|
||||
BEAST_EXPECT(v3.flags() == ApplyFlags::Retry);
|
||||
}
|
||||
{
|
||||
ApplyViewImpl v1(&v0, TapRetry);
|
||||
ApplyViewImpl v1(&v0, ApplyFlags::Retry);
|
||||
PaymentSandbox v2(&v1);
|
||||
BEAST_EXPECT(v2.seq() == v0.seq());
|
||||
BEAST_EXPECT(v2.parentCloseTime() == v0.parentCloseTime());
|
||||
BEAST_EXPECT(v2.flags() == TapRetry);
|
||||
BEAST_EXPECT(v2.flags() == ApplyFlags::Retry);
|
||||
PaymentSandbox const v3(&v2);
|
||||
BEAST_EXPECT(v3.seq() == v2.seq());
|
||||
BEAST_EXPECT(v3.parentCloseTime() == v2.parentCloseTime());
|
||||
@@ -1030,7 +1030,7 @@ class View_test : public beast::unit_test::Suite
|
||||
wipe(*ledger);
|
||||
ledger->rawInsert(sle(1));
|
||||
ReadView const& v0 = *ledger;
|
||||
ApplyViewImpl v1(&v0, TapNone);
|
||||
ApplyViewImpl v1(&v0, ApplyFlags::None);
|
||||
{
|
||||
Sandbox v2(&v1);
|
||||
v2.erase(v2.peek(k(1)));
|
||||
|
||||
@@ -113,7 +113,8 @@ TxTest::getRules() const
|
||||
[[nodiscard]] TxResult
|
||||
TxTest::submit(std::shared_ptr<STTx const> stx)
|
||||
{
|
||||
auto result = apply(registry_, *openLedger_, *stx, TapNone, registry_.getJournal("apply"));
|
||||
auto result =
|
||||
apply(registry_, *openLedger_, *stx, ApplyFlags::None, registry_.getJournal("apply"));
|
||||
|
||||
// Track successfully applied transactions for canonical reordering on close
|
||||
// We make a copy since the TransactionBase doesn't own the STTx
|
||||
@@ -206,7 +207,7 @@ TxTest::close()
|
||||
for (auto const& [key, tx] : txSet)
|
||||
{
|
||||
auto const result =
|
||||
apply(registry_, accum, *tx, TapNone, registry_.getJournal("apply"));
|
||||
apply(registry_, accum, *tx, ApplyFlags::None, registry_.getJournal("apply"));
|
||||
if (!result.applied)
|
||||
{
|
||||
throw std::runtime_error("TxTest::close: failed to apply transaction");
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
Account const bob{"bob"};
|
||||
Account const carol{"carol"};
|
||||
|
||||
EntryTestEnv() : av_(&fundAndClose(), TapNone)
|
||||
EntryTestEnv() : av_(&fundAndClose(), ApplyFlags::None)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ TEST_F(SLEBaseTests, adopt_sle)
|
||||
|
||||
TEST_F(SLEBaseTests, writable_accessors)
|
||||
{
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
beast::Journal const j{beast::Journal::getNullSink()};
|
||||
|
||||
AccountRootEntryW account(alice_.id(), av, j);
|
||||
@@ -250,7 +250,7 @@ TEST_F(SLEBaseTests, writable_accessors)
|
||||
|
||||
TEST_F(SLEBaseTests, apply_view_context_ctor)
|
||||
{
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
beast::Journal const j{beast::Journal::getNullSink()};
|
||||
|
||||
transactions::AccountSetBuilder builder{alice_.id()};
|
||||
@@ -275,7 +275,7 @@ TEST_F(SLEBaseTests, apply_view_context_ctor)
|
||||
TEST_F(SLEBaseTests, writable_lifecycle)
|
||||
{
|
||||
// A view we never apply, so nothing here reaches the ledger.
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
|
||||
// Entry that does not exist yet: newSLE() -> insert().
|
||||
{
|
||||
@@ -300,7 +300,7 @@ TEST_F(SLEBaseTests, writable_lifecycle)
|
||||
// Erase but not Cache, so it shows the difference: building the entry
|
||||
// only peeks, and the write is invisible to the view until update().
|
||||
{
|
||||
ApplyViewImpl fresh(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl fresh(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
|
||||
AccountRootEntryW account(alice_.id(), fresh);
|
||||
EXPECT_TRUE(account.exists());
|
||||
@@ -332,7 +332,7 @@ TEST_F(SLEBaseTests, writable_lifecycle)
|
||||
|
||||
TEST_F(SLEBaseTests, conversion)
|
||||
{
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
|
||||
AccountRootEntryW const writable(alice_.id(), av);
|
||||
EXPECT_TRUE(writable.exists());
|
||||
@@ -357,7 +357,7 @@ TEST_F(SLEBaseTests, resolve_entry_peeks)
|
||||
AccountRootEntryR const overLedger(alice_.id(), ledger);
|
||||
EXPECT_TRUE(overLedger.exists());
|
||||
|
||||
ApplyViewImpl av(&ledger, TapNone);
|
||||
ApplyViewImpl av(&ledger, ApplyFlags::None);
|
||||
|
||||
// ReadView const& binds an ApplyViewImpl just as happily, and there the
|
||||
// dynamic_cast succeeds, so this one resolves through ApplyView::peek().
|
||||
@@ -404,7 +404,7 @@ TEST_F(SLEBaseTests, throws_on_missing_entry)
|
||||
TEST_F(SLEBaseTests, throws_on_missing_writable_entry)
|
||||
{
|
||||
// A view we never apply, so nothing here reaches the ledger.
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), TapNone);
|
||||
ApplyViewImpl av(&env_.getClosedLedger(), ApplyFlags::None);
|
||||
|
||||
// bob is unfunded, so this resolves to nothing and every operation that
|
||||
// needs an SLE has to throw instead of dereferencing null. These are the
|
||||
|
||||
@@ -655,7 +655,7 @@ RCLConsensus::Adaptor::doAccept(
|
||||
localTxs_.getTxSet(),
|
||||
anyDisputes,
|
||||
retriableTxs,
|
||||
TapNone,
|
||||
ApplyFlags::None,
|
||||
"consensus",
|
||||
[&](OpenView& view, beast::Journal j) {
|
||||
// Stuff the ledger with transactions from the queue.
|
||||
@@ -760,7 +760,7 @@ RCLConsensus::Adaptor::buildLCL(
|
||||
XRPL_ASSERT(
|
||||
replayData->parent()->header().hash == previousLedger.id(),
|
||||
"xrpl::RCLConsensus::Adaptor::buildLCL : parent hash match");
|
||||
return buildLedger(*replayData, TapNone, app_, j_);
|
||||
return buildLedger(*replayData, ApplyFlags::None, app_, j_);
|
||||
}
|
||||
return buildLedger(
|
||||
previousLedger.ledger,
|
||||
|
||||
@@ -138,7 +138,7 @@ applyTransactions(
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (applyTransaction(app, view, *it->second, certainRetry, TapNone, j))
|
||||
switch (applyTransaction(app, view, *it->second, certainRetry, ApplyFlags::None, j))
|
||||
{
|
||||
case ApplyTransactionResult::Success:
|
||||
it = txns.erase(it);
|
||||
|
||||
@@ -207,7 +207,7 @@ LedgerDeltaAcquire::tryBuild(std::shared_ptr<Ledger const> const& parent)
|
||||
"xrpl::LedgerDeltaAcquire::tryBuild : parent hash match");
|
||||
// build ledger
|
||||
LedgerReplay const replayData(parent, replayTemp_, std::move(orderedTxns_));
|
||||
fullLedger_ = buildLedger(replayData, TapNone, app_, journal_);
|
||||
fullLedger_ = buildLedger(replayData, ApplyFlags::None, app_, journal_);
|
||||
if (fullLedger_ && fullLedger_->header().hash == hash_)
|
||||
{
|
||||
JLOG(journal_.info()) << "Built " << hash_;
|
||||
|
||||
@@ -178,7 +178,7 @@ OpenLedger::applyOne(
|
||||
beast::Journal j) -> Result
|
||||
{
|
||||
if (retry)
|
||||
flags = flags | TapRetry;
|
||||
flags = flags | ApplyFlags::Retry;
|
||||
// If it's in anybody's proposed set, try to keep it in the ledger
|
||||
auto const result = xrpl::apply(app, view, *tx, flags, j);
|
||||
if (result.applied || result.ter == terQUEUED)
|
||||
|
||||
@@ -1710,12 +1710,12 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
for (TransactionStatus& e : transactions)
|
||||
{
|
||||
// we check before adding to the batch
|
||||
ApplyFlags flags = TapNone;
|
||||
ApplyFlags flags = ApplyFlags::None;
|
||||
if (e.admin)
|
||||
flags |= TapUnlimited;
|
||||
flags |= ApplyFlags::Unlimited;
|
||||
|
||||
if (e.failType == FailHard::Yes)
|
||||
flags |= TapFailHard;
|
||||
flags |= ApplyFlags::FailHard;
|
||||
|
||||
auto const result = registry_.get().getTxQ().apply(
|
||||
registry_.get().getApp(), view, e.transaction->getSTransaction(), flags, j);
|
||||
@@ -2212,7 +2212,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
OrderedTxs({}),
|
||||
false,
|
||||
retries,
|
||||
TapNone,
|
||||
ApplyFlags::None,
|
||||
"jump",
|
||||
[&](OpenView& view, beast::Journal j) {
|
||||
// Stuff the ledger with transactions from the queue.
|
||||
|
||||
@@ -799,7 +799,7 @@ TxQApplyImpl::addTxToQueue()
|
||||
// will not be checked again, so the cost should be minimal.
|
||||
|
||||
// Don't allow soft failures, which can lead to retries
|
||||
flags_ &= ~TapRetry;
|
||||
flags_ &= ~ApplyFlags::Retry;
|
||||
|
||||
auto& candidate =
|
||||
byAccountIter_->second.add({tx_, txID_, feeLevelPaid_, flags_, preflightRes_});
|
||||
@@ -809,7 +809,7 @@ TxQApplyImpl::addTxToQueue()
|
||||
JLOG(j_.debug()) << "Added transaction " << candidate.txID << " with result "
|
||||
<< transToken(preflightRes_.ter) << " from " << (!created ? "existing" : "new")
|
||||
<< " account " << candidate.account << " to queue."
|
||||
<< " Flags: " << flags_;
|
||||
<< " Flags: " << std::to_underlying(flags_);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -1040,8 +1040,9 @@ TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j)
|
||||
if (pfResult->rules != view.rules() || pfResult->flags != flags)
|
||||
{
|
||||
JLOG(j.debug()) << "Queued transaction " << txID
|
||||
<< " rules or flags have changed. Flags from " << pfResult->flags << " to "
|
||||
<< flags;
|
||||
<< " rules or flags have changed. Flags from "
|
||||
<< std::to_underlying(pfResult->flags) << " to "
|
||||
<< std::to_underlying(flags);
|
||||
|
||||
pfResult.emplace(preflight(app, view.rules(), pfResult->tx, flags, pfResult->j));
|
||||
}
|
||||
@@ -1132,7 +1133,7 @@ TxQ::canBeHeld(
|
||||
// queue yet, but should be added in the future.
|
||||
// TapFailHard transactions are never held
|
||||
if (tx.isFieldPresent(sfPreviousTxnID) || tx.isFieldPresent(sfAccountTxnID) ||
|
||||
((flags & TapFailHard) != 0u))
|
||||
((flags & ApplyFlags::FailHard) != ApplyFlags::None))
|
||||
return telCAN_NOT_QUEUE;
|
||||
|
||||
// Disallow delegated transactions from being queued.
|
||||
@@ -1502,7 +1503,7 @@ TxQApplyImpl::applyImplPrelock()
|
||||
if (auto const directApplied = txq_.tryDirectApply(app_, view_, tx_, flags_, jExt_))
|
||||
return directApplied;
|
||||
|
||||
if ((flags_ & TapDryRun) != 0u)
|
||||
if ((flags_ & ApplyFlags::DryRun) != ApplyFlags::None)
|
||||
return ApplyResult{telCAN_NOT_QUEUE, false};
|
||||
|
||||
// If we get past tryDirectApply() without returning then we expect
|
||||
@@ -1788,7 +1789,8 @@ TxQ::accept(Application& app, OpenView& view)
|
||||
candidateIter++;
|
||||
continue;
|
||||
}
|
||||
auto const requiredFeeLevel = getRequiredFeeLevel(view, TapNone, metricsSnapshot, lock);
|
||||
auto const requiredFeeLevel =
|
||||
getRequiredFeeLevel(view, ApplyFlags::None, metricsSnapshot, lock);
|
||||
auto const feeLevelPaid = candidateIter->feeLevel;
|
||||
JLOG(j_.trace()) << "Queued transaction " << candidateIter->txID << " from account "
|
||||
<< candidateIter->account << " has fee level of " << feeLevelPaid
|
||||
@@ -1830,7 +1832,8 @@ TxQ::accept(Application& app, OpenView& view)
|
||||
{
|
||||
JLOG(j_.debug()) << "Queued transaction " << candidateIter->txID << " failed with "
|
||||
<< transToken(txnResult) << ". Leave in queue."
|
||||
<< " Applied: " << didApply << ". Flags: " << candidateIter->flags;
|
||||
<< " Applied: " << didApply
|
||||
<< ". Flags: " << std::to_underlying(candidateIter->flags);
|
||||
if (account.retryPenalty && candidateIter->retriesRemaining > 2)
|
||||
{
|
||||
candidateIter->retriesRemaining = 1;
|
||||
|
||||
@@ -634,7 +634,7 @@ PathRequest::findPaths(
|
||||
path::RippleCalc::Input rcInput;
|
||||
if (convertAll_)
|
||||
rcInput.partialPaymentAllowed = true;
|
||||
auto sandbox = std::make_unique<PaymentSandbox>(&*cache->getLedger(), TapNone);
|
||||
auto sandbox = std::make_unique<PaymentSandbox>(&*cache->getLedger(), ApplyFlags::None);
|
||||
auto rc = path::RippleCalc::rippleCalculate(
|
||||
*sandbox,
|
||||
saMaxAmount, // --> Amount to send is unlimited
|
||||
@@ -655,7 +655,7 @@ PathRequest::findPaths(
|
||||
JLOG(journal_.debug()) << iIdentifier_ << " Trying with an extra path element";
|
||||
|
||||
ps.pushBack(fullLiquidityPath);
|
||||
sandbox = std::make_unique<PaymentSandbox>(&*cache->getLedger(), TapNone);
|
||||
sandbox = std::make_unique<PaymentSandbox>(&*cache->getLedger(), ApplyFlags::None);
|
||||
rc = path::RippleCalc::rippleCalculate(
|
||||
*sandbox,
|
||||
saMaxAmount, // --> Amount to send is unlimited
|
||||
|
||||
@@ -392,7 +392,7 @@ Pathfinder::getPathLiquidity(
|
||||
path::RippleCalc::Input rcInput;
|
||||
rcInput.defaultPathsAllowed = false;
|
||||
|
||||
PaymentSandbox sandbox(&*ledger_, TapNone);
|
||||
PaymentSandbox sandbox(&*ledger_, ApplyFlags::None);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -455,7 +455,7 @@ Pathfinder::computePathRanks(int maxPaths, std::function<bool()> const& continue
|
||||
// Must subtract liquidity in default path from remaining amount.
|
||||
try
|
||||
{
|
||||
PaymentSandbox sandbox(&*ledger_, TapNone);
|
||||
PaymentSandbox sandbox(&*ledger_, ApplyFlags::None);
|
||||
|
||||
path::RippleCalc::Input rcInput;
|
||||
rcInput.partialPaymentAllowed = true;
|
||||
@@ -947,7 +947,7 @@ Pathfinder::isNoRippleOut(STPath const& currentPath)
|
||||
|
||||
// Last link must be an account.
|
||||
STPathElement const& endElement = currentPath.back();
|
||||
if ((endElement.getNodeType() & STPathElement::TypeAccount) == 0u)
|
||||
if (!endElement.isType(STPathElementType::Account))
|
||||
return false;
|
||||
|
||||
// If there's only one item in the path, return true if that item specifies
|
||||
@@ -1171,7 +1171,7 @@ Pathfinder::addLink(
|
||||
return;
|
||||
// Add accounts to incompletePaths
|
||||
STPathElement const pathElement(
|
||||
STPathElement::TypeAccount, it->account, uEndPathAsset, it->account);
|
||||
STPathElementType::Account, it->account, uEndPathAsset, it->account);
|
||||
incompletePaths.assembleAdd(currentPath, pathElement);
|
||||
++it;
|
||||
}
|
||||
@@ -1194,7 +1194,7 @@ Pathfinder::addLink(
|
||||
assetFromPathAsset(uEndPathAsset, uEndIssuer), domain_))
|
||||
{
|
||||
STPathElement const pathElement(
|
||||
STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount());
|
||||
STPathElementType::Currency, xrpAccount(), xrpCurrency(), xrpAccount());
|
||||
incompletePaths.assembleAdd(currentPath, pathElement);
|
||||
}
|
||||
}
|
||||
@@ -1220,7 +1220,7 @@ Pathfinder::addLink(
|
||||
|
||||
// add the order book itself
|
||||
newPath.emplaceBack(
|
||||
STPathElement::TypeCurrency, xrpAccount(), xrpCurrency(), xrpAccount());
|
||||
STPathElementType::Currency, xrpAccount(), xrpCurrency(), xrpAccount());
|
||||
|
||||
if (isXRP(dstAmount_.asset()))
|
||||
{
|
||||
@@ -1239,8 +1239,8 @@ Pathfinder::addLink(
|
||||
else if (!currentPath.hasSeen(
|
||||
book.out.getIssuer(), book.out, book.out.getIssuer()))
|
||||
{
|
||||
auto const assetType = book.out.holds<Issue>() ? STPathElement::TypeCurrency
|
||||
: STPathElement::TypeMpt;
|
||||
auto const assetType = book.out.holds<Issue>() ? STPathElementType::Currency
|
||||
: STPathElementType::Mpt;
|
||||
// Don't want the book if we've already seen the issuer
|
||||
// book -> account -> book
|
||||
if ((newPath.size() >= 2) && newPath.back().isAccount() &&
|
||||
@@ -1248,7 +1248,7 @@ Pathfinder::addLink(
|
||||
{
|
||||
// replace the redundant account with the order book
|
||||
newPath[newPath.size() - 1] = STPathElement(
|
||||
assetType | STPathElement::TypeIssuer,
|
||||
assetType | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
book.out,
|
||||
book.out.getIssuer());
|
||||
@@ -1257,7 +1257,7 @@ Pathfinder::addLink(
|
||||
{
|
||||
// add the order book
|
||||
newPath.emplaceBack(
|
||||
assetType | STPathElement::TypeIssuer,
|
||||
assetType | STPathElementType::Issuer,
|
||||
xrpAccount(),
|
||||
book.out,
|
||||
book.out.getIssuer());
|
||||
@@ -1283,7 +1283,7 @@ Pathfinder::addLink(
|
||||
incompletePaths.assembleAdd(
|
||||
newPath,
|
||||
STPathElement(
|
||||
STPathElement::TypeAccount,
|
||||
STPathElementType::Account,
|
||||
book.out.getIssuer(),
|
||||
book.out,
|
||||
book.out.getIssuer()));
|
||||
|
||||
@@ -248,7 +248,7 @@ simulateTxn(rpc::JsonContext& context, std::shared_ptr<Transaction> transaction)
|
||||
// Process the transaction
|
||||
OpenView view = *context.app.getOpenLedger().current();
|
||||
auto const result = context.app.getTxQ().apply(
|
||||
context.app, view, transaction->getSTransaction(), TapDryRun, context.j);
|
||||
context.app, view, transaction->getSTransaction(), ApplyFlags::DryRun, context.j);
|
||||
|
||||
jvResult[jss::applied] = result.applied;
|
||||
jvResult[jss::ledger_index] = view.seq();
|
||||
|
||||
Reference in new issue
Block a user