xrpld
Loading...
Searching...
No Matches
View.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/MPTIssue.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/STLedgerEntry.h>
9#include <xrpl/protocol/STTx.h>
10#include <xrpl/protocol/TER.h>
11
12#include <cstdint>
13#include <functional>
14#include <map>
15#include <optional>
16#include <set>
17#include <utility>
18
19namespace xrpl {
20
21enum class SkipEntry : bool { No = false, Yes };
22
23//------------------------------------------------------------------------------
24//
25// Observers
26//
27//------------------------------------------------------------------------------
28
50[[nodiscard]] bool
51hasExpired(ReadView const& view, std::optional<std::uint32_t> const& exp);
52
53// Note, depth parameter is used to limit the recursion depth
54[[nodiscard]] bool
56 ReadView const& view,
57 AccountID const& account,
58 MPTIssue const& mptShare,
59 std::uint8_t depth);
60
61[[nodiscard]] bool
63 ReadView const& view,
64 AccountID const& account,
65 Asset const& asset,
66 Asset const& asset2);
67
68// Return the list of enabled amendments
69[[nodiscard]] std::set<uint256>
70getEnabledAmendments(ReadView const& view);
71
72// Return a map of amendments that have achieved majority
74[[nodiscard]] majorityAmendments_t
76
86[[nodiscard]] std::optional<uint256>
87hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
88
101inline LedgerIndex
103{
104 return (requested + 255) & (~255);
105}
106
112[[nodiscard]] bool
114 ReadView const& validLedger,
115 ReadView const& testLedger,
117 char const* reason);
118
119[[nodiscard]] bool
121 uint256 const& validHash,
122 LedgerIndex validIndex,
123 ReadView const& testLedger,
125 char const* reason);
126
127//------------------------------------------------------------------------------
128//
129// Modifiers
130//
131//------------------------------------------------------------------------------
132
133[[nodiscard]] TER
134dirLink(
135 ApplyView& view,
136 AccountID const& owner,
137 SLE::pointer& object,
138 SF_UINT64 const& node = sfOwnerNode);
139
154[[nodiscard]] TER
156 ReadView const& view,
157 AccountID const& from,
158 AccountID const& to,
159 SLE::const_ref toSle,
160 STAmount const& amount,
161 bool hasDestinationTag);
162
177[[nodiscard]] TER
179 ReadView const& view,
180 AccountID const& from,
181 AccountID const& to,
182 STAmount const& amount,
183 bool hasDestinationTag);
184
199[[nodiscard]] TER
200canWithdraw(ReadView const& view, STTx const& tx);
201
202[[nodiscard]] TER
204 ApplyView& view,
205 STTx const& tx,
206 AccountID const& senderAcct,
207 AccountID const& dstAcct,
208 AccountID const& sourceAcct,
209 XRPAmount priorBalance,
210 STAmount const& amount,
212
226[[nodiscard]] TER
228 ApplyView& view,
229 Keylet const& ownerDirKeylet,
230 EntryDeleter const& deleter,
232 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
233
240bool
242
243} // namespace xrpl
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:176
A generic endpoint for log messages.
Definition Journal.h:38
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:118
std::chrono::time_point< NetClock > time_point
Definition chrono.h:46
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry > pointer
std::shared_ptr< STLedgerEntry const > const & const_ref
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TypedField< STInteger< std::uint64_t > > SF_UINT64
Definition SField.h:336
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:231
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:259
TER doWithdraw(ApplyView &view, STTx const &tx, AccountID const &senderAcct, AccountID const &dstAcct, AccountID const &sourceAcct, XRPAmount priorBalance, STAmount const &amount, beast::Journal j)
Definition View.cpp:433
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:47
SkipEntry
Definition View.h:21
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, std::uint8_t depth)
Definition View.cpp:56
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:133
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:102
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:270
TER dirLink(ApplyView &view, AccountID const &owner, SLE::pointer &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:334
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:248
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:554
std::map< uint256, NetClock::time_point > majorityAmendments_t
Definition View.h:73
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TERSubset< CanCvtToTER > TER
Definition TER.h:634
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Asset const &asset, Asset const &asset2)
Definition View.cpp:123
std::function< std::pair< TER, SkipEntry >(LedgerEntryType, uint256 const &, SLE::pointer &)> EntryDeleter
Deleter function prototype.
Definition View.h:217
LedgerEntryType
Identifiers for on-ledger objects.
TER canWithdraw(ReadView const &view, AccountID const &from, AccountID const &to, SLE::const_ref toSle, STAmount const &amount, bool hasDestinationTag)
Checks that can withdraw funds from an object to itself or a destination.
Definition View.cpp:387
BaseUInt< 256 > uint256
Definition base_uint.h:562
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:19