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 <xrpld/ledger/ApplyViewImpl.h>
24#include <xrpl/beast/utility/Journal.h>
25
26namespace ripple {
27
28class Application;
29class STTx;
30class TxQ;
31
35inline bool
37{
38 return isTecClaim(ter) && !(flags & tapRETRY);
39}
40
46{
47public:
50 enum Category {
52 normal = 0,
56 };
57
58private:
70
71public:
72 // Constructor if preflight returns a value other than tesSUCCESS.
73 // Asserts if tesSUCCESS is passed.
74 explicit TxConsequences(NotTEC pfresult);
75
77 explicit TxConsequences(STTx const& tx);
78
80 TxConsequences(STTx const& tx, Category category);
81
84
87
89 TxConsequences(TxConsequences const&) = default;
92 operator=(TxConsequences const&) = default;
98
101 fee() const
102 {
103 return fee_;
104 }
105
107 XRPAmount const&
109 {
110 return potentialSpend_;
111 }
112
115 seqProxy() const
116 {
117 return seqProx_;
118 }
119
123 {
124 return sequencesConsumed_;
125 }
126
128 bool
129 isBlocker() const
130 {
131 return isBlocker_;
132 }
133
134 // Return the SeqProxy that would follow this.
137 {
138 SeqProxy following = seqProx_;
139 following.advanceBy(sequencesConsumed());
140 return following;
141 }
142};
143
151{
152public:
154 STTx const& tx;
163
165 NotTEC const ter;
166
168 template <class Context>
170 Context const& ctx_,
172 : tx(ctx_.tx)
173 , rules(ctx_.rules)
174 , consequences(result.second)
175 , flags(ctx_.flags)
176 , j(ctx_.j)
177 , ter(result.first)
178 {
179 }
180
184 operator=(PreflightResult const&) = delete;
185};
186
194{
195public:
199 STTx const& tx;
204
206 TER const ter;
210
212 template <class Context>
213 PreclaimResult(Context const& ctx_, TER ter_)
214 : view(ctx_.view)
215 , tx(ctx_.tx)
216 , flags(ctx_.flags)
217 , j(ctx_.j)
218 , ter(ter_)
220 {
221 }
222
226 operator=(PreclaimResult const&) = delete;
227};
228
247 Application& app,
248 Rules const& rules,
249 STTx const& tx,
250 ApplyFlags flags,
252
283 PreflightResult const& preflightResult,
284 Application& app,
285 OpenView const& view);
286
304calculateBaseFee(ReadView const& view, STTx const& tx);
305
318calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
319
337doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view);
338
339} // namespace ripple
340
341#endif
A generic endpoint for log messages.
Definition: Journal.h:59
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:56
A view into a ledger.
Definition: ReadView.h:55
Rules controlling protocol behavior.
Definition: Rules.h:35
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:46
XRPAmount fee_
Transaction fee.
Definition: applySteps.h:63
std::uint32_t sequencesConsumed() const
Sequences consumed.
Definition: applySteps.h:122
TxConsequences(TxConsequences &&)=default
Move constructor.
TxConsequences & operator=(TxConsequences &&)=default
Move assignment operator.
TxConsequences(TxConsequences const &)=default
Copy constructor.
SeqProxy followingSeq() const
Definition: applySteps.h:136
std::uint32_t sequencesConsumed_
Number of sequences consumed.
Definition: applySteps.h:69
XRPAmount const & potentialSpend() const
Potential Spend.
Definition: applySteps.h:108
SeqProxy seqProxy() const
SeqProxy.
Definition: applySteps.h:115
XRPAmount fee() const
Fee.
Definition: applySteps.h:101
bool isBlocker_
Describes how the transaction affects subsequent transactions.
Definition: applySteps.h:61
TxConsequences & operator=(TxConsequences const &)=default
Copy assignment operator.
bool isBlocker() const
Returns true if the transaction is a blocker.
Definition: applySteps.h:129
Category
Describes how the transaction affects subsequent transactions.
Definition: applySteps.h:50
@ normal
Moves currency around, creates offers, etc.
Definition: applySteps.h:52
@ blocker
Affects the ability of subsequent transactions to claim a fee.
Definition: applySteps.h:55
XRPAmount potentialSpend_
Does NOT include the fee.
Definition: applySteps.h:65
SeqProxy seqProx_
SeqProxy of transaction.
Definition: applySteps.h:67
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
bool isTecClaim(TER x)
Definition: TER.h:662
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
Definition: applySteps.cpp:296
std::pair< TER, bool > doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
Definition: applySteps.cpp:374
XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Compute only the expected base fee for a transaction.
Definition: applySteps.cpp:362
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
Definition: applySteps.cpp:316
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:36
@ tesSUCCESS
Definition: TER.h:242
ApplyFlags
Definition: ApplyView.h:30
@ tapRETRY
Definition: ApplyView.h:39
XRPAmount calculateDefaultBaseFee(ReadView const &view, STTx const &tx)
Return the minimum fee that an "ordinary" transaction would pay.
Definition: applySteps.cpp:368
Describes the results of the preclaim check.
Definition: applySteps.h:194
ApplyFlags const flags
From the input - the flags.
Definition: applySteps.h:201
TER const ter
Intermediate transaction result.
Definition: applySteps.h:206
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:209
ReadView const & view
From the input - the ledger view.
Definition: applySteps.h:197
PreclaimResult(Context const &ctx_, TER ter_)
Constructor.
Definition: applySteps.h:213
beast::Journal const j
From the input - the journal.
Definition: applySteps.h:203
PreclaimResult(PreclaimResult const &)=default
STTx const & tx
From the input - the transaction.
Definition: applySteps.h:199
Describes the results of the preflight check.
Definition: applySteps.h:151
Rules const rules
From the input - the rules.
Definition: applySteps.h:156
PreflightResult & operator=(PreflightResult const &)=delete
Deleted copy assignment operator.
ApplyFlags const flags
From the input - the flags.
Definition: applySteps.h:160
PreflightResult(PreflightResult const &)=default
beast::Journal const j
From the input - the journal.
Definition: applySteps.h:162
NotTEC const ter
Intermediate transaction result.
Definition: applySteps.h:165
PreflightResult(Context const &ctx_, std::pair< NotTEC, TxConsequences > const &result)
Constructor.
Definition: applySteps.h:169
TxConsequences const consequences
Consequences of the transaction.
Definition: applySteps.h:158
STTx const & tx
From the input - the transaction.
Definition: applySteps.h:154