rippled
Loading...
Searching...
No Matches
Indexes.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PROTOCOL_INDEXES_H_INCLUDED
21#define RIPPLE_PROTOCOL_INDEXES_H_INCLUDED
22
23#include <xrpl/basics/base_uint.h>
24#include <xrpl/protocol/Book.h>
25#include <xrpl/protocol/Keylet.h>
26#include <xrpl/protocol/LedgerFormats.h>
27#include <xrpl/protocol/Protocol.h>
28#include <xrpl/protocol/PublicKey.h>
29#include <xrpl/protocol/STXChainBridge.h>
30#include <xrpl/protocol/Serializer.h>
31#include <xrpl/protocol/UintTypes.h>
32#include <xrpl/protocol/jss.h>
33
34#include <cstdint>
35#include <set>
36
37namespace ripple {
38
39class SeqProxy;
54namespace keylet {
55
58account(AccountID const& id) noexcept;
59
61Keylet const&
62amendments() noexcept;
63
66child(uint256 const& key) noexcept;
67
73Keylet const&
74skip() noexcept;
75
87skip(LedgerIndex ledger) noexcept;
88
90Keylet const&
91fees() noexcept;
92
94Keylet const&
95negativeUNL() noexcept;
96
98struct book_t
99{
100 explicit book_t() = default;
101
102 Keylet
103 operator()(Book const& b) const;
104};
105static book_t const book{};
106
115Keylet
116line(
117 AccountID const& id0,
118 AccountID const& id1,
119 Currency const& currency) noexcept;
120
121inline Keylet
122line(AccountID const& id, Issue const& issue) noexcept
123{
124 return line(id, issue.account, issue.currency);
125}
130Keylet
131offer(AccountID const& id, std::uint32_t seq) noexcept;
132
133inline Keylet
134offer(uint256 const& key) noexcept
135{
136 return {ltOFFER, key};
137}
141Keylet
142quality(Keylet const& k, std::uint64_t q) noexcept;
143
145struct next_t
146{
147 explicit next_t() = default;
148
149 Keylet
150 operator()(Keylet const& k) const;
151};
152static next_t const next{};
153
156{
157 explicit ticket_t() = default;
158
159 Keylet
160 operator()(AccountID const& id, std::uint32_t ticketSeq) const;
161
162 Keylet
163 operator()(AccountID const& id, SeqProxy ticketSeq) const;
164
165 Keylet
166 operator()(uint256 const& key) const
167 {
168 return {ltTICKET, key};
169 }
170};
171static ticket_t const ticket{};
172
174Keylet
175signers(AccountID const& account) noexcept;
176
179Keylet
180check(AccountID const& id, std::uint32_t seq) noexcept;
181
182inline Keylet
183check(uint256 const& key) noexcept
184{
185 return {ltCHECK, key};
186}
191Keylet
192depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
193
194Keylet
196 AccountID const& owner,
197 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
198
199inline Keylet
200depositPreauth(uint256 const& key) noexcept
201{
202 return {ltDEPOSIT_PREAUTH, key};
203}
206//------------------------------------------------------------------------------
207
209Keylet
210unchecked(uint256 const& key) noexcept;
211
213Keylet
214ownerDir(AccountID const& id) noexcept;
215
218Keylet
219page(uint256 const& root, std::uint64_t index = 0) noexcept;
220
221inline Keylet
222page(Keylet const& root, std::uint64_t index = 0) noexcept
223{
224 XRPL_ASSERT(
225 root.type == ltDIR_NODE, "ripple::keylet::page : valid root type");
226 return page(root.key, index);
227}
231Keylet
232escrow(AccountID const& src, std::uint32_t seq) noexcept;
233
235Keylet
236payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
237
247Keylet
248nftpage_min(AccountID const& owner);
249
251Keylet
252nftpage_max(AccountID const& owner);
253
254Keylet
255nftpage(Keylet const& k, uint256 const& token);
259Keylet
260nftoffer(AccountID const& owner, std::uint32_t seq);
261
262inline Keylet
264{
265 return {ltNFTOKEN_OFFER, offer};
266}
267
269Keylet
270nft_buys(uint256 const& id) noexcept;
271
273Keylet
274nft_sells(uint256 const& id) noexcept;
275
277Keylet
278amm(Asset const& issue1, Asset const& issue2) noexcept;
279
280Keylet
281amm(uint256 const& amm) noexcept;
282
284Keylet
285delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
286
287Keylet
289
290// `seq` is stored as `sfXChainClaimID` in the object
291Keylet
293
294// `seq` is stored as `sfXChainAccountCreateCount` in the object
295Keylet
297
298Keylet
299did(AccountID const& account) noexcept;
300
301Keylet
302oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
303
304Keylet
306 AccountID const& subject,
307 AccountID const& issuer,
308 Slice const& credType) noexcept;
309
310inline Keylet
311credential(uint256 const& key) noexcept
312{
313 return {ltCREDENTIAL, key};
314}
315
316Keylet
317mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
318
319Keylet
320mptIssuance(MPTID const& issuanceID) noexcept;
321
322inline Keylet
323mptIssuance(uint256 const& issuanceKey)
324{
325 return {ltMPTOKEN_ISSUANCE, issuanceKey};
326}
327
328Keylet
329mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
330
331inline Keylet
332mptoken(uint256 const& mptokenKey)
333{
334 return {ltMPTOKEN, mptokenKey};
335}
336
337Keylet
338mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
339
340Keylet
341vault(AccountID const& owner, std::uint32_t seq) noexcept;
342
343inline Keylet
344vault(uint256 const& vaultKey)
345{
346 return {ltVAULT, vaultKey};
347}
348
349Keylet
350permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
351
352Keylet
353permissionedDomain(uint256 const& domainID) noexcept;
354} // namespace keylet
355
356// Everything below is deprecated and should be removed in favor of keylets:
357
359getBookBase(Book const& book);
360
362getQualityNext(uint256 const& uBase);
363
364// VFALCO This name could be better
366getQuality(uint256 const& uBase);
367
369getTicketIndex(AccountID const& account, std::uint32_t uSequence);
370
372getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
373
374template <class... keyletParams>
381
382// This list should include all of the keylet functions that take a single
383// AccountID parameter.
385 {{&keylet::account, jss::AccountRoot, false},
386 {&keylet::ownerDir, jss::DirectoryNode, true},
387 {&keylet::signers, jss::SignerList, true},
388 // It's normally impossible to create an item at nftpage_min, but
389 // test it anyway, since the invariant checks for it.
390 {&keylet::nftpage_min, jss::NFTokenPage, true},
391 {&keylet::nftpage_max, jss::NFTokenPage, true},
392 {&keylet::did, jss::DID, true}}};
393
394MPTID
395makeMptID(std::uint32_t sequence, AccountID const& account);
396
397} // namespace ripple
398
399#endif
Lightweight wrapper to tag static string.
Definition json_value.h:63
Specifies an order book.
Definition Book.h:36
A currency issued by an account.
Definition Issue.h:33
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:56
An immutable linear range of bytes.
Definition Slice.h:46
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:280
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:540
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:520
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:465
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:190
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:570
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:230
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:446
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:244
static next_t const next
Definition Indexes.h:152
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:214
static book_t const book
Definition Indexes.h:105
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:419
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:526
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:486
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:514
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:564
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:184
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:380
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:368
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:389
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:403
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:473
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:222
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:411
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:374
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:434
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:196
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:440
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:330
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:500
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:427
static ticket_t const ticket
Definition Indexes.h:171
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:336
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:274
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:342
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:395
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:48
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:149
base_uint< 256 > uint256
Definition base_uint.h:558
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:64
std::array< keyletDesc< AccountID const & >, 6 > const directAccountKeylets
Definition Indexes.h:384
uint256 getQualityNext(uint256 const &uBase)
Definition Indexes.cpp:141
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition Indexes.cpp:156
Number root(Number f, unsigned d)
Definition Number.cpp:636
@ credential
Credentials signature.
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:170
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:115
STL namespace.
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:39
Json::StaticString expectedLEName
Definition Indexes.h:378
std::function< Keylet(keyletParams...)> function
Definition Indexes.h:377
The beginning of an order book.
Definition Indexes.h:99
Keylet operator()(Book const &b) const
Definition Indexes.cpp:238
The directory for the next lower quality.
Definition Indexes.h:146
Keylet operator()(Keylet const &k) const
Definition Indexes.cpp:299
A ticket belonging to an account.
Definition Indexes.h:156
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition Indexes.cpp:308
Keylet operator()(uint256 const &key) const
Definition Indexes.h:166