20#include <xrpl/basics/Blob.h>
21#include <xrpl/basics/base_uint.h>
22#include <xrpl/basics/contract.h>
23#include <xrpl/beast/utility/instrumentation.h>
24#include <xrpl/protocol/AccountID.h>
25#include <xrpl/protocol/SField.h>
26#include <xrpl/protocol/STAccount.h>
27#include <xrpl/protocol/STAmount.h>
28#include <xrpl/protocol/STLedgerEntry.h>
29#include <xrpl/protocol/STObject.h>
30#include <xrpl/protocol/Serializer.h>
31#include <xrpl/protocol/TER.h>
32#include <xrpl/protocol/TxMeta.h>
34#include <boost/container/flat_set.hpp>
48 : mTransactionID(txid), mLedger(ledger), mNodes(sfAffectedNodes, 32)
62 : mTransactionID(txid)
64 , mNodes(obj.getFieldArray(sfAffectedNodes))
73 "ripple::TxMeta::TxMeta(STObject) : type cast succeeded");
97 , mIndex(static_cast<
std::uint32_t>(-1))
99 , mNodes(sfAffectedNodes)
113 if (n.getFieldH256(sfLedgerIndex) == node)
116 n.setFieldU16(sfLedgerEntryType, nodeType);
126 "ripple::TxMeta::setAffectedNode : field type match");
131boost::container::flat_set<AccountID>
134 boost::container::flat_set<AccountID> list;
139 for (
auto const& it :
mNodes)
141 int index = it.getFieldIndex(
142 (it.getFName() == sfCreatedNode) ? sfNewFields : sfFinalFields);
146 auto inner =
dynamic_cast<STObject const*
>(&it.peekAtIndex(index));
149 "ripple::getAffectedAccounts : STObject type cast succeeded");
152 for (
auto const& field : *inner)
154 if (
auto sa =
dynamic_cast<STAccount const*
>(&field))
158 "ripple::getAffectedAccounts : account is set");
159 if (!sa->isDefault())
160 list.insert(sa->value());
163 (field.getFName() == sfLowLimit) ||
164 (field.getFName() == sfHighLimit) ||
165 (field.getFName() == sfTakerPays) ||
166 (field.getFName() == sfTakerGets))
168 auto lim =
dynamic_cast<STAmount const*
>(&field);
171 "ripple::getAffectedAccounts : STAmount type cast "
176 auto issuer = lim->getIssuer();
178 if (issuer.isNonZero())
196 if (n.getFieldH256(sfLedgerIndex) == index)
204 "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match");
206 obj.
setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType));
216 if (n.getFieldH256(sfLedgerIndex) == node)
219 UNREACHABLE(
"ripple::TxMeta::getAffectedNode(uint256) : node not found");
220 Throw<std::runtime_error>(
"Affected node not found");
227 STObject metaData(sfTransactionMetaData);
228 XRPL_ASSERT(
mResult != 255,
"ripple::TxMeta::getAsObject : result is set");
244 "ripple::TxMeta::addRaw : valid TER input");
void sort(bool(*compare)(const STObject &o1, const STObject &o2))
void reserve(std::size_t n)
void push_back(STObject const &object)
SField const & getFName() const
unsigned char getFieldU8(SField const &field) const
const STBase * peekAtPField(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 setFieldU8(SField const &field, unsigned char)
void add(Serializer &s) const override
void setFieldAmount(SField const &field, STAmount const &)
STBase & getField(SField const &field)
STAmount const & getFieldAmount(SField const &field) const
bool isFieldPresent(SField const &field) const
void setFieldU32(SField const &field, std::uint32_t)
std::size_t emplace_back(Args &&... args)
uint256 getFieldH256(SField const &field) const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
constexpr TERUnderlyingType TERtoInt(TELcodes v)
@ transactionID
transaction plus signature to give transaction ID