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
36namespace ripple {
37
38class SeqProxy;
53namespace keylet {
54
57account(AccountID const& id) noexcept;
58
60Keylet const&
61amendments() noexcept;
62
65child(uint256 const& key) noexcept;
66
72Keylet const&
73skip() noexcept;
74
86skip(LedgerIndex ledger) noexcept;
87
89Keylet const&
90fees() noexcept;
91
93Keylet const&
94negativeUNL() noexcept;
95
97struct book_t
98{
99 explicit book_t() = default;
100
101 Keylet
102 operator()(Book const& b) const;
103};
104static book_t const book{};
105
114Keylet
115line(
116 AccountID const& id0,
117 AccountID const& id1,
118 Currency const& currency) noexcept;
119
120inline Keylet
121line(AccountID const& id, Issue const& issue) noexcept
122{
123 return line(id, issue.account, issue.currency);
124}
129Keylet
130offer(AccountID const& id, std::uint32_t seq) noexcept;
131
132inline Keylet
133offer(uint256 const& key) noexcept
134{
135 return {ltOFFER, key};
136}
140Keylet
141quality(Keylet const& k, std::uint64_t q) noexcept;
142
144struct next_t
145{
146 explicit next_t() = default;
147
148 Keylet
149 operator()(Keylet const& k) const;
150};
151static next_t const next{};
152
155{
156 explicit ticket_t() = default;
157
158 Keylet
159 operator()(AccountID const& id, std::uint32_t ticketSeq) const;
160
161 Keylet
162 operator()(AccountID const& id, SeqProxy ticketSeq) const;
163
164 Keylet
165 operator()(uint256 const& key) const
166 {
167 return {ltTICKET, key};
168 }
169};
170static ticket_t const ticket{};
171
173Keylet
174signers(AccountID const& account) noexcept;
175
178Keylet
179check(AccountID const& id, std::uint32_t seq) noexcept;
180
181inline Keylet
182check(uint256 const& key) noexcept
183{
184 return {ltCHECK, key};
185}
190Keylet
191depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
192
193Keylet
195 AccountID const& owner,
196 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
197
198inline Keylet
199depositPreauth(uint256 const& key) noexcept
200{
201 return {ltDEPOSIT_PREAUTH, key};
202}
205//------------------------------------------------------------------------------
206
208Keylet
209unchecked(uint256 const& key) noexcept;
210
212Keylet
213ownerDir(AccountID const& id) noexcept;
214
217Keylet
218page(uint256 const& root, std::uint64_t index = 0) noexcept;
219
220inline Keylet
221page(Keylet const& root, std::uint64_t index = 0) noexcept
222{
223 XRPL_ASSERT(
224 root.type == ltDIR_NODE, "ripple::keylet::page : valid root type");
225 return page(root.key, index);
226}
230Keylet
231escrow(AccountID const& src, std::uint32_t seq) noexcept;
232
234Keylet
235payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
236
246Keylet
247nftpage_min(AccountID const& owner);
248
250Keylet
251nftpage_max(AccountID const& owner);
252
253Keylet
254nftpage(Keylet const& k, uint256 const& token);
258Keylet
259nftoffer(AccountID const& owner, std::uint32_t seq);
260
261inline Keylet
263{
264 return {ltNFTOKEN_OFFER, offer};
265}
266
268Keylet
269nft_buys(uint256 const& id) noexcept;
270
272Keylet
273nft_sells(uint256 const& id) noexcept;
274
276Keylet
277amm(Asset const& issue1, Asset const& issue2) noexcept;
278
279Keylet
280amm(uint256 const& amm) noexcept;
281
282Keylet
284
285Keylet
287
288Keylet
290
291Keylet
292did(AccountID const& account) noexcept;
293
294Keylet
295oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
296
297Keylet
299 AccountID const& subject,
300 AccountID const& issuer,
301 Slice const& credType) noexcept;
302
303inline Keylet
304credential(uint256 const& key) noexcept
305{
306 return {ltCREDENTIAL, key};
307}
308
309Keylet
310mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
311
312Keylet
313mptIssuance(MPTID const& issuanceID) noexcept;
314
315inline Keylet
316mptIssuance(uint256 const& issuanceKey)
317{
318 return {ltMPTOKEN_ISSUANCE, issuanceKey};
319}
320
321Keylet
322mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
323
324inline Keylet
325mptoken(uint256 const& mptokenKey)
326{
327 return {ltMPTOKEN, mptokenKey};
328}
329
330Keylet
331mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
332
333Keylet
334permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
335
336Keylet
337permissionedDomain(uint256 const& domainID) noexcept;
338} // namespace keylet
339
340// Everything below is deprecated and should be removed in favor of keylets:
341
343getBookBase(Book const& book);
344
346getQualityNext(uint256 const& uBase);
347
348// VFALCO This name could be better
350getQuality(uint256 const& uBase);
351
353getTicketIndex(AccountID const& account, std::uint32_t uSequence);
354
356getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
357
358template <class... keyletParams>
360{
361 std::function<Keylet(keyletParams...)> function;
364};
365
366// This list should include all of the keylet functions that take a single
367// AccountID parameter.
369 {{&keylet::account, jss::AccountRoot, false},
370 {&keylet::ownerDir, jss::DirectoryNode, true},
371 {&keylet::signers, jss::SignerList, true},
372 // It's normally impossible to create an item at nftpage_min, but
373 // test it anyway, since the invariant checks for it.
374 {&keylet::nftpage_min, jss::NFTokenPage, true},
375 {&keylet::nftpage_max, jss::NFTokenPage, true},
376 {&keylet::did, jss::DID, true}}};
377
378MPTID
379makeMptID(std::uint32_t sequence, AccountID const& account);
380
381} // namespace ripple
382
383#endif
Lightweight wrapper to tag static string.
Definition: json_value.h:62
Specifies an order book.
Definition: Book.h:35
A currency issued by an account.
Definition: Issue.h:36
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:271
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition: Indexes.cpp:523
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition: Indexes.cpp:503
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition: Indexes.cpp:181
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition: Indexes.cpp:547
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition: Indexes.cpp:221
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition: Indexes.cpp:437
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:235
static next_t const next
Definition: Indexes.h:151
Keylet const & amendments() noexcept
The index of the amendment table.
Definition: Indexes.cpp:205
static book_t const book
Definition: Indexes.h:104
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition: Indexes.cpp:410
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition: Indexes.cpp:509
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition: Indexes.cpp:469
Keylet did(AccountID const &account) noexcept
Definition: Indexes.cpp:497
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition: Indexes.cpp:175
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition: Indexes.cpp:371
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition: Indexes.cpp:359
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition: Indexes.cpp:380
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition: Indexes.cpp:394
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition: Indexes.cpp:456
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition: Indexes.cpp:213
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition: Indexes.cpp:402
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:365
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition: Indexes.cpp:425
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition: Indexes.cpp:187
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition: Indexes.cpp:431
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition: Indexes.cpp:321
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition: Indexes.cpp:483
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition: Indexes.cpp:418
static ticket_t const ticket
Definition: Indexes.h:170
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition: Indexes.cpp:327
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition: Indexes.cpp:265
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition: Indexes.cpp:333
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition: Indexes.cpp:386
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:49
std::uint64_t getQuality(uint256 const &uBase)
Definition: Indexes.cpp:140
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:368
uint256 getQualityNext(uint256 const &uBase)
Definition: Indexes.cpp:132
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition: Indexes.cpp:147
Number root(Number f, unsigned d)
Definition: Number.cpp:635
@ credential
Credentials signature.
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition: Indexes.cpp:161
uint256 getBookBase(Book const &book)
Definition: Indexes.cpp:113
STL namespace.
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:39
Json::StaticString expectedLEName
Definition: Indexes.h:362
std::function< Keylet(keyletParams...)> function
Definition: Indexes.h:361
The beginning of an order book.
Definition: Indexes.h:98
Keylet operator()(Book const &b) const
Definition: Indexes.cpp:229
The directory for the next lower quality.
Definition: Indexes.h:145
Keylet operator()(Keylet const &k) const
Definition: Indexes.cpp:290
A ticket belonging to an account.
Definition: Indexes.h:155
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition: Indexes.cpp:299
Keylet operator()(uint256 const &key) const
Definition: Indexes.h:165