rippled
Loading...
Searching...
No Matches
applySteps.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ApplyViewImpl.h>
5
6namespace xrpl {
7
8class Application;
9class STTx;
10class TxQ;
11
22
26inline bool
28{
29 return isTecClaim(ter) && !(flags & tapRETRY);
30}
31
37{
38public:
41 enum Category {
43 normal = 0,
47 };
48
49private:
61
62public:
63 // Constructor if preflight returns a value other than tesSUCCESS.
64 // Asserts if tesSUCCESS is passed.
65 explicit TxConsequences(NotTEC pfResult);
66
68 explicit TxConsequences(STTx const& tx);
69
71 TxConsequences(STTx const& tx, Category category);
72
75
78
80 TxConsequences(TxConsequences const&) = default;
83 operator=(TxConsequences const&) = default;
89
92 fee() const
93 {
94 return fee_;
95 }
96
98 XRPAmount const&
100 {
101 return potentialSpend_;
102 }
103
106 seqProxy() const
107 {
108 return seqProx_;
109 }
110
114 {
115 return sequencesConsumed_;
116 }
117
119 bool
120 isBlocker() const
121 {
122 return isBlocker_;
123 }
124
125 // Return the SeqProxy that would follow this.
128 {
129 SeqProxy following = seqProx_;
130 following.advanceBy(sequencesConsumed());
131 return following;
132 }
133};
134
142{
143public:
145 STTx const& tx;
156
158 NotTEC const ter;
159
161 template <class Context>
162 PreflightResult(Context const& ctx_, std::pair<NotTEC, TxConsequences> const& result)
163 : tx(ctx_.tx)
165 , rules(ctx_.rules)
166 , consequences(result.second)
167 , flags(ctx_.flags)
168 , j(ctx_.j)
169 , ter(result.first)
170 {
171 }
172
176 operator=(PreflightResult const&) = delete;
177};
178
186{
187public:
191 STTx const& tx;
198
200 TER const ter;
201
205
207 template <class Context>
208 PreclaimResult(Context const& ctx_, TER ter_)
209 : view(ctx_.view)
210 , tx(ctx_.tx)
212 , flags(ctx_.flags)
213 , j(ctx_.j)
214 , ter(ter_)
216 {
217 }
218
222 operator=(PreclaimResult const&) = delete;
223};
224
243preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j);
244
247 Application& app,
248 Rules const& rules,
249 uint256 const& parentBatchId,
250 STTx const& tx,
251 ApplyFlags flags,
284preclaim(PreflightResult const& preflightResult, Application& app, OpenView const& view);
285
303calculateBaseFee(ReadView const& view, STTx const& tx);
304
317calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
318
336doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view);
337
338} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:45
A view into a ledger.
Definition ReadView.h:31
Rules controlling protocol behavior.
Definition Rules.h:18
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:36
SeqProxy & advanceBy(std::uint32_t amount)
Definition SeqProxy.h:84
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:37
std::uint32_t sequencesConsumed_
Number of sequences consumed.
Definition applySteps.h:60
Category
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:41
@ normal
Moves currency around, creates offers, etc.
Definition applySteps.h:43
@ blocker
Affects the ability of subsequent transactions to claim a fee.
Definition applySteps.h:46
SeqProxy seqProxy() const
SeqProxy.
Definition applySteps.h:106
XRPAmount potentialSpend_
Does NOT include the fee.
Definition applySteps.h:56
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:52
bool isBlocker() const
Returns true if the transaction is a blocker.
Definition applySteps.h:120
std::uint32_t sequencesConsumed() const
Sequences consumed.
Definition applySteps.h:113
XRPAmount const & potentialSpend() const
Potential Spend.
Definition applySteps.h:99
TxConsequences & operator=(TxConsequences const &)=default
Copy assignment operator.
SeqProxy followingSeq() const
Definition applySteps.h:127
SeqProxy seqProx_
SeqProxy of transaction.
Definition applySteps.h:58
XRPAmount fee_
Transaction fee.
Definition applySteps.h:54
TxConsequences & operator=(TxConsequences &&)=default
Move assignment operator.
TxConsequences(TxConsequences const &)=default
Copy constructor.
TxConsequences(TxConsequences &&)=default
Move constructor.
XRPAmount fee() const
Fee.
Definition applySteps.h:92
T is_same_v
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool isTecClaimHardFail(TER ter, ApplyFlags flags)
Return true if the transaction can claim a fee (tec), and the ApplyFlags do not allow soft failures.
Definition applySteps.h:27
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
ApplyResult doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
ApplyFlags
Definition ApplyView.h:10
@ tapRETRY
Definition ApplyView.h:19
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
bool isTecClaim(TER x) noexcept
Definition TER.h:656
@ tesSUCCESS
Definition TER.h:225
std::optional< TxMeta > metadata
Definition applySteps.h:16
ApplyResult(TER t, bool a, std::optional< TxMeta > m=std::nullopt)
Definition applySteps.h:18
Describes the results of the preclaim check.
Definition applySteps.h:186
ReadView const & view
From the input - the ledger view.
Definition applySteps.h:189
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:193
TER const ter
Intermediate transaction result.
Definition applySteps.h:200
PreclaimResult(Context const &ctx_, TER ter_)
Constructor.
Definition applySteps.h:208
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:195
PreclaimResult(PreclaimResult const &)=default
STTx const & tx
From the input - the transaction.
Definition applySteps.h:191
PreclaimResult & operator=(PreclaimResult const &)=delete
Deleted copy assignment operator.
beast::Journal const j
From the input - the journal.
Definition applySteps.h:197
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
Definition applySteps.h:204
Describes the results of the preflight check.
Definition applySteps.h:142
TxConsequences const consequences
Consequences of the transaction.
Definition applySteps.h:151
PreflightResult & operator=(PreflightResult const &)=delete
Deleted copy assignment operator.
beast::Journal const j
From the input - the journal.
Definition applySteps.h:155
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:153
Rules const rules
From the input - the rules.
Definition applySteps.h:149
NotTEC const ter
Intermediate transaction result.
Definition applySteps.h:158
PreflightResult(PreflightResult const &)=default
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:147
STTx const & tx
From the input - the transaction.
Definition applySteps.h:145
PreflightResult(Context const &ctx_, std::pair< NotTEC, TxConsequences > const &result)
Constructor.
Definition applySteps.h:162