rippled
Loading...
Searching...
No Matches
ApplyViewBase.cpp
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#include <xrpld/ledger/detail/ApplyViewBase.h>
21
22namespace ripple {
23namespace detail {
24
26 : flags_(flags), base_(base)
27{
28}
29
30//---
31
32bool
34{
35 return base_->open();
36}
37
38LedgerInfo const&
40{
41 return base_->info();
42}
43
44Fees const&
46{
47 return base_->fees();
48}
49
50Rules const&
52{
53 return base_->rules();
54}
55
56bool
58{
59 return items_.exists(*base_, k);
60}
61
62auto
65{
66 return items_.succ(*base_, key, last);
67}
68
71{
72 return items_.read(*base_, k);
73}
74
75auto
76ApplyViewBase::slesBegin() const -> std::unique_ptr<sles_type::iter_base>
77{
78 return base_->slesBegin();
79}
80
81auto
82ApplyViewBase::slesEnd() const -> std::unique_ptr<sles_type::iter_base>
83{
84 return base_->slesEnd();
85}
86
87auto
90{
91 return base_->slesUpperBound(key);
92}
93
94auto
95ApplyViewBase::txsBegin() const -> std::unique_ptr<txs_type::iter_base>
96{
97 return base_->txsBegin();
98}
99
100auto
101ApplyViewBase::txsEnd() const -> std::unique_ptr<txs_type::iter_base>
102{
103 return base_->txsEnd();
104}
105
106bool
108{
109 return base_->txExists(key);
110}
111
112auto
114{
115 return base_->txRead(key);
116}
117
118//---
119
122{
123 return flags_;
124}
125
128{
129 return items_.peek(*base_, k);
130}
131
132void
134{
135 items_.erase(*base_, sle);
136}
137
138void
140{
141 items_.insert(*base_, sle);
142}
143
144void
146{
147 items_.update(*base_, sle);
148}
149
150//---
151
152void
154{
155 items_.rawErase(*base_, sle);
156}
157
158void
160{
161 items_.insert(*base_, sle);
162}
163
164void
166{
167 items_.replace(*base_, sle);
168}
169
170void
172{
173 items_.destroyXRP(fee);
174}
175
176} // namespace detail
177} // namespace ripple
A view into a ledger.
Definition: ReadView.h:52
virtual std::unique_ptr< txs_type::iter_base > txsBegin() const =0
virtual std::unique_ptr< sles_type::iter_base > slesEnd() const =0
virtual bool open() const =0
Returns true if this reflects an open ledger.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual std::unique_ptr< txs_type::iter_base > txsEnd() const =0
virtual std::unique_ptr< sles_type::iter_base > slesBegin() const =0
virtual bool txExists(key_type const &key) const =0
Returns true if a tx exists in the tx map.
Rules controlling protocol behavior.
Definition: Rules.h:38
std::shared_ptr< SLE > peek(ReadView const &base, Keylet const &k)
void erase(ReadView const &base, std::shared_ptr< SLE > const &sle)
void rawErase(ReadView const &base, std::shared_ptr< SLE > const &sle)
std::shared_ptr< SLE const > read(ReadView const &base, Keylet const &k) const
void update(ReadView const &base, std::shared_ptr< SLE > const &sle)
bool exists(ReadView const &base, Keylet const &k) const
void insert(ReadView const &base, std::shared_ptr< SLE > const &sle)
void replace(ReadView const &base, std::shared_ptr< SLE > const &sle)
void destroyXRP(XRPAmount const &fee)
Fees const & fees() const override
Returns the fees for the base ledger.
void erase(std::shared_ptr< SLE > const &sle) override
Remove a peeked SLE.
void rawDestroyXRP(XRPAmount const &feeDrops) override
Destroy XRP.
std::unique_ptr< txs_type::iter_base > txsEnd() const override
bool open() const override
Returns true if this reflects an open ledger.
void update(std::shared_ptr< SLE > const &sle) override
Indicate changes to a peeked SLE.
void insert(std::shared_ptr< SLE > const &sle) override
Insert a new state SLE.
std::unique_ptr< sles_type::iter_base > slesEnd() const override
LedgerInfo const & info() const override
Returns information about the ledger.
detail::ApplyStateTable items_
void rawReplace(std::shared_ptr< SLE > const &sle) override
Unconditionally replace a state item.
void rawErase(std::shared_ptr< SLE > const &sle) override
Delete an existing state item.
tx_type txRead(key_type const &key) const override
Read a transaction from the tx map.
std::unique_ptr< sles_type::iter_base > slesBegin() const override
std::unique_ptr< txs_type::iter_base > txsBegin() const override
void rawInsert(std::shared_ptr< SLE > const &sle) override
Unconditionally insert a state item.
bool exists(Keylet const &k) const override
Determine if a state item exists.
std::optional< key_type > succ(key_type const &key, std::optional< key_type > const &last=std::nullopt) const override
Return the key of the next state item.
ApplyFlags flags() const override
Returns the tx apply flags.
bool txExists(key_type const &key) const override
Returns true if a tx exists in the tx map.
std::shared_ptr< SLE const > read(Keylet const &k) const override
Return the state item associated with a key.
std::unique_ptr< sles_type::iter_base > slesUpperBound(uint256 const &key) const override
Rules const & rules() const override
Returns the tx processing rules.
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
ApplyFlags
Definition: ApplyView.h:31
STL namespace.
Reflects the fee settings for a particular ledger.
Definition: protocol/Fees.h:33
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:39
Information about the notional ledger backing the view.
Definition: LedgerHeader.h:34