rippled
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 <memory>
16#include <optional>
17#include <set>
18#include <utility>
19
20namespace xrpl {
21
22enum class SkipEntry : bool { No = false, Yes };
23
24//------------------------------------------------------------------------------
25//
26// Observers
27//
28//------------------------------------------------------------------------------
29
51[[nodiscard]] bool
52hasExpired(ReadView const& view, std::optional<std::uint32_t> const& exp);
53
54// Note, depth parameter is used to limit the recursion depth
55[[nodiscard]] bool
57 ReadView const& view,
58 AccountID const& account,
59 MPTIssue const& mptShare,
60 int depth);
61
62[[nodiscard]] bool
64 ReadView const& view,
65 AccountID const& account,
66 Issue const& asset,
67 Issue const& asset2);
68
69// Return the list of enabled amendments
70[[nodiscard]] std::set<uint256>
71getEnabledAmendments(ReadView const& view);
72
73// Return a map of amendments that have achieved majority
75[[nodiscard]] majorityAmendments_t
77
87[[nodiscard]] std::optional<uint256>
88hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
89
102inline LedgerIndex
104{
105 return (requested + 255) & (~255);
106}
107
113[[nodiscard]] bool
115 ReadView const& validLedger,
116 ReadView const& testLedger,
118 char const* reason);
119
120[[nodiscard]] bool
122 uint256 const& validHash,
123 LedgerIndex validIndex,
124 ReadView const& testLedger,
126 char const* reason);
127
128//------------------------------------------------------------------------------
129//
130// Modifiers
131//
132//------------------------------------------------------------------------------
133
134[[nodiscard]] TER
135dirLink(
136 ApplyView& view,
137 AccountID const& owner,
138 std::shared_ptr<SLE>& object,
139 SF_UINT64 const& node = sfOwnerNode);
140
155[[nodiscard]] TER
157 ReadView const& view,
158 AccountID const& from,
159 AccountID const& to,
160 SLE::const_ref toSle,
161 STAmount const& amount,
162 bool hasDestinationTag);
163
178[[nodiscard]] TER
180 ReadView const& view,
181 AccountID const& from,
182 AccountID const& to,
183 STAmount const& amount,
184 bool hasDestinationTag);
185
200[[nodiscard]] TER
201canWithdraw(ReadView const& view, STTx const& tx);
202
203[[nodiscard]] TER
205 ApplyView& view,
206 STTx const& tx,
207 AccountID const& senderAcct,
208 AccountID const& dstAcct,
209 AccountID const& sourceAcct,
210 XRPAmount priorBalance,
211 STAmount const& amount,
213
227[[nodiscard]] TER
229 ApplyView& view,
230 Keylet const& ownerDirKeylet,
231 EntryDeleter const& deleter,
233 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
234
241bool
243
244} // namespace xrpl
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:180
A generic endpoint for log messages.
Definition Journal.h:40
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:116
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry const > const & const_ref
T is_same_v
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:333
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:193
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, int depth)
Definition View.cpp:43
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:402
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:34
SkipEntry
Definition View.h:22
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
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:95
base_uint< 256 > uint256
Definition base_uint.h:531
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:103
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:232
TERSubset< CanCvtToTER > TER
Definition TER.h:622
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:255
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:210
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:523
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object, SF_UINT64 const &node=sfOwnerNode)
Definition View.cpp:296
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:356
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:84
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