rippled
Loading...
Searching...
No Matches
ApplyContext.h
1#pragma once
2
3#include <xrpld/app/main/Application.h>
4#include <xrpld/core/Config.h>
5
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/ledger/ApplyViewImpl.h>
8#include <xrpl/protocol/STTx.h>
9#include <xrpl/protocol/XRPAmount.h>
10
11#include <optional>
12
13namespace xrpl {
14
17{
18public:
19 explicit ApplyContext(
21 OpenView& base,
22 std::optional<uint256 const> const& parentBatchId,
23 STTx const& tx,
28
29 explicit ApplyContext(
31 OpenView& base,
32 STTx const& tx,
38 {
39 XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set");
40 }
41
43 STTx const& tx;
47
50 {
51 return *view_;
52 }
53
54 ApplyView const&
55 view() const
56 {
57 return *view_;
58 }
59
60 // VFALCO Unfortunately this is necessary
61 RawView&
63 {
64 return *view_;
65 }
66
67 ApplyFlags const&
68 flags() const
69 {
70 return flags_;
71 }
72
74 void
75 deliver(STAmount const& amount)
76 {
77 view_->deliver(amount);
78 }
79
81 void
82 discard();
83
86
89 size();
90
92 void
94 uint256 const& key,
95 bool isDelete,
96 std::shared_ptr<SLE const> const& before,
97 std::shared_ptr<SLE const> const& after)> const& func);
98
99 void
101 {
102 view_->rawDestroyXRP(fee);
103 }
104
111 TER
112 checkInvariants(TER const result, XRPAmount const fee);
113
114private:
115 TER
116 failInvariantCheck(TER const result);
117
118 template <std::size_t... Is>
119 TER
121
125
126 // The ID of the batch transaction we are executing under, if seated.
128};
129
130} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
static Sink & getNullSink()
Returns a Sink which does nothing.
State information when applying a tx.
ApplyContext(Application &app, OpenView &base, STTx const &tx, TER preclaimResult, XRPAmount baseFee, ApplyFlags flags, beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
std::size_t size()
Get the number of unapplied changes.
STTx const & tx
TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
XRPAmount const baseFee
ApplyFlags const & flags() const
void discard()
Discard changes and start fresh.
void deliver(STAmount const &amount)
Sets the DeliveredAmount field in the metadata.
std::optional< TxMeta > apply(TER)
Apply the transaction result to the base.
std::optional< ApplyViewImpl > view_
beast::Journal const journal
ApplyView const & view() const
RawView & rawView()
TER checkInvariantsHelper(TER const result, XRPAmount const fee, std::index_sequence< Is... >)
ApplyView & view()
TER checkInvariants(TER const result, XRPAmount const fee)
Applies all invariant checkers one by one.
std::optional< uint256 const > parentBatchId_
TER const preclaimResult
Application & app
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.
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:114
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:45
Interface for ledger entry changes.
Definition RawView.h:14
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3436
ApplyFlags
Definition ApplyView.h:10
@ tapBATCH
Definition ApplyView.h:25