rippled
Loading...
Searching...
No Matches
ApplyContext.h
1#ifndef XRPL_TX_APPLYCONTEXT_H_INCLUDED
2#define XRPL_TX_APPLYCONTEXT_H_INCLUDED
3
4#include <xrpld/app/main/Application.h>
5#include <xrpld/core/Config.h>
6
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/ledger/ApplyViewImpl.h>
9#include <xrpl/protocol/STTx.h>
10#include <xrpl/protocol/XRPAmount.h>
11
12#include <optional>
13
14namespace ripple {
15
18{
19public:
20 explicit ApplyContext(
22 OpenView& base,
23 std::optional<uint256 const> const& parentBatchId,
24 STTx const& tx,
29
30 explicit ApplyContext(
32 OpenView& base,
33 STTx const& tx,
39 app,
40 base,
41 std::nullopt,
42 tx,
44 baseFee,
45 flags,
46 journal)
47 {
48 XRPL_ASSERT(
49 (flags & tapBATCH) == 0, "Batch apply flag should not be set");
50 }
51
53 STTx const& tx;
57
60 {
61 return *view_;
62 }
63
64 ApplyView const&
65 view() const
66 {
67 return *view_;
68 }
69
70 // VFALCO Unfortunately this is necessary
71 RawView&
73 {
74 return *view_;
75 }
76
77 ApplyFlags const&
78 flags() const
79 {
80 return flags_;
81 }
82
84 void
85 deliver(STAmount const& amount)
86 {
87 view_->deliver(amount);
88 }
89
91 void
92 discard();
93
96
99 size();
100
102 void
103 visit(std::function<void(
104 uint256 const& key,
105 bool isDelete,
106 std::shared_ptr<SLE const> const& before,
107 std::shared_ptr<SLE const> const& after)> const& func);
108
109 void
111 {
112 view_->rawDestroyXRP(fee);
113 }
114
121 TER
122 checkInvariants(TER const result, XRPAmount const fee);
123
124private:
125 TER
126 failInvariantCheck(TER const result);
127
128 template <std::size_t... Is>
129 TER
131 TER const result,
132 XRPAmount const fee,
134
138
139 // The ID of the batch transaction we are executing under, if seated.
141};
142
143} // namespace ripple
144
145#endif
A generic endpoint for log messages.
Definition Journal.h:41
static Sink & getNullSink()
Returns a Sink which does nothing.
State information when applying a tx.
void visit(std::function< void(uint256 const &key, bool isDelete, std::shared_ptr< SLE const > const &before, std::shared_ptr< SLE const > const &after)> const &func)
Visit unapplied changes.
ApplyContext(Application &app, OpenView &base, STTx const &tx, TER preclaimResult, XRPAmount baseFee, ApplyFlags flags, beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
std::optional< TxMeta > apply(TER)
Apply the transaction result to the base.
ApplyView & view()
ApplyFlags const & flags() const
void discard()
Discard changes and start fresh.
TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
Application & app
ApplyView const & view() const
beast::Journal const journal
XRPAmount const baseFee
std::size_t size()
Get the number of unapplied changes.
std::optional< ApplyViewImpl > view_
TER checkInvariants(TER const result, XRPAmount const fee)
Applies all invariant checkers one by one.
void deliver(STAmount const &amount)
Sets the DeliveredAmount field in the metadata.
std::optional< uint256 const > parentBatchId_
TER checkInvariantsHelper(TER const result, XRPAmount const fee, std::index_sequence< Is... >)
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:124
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:46
Interface for ledger entry changes.
Definition RawView.h:15
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3247
@ tapBATCH
Definition ApplyView.h:26
STL namespace.