20#include <xrpl/basics/Log.h>
21#include <xrpl/basics/base_uint.h>
22#include <xrpl/basics/contract.h>
23#include <xrpl/basics/safe_cast.h>
24#include <xrpl/beast/utility/instrumentation.h>
25#include <xrpl/json/to_string.h>
26#include <xrpl/protocol/Feature.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/Keylet.h>
29#include <xrpl/protocol/LedgerFormats.h>
30#include <xrpl/protocol/Rules.h>
31#include <xrpl/protocol/SField.h>
32#include <xrpl/protocol/STBase.h>
33#include <xrpl/protocol/STLedgerEntry.h>
34#include <xrpl/protocol/STObject.h>
35#include <xrpl/protocol/Serializer.h>
36#include <xrpl/protocol/jss.h>
38#include <boost/format/free_funcs.hpp>
51 :
STObject(sfLedgerEntry), key_(k.key), type_(k.type)
55 if (format ==
nullptr)
56 Throw<std::runtime_error>(
57 "Attempt to create a SLE of unknown type " +
60 set(format->getSOTemplate());
66 :
STObject(sfLedgerEntry), key_(index)
82 safe_cast<LedgerEntryType>(
getFieldU16(sfLedgerEntryType)));
84 if (format ==
nullptr)
85 Throw<std::runtime_error>(
"invalid ledger entry type");
87 type_ = format->getType();
96 if (format ==
nullptr)
97 Throw<std::runtime_error>(
"invalid ledger entry type");
102 ret += format->getName();
118 return emplace(n, buf, std::move(*
this));
124 return STI_LEDGERENTRY;
141 if (
getType() == ltMPTOKEN_ISSUANCE)
152 ltDIR_NODE, ltAMENDMENTS, ltFEE_SETTINGS, ltNEGATIVE_UNL, ltAMM};
155 bool const excludePrevTxnID = !rules.
enabled(fixPreviousTxnID) &&
157 newPreviousTxnIDTypes.
cbegin(),
158 newPreviousTxnIDTypes.
cend(),
160 return !excludePrevTxnID &&
getFieldIndex(sfPreviousTxnID) != -1;
172 JLOG(
debugLog().info()) <<
"Thread Tx:" << txID <<
" prev:" << oldPrevTxID;
174 if (oldPrevTxID == txID)
179 "ripple::STLedgerEntry::thread : ledger sequence match");
183 prevTxID = oldPrevTxID;
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
A type which can be exported to a well known binary format.
static STBase * emplace(std::size_t n, void *buf, T &&val)
STBase * move(std::size_t n, void *buf) override
STLedgerEntry(Keylet const &k)
Create an empty object with the given key and type.
LedgerEntryType getType() const
SerializedTypeID getSType() const override
std::string getFullText() const override
bool thread(uint256 const &txID, std::uint32_t ledgerSeq, uint256 &prevTxID, std::uint32_t &prevLedgerID)
Json::Value getJson(JsonOptions options) const override
STBase * copy(std::size_t n, void *buf) const override
bool isThreadedType(Rules const &rules) const
std::string getText() const override
void applyTemplate(SOTemplate const &type)
AccountID getAccountID(SField const &field) const
std::uint16_t getFieldU16(SField const &field) const
void setFieldH256(SField const &field, uint256 const &)
std::uint32_t getFieldU32(SField const &field) const
void setFieldU16(SField const &field, std::uint16_t)
void set(SOTemplate const &)
int getFieldIndex(SField const &field) const
std::string getFullText() const override
std::string getText() const override
Json::Value getJson(JsonOptions=JsonOptions::none) const override
void setFieldU32(SField const &field, std::uint32_t)
uint256 getFieldH256(SField const &field) const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::Journal debugLog()
Returns a debug journal.
std::string to_string(base_uint< Bits, Tag > const &a)
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Note, should be treated as flags that can be | and &.
A pair of SHAMap key and LedgerEntryType.