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 ServiceRegistry;
9class STTx;
10class TxQ;
11
23
27inline bool
29{
30 return isTecClaim(ter) && !(flags & tapRETRY);
31}
32
38{
39public:
42 enum Category {
44 normal = 0,
48 };
49
50private:
62
63public:
64 // Constructor if preflight returns a value other than tesSUCCESS.
65 // Asserts if tesSUCCESS is passed.
66 explicit TxConsequences(NotTEC pfResult);
67
69 explicit TxConsequences(STTx const& tx);
70
72 TxConsequences(STTx const& tx, Category category);
73
76
79
81 TxConsequences(TxConsequences const&) = default;
84 operator=(TxConsequences const&) = default;
90
93 fee() const
94 {
95 return fee_;
96 }
97
99 XRPAmount const&
101 {
102 return potentialSpend_;
103 }
104
107 seqProxy() const
108 {
109 return seqProx_;
110 }
111
115 {
116 return sequencesConsumed_;
117 }
118
120 bool
121 isBlocker() const
122 {
123 return isBlocker_;
124 }
125
126 // Return the SeqProxy that would follow this.
129 {
130 SeqProxy following = seqProx_;
131 following.advanceBy(sequencesConsumed());
132 return following;
133 }
134};
135
143{
144public:
146 STTx const& tx;
157
159 NotTEC const ter;
160
162 template <class Context>
163 PreflightResult(Context const& ctx_, std::pair<NotTEC, TxConsequences> const& result)
164 : tx(ctx_.tx)
166 , rules(ctx_.rules)
167 , consequences(result.second)
168 , flags(ctx_.flags)
169 , j(ctx_.j)
170 , ter(result.first)
171 {
172 }
173
177 operator=(PreflightResult const&) = delete;
178};
179
187{
188public:
192 STTx const& tx;
199
201 TER const ter;
202
206
208 template <class Context>
209 PreclaimResult(Context const& ctx_, TER ter_)
210 : view(ctx_.view)
211 , tx(ctx_.tx)
213 , flags(ctx_.flags)
214 , j(ctx_.j)
215 , ter(ter_)
217 {
218 }
219
223 operator=(PreclaimResult const&) = delete;
224};
225
245 ServiceRegistry& registry,
246 Rules const& rules,
247 STTx const& tx,
248 ApplyFlags flags,
250
253 ServiceRegistry& registry,
254 Rules const& rules,
255 uint256 const& parentBatchId,
256 STTx const& tx,
257 ApplyFlags flags,
290preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, OpenView const& view);
291
309calculateBaseFee(ReadView const& view, STTx const& tx);
310
323calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
324
342doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenView& view);
343
344} // 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
Service registry for dependency injection.
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:38
std::uint32_t sequencesConsumed_
Number of sequences consumed.
Definition applySteps.h:61
Category
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:42
@ normal
Moves currency around, creates offers, etc.
Definition applySteps.h:44
@ blocker
Affects the ability of subsequent transactions to claim a fee.
Definition applySteps.h:47
SeqProxy seqProxy() const
SeqProxy.
Definition applySteps.h:107
XRPAmount potentialSpend_
Does NOT include the fee.
Definition applySteps.h:57
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:53
bool isBlocker() const
Returns true if the transaction is a blocker.
Definition applySteps.h:121
std::uint32_t sequencesConsumed() const
Sequences consumed.
Definition applySteps.h:114
XRPAmount const & potentialSpend() const
Potential Spend.
Definition applySteps.h:100
TxConsequences & operator=(TxConsequences const &)=default
Copy assignment operator.
SeqProxy followingSeq() const
Definition applySteps.h:128
SeqProxy seqProx_
SeqProxy of transaction.
Definition applySteps.h:59
XRPAmount fee_
Transaction fee.
Definition applySteps.h:55
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:93
T is_same_v
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
PreflightResult preflight(ServiceRegistry &registry, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
PreclaimResult preclaim(PreflightResult const &preflightResult, ServiceRegistry &registry, 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:28
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
bool isTesSuccess(TER x) noexcept
Definition TER.h:651
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:658
ApplyResult doApply(PreclaimResult const &preclaimResult, ServiceRegistry &registry, OpenView &view)
Apply a prechecked transaction to an OpenView.
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:187
ReadView const & view
From the input - the ledger view.
Definition applySteps.h:190
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:194
TER const ter
Intermediate transaction result.
Definition applySteps.h:201
PreclaimResult(Context const &ctx_, TER ter_)
Constructor.
Definition applySteps.h:209
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:196
PreclaimResult(PreclaimResult const &)=default
STTx const & tx
From the input - the transaction.
Definition applySteps.h:192
PreclaimResult & operator=(PreclaimResult const &)=delete
Deleted copy assignment operator.
beast::Journal const j
From the input - the journal.
Definition applySteps.h:198
bool const likelyToClaimFee
Success flag - whether the transaction is likely to claim a fee.
Definition applySteps.h:205
Describes the results of the preflight check.
Definition applySteps.h:143
TxConsequences const consequences
Consequences of the transaction.
Definition applySteps.h:152
PreflightResult & operator=(PreflightResult const &)=delete
Deleted copy assignment operator.
beast::Journal const j
From the input - the journal.
Definition applySteps.h:156
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:154
Rules const rules
From the input - the rules.
Definition applySteps.h:150
NotTEC const ter
Intermediate transaction result.
Definition applySteps.h:159
PreflightResult(PreflightResult const &)=default
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:148
STTx const & tx
From the input - the transaction.
Definition applySteps.h:146
PreflightResult(Context const &ctx_, std::pair< NotTEC, TxConsequences > const &result)
Constructor.
Definition applySteps.h:163