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
283Keylet
284delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
285
286Keylet
288
289Keylet
291
292Keylet
294
295Keylet
296did(AccountID const& account) noexcept;
297
298Keylet
299oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
300
301Keylet
303 AccountID const& subject,
304 AccountID const& issuer,
305 Slice const& credType) noexcept;
306
307inline Keylet
308credential(uint256 const& key) noexcept
309{
310 return {ltCREDENTIAL, key};
311}
312
313Keylet
314mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
315
316Keylet
317mptIssuance(MPTID const& issuanceID) noexcept;
318
319inline Keylet
320mptIssuance(uint256 const& issuanceKey)
321{
322 return {ltMPTOKEN_ISSUANCE, issuanceKey};
323}
324
325Keylet
326mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
327
328inline Keylet
329mptoken(uint256 const& mptokenKey)
330{
331 return {ltMPTOKEN, mptokenKey};
332}
333
334Keylet
335mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
336
337Keylet
338vault(AccountID const& owner, std::uint32_t seq) noexcept;
339
340inline Keylet
341vault(uint256 const& vaultKey)
342{
343 return {ltVAULT, vaultKey};
344}
345
346Keylet
347permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
348
349Keylet
350permissionedDomain(uint256 const& domainID) noexcept;
351} // namespace keylet
352
353// Everything below is deprecated and should be removed in favor of keylets:
354
356getBookBase(Book const& book);
357
359getQualityNext(uint256 const& uBase);
360
361// VFALCO This name could be better
363getQuality(uint256 const& uBase);
364
366getTicketIndex(AccountID const& account, std::uint32_t uSequence);
367
369getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
370
371template <class... keyletParams>
373{
374 std::function<Keylet(keyletParams...)> function;
377};
378
379// This list should include all of the keylet functions that take a single
380// AccountID parameter.
382 {{&keylet::account, jss::AccountRoot, false},
383 {&keylet::ownerDir, jss::DirectoryNode, true},
384 {&keylet::signers, jss::SignerList, true},
385 // It's normally impossible to create an item at nftpage_min, but
386 // test it anyway, since the invariant checks for it.
387 {&keylet::nftpage_min, jss::NFTokenPage, true},
388 {&keylet::nftpage_max, jss::NFTokenPage, true},
389 {&keylet::did, jss::DID, true}}};
390
391MPTID
392makeMptID(std::uint32_t sequence, AccountID const& account);
393
394} // namespace ripple
395
396#endif
Lightweight wrapper to tag static string.
Definition: json_value.h:64
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:273
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition: Indexes.cpp:533
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition: Indexes.cpp:183
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition: Indexes.cpp:563
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition: Indexes.cpp:223
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:237
static next_t const next
Definition: Indexes.h:151
Keylet const & amendments() noexcept
The index of the amendment table.
Definition: Indexes.cpp:207
static book_t const book
Definition: Indexes.h:104
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition: Indexes.cpp:412
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition: Indexes.cpp:519
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition: Indexes.cpp:479
Keylet did(AccountID const &account) noexcept
Definition: Indexes.cpp:507
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition: Indexes.cpp:557
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition: Indexes.cpp:177
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition: Indexes.cpp:373
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition: Indexes.cpp:361
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition: Indexes.cpp:382
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition: Indexes.cpp:396
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition: Indexes.cpp:466
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition: Indexes.cpp:215
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition: Indexes.cpp:404
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:367
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition: Indexes.cpp:427
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition: Indexes.cpp:189
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition: Indexes.cpp:433
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition: Indexes.cpp:323
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition: Indexes.cpp:493
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition: Indexes.cpp:420
static ticket_t const ticket
Definition: Indexes.h:170
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition: Indexes.cpp:267
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition: Indexes.cpp:335
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition: Indexes.cpp:388
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:142
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:381
uint256 getQualityNext(uint256 const &uBase)
Definition: Indexes.cpp:134
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition: Indexes.cpp:149
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:163
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:375
std::function< Keylet(keyletParams...)> function
Definition: Indexes.h:374
The beginning of an order book.
Definition: Indexes.h:98
Keylet operator()(Book const &b) const
Definition: Indexes.cpp:231
The directory for the next lower quality.
Definition: Indexes.h:145
Keylet operator()(Keylet const &k) const
Definition: Indexes.cpp:292
A ticket belonging to an account.
Definition: Indexes.h:155
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition: Indexes.cpp:301
Keylet operator()(uint256 const &key) const
Definition: Indexes.h:165
Set the sequence number on a JTx.
Definition: seq.h:34