rippled
Loading...
Searching...
No Matches
ApplyContext.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_APPLYCONTEXT_H_INCLUDED
21#define RIPPLE_TX_APPLYCONTEXT_H_INCLUDED
22
23#include <xrpld/app/main/Application.h>
24#include <xrpld/core/Config.h>
25#include <xrpld/ledger/ApplyViewImpl.h>
26
27#include <xrpl/beast/utility/Journal.h>
28#include <xrpl/protocol/STTx.h>
29#include <xrpl/protocol/XRPAmount.h>
30
31#include <optional>
32
33namespace ripple {
34
37{
38public:
39 explicit ApplyContext(
41 OpenView& base,
42 STTx const& tx,
47
49 STTx const& tx;
53
56 {
57 return *view_;
58 }
59
60 ApplyView const&
61 view() const
62 {
63 return *view_;
64 }
65
66 // VFALCO Unfortunately this is necessary
67 RawView&
69 {
70 return *view_;
71 }
72
73 ApplyFlags const&
74 flags() const
75 {
76 return flags_;
77 }
78
80 void
81 deliver(STAmount const& amount)
82 {
83 view_->deliver(amount);
84 }
85
87 void
88 discard();
89
92
95 size();
96
98 void
100 uint256 const& key,
101 bool isDelete,
102 std::shared_ptr<SLE const> const& before,
103 std::shared_ptr<SLE const> const& after)> const& func);
104
105 void
107 {
108 view_->rawDestroyXRP(fee);
109 }
110
117 TER
118 checkInvariants(TER const result, XRPAmount const fee);
119
120private:
121 TER
122 failInvariantCheck(TER const result);
123
124 template <std::size_t... Is>
125 TER
127 TER const result,
128 XRPAmount const fee,
130
134};
135
136} // namespace ripple
137
138#endif
A generic endpoint for log messages.
Definition: Journal.h:60
static Sink & getNullSink()
Returns a Sink which does nothing.
State information when applying a tx.
Definition: ApplyContext.h:37
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.
TER const preclaimResult
Definition: ApplyContext.h:50
RawView & rawView()
Definition: ApplyContext.h:68
std::optional< TxMeta > apply(TER)
Apply the transaction result to the base.
ApplyView & view()
Definition: ApplyContext.h:55
ApplyFlags const & flags() const
Definition: ApplyContext.h:74
void discard()
Discard changes and start fresh.
TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
Definition: ApplyContext.h:106
Application & app
Definition: ApplyContext.h:48
ApplyView const & view() const
Definition: ApplyContext.h:61
beast::Journal const journal
Definition: ApplyContext.h:52
XRPAmount const baseFee
Definition: ApplyContext.h:51
std::size_t size()
Get the number of unapplied changes.
std::optional< ApplyViewImpl > view_
Definition: ApplyContext.h:133
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.
Definition: ApplyContext.h:81
TER checkInvariantsHelper(TER const result, XRPAmount const fee, std::index_sequence< Is... >)
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:141
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:57
Interface for ledger entry changes.
Definition: RawView.h:35
Set the fee on a JTx.
Definition: fee.h:37
Match set account flags.
Definition: flags.h:125
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition: View.cpp:2696
ApplyFlags
Definition: ApplyView.h:31