rippled
Loading...
Searching...
No Matches
Indexes.h
1#ifndef XRPL_PROTOCOL_INDEXES_H_INCLUDED
2#define XRPL_PROTOCOL_INDEXES_H_INCLUDED
3
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/protocol/Book.h>
6#include <xrpl/protocol/Keylet.h>
7#include <xrpl/protocol/LedgerFormats.h>
8#include <xrpl/protocol/Protocol.h>
9#include <xrpl/protocol/PublicKey.h>
10#include <xrpl/protocol/STXChainBridge.h>
11#include <xrpl/protocol/Serializer.h>
12#include <xrpl/protocol/UintTypes.h>
13#include <xrpl/protocol/jss.h>
14
15#include <cstdint>
16#include <set>
17
18namespace ripple {
19
20class SeqProxy;
35namespace keylet {
36
39account(AccountID const& id) noexcept;
40
42Keylet const&
43amendments() noexcept;
44
47child(uint256 const& key) noexcept;
48
54Keylet const&
55skip() noexcept;
56
68skip(LedgerIndex ledger) noexcept;
69
71Keylet const&
72fees() noexcept;
73
75Keylet const&
76negativeUNL() noexcept;
77
79struct book_t
80{
81 explicit book_t() = default;
82
83 Keylet
84 operator()(Book const& b) const;
85};
86static book_t const book{};
87
97line(
98 AccountID const& id0,
99 AccountID const& id1,
100 Currency const& currency) noexcept;
101
102inline Keylet
103line(AccountID const& id, Issue const& issue) noexcept
104{
105 return line(id, issue.account, issue.currency);
106}
111Keylet
112offer(AccountID const& id, std::uint32_t seq) noexcept;
113
114inline Keylet
115offer(uint256 const& key) noexcept
116{
117 return {ltOFFER, key};
118}
122Keylet
123quality(Keylet const& k, std::uint64_t q) noexcept;
124
126struct next_t
127{
128 explicit next_t() = default;
129
130 Keylet
131 operator()(Keylet const& k) const;
132};
133static next_t const next{};
134
137{
138 explicit ticket_t() = default;
139
140 Keylet
141 operator()(AccountID const& id, std::uint32_t ticketSeq) const;
142
143 Keylet
144 operator()(AccountID const& id, SeqProxy ticketSeq) const;
145
146 Keylet
147 operator()(uint256 const& key) const
148 {
149 return {ltTICKET, key};
150 }
151};
152static ticket_t const ticket{};
153
155Keylet
156signers(AccountID const& account) noexcept;
157
160Keylet
161check(AccountID const& id, std::uint32_t seq) noexcept;
162
163inline Keylet
164check(uint256 const& key) noexcept
165{
166 return {ltCHECK, key};
167}
172Keylet
173depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
174
175Keylet
177 AccountID const& owner,
178 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
179
180inline Keylet
181depositPreauth(uint256 const& key) noexcept
182{
183 return {ltDEPOSIT_PREAUTH, key};
184}
187//------------------------------------------------------------------------------
188
190Keylet
191unchecked(uint256 const& key) noexcept;
192
194Keylet
195ownerDir(AccountID const& id) noexcept;
196
199Keylet
200page(uint256 const& root, std::uint64_t index = 0) noexcept;
201
202inline Keylet
203page(Keylet const& root, std::uint64_t index = 0) noexcept
204{
205 XRPL_ASSERT(
206 root.type == ltDIR_NODE, "ripple::keylet::page : valid root type");
207 return page(root.key, index);
208}
212Keylet
213escrow(AccountID const& src, std::uint32_t seq) noexcept;
214
216Keylet
217payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
218
228Keylet
229nftpage_min(AccountID const& owner);
230
232Keylet
233nftpage_max(AccountID const& owner);
234
235Keylet
236nftpage(Keylet const& k, uint256 const& token);
240Keylet
241nftoffer(AccountID const& owner, std::uint32_t seq);
242
243inline Keylet
245{
246 return {ltNFTOKEN_OFFER, offer};
247}
248
250Keylet
251nft_buys(uint256 const& id) noexcept;
252
254Keylet
255nft_sells(uint256 const& id) noexcept;
256
258Keylet
259amm(Asset const& issue1, Asset const& issue2) noexcept;
260
261Keylet
262amm(uint256 const& amm) noexcept;
263
265Keylet
266delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
267
268Keylet
270
271// `seq` is stored as `sfXChainClaimID` in the object
272Keylet
274
275// `seq` is stored as `sfXChainAccountCreateCount` in the object
276Keylet
278
279Keylet
280did(AccountID const& account) noexcept;
281
282Keylet
283oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
284
285Keylet
287 AccountID const& subject,
288 AccountID const& issuer,
289 Slice const& credType) noexcept;
290
291inline Keylet
292credential(uint256 const& key) noexcept
293{
294 return {ltCREDENTIAL, key};
295}
296
297Keylet
298mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
299
300Keylet
301mptIssuance(MPTID const& issuanceID) noexcept;
302
303inline Keylet
304mptIssuance(uint256 const& issuanceKey)
305{
306 return {ltMPTOKEN_ISSUANCE, issuanceKey};
307}
308
309Keylet
310mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
311
312inline Keylet
313mptoken(uint256 const& mptokenKey)
314{
315 return {ltMPTOKEN, mptokenKey};
316}
317
318Keylet
319mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
320
321Keylet
322vault(AccountID const& owner, std::uint32_t seq) noexcept;
323
324inline Keylet
325vault(uint256 const& vaultKey)
326{
327 return {ltVAULT, vaultKey};
328}
329
330Keylet
331permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
332
333Keylet
334permissionedDomain(uint256 const& domainID) noexcept;
335} // namespace keylet
336
337// Everything below is deprecated and should be removed in favor of keylets:
338
340getBookBase(Book const& book);
341
343getQualityNext(uint256 const& uBase);
344
345// VFALCO This name could be better
347getQuality(uint256 const& uBase);
348
350getTicketIndex(AccountID const& account, std::uint32_t uSequence);
351
353getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
354
355template <class... keyletParams>
362
363// This list should include all of the keylet functions that take a single
364// AccountID parameter.
366 {{&keylet::account, jss::AccountRoot, false},
367 {&keylet::ownerDir, jss::DirectoryNode, true},
368 {&keylet::signers, jss::SignerList, true},
369 // It's normally impossible to create an item at nftpage_min, but
370 // test it anyway, since the invariant checks for it.
371 {&keylet::nftpage_min, jss::NFTokenPage, true},
372 {&keylet::nftpage_max, jss::NFTokenPage, true},
373 {&keylet::did, jss::DID, true}}};
374
375MPTID
376makeMptID(std::uint32_t sequence, AccountID const& account);
377
378} // namespace ripple
379
380#endif
Lightweight wrapper to tag static string.
Definition json_value.h:45
Specifies an order book.
Definition Book.h:17
A currency issued by an account.
Definition Issue.h:14
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:37
An immutable linear range of bytes.
Definition Slice.h:27
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:261
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:521
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:501
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:446
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:171
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:551
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:211
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:427
Keylet line(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:225
static next_t const next
Definition Indexes.h:133
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:195
static book_t const book
Definition Indexes.h:86
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:400
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:507
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:467
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:495
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:545
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:361
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:349
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:370
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:384
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:454
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:203
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:392
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:355
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:415
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:177
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:421
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:311
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:481
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:408
static ticket_t const ticket
Definition Indexes.h:152
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:317
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:255
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:323
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:376
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:130
base_uint< 256 > uint256
Definition base_uint.h:539
base_uint< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
Definition UintTypes.h:45
std::array< keyletDesc< AccountID const & >, 6 > const directAccountKeylets
Definition Indexes.h:365
uint256 getQualityNext(uint256 const &uBase)
Definition Indexes.cpp:122
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition Indexes.cpp:137
Number root(Number f, unsigned d)
Definition Number.cpp:617
@ credential
Credentials signature.
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:151
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:96
STL namespace.
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
Json::StaticString expectedLEName
Definition Indexes.h:359
std::function< Keylet(keyletParams...)> function
Definition Indexes.h:358
The beginning of an order book.
Definition Indexes.h:80
Keylet operator()(Book const &b) const
Definition Indexes.cpp:219
The directory for the next lower quality.
Definition Indexes.h:127
Keylet operator()(Keylet const &k) const
Definition Indexes.cpp:280
A ticket belonging to an account.
Definition Indexes.h:137
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition Indexes.cpp:289
Keylet operator()(uint256 const &key) const
Definition Indexes.h:147