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,
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
72 ApplyFlags const&
73 flags() const
74 {
75 return flags_;
76 }
77
79 void
80 deliver(STAmount const& amount)
81 {
82 view_->deliver(amount);
83 }
84
86 void
87 discard();
88
91
94 size();
95
97 void
99 uint256 const& key,
100 bool isDelete,
101 std::shared_ptr<SLE const> const& before,
102 std::shared_ptr<SLE const> const& after)> const& func);
103
104 void
106 {
107 view_->rawDestroyXRP(fee);
108 }
109
116 TER
117 checkInvariants(TER const result, XRPAmount const fee);
118
119private:
120 TER
121 failInvariantCheck(TER const result);
122
123 template <std::size_t... Is>
124 TER
126 TER const result,
127 XRPAmount const fee,
129
133};
134
135} // namespace ripple
136
137#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
std::optional< TxMeta > apply(TER)
Apply the transaction result to the base.
ApplyView & view()
Definition: ApplyContext.h:54
ApplyFlags const & flags() const
Definition: ApplyContext.h:73
void discard()
Discard changes and start fresh.
TER failInvariantCheck(TER const result)
void destroyXRP(XRPAmount const &fee)
Definition: ApplyContext.h:105
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:132
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:80
TER checkInvariantsHelper(TER const result, XRPAmount const fee, std::index_sequence< Is... >)
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:140
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