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>
36 hashAccount += (hashAccount * 257) ^ x;
44 for (
auto const x : currency)
45 hashCurrency += (hashCurrency * 509) ^ x;
49 hashIssuer += (hashIssuer * 911) ^ x;
51 return (hashAccount ^ hashCurrency ^ hashIssuer);
65 int const iType = sit.
get8();
71 JLOG(
debugLog().error()) <<
"Empty path in pathset";
83 JLOG(
debugLog().error()) <<
"Bad path element " << iType <<
" in pathset";
100 if (hasCurrency && hasMPT)
102 JLOG(
debugLog().error()) <<
"Bad path element MPT and Currency in pathset";
115 path.emplace_back(account, asset, issuer, hasCurrency || hasMPT);
129 return emplace(n, buf, std::move(*
this));
143 value_.push_back(std::move(combined));
150 auto const* v =
dynamic_cast<STPathSet const*
>(&t);
151 return (v !=
nullptr) && (
value_ == v->value_);
164 return p.getAccountID() == account && p.getPathAsset() == asset &&
165 p.getIssuerID() == issuer;
174 for (
auto const& it :
path_)
177 auto const iType = it.getNodeType();
179 elem[jss::type] = iType;
182 elem[jss::account] =
to_string(it.getAccountID());
187 "xrpl::STPath::getJson : not type Currency and MPT");
189 elem[jss::currency] =
to_string(it.getCurrency());
192 elem[jss::mpt_issuance_id] =
to_string(it.getMPTID());
195 elem[jss::issuer] =
to_string(it.getIssuerID());
207 for (
auto const& it :
value_)
208 ret.
append(it.getJson(options));
222 XRPL_ASSERT(
getFName().isBinary(),
"xrpl::STPathSet::add : field is binary");
223 XRPL_ASSERT(
getFName().fieldType == STI_PATHSET,
"xrpl::STPathSet::add : valid field type");
226 for (
auto const& spPath :
value_)
231 for (
auto const& speElement : spPath)
233 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)
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
xrpl::hardened_hash_set< STPath > seenHashes_
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 &.