xrpld
Loading...
Searching...
No Matches
View.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/ledger/ApplyView.h>
7#include <xrpl/ledger/ReadView.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/Asset.h>
10#include <xrpl/protocol/Keylet.h>
11#include <xrpl/protocol/LedgerFormats.h>
12#include <xrpl/protocol/MPTIssue.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/STAmount.h>
16#include <xrpl/protocol/STLedgerEntry.h>
17#include <xrpl/protocol/STTx.h>
18#include <xrpl/protocol/TER.h>
19#include <xrpl/protocol/XRPAmount.h>
20
21#include <cstdint>
22#include <functional>
23#include <map>
24#include <optional>
25#include <set>
26#include <utility>
27#include <vector>
28
29namespace xrpl {
30
31enum class SkipEntry : bool { No = false, Yes };
32
33//------------------------------------------------------------------------------
34//
35// Observers
36//
37//------------------------------------------------------------------------------
38
43
68[[nodiscard]] bool
70 ReadView const& view,
73
74// Note, depth parameter is used to limit the recursion depth
75[[nodiscard]] bool
77 ReadView const& view,
78 AccountID const& account,
79 MPTIssue const& mptShare,
80 std::uint8_t depth);
81
82[[nodiscard]] bool
84 ReadView const& view,
85 AccountID const& account,
86 SLE const& issuanceSle,
87 std::uint8_t depth);
88
89[[nodiscard]] bool
91 ReadView const& view,
92 AccountID const& account,
93 Asset const& asset,
94 Asset const& asset2);
95
109[[nodiscard]] TER
111 ReadView const& view,
112 AccountID const& from,
113 AccountID const& to,
114 AccountID const& lpTokenIssuer);
115
116// Return the list of enabled amendments
117[[nodiscard]] std::set<UInt256>
118getEnabledAmendments(ReadView const& view);
119
120// Return a map of amendments that have achieved majority
122[[nodiscard]] MajorityAmendmentsT
124
135[[nodiscard]] std::optional<UInt256>
136hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
137
151inline LedgerIndex
153{
154 return (requested + 255) & (~255);
155}
156
163[[nodiscard]] bool
165 ReadView const& validLedger,
166 ReadView const& testLedger,
168 char const* reason);
169
170[[nodiscard]] bool
172 UInt256 const& validHash,
173 LedgerIndex validIndex,
174 ReadView const& testLedger,
176 char const* reason);
177
178//------------------------------------------------------------------------------
179//
180// Modifiers
181//
182//------------------------------------------------------------------------------
183
184[[nodiscard]] TER
185dirLink(
186 ApplyView& view,
187 AccountID const& owner,
188 SLE::pointer& object,
189 SF_UINT64 const& node = sfOwnerNode);
190
209[[nodiscard]] TER
211 ReadView const& view,
212 AccountID const& from,
213 AccountID const& to,
214 SLE::ConstRef toSle,
215 STAmount const& amount,
216 bool hasDestinationTag,
217 std::optional<std::vector<UInt256>> const& credentialIDs = std::nullopt);
218
237[[nodiscard]] TER
239 ReadView const& view,
240 AccountID const& from,
241 AccountID const& to,
242 STAmount const& amount,
243 bool hasDestinationTag,
244 std::optional<std::vector<UInt256>> const& credentialIDs = std::nullopt);
245
265[[nodiscard]] TER
266canWithdraw(ReadView const& view, STTx const& tx);
267
268[[nodiscard]] TER
270 ApplyViewContext ctx,
271 AccountID const& senderAcct,
272 AccountID const& dstAcct,
273 AccountID const& sourceAcct,
274 XRPAmount priorBalance,
275 STAmount const& amount,
277
293[[nodiscard]] TER
295 ApplyView& view,
296 Keylet const& ownerDirKeylet,
297 EntryDeleter const& deleter,
299 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
300
308bool
310
311} // namespace xrpl
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:199
A generic endpoint for log messages.
Definition Journal.h:44
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:141
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & ConstRef
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::optional< UInt256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:323
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp, ExpiryComparison comparison=ExpiryComparison::Inclusive)
Determines whether the given expiration time has passed.
Definition View.cpp:51
TypedField< STInteger< std::uint64_t > > SF_UINT64
Definition SField.h:345
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:382
std::set< UInt256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:311
SkipEntry
Definition View.h:31
ExpiryComparison
Whether an expiration check should be inclusive or exclusive.
Definition View.h:42
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, std::uint8_t depth)
Definition View.cpp:159
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
Definition View.cpp:213
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:152
STLedgerEntry SLE
@ Yes
We have consensus along with the network.
@ No
We do not have consensus.
TER doWithdraw(ApplyViewContext ctx, AccountID const &senderAcct, AccountID const &dstAcct, AccountID const &sourceAcct, XRPAmount priorBalance, STAmount const &amount, beast::Journal j)
Definition View.cpp:507
BaseUInt< 256 > UInt256
Definition base_uint.h:580
TER canTransferLPToken(ReadView const &view, AccountID const &from, AccountID const &to, AccountID const &lpTokenIssuer)
Check whether an AMM LPToken may be transferred between from and to.
Definition View.cpp:186
TER dirLink(ApplyView &view, AccountID const &owner, SLE::pointer &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:384
TER canWithdraw(ReadView const &view, AccountID const &from, AccountID const &to, SLE::ConstRef toSle, STAmount const &amount, bool hasDestinationTag, std::optional< std::vector< UInt256 > > const &credentialIDs=std::nullopt)
Checks that can withdraw funds from an object to itself or a destination.
Definition View.cpp:437
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:644
std::map< UInt256, NetClock::time_point > MajorityAmendmentsT
Definition View.h:121
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
std::function< std::pair< TER, SkipEntry >(LedgerEntryType, UInt256 const &, SLE::pointer &)> EntryDeleter
Deleter function prototype.
Definition View.h:283
TERSubset< CanCvtToTER > TER
Definition TER.h:654
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Asset const &asset, Asset const &asset2)
Definition View.cpp:176
LedgerEntryType
Identifiers for on-ledger objects.
MajorityAmendmentsT getMajorityAmendments(ReadView const &view)
Definition View.cpp:317
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< std::uint16_t > maxNodesToDelete=std::nullopt)
Cleanup owner directory entries on account delete.
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20