rippled
RawStateTable.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_RAWSTATETABLE_H_INCLUDED
21 #define RIPPLE_LEDGER_RAWSTATETABLE_H_INCLUDED
22 
23 #include <ripple/ledger/RawView.h>
24 #include <ripple/ledger/ReadView.h>
25 #include <ripple/basics/qalloc.h>
26 #include <map>
27 #include <utility>
28 
29 namespace ripple {
30 namespace detail {
31 
32 // Helper class that buffers raw modifications
34 {
35 public:
37 
38  RawStateTable() = default;
39  RawStateTable (RawStateTable const&) = default;
40  RawStateTable (RawStateTable&&) = default;
41 
43  RawStateTable& operator= (RawStateTable const&) = delete;
44 
45  void
46  apply (RawView& to) const;
47 
48  bool
49  exists (ReadView const& base,
50  Keylet const& k) const;
51 
52  boost::optional<key_type>
53  succ (ReadView const& base,
54  key_type const& key, boost::optional<
55  key_type> const& last) const;
56 
57  void
58  erase (std::shared_ptr<SLE> const& sle);
59 
60  void
61  insert (std::shared_ptr<SLE> const& sle);
62 
63  void
64  replace (std::shared_ptr<SLE> const& sle);
65 
67  read (ReadView const& base,
68  Keylet const& k) const;
69 
70  void
71  destroyXRP (XRPAmount const& fee);
72 
74  slesBegin (ReadView const& base) const;
75 
77  slesEnd (ReadView const& base) const;
78 
80  slesUpperBound (ReadView const& base, uint256 const& key) const;
81 
82 private:
83  enum class Action
84  {
85  erase,
86  insert,
87  replace,
88  };
89 
90  class sles_iter_impl;
91 
92  using items_t = std::map<key_type,
96 
99 };
100 
101 } // detail
102 } // ripple
103 
104 #endif
ripple::detail::RawStateTable::dropsDestroyed_
XRPAmount dropsDestroyed_
Definition: RawStateTable.h:98
ripple::detail::RawStateTable::operator=
RawStateTable & operator=(RawStateTable &&)=delete
ripple::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:38
std::shared_ptr
STL class.
utility
std::pair
ripple::ReadView::key_type
uint256 key_type
Definition: ReadView.h:193
ripple::detail::RawStateTable::Action::erase
@ erase
ripple::detail::RawStateTable::RawStateTable
RawStateTable()=default
ripple::detail::RawStateTable::read
std::shared_ptr< SLE const > read(ReadView const &base, Keylet const &k) const
Definition: RawStateTable.cpp:316
ripple::detail::RawStateTable::Action::replace
@ replace
std::less
ripple::qalloc_type
Definition: qalloc.h:89
ripple::detail::RawStateTable::items_t
std::map< key_type, std::pair< Action, std::shared_ptr< SLE > >, std::less< key_type >, qalloc_type< std::pair< key_type const, std::pair< Action, std::shared_ptr< SLE > >>, false > > items_t
Definition: RawStateTable.h:95
ripple::base_uint< 256 >
ripple::RawView
Interface for ledger entry changes.
Definition: RawView.h:37
ripple::detail::RawStateTable::slesUpperBound
std::unique_ptr< ReadView::sles_type::iter_base > slesUpperBound(ReadView const &base, uint256 const &key) const
Definition: RawStateTable.cpp:357
ripple::detail::RawStateTable::Action::insert
@ insert
ripple::detail::RawStateTable::slesBegin
std::unique_ptr< ReadView::sles_type::iter_base > slesBegin(ReadView const &base) const
Definition: RawStateTable.cpp:341
ripple::detail::RawStateTable::Action
Action
Definition: RawStateTable.h:83
ripple::detail::RawStateTable::erase
void erase(std::shared_ptr< SLE > const &sle)
Definition: RawStateTable.cpp:237
map
ripple::detail::RawStateTable::exists
bool exists(ReadView const &base, Keylet const &k) const
Definition: RawStateTable.cpp:179
ripple::detail::RawStateTable::succ
boost::optional< key_type > succ(ReadView const &base, key_type const &key, boost::optional< key_type > const &last) const
Definition: RawStateTable.cpp:199
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:186
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::detail::RawStateTable::apply
void apply(RawView &to) const
Definition: RawStateTable.cpp:157
ripple::detail::RawStateTable::items_
items_t items_
Definition: RawStateTable.h:97
ripple::detail::RawStateTable::destroyXRP
void destroyXRP(XRPAmount const &fee)
Definition: RawStateTable.cpp:335
ripple::detail::RawStateTable::insert
void insert(std::shared_ptr< SLE > const &sle)
Definition: RawStateTable.cpp:265
ripple::detail::RawStateTable
Definition: RawStateTable.h:33
ripple::detail::RawStateTable::replace
void replace(std::shared_ptr< SLE > const &sle)
Definition: RawStateTable.cpp:292
ripple::detail::RawStateTable::key_type
ReadView::key_type key_type
Definition: RawStateTable.h:36
ripple::detail::RawStateTable::slesEnd
std::unique_ptr< ReadView::sles_type::iter_base > slesEnd(ReadView const &base) const
Definition: RawStateTable.cpp:349
std::unique_ptr
STL class.
ripple::XRPAmount
Definition: XRPAmount.h:46