rippled
Loading...
Searching...
No Matches
ApplyContext.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/core/ServiceRegistry.h>
5#include <xrpl/ledger/ApplyViewImpl.h>
6#include <xrpl/protocol/STTx.h>
7#include <xrpl/protocol/XRPAmount.h>
8
9#include <optional>
10
11namespace xrpl {
12
15{
16public:
17 explicit ApplyContext(
19 OpenView& base,
20 std::optional<uint256 const> const& parentBatchId,
21 STTx const& tx,
26
27 explicit ApplyContext(
29 OpenView& base,
30 STTx const& tx,
36 {
37 XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set");
38 }
39
41 STTx const& tx;
45
48 {
49 return *view_;
50 }
51
52 ApplyView const&
53 view() const
54 {
55 return *view_;
56 }
57
58 // VFALCO Unfortunately this is necessary
59 RawView&
61 {
62 return *view_;
63 }
64
65 ApplyFlags const&
66 flags() const
67 {
68 return flags_;
69 }
70
72 void
73 deliver(STAmount const& amount)
74 {
75 view_->deliver(amount);
76 }
77
79 void
80 discard();
81
84
87 size();
88
90 void
91 visit(
92 std::function<void(
93 uint256 const& key,
94 bool isDelete,
95 std::shared_ptr<SLE const> const& before,
96 std::shared_ptr<SLE const> const& after)> const& func);
97
98 void
100 {
101 view_->rawDestroyXRP(fee);
102 }
103
110 TER
111 checkInvariants(TER const result, XRPAmount const fee);
112
113private:
114 static TER
115 failInvariantCheck(TER const result);
116
117 template <std::size_t... Is>
118 TER
120
124
125 // The ID of the batch transaction we are executing under, if seated.
127};
128
129} // 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.
std::size_t size()
Get the number of unapplied changes.
STTx const & tx
static TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
XRPAmount const baseFee
ApplyFlags const & flags() const
void discard()
Discard changes and start fresh.
std::reference_wrapper< ServiceRegistry > registry
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_
ApplyContext(ServiceRegistry &registry, OpenView &base, STTx const &tx, TER preclaimResult, XRPAmount baseFee, ApplyFlags flags, beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
TER const preclaimResult
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:116
Writable ledger view that accumulates state and tx changes.
Definition OpenView.h:45
Interface for ledger entry changes.
Definition RawView.h:14
Service registry for dependency injection.
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:523
ApplyFlags
Definition ApplyView.h:10
@ tapBATCH
Definition ApplyView.h:25