rippled
Loading...
Searching...
No Matches
applySteps.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TX_APPLYSTEPS_H_INCLUDED
21#define RIPPLE_TX_APPLYSTEPS_H_INCLUDED
22
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/ledger/ApplyViewImpl.h>
25
26namespace ripple {
27
28class Application;
29class STTx;
30class TxQ;
31
43
47inline bool
49{
50 return isTecClaim(ter) && !(flags & tapRETRY);
51}
52
58{
59public:
62 enum Category {
64 normal = 0,
68 };
69
70private:
82
83public:
84 // Constructor if preflight returns a value other than tesSUCCESS.
85 // Asserts if tesSUCCESS is passed.
86 explicit TxConsequences(NotTEC pfresult);
87
89 explicit TxConsequences(STTx const& tx);
90
92 TxConsequences(STTx const& tx, Category category);
93
96
99
104 operator=(TxConsequences const&) = default;
110
113 fee() const
114 {
115 return fee_;
116 }
117
119 XRPAmount const&
121 {
122 return potentialSpend_;
123 }
124
127 seqProxy() const
128 {
129 return seqProx_;
130 }
131
135 {
136 return sequencesConsumed_;
137 }
138
140 bool
141 isBlocker() const
142 {
143 return isBlocker_;
144 }
145
146 // Return the SeqProxy that would follow this.
149 {
150 SeqProxy following = seqProx_;
151 following.advanceBy(sequencesConsumed());
152 return following;
153 }
154};
155
163{
164public:
166 STTx const& tx;
177
179 NotTEC const ter;
180
182 template <class Context>
184 Context const& ctx_,
186 : tx(ctx_.tx)
188 , rules(ctx_.rules)
189 , consequences(result.second)
190 , flags(ctx_.flags)
191 , j(ctx_.j)
192 , ter(result.first)
193 {
194 }
195
199 operator=(PreflightResult const&) = delete;
200};
201
209{
210public:
214 STTx const& tx;
221
223 TER const ter;
224
228
230 template <class Context>
231 PreclaimResult(Context const& ctx_, TER ter_)
232 : view(ctx_.view)
233 , tx(ctx_.tx)
235 , flags(ctx_.flags)
236 , j(ctx_.j)
237 , ter(ter_)
239 {
240 }
241
245 operator=(PreclaimResult const&) = delete;
246};
247
267 Application& app,
268 Rules const& rules,
269 STTx const& tx,
270 ApplyFlags flags,
272
275 Application& app,
276 Rules const& rules,
277 uint256 const& parentBatchId,
278 STTx const& tx,
279 ApplyFlags flags,
313 PreflightResult const& preflightResult,
314 Application& app,
315 OpenView const& view);
316
334calculateBaseFee(ReadView const& view, STTx const& tx);
335
348calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
349
367doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view);
368
369} // namespace ripple
370
371#endif
A generic endpoint for log messages.
Definition Journal.h:60
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:65
A view into a ledger.
Definition ReadView.h:51
Rules controlling protocol behavior.
Definition Rules.h:38
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:56
SeqProxy & advanceBy(std::uint32_t amount)
Definition SeqProxy.h:104
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:58
XRPAmount fee_
Transaction fee.
Definition applySteps.h:75
std::uint32_t sequencesConsumed() const
Sequences consumed.
Definition applySteps.h:134
TxConsequences(TxConsequences &&)=default
Move constructor.
TxConsequences & operator=(TxConsequences &&)=default
Move assignment operator.
TxConsequences(TxConsequences const &)=default
Copy constructor.
SeqProxy followingSeq() const
Definition applySteps.h:148
std::uint32_t sequencesConsumed_
Number of sequences consumed.
Definition applySteps.h:81
XRPAmount const & potentialSpend() const
Potential Spend.
Definition applySteps.h:120
SeqProxy seqProxy() const
SeqProxy.
Definition applySteps.h:127
XRPAmount fee() const
Fee.
Definition applySteps.h:113
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:73
TxConsequences & operator=(TxConsequences const &)=default
Copy assignment operator.
bool isBlocker() const
Returns true if the transaction is a blocker.
Definition applySteps.h:141
Category
Describes how the transaction affects subsequent transactions.
Definition applySteps.h:62
@ normal
Moves currency around, creates offers, etc.
Definition applySteps.h:64
@ blocker
Affects the ability of subsequent transactions to claim a fee.
Definition applySteps.h:67
XRPAmount potentialSpend_
Does NOT include the fee.
Definition applySteps.h:77
SeqProxy seqProx_
SeqProxy of transaction.
Definition applySteps.h:79
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
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:48
@ tesSUCCESS
Definition TER.h:245
@ tapRETRY
Definition ApplyView.h:39
bool isTecClaim(TER x) noexcept
Definition TER.h:685
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:38
std::optional< TxMeta > metadata
Definition applySteps.h:36
Describes the results of the preclaim check.
Definition applySteps.h:209
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:218
TER const ter
Intermediate transaction result.
Definition applySteps.h:223
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:227
ReadView const & view
From the input - the ledger view.
Definition applySteps.h:212
PreclaimResult(Context const &ctx_, TER ter_)
Constructor.
Definition applySteps.h:231
beast::Journal const j
From the input - the journal.
Definition applySteps.h:220
PreclaimResult(PreclaimResult const &)=default
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:216
STTx const & tx
From the input - the transaction.
Definition applySteps.h:214
Describes the results of the preflight check.
Definition applySteps.h:163
Rules const rules
From the input - the rules.
Definition applySteps.h:170
PreflightResult & operator=(PreflightResult const &)=delete
Deleted copy assignment operator.
ApplyFlags const flags
From the input - the flags.
Definition applySteps.h:174
PreflightResult(PreflightResult const &)=default
beast::Journal const j
From the input - the journal.
Definition applySteps.h:176
NotTEC const ter
Intermediate transaction result.
Definition applySteps.h:179
PreflightResult(Context const &ctx_, std::pair< NotTEC, TxConsequences > const &result)
Constructor.
Definition applySteps.h:183
std::optional< uint256 const > const parentBatchId
From the input - the batch identifier, if part of a batch.
Definition applySteps.h:168
TxConsequences const consequences
Consequences of the transaction.
Definition applySteps.h:172
STTx const & tx
From the input - the transaction.
Definition applySteps.h:166