mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Fix formatting
This commit is contained in:
@@ -123,14 +123,14 @@ field_code(SerializedTypeID id, int index)
|
|||||||
return (safe_cast<int>(id) << 16) | index;
|
return (safe_cast<int>(id) << 16) | index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// constexpr
|
// constexpr
|
||||||
inline int
|
inline int
|
||||||
field_code(int id, int index)
|
field_code(int id, int index)
|
||||||
{
|
{
|
||||||
return (id << 16) | index;
|
return (id << 16) | index;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Identifies fields.
|
/** Identifies fields.
|
||||||
|
|
||||||
Fields are necessary to tag data in signed transactions so that
|
Fields are necessary to tag data in signed transactions so that
|
||||||
the binary format of the transaction can be canonicalized. All
|
the binary format of the transaction can be canonicalized. All
|
||||||
@@ -139,22 +139,20 @@ field_code(int id, int index)
|
|||||||
Each SField, once constructed, lives until program termination, and
|
Each SField, once constructed, lives until program termination, and
|
||||||
there is only one instance per fieldType/fieldValue pair which serves the
|
there is only one instance per fieldType/fieldValue pair which serves the
|
||||||
entire application.
|
entire application.
|
||||||
*/
|
*/
|
||||||
class SField
|
class SField
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
sMD_Never = 0x00,
|
sMD_Never = 0x00,
|
||||||
sMD_ChangeOrig = 0x01, // original value when it changes
|
sMD_ChangeOrig = 0x01, // original value when it changes
|
||||||
sMD_ChangeNew = 0x02, // new value when it changes
|
sMD_ChangeNew = 0x02, // new value when it changes
|
||||||
sMD_DeleteFinal = 0x04, // final value when it is deleted
|
sMD_DeleteFinal = 0x04, // final value when it is deleted
|
||||||
sMD_Create = 0x08, // value when it's created
|
sMD_Create = 0x08, // value when it's created
|
||||||
sMD_Always =
|
sMD_Always = 0x10, // value when node containing it is affected at all
|
||||||
0x10, // value when node containing it is affected at all
|
|
||||||
sMD_BaseTen = 0x20, // value is treated as base 10, overriding
|
sMD_BaseTen = 0x20, // value is treated as base 10, overriding
|
||||||
// default behavior
|
// default behavior
|
||||||
sMD_PseudoAccount =
|
sMD_PseudoAccount = 0x40, // if this field is set in an ACCOUNT_ROOT
|
||||||
0x40, // if this field is set in an ACCOUNT_ROOT
|
|
||||||
// _only_, then it is a pseudo-account
|
// _only_, then it is a pseudo-account
|
||||||
sMD_Default =
|
sMD_Default =
|
||||||
sMD_ChangeOrig | sMD_ChangeNew | sMD_DeleteFinal | sMD_Create
|
sMD_ChangeOrig | sMD_ChangeNew | sMD_DeleteFinal | sMD_Create
|
||||||
@@ -179,7 +177,7 @@ field_code(int id, int index)
|
|||||||
SField&
|
SField&
|
||||||
operator=(SField&&) = delete;
|
operator=(SField&&) = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct private_access_tag_t; // public, but still an implementation
|
struct private_access_tag_t; // public, but still an implementation
|
||||||
// detail
|
// detail
|
||||||
|
|
||||||
@@ -310,78 +308,78 @@ field_code(int id, int index)
|
|||||||
return knownCodeToField;
|
return knownCodeToField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int num;
|
static int num;
|
||||||
static std::map<int, SField const*> knownCodeToField;
|
static std::map<int, SField const*> knownCodeToField;
|
||||||
static std::map<std::string, SField const*> knownNameToField;
|
static std::map<std::string, SField const*> knownNameToField;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A field with a type known at compile time. */
|
/** A field with a type known at compile time. */
|
||||||
template <class T>
|
template <class T>
|
||||||
struct TypedField : SField
|
struct TypedField : SField
|
||||||
{
|
{
|
||||||
using type = T;
|
using type = T;
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
explicit TypedField(private_access_tag_t pat, Args&&... args);
|
explicit TypedField(private_access_tag_t pat, Args&&... args);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Indicate std::optional field semantics. */
|
/** Indicate std::optional field semantics. */
|
||||||
template <class T>
|
template <class T>
|
||||||
struct OptionaledField
|
struct OptionaledField
|
||||||
{
|
{
|
||||||
TypedField<T> const* f;
|
TypedField<T> const* f;
|
||||||
|
|
||||||
explicit OptionaledField(TypedField<T> const& f_) : f(&f_)
|
explicit OptionaledField(TypedField<T> const& f_) : f(&f_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline OptionaledField<T>
|
inline OptionaledField<T>
|
||||||
operator~(TypedField<T> const& f)
|
operator~(TypedField<T> const& f)
|
||||||
{
|
{
|
||||||
return OptionaledField<T>(f);
|
return OptionaledField<T>(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
using SF_UINT8 = TypedField<STInteger<std::uint8_t>>;
|
using SF_UINT8 = TypedField<STInteger<std::uint8_t>>;
|
||||||
using SF_UINT16 = TypedField<STInteger<std::uint16_t>>;
|
using SF_UINT16 = TypedField<STInteger<std::uint16_t>>;
|
||||||
using SF_UINT32 = TypedField<STInteger<std::uint32_t>>;
|
using SF_UINT32 = TypedField<STInteger<std::uint32_t>>;
|
||||||
using SF_UINT64 = TypedField<STInteger<std::uint64_t>>;
|
using SF_UINT64 = TypedField<STInteger<std::uint64_t>>;
|
||||||
using SF_UINT96 = TypedField<STBitString<96>>;
|
using SF_UINT96 = TypedField<STBitString<96>>;
|
||||||
using SF_UINT128 = TypedField<STBitString<128>>;
|
using SF_UINT128 = TypedField<STBitString<128>>;
|
||||||
using SF_UINT160 = TypedField<STBitString<160>>;
|
using SF_UINT160 = TypedField<STBitString<160>>;
|
||||||
using SF_UINT192 = TypedField<STBitString<192>>;
|
using SF_UINT192 = TypedField<STBitString<192>>;
|
||||||
using SF_UINT256 = TypedField<STBitString<256>>;
|
using SF_UINT256 = TypedField<STBitString<256>>;
|
||||||
using SF_UINT384 = TypedField<STBitString<384>>;
|
using SF_UINT384 = TypedField<STBitString<384>>;
|
||||||
using SF_UINT512 = TypedField<STBitString<512>>;
|
using SF_UINT512 = TypedField<STBitString<512>>;
|
||||||
|
|
||||||
// These BIPS and TENTHBIPS values are serialized as the underlying type.
|
// These BIPS and TENTHBIPS values are serialized as the underlying type.
|
||||||
// The tag is only applied when deserialized.
|
// The tag is only applied when deserialized.
|
||||||
//
|
//
|
||||||
// Basis points (bips) values:
|
// Basis points (bips) values:
|
||||||
using SF_BIPS16 = TypedField<STInteger<Bips16>>;
|
using SF_BIPS16 = TypedField<STInteger<Bips16>>;
|
||||||
using SF_BIPS32 = TypedField<STInteger<Bips32>>;
|
using SF_BIPS32 = TypedField<STInteger<Bips32>>;
|
||||||
// Tenth of a basis point values:
|
// Tenth of a basis point values:
|
||||||
using SF_TENTHBIPS16 = TypedField<STInteger<TenthBips16>>;
|
using SF_TENTHBIPS16 = TypedField<STInteger<TenthBips16>>;
|
||||||
using SF_TENTHBIPS32 = TypedField<STInteger<TenthBips32>>;
|
using SF_TENTHBIPS32 = TypedField<STInteger<TenthBips32>>;
|
||||||
|
|
||||||
using SF_ACCOUNT = TypedField<STAccount>;
|
using SF_ACCOUNT = TypedField<STAccount>;
|
||||||
using SF_AMOUNT = TypedField<STAmount>;
|
using SF_AMOUNT = TypedField<STAmount>;
|
||||||
using SF_ISSUE = TypedField<STIssue>;
|
using SF_ISSUE = TypedField<STIssue>;
|
||||||
using SF_CURRENCY = TypedField<STCurrency>;
|
using SF_CURRENCY = TypedField<STCurrency>;
|
||||||
using SF_NUMBER = TypedField<STNumber>;
|
using SF_NUMBER = TypedField<STNumber>;
|
||||||
using SF_VL = TypedField<STBlob>;
|
using SF_VL = TypedField<STBlob>;
|
||||||
using SF_VECTOR256 = TypedField<STVector256>;
|
using SF_VECTOR256 = TypedField<STVector256>;
|
||||||
using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
|
using SF_XCHAIN_BRIDGE = TypedField<STXChainBridge>;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Use macros for most SField construction to enforce naming conventions.
|
// Use macros for most SField construction to enforce naming conventions.
|
||||||
#pragma push_macro("UNTYPED_SFIELD")
|
#pragma push_macro("UNTYPED_SFIELD")
|
||||||
#undef UNTYPED_SFIELD
|
#undef UNTYPED_SFIELD
|
||||||
#pragma push_macro("TYPED_SFIELD")
|
#pragma push_macro("TYPED_SFIELD")
|
||||||
@@ -393,12 +391,11 @@ field_code(int id, int index)
|
|||||||
extern SField const sfName;
|
extern SField const sfName;
|
||||||
#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
|
#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
|
||||||
extern SF_##stiSuffix const sfName;
|
extern SF_##stiSuffix const sfName;
|
||||||
#define INTERPRETED_SFIELD( \
|
#define INTERPRETED_SFIELD(sfName, stiSuffix, fieldValue, stiInterpreted, ...) \
|
||||||
sfName, stiSuffix, fieldValue, stiInterpreted, ...) \
|
|
||||||
extern SF_##stiInterpreted const sfName;
|
extern SF_##stiInterpreted const sfName;
|
||||||
|
|
||||||
extern SField const sfInvalid;
|
extern SField const sfInvalid;
|
||||||
extern SField const sfGeneric;
|
extern SField const sfGeneric;
|
||||||
|
|
||||||
#include <xrpl/protocol/detail/sfields.macro>
|
#include <xrpl/protocol/detail/sfields.macro>
|
||||||
|
|
||||||
|
|||||||
@@ -1098,14 +1098,11 @@ isPseudoAccount(std::shared_ptr<SLE const> sleAcct)
|
|||||||
// semantics of true return value clean.
|
// semantics of true return value clean.
|
||||||
return sleAcct && sleAcct->getType() == ltACCOUNT_ROOT &&
|
return sleAcct && sleAcct->getType() == ltACCOUNT_ROOT &&
|
||||||
std::count_if(
|
std::count_if(
|
||||||
fields.begin(),
|
fields.begin(), fields.end(), [&sleAcct](SField const* sf) -> bool {
|
||||||
fields.end(),
|
|
||||||
[&sleAcct](SField const* sf) -> bool {
|
|
||||||
return sleAcct->isFieldPresent(*sf);
|
return sleAcct->isFieldPresent(*sf);
|
||||||
}) > 0;
|
}) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expected<std::shared_ptr<SLE>, TER>
|
Expected<std::shared_ptr<SLE>, TER>
|
||||||
createPseudoAccount(
|
createPseudoAccount(
|
||||||
ApplyView& view,
|
ApplyView& view,
|
||||||
|
|||||||
Reference in New Issue
Block a user