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#include <xrpl/beast/utility/Journal.h>
27#include <xrpl/protocol/STTx.h>
28#include <xrpl/protocol/XRPAmount.h>
29#include <optional>
30#include <utility>
31
32namespace ripple {
33
36{
37public:
38 explicit ApplyContext(
40 OpenView& base,
41 STTx const& tx,
44 ApplyFlags flags,
46
48 STTx const& tx;
52
55 {
56 return *view_;
57 }
58
59 ApplyView const&
60 view() const
61 {
62 return *view_;
63 }
64
65 // VFALCO Unfortunately this is necessary
66 RawView&
68 {
69 return *view_;
70 }
71
73 void
74 deliver(STAmount const& amount)
75 {
76 view_->deliver(amount);
77 }
78
80 void
81 discard();
82
84 void apply(TER);
85
88 size();
89
91 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 TER
115 failInvariantCheck(TER const result);
116
117 template <std::size_t... Is>
118 TER
120 TER const result,
121 XRPAmount const fee,
123
127};
128
129} // namespace ripple
130
131#endif
A generic endpoint for log messages.
Definition: Journal.h:59
static Sink & getNullSink()
Returns a Sink which does nothing.
State information when applying a tx.
Definition: ApplyContext.h:36
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:49
RawView & rawView()
Definition: ApplyContext.h:67
ApplyView & view()
Definition: ApplyContext.h:54
void discard()
Discard changes and start fresh.
TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
Definition: ApplyContext.h:99
Application & app
Definition: ApplyContext.h:47
ApplyView const & view() const
Definition: ApplyContext.h:60
beast::Journal const journal
Definition: ApplyContext.h:51
XRPAmount const baseFee
Definition: ApplyContext.h:50
std::size_t size()
Get the number of unapplied changes.
std::optional< ApplyViewImpl > view_
Definition: ApplyContext.h:126
void apply(TER)
Apply the transaction result to the base.
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:74
TER checkInvariantsHelper(TER const result, XRPAmount const fee, std::index_sequence< Is... >)
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:136
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:56
Interface for ledger entry changes.
Definition: RawView.h:37
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
ApplyFlags
Definition: ApplyView.h:30
static bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition: Escrow.cpp:89