1#include <xrpl/protocol/STPathSet.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/beast/hash/uhash.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/SField.h>
11#include <xrpl/protocol/STBase.h>
12#include <xrpl/protocol/Serializer.h>
13#include <xrpl/protocol/UintTypes.h>
14#include <xrpl/protocol/jss.h>
35 hashAccount += (hashAccount * 257) ^ x;
43 for (
auto const x : currency)
44 hashCurrency += (hashCurrency * 509) ^ x;
48 hashIssuer += (hashIssuer * 911) ^ x;
50 return (hashAccount ^ hashCurrency ^ hashIssuer);
58 int const iType = sit.
get8();
64 JLOG(
debugLog().error()) <<
"Empty path in pathset";
76 JLOG(
debugLog().error()) <<
"Bad path element " << iType <<
" in pathset";
93 if (hasCurrency && hasMPT)
95 JLOG(
debugLog().error()) <<
"Bad path element MPT and Currency in pathset";
108 path.emplace_back(account, asset, issuer, hasCurrency || hasMPT);
122 return emplace(n, buf, std::move(*
this));
130 std::vector<STPath>::reverse_iterator it =
value_.rbegin();
135 while (++it !=
value_.rend())
162 for (
auto& p :
path_)
164 if (p.getAccountID() == account && p.getPathAsset() == asset && p.getIssuerID() == issuer)
176 for (
auto const& it :
path_)
179 auto const iType = it.getNodeType();
181 elem[jss::type] = iType;
184 elem[jss::account] =
to_string(it.getAccountID());
189 "xrpl::STPath::getJson : not type Currency and MPT");
191 elem[jss::currency] =
to_string(it.getCurrency());
194 elem[jss::mpt_issuance_id] =
to_string(it.getMPTID());
197 elem[jss::issuer] =
to_string(it.getIssuerID());
209 for (
auto const& it :
value_)
210 ret.
append(it.getJson(options));
224 XRPL_ASSERT(
getFName().isBinary(),
"xrpl::STPathSet::add : field is binary");
225 XRPL_ASSERT(
getFName().fieldType == STI_PATHSET,
"xrpl::STPathSet::add : valid field type");
228 for (
auto const& spPath :
value_)
233 for (
auto const& speElement : spPath)
235 int const iType = speElement.getNodeType();
Value & append(Value const &value)
Append value to array at the end.
static BaseUInt fromRaw(Container const &c)
constexpr auto visit(Visitors &&... visitors) const -> decltype(auto)
A type which can be exported to a well known binary format.
SField const & getFName() const
static STBase * emplace(std::size_t n, void *buf, T &&val)
static std::size_t getHash(STPathElement const &element)
AccountID const & getAccountID() const
PathAsset const & getPathAsset() const
AccountID const & getIssuerID() const
void add(Serializer &s) const override
bool assembleAdd(STPath const &base, STPathElement const &tail)
STBase * copy(std::size_t n, void *buf) const override
json::Value getJson(JsonOptions) const override
void pushBack(STPath const &e)
std::vector< STPath > value_
STBase * move(std::size_t n, void *buf) override
bool isEquivalent(STBase const &t) const override
bool isDefault() const override
SerializedTypeID getSType() const override
std::vector< STPathElement > path_
bool hasSeen(AccountID const &account, PathAsset const &asset, AccountID const &issuer) const
void pushBack(STPathElement const &e)
json::Value getJson(JsonOptions) const
int addBitString(BaseUInt< Bits, Tag > const &v)
int add8(unsigned char i)
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::Journal debugLog()
Returns a debug journal.
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
std::string to_string(BaseUInt< Bits, Tag > const &a)
BaseUInt< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Note, should be treated as flags that can be | and &.