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#include <xrpl/basics/contract.h>
22
23namespace ripple {
24namespace detail {
25
27 : flags_(flags), base_(base)
28{
29}
30
31//---
32
33bool
35{
36 return base_->open();
37}
38
39LedgerInfo const&
41{
42 return base_->info();
43}
44
45Fees const&
47{
48 return base_->fees();
49}
50
51Rules const&
53{
54 return base_->rules();
55}
56
57bool
59{
60 return items_.exists(*base_, k);
61}
62
63auto
66{
67 return items_.succ(*base_, key, last);
68}
69
72{
73 return items_.read(*base_, k);
74}
75
76auto
77ApplyViewBase::slesBegin() const -> std::unique_ptr<sles_type::iter_base>
78{
79 return base_->slesBegin();
80}
81
82auto
83ApplyViewBase::slesEnd() const -> std::unique_ptr<sles_type::iter_base>
84{
85 return base_->slesEnd();
86}
87
88auto
91{
92 return base_->slesUpperBound(key);
93}
94
95auto
96ApplyViewBase::txsBegin() const -> std::unique_ptr<txs_type::iter_base>
97{
98 return base_->txsBegin();
99}
100
101auto
102ApplyViewBase::txsEnd() const -> std::unique_ptr<txs_type::iter_base>
103{
104 return base_->txsEnd();
105}
106
107bool
109{
110 return base_->txExists(key);
111}
112
113auto
115{
116 return base_->txRead(key);
117}
118
119//---
120
123{
124 return flags_;
125}
126
129{
130 return items_.peek(*base_, k);
131}
132
133void
135{
136 items_.erase(*base_, sle);
137}
138
139void
141{
142 items_.insert(*base_, sle);
143}
144
145void
147{
148 items_.update(*base_, sle);
149}
150
151//---
152
153void
155{
156 items_.rawErase(*base_, sle);
157}
158
159void
161{
162 items_.insert(*base_, sle);
163}
164
165void
167{
168 items_.replace(*base_, sle);
169}
170
171void
173{
174 items_.destroyXRP(fee);
175}
176
177} // namespace detail
178} // namespace ripple
A view into a ledger.
Definition: ReadView.h:55
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:35
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:30
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