rippled
ApplyViewBase.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_LEDGER_APPLYVIEWBASE_H_INCLUDED
21 #define RIPPLE_LEDGER_APPLYVIEWBASE_H_INCLUDED
22 
23 #include <ripple/basics/XRPAmount.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/CashDiff.h>
26 #include <ripple/ledger/OpenView.h>
27 #include <ripple/ledger/ReadView.h>
28 #include <ripple/ledger/detail/ApplyStateTable.h>
29 
30 namespace ripple {
31 namespace detail {
32 
33 class ApplyViewBase : public ApplyView, public RawView
34 {
35 public:
36  ApplyViewBase() = delete;
37  ApplyViewBase(ApplyViewBase const&) = delete;
39  operator=(ApplyViewBase&&) = delete;
41  operator=(ApplyViewBase const&) = delete;
42 
43  ApplyViewBase(ApplyViewBase&&) = default;
44 
45  ApplyViewBase(ReadView const* base, ApplyFlags flags);
46 
47  // ReadView
48  bool
49  open() const override;
50 
51  LedgerInfo const&
52  info() const override;
53 
54  Fees const&
55  fees() const override;
56 
57  Rules const&
58  rules() const override;
59 
60  bool
61  exists(Keylet const& k) const override;
62 
63  boost::optional<key_type>
64  succ(
65  key_type const& key,
66  boost::optional<key_type> const& last = boost::none) const override;
67 
69  read(Keylet const& k) const override;
70 
72  slesBegin() const override;
73 
75  slesEnd() const override;
76 
78  slesUpperBound(uint256 const& key) const override;
79 
81  txsBegin() const override;
82 
84  txsEnd() const override;
85 
86  bool
87  txExists(key_type const& key) const override;
88 
89  tx_type
90  txRead(key_type const& key) const override;
91 
92  // ApplyView
93 
95  flags() const override;
96 
98  peek(Keylet const& k) override;
99 
100  void
101  erase(std::shared_ptr<SLE> const& sle) override;
102 
103  void
104  insert(std::shared_ptr<SLE> const& sle) override;
105 
106  void
107  update(std::shared_ptr<SLE> const& sle) override;
108 
109  // RawView
110 
111  void
112  rawErase(std::shared_ptr<SLE> const& sle) override;
113 
114  void
115  rawInsert(std::shared_ptr<SLE> const& sle) override;
116 
117  void
118  rawReplace(std::shared_ptr<SLE> const& sle) override;
119 
120  void
121  rawDestroyXRP(XRPAmount const& feeDrops) override;
122 
123  friend CashDiff
124  cashFlowDiff(
125  CashFilter lhsFilter,
126  ApplyViewBase const& lhs,
127  CashFilter rhsFilter,
128  ApplyViewBase const& rhs);
129 
130 protected:
132  ReadView const* base_;
134 };
135 
136 } // namespace detail
137 } // namespace ripple
138 
139 #endif
ripple::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:38
std::shared_ptr
STL class.
ripple::detail::ApplyViewBase::rawReplace
void rawReplace(std::shared_ptr< SLE > const &sle) override
Unconditionally replace a state item.
Definition: ApplyViewBase.cpp:167
ripple::detail::ApplyViewBase::txsBegin
std::unique_ptr< txs_type::iter_base > txsBegin() const override
Definition: ApplyViewBase.cpp:97
std::pair
ripple::detail::ApplyViewBase::txRead
tx_type txRead(key_type const &key) const override
Read a transaction from the tx map.
Definition: ApplyViewBase.cpp:115
ripple::detail::ApplyViewBase::exists
bool exists(Keylet const &k) const override
Determine if a state item exists.
Definition: ApplyViewBase.cpp:59
ripple::CashDiff
Definition: CashDiff.h:60
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:30
ripple::detail::ApplyViewBase::update
void update(std::shared_ptr< SLE > const &sle) override
Indicate changes to a peeked SLE.
Definition: ApplyViewBase.cpp:147
ripple::detail::ApplyViewBase::operator=
ApplyViewBase & operator=(ApplyViewBase &&)=delete
ripple::detail::ApplyViewBase::fees
Fees const & fees() const override
Returns the fees for the base ledger.
Definition: ApplyViewBase.cpp:47
ripple::detail::ApplyViewBase::items_
detail::ApplyStateTable items_
Definition: ApplyViewBase.h:133
ripple::ApplyView
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:140
ripple::detail::ApplyViewBase::ApplyViewBase
ApplyViewBase()=delete
ripple::detail::ApplyViewBase::txsEnd
std::unique_ptr< txs_type::iter_base > txsEnd() const override
Definition: ApplyViewBase.cpp:103
ripple::base_uint< 256 >
ripple::detail::ApplyViewBase::open
bool open() const override
Returns true if this reflects an open ledger.
Definition: ApplyViewBase.cpp:35
ripple::RawView
Interface for ledger entry changes.
Definition: RawView.h:37
ripple::Fees
Reflects the fee settings for a particular ledger.
Definition: ReadView.h:47
ripple::detail::ApplyViewBase::info
LedgerInfo const & info() const override
Returns information about the ledger.
Definition: ApplyViewBase.cpp:41
ripple::detail::ApplyViewBase::slesEnd
std::unique_ptr< sles_type::iter_base > slesEnd() const override
Definition: ApplyViewBase.cpp:84
ripple::detail::ApplyViewBase::base_
ReadView const * base_
Definition: ApplyViewBase.h:132
ripple::detail::ApplyViewBase::succ
boost::optional< key_type > succ(key_type const &key, boost::optional< key_type > const &last=boost::none) const override
Return the key of the next state item.
Definition: ApplyViewBase.cpp:65
ripple::detail::ApplyViewBase::slesBegin
std::unique_ptr< sles_type::iter_base > slesBegin() const override
Definition: ApplyViewBase.cpp:78
ripple::detail::ApplyViewBase::rawErase
void rawErase(std::shared_ptr< SLE > const &sle) override
Delete an existing state item.
Definition: ApplyViewBase.cpp:155
ripple::detail::ApplyViewBase::cashFlowDiff
friend CashDiff cashFlowDiff(CashFilter lhsFilter, ApplyViewBase const &lhs, CashFilter rhsFilter, ApplyViewBase const &rhs)
Definition: ApplyViewBase.cpp:181
ripple::detail::ApplyViewBase::insert
void insert(std::shared_ptr< SLE > const &sle) override
Insert a new state SLE.
Definition: ApplyViewBase.cpp:141
ripple::detail::ApplyViewBase::erase
void erase(std::shared_ptr< SLE > const &sle) override
Remove a peeked SLE.
Definition: ApplyViewBase.cpp:135
ripple::detail::ApplyViewBase::flags
ApplyFlags flags() const override
Returns the tx apply flags.
Definition: ApplyViewBase.cpp:123
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:188
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Rules
Rules controlling protocol behavior.
Definition: ReadView.h:127
ripple::detail::ApplyViewBase::flags_
ApplyFlags flags_
Definition: ApplyViewBase.h:131
ripple::detail::ApplyViewBase::read
std::shared_ptr< SLE const > read(Keylet const &k) const override
Return the state item associated with a key.
Definition: ApplyViewBase.cpp:72
ripple::detail::ApplyViewBase::peek
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
Definition: ApplyViewBase.cpp:129
ripple::LedgerInfo
Information about the notional ledger backing the view.
Definition: ReadView.h:80
ripple::detail::ApplyViewBase::rules
Rules const & rules() const override
Returns the tx processing rules.
Definition: ApplyViewBase.cpp:53
ripple::detail::ApplyViewBase::txExists
bool txExists(key_type const &key) const override
Returns true if a tx exists in the tx map.
Definition: ApplyViewBase.cpp:109
std::unique_ptr
STL class.
ripple::detail::ApplyViewBase
Definition: ApplyViewBase.h:33
ripple::CashFilter
CashFilter
Definition: CashDiff.h:39
ripple::detail::ApplyViewBase::rawInsert
void rawInsert(std::shared_ptr< SLE > const &sle) override
Unconditionally insert a state item.
Definition: ApplyViewBase.cpp:161
ripple::detail::ApplyViewBase::slesUpperBound
std::unique_ptr< sles_type::iter_base > slesUpperBound(uint256 const &key) const override
Definition: ApplyViewBase.cpp:90
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::detail::ApplyStateTable
Definition: ApplyStateTable.h:36
ripple::detail::ApplyViewBase::rawDestroyXRP
void rawDestroyXRP(XRPAmount const &feeDrops) override
Destroy XRP.
Definition: ApplyViewBase.cpp:173