rippled
Loading...
Searching...
No Matches
applySteps.h
1#ifndef XRPL_TX_APPLYSTEPS_H_INCLUDED
2#define XRPL_TX_APPLYSTEPS_H_INCLUDED
3
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/ApplyViewImpl.h>
6
7namespace ripple {
8
9class Application;
10class STTx;
11class TxQ;
12
24
28inline bool
30{
31 return isTecClaim(ter) && !(flags & tapRETRY);
32}
33
39{
40public:
43 enum Category {
45 normal = 0,
49 };
50
51private:
63
64public:
65 // Constructor if preflight returns a value other than tesSUCCESS.
66 // Asserts if tesSUCCESS is passed.
67 explicit TxConsequences(NotTEC pfresult);
68
70 explicit TxConsequences(STTx const& tx);
71
73 TxConsequences(STTx const& tx, Category category);
74
77
80
82 TxConsequences(TxConsequences const&) = default;
85 operator=(TxConsequences const&) = default;
91
94 fee() const
95 {
96 return fee_;
97 }
98
100 XRPAmount const&
102 {
103 return potentialSpend_;
104 }
105
108 seqProxy() const
109 {
110 return seqProx_;
111 }
112
116 {
117 return sequencesConsumed_;
118 }
119
121 bool
122 isBlocker() const
123 {
124 return isBlocker_;
125 }
126
127 // Return the SeqProxy that would follow this.
130 {
131 SeqProxy following = seqProx_;
132 following.advanceBy(sequencesConsumed());
133 return following;
134 }
135};
136
144{
145public:
147 STTx const& tx;
158
160 NotTEC const ter;
161
163 template <class Context>
165 Context const& ctx_,
167 : tx(ctx_.tx)
169 , rules(ctx_.rules)
170 , consequences(result.second)
171 , flags(ctx_.flags)
172 , j(ctx_.j)
173 , ter(result.first)
174 {
175 }
176
180 operator=(PreflightResult const&) = delete;
181};
182
190{
191public:
195 STTx const& tx;
202
204 TER const ter;
205
209
211 template <class Context>
212 PreclaimResult(Context const& ctx_, TER ter_)
213 : view(ctx_.view)
214 , tx(ctx_.tx)
216 , flags(ctx_.flags)
217 , j(ctx_.j)
218 , ter(ter_)
220 {
221 }
222
226 operator=(PreclaimResult const&) = delete;
227};
228
248 Application& app,
249 Rules const& rules,
250 STTx const& tx,
251 ApplyFlags flags,
253
256 Application& app,
257 Rules const& rules,
258 uint256 const& parentBatchId,
259 STTx const& tx,
260 ApplyFlags flags,
294 PreflightResult const& preflightResult,
295 Application& app,
296 OpenView const& view);
297
315calculateBaseFee(ReadView const& view, STTx const& tx);
316
329calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
330
348doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view);
349
350} // namespace ripple
351
352#endif
A generic endpoint for log messages.
Definition Journal.h:41
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:46
A view into a ledger.
Definition ReadView.h:32
Rules controlling protocol behavior.
Definition Rules.h:19
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:37
SeqProxy & advanceBy(std::uint32_t amount)
Definition SeqProxy.h:85
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:39
XRPAmount fee_
Transaction fee.
Definition applySteps.h:56
std::uint32_t sequencesConsumed() const
Sequences consumed.
Definition applySteps.h:115
TxConsequences(TxConsequences &&)=default
Move constructor.
TxConsequences & operator=(TxConsequences &&)=default
Move assignment operator.
TxConsequences(TxConsequences const &)=default
Copy constructor.
SeqProxy followingSeq() const
Definition applySteps.h:129
std::uint32_t sequencesConsumed_
Number of sequences consumed.
Definition applySteps.h:62
XRPAmount const & potentialSpend() const
Potential Spend.
Definition applySteps.h:101
SeqProxy seqProxy() const
SeqProxy.
Definition applySteps.h:108
XRPAmount fee() const
Fee.
Definition applySteps.h:94
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:54
TxConsequences & operator=(TxConsequences const &)=default
Copy assignment operator.
bool isBlocker() const
Returns true if the transaction is a blocker.
Definition applySteps.h:122
Category
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:43
@ normal
Moves currency around, creates offers, etc.
Definition applySteps.h:45
@ blocker
Affects the ability of subsequent transactions to claim a fee.
Definition applySteps.h:48
XRPAmount potentialSpend_
Does NOT include the fee.
Definition applySteps.h:58
SeqProxy seqProx_
SeqProxy of transaction.
Definition applySteps.h:60
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
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 calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
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:29
@ tesSUCCESS
Definition TER.h:226
@ tapRETRY
Definition ApplyView.h:20
bool isTecClaim(TER x) noexcept
Definition TER.h:666
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
STL namespace.
ApplyResult(TER t, bool a, std::optional< TxMeta > m=std::nullopt)
Definition applySteps.h:19
std::optional< TxMeta > metadata
Definition applySteps.h:17
Describes the results of the preclaim check.
Definition applySteps.h:190
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:199
TER const ter
Intermediate transaction result.
Definition applySteps.h:204
PreclaimResult & operator=(PreclaimResult const &)=delete
Deleted copy assignment operator.
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
Definition applySteps.h:208
ReadView const & view
From the input - the ledger view.
Definition applySteps.h:193
PreclaimResult(Context const &ctx_, TER ter_)
Constructor.
Definition applySteps.h:212
beast::Journal const j
From the input - the journal.
Definition applySteps.h:201
PreclaimResult(PreclaimResult const &)=default
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:197
STTx const & tx
From the input - the transaction.
Definition applySteps.h:195
Describes the results of the preflight check.
Definition applySteps.h:144
Rules const rules
From the input - the rules.
Definition applySteps.h:151
PreflightResult & operator=(PreflightResult const &)=delete
Deleted copy assignment operator.
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:155
PreflightResult(PreflightResult const &)=default
beast::Journal const j
From the input - the journal.
Definition applySteps.h:157
NotTEC const ter
Intermediate transaction result.
Definition applySteps.h:160
PreflightResult(Context const &ctx_, std::pair< NotTEC, TxConsequences > const &result)
Constructor.
Definition applySteps.h:164
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:149
TxConsequences const consequences
Consequences of the transaction.
Definition applySteps.h:153
STTx const & tx
From the input - the transaction.
Definition applySteps.h:147