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
28namespace xrpl {
29
30enum class SkipEntry : bool { No = false, Yes };
31
32//------------------------------------------------------------------------------
33//
34// Observers
35//
36//------------------------------------------------------------------------------
37
42
67[[nodiscard]] bool
69 ReadView const& view,
72
73// Note, depth parameter is used to limit the recursion depth
74[[nodiscard]] bool
76 ReadView const& view,
77 AccountID const& account,
78 MPTIssue const& mptShare,
79 std::uint8_t depth);
80
81[[nodiscard]] bool
83 ReadView const& view,
84 AccountID const& account,
85 Asset const& asset,
86 Asset const& asset2);
87
88// Return the list of enabled amendments
89[[nodiscard]] std::set<uint256>
90getEnabledAmendments(ReadView const& view);
91
92// Return a map of amendments that have achieved majority
94[[nodiscard]] majorityAmendments_t
96
107[[nodiscard]] std::optional<uint256>
108hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
109
123inline LedgerIndex
125{
126 return (requested + 255) & (~255);
127}
128
135[[nodiscard]] bool
137 ReadView const& validLedger,
138 ReadView const& testLedger,
140 char const* reason);
141
142[[nodiscard]] bool
144 uint256 const& validHash,
145 LedgerIndex validIndex,
146 ReadView const& testLedger,
148 char const* reason);
149
150//------------------------------------------------------------------------------
151//
152// Modifiers
153//
154//------------------------------------------------------------------------------
155
156[[nodiscard]] TER
157dirLink(
158 ApplyView& view,
159 AccountID const& owner,
160 SLE::pointer& object,
161 SF_UINT64 const& node = sfOwnerNode);
162
178[[nodiscard]] TER
180 ReadView const& view,
181 AccountID const& from,
182 AccountID const& to,
183 SLE::const_ref toSle,
184 STAmount const& amount,
185 bool hasDestinationTag);
186
202[[nodiscard]] TER
204 ReadView const& view,
205 AccountID const& from,
206 AccountID const& to,
207 STAmount const& amount,
208 bool hasDestinationTag);
209
225[[nodiscard]] TER
226canWithdraw(ReadView const& view, STTx const& tx);
227
228[[nodiscard]] TER
230 ApplyViewContext ctx,
231 AccountID const& senderAcct,
232 AccountID const& dstAcct,
233 AccountID const& sourceAcct,
234 XRPAmount priorBalance,
235 STAmount const& amount,
237
253[[nodiscard]] TER
255 ApplyView& view,
256 Keylet const& ownerDirKeylet,
257 EntryDeleter const& deleter,
259 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
260
268bool
270
271} // 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:134
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 & const_ref
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
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:48
TypedField< STInteger< std::uint64_t > > SF_UINT64
Definition SField.h:342
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:240
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:370
SkipEntry
Definition View.h:30
ExpiryComparison
Whether an expiration check should be inclusive or exclusive.
Definition View.h:41
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, std::uint8_t depth)
Definition View.cpp:65
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:142
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:124
@ 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:442
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:279
TER dirLink(ApplyView &view, AccountID const &owner, SLE::pointer &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:343
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:257
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:572
std::map< uint256, NetClock::time_point > majorityAmendments_t
Definition View.h:93
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
TERSubset< CanCvtToTER > TER
Definition TER.h:647
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Asset const &asset, Asset const &asset2)
Definition View.cpp:132
std::function< std::pair< TER, SkipEntry >(LedgerEntryType, uint256 const &, SLE::pointer &)> EntryDeleter
Deleter function prototype.
Definition View.h:243
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:396
BaseUInt< 256 > uint256
Definition base_uint.h:580
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