| 
    rippled
    
   | 
 
Writable ledger view that accumulates state and tx changes. More...
#include <OpenView.h>


Classes | |
| struct | txData | 
| class | txs_iter_impl | 
Public Types | |
| using | tx_type = std::pair< std::shared_ptr< STTx const >, std::shared_ptr< STObject const > > | 
| using | key_type = uint256 | 
| using | mapped_type = std::shared_ptr< SLE const > | 
Public Member Functions | |
| OpenView ()=delete | |
| OpenView & | operator= (OpenView &&)=delete | 
| OpenView & | operator= (OpenView const &)=delete | 
| OpenView (OpenView &&)=default | |
| OpenView (OpenView const &) | |
| Construct a shallow copy.   | |
| OpenView (open_ledger_t, ReadView const *base, Rules const &rules, std::shared_ptr< void const > hold=nullptr) | |
| Construct an open ledger view.   | |
| OpenView (open_ledger_t, Rules const &rules, std::shared_ptr< ReadView const > const &base) | |
| OpenView (batch_view_t, OpenView &base) | |
| OpenView (ReadView const *base, std::shared_ptr< void const > hold=nullptr) | |
| Construct a new last closed ledger.   | |
| bool | open () const override | 
| Returns true if this reflects an open ledger.   | |
| std::size_t | txCount () const | 
| Return the number of tx inserted since creation.   | |
| void | apply (TxsRawView &to) const | 
| Apply changes.   | |
| LedgerInfo const & | info () const override | 
| Returns information about the ledger.   | |
| Fees const & | fees () const override | 
| Returns the fees for the base ledger.   | |
| Rules const & | rules () const override | 
| Returns the tx processing rules.   | |
| 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.   | |
| 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 > | slesBegin () const override | 
| std::unique_ptr< sles_type::iter_base > | slesEnd () const override | 
| std::unique_ptr< sles_type::iter_base > | slesUpperBound (uint256 const &key) const override | 
| std::unique_ptr< txs_type::iter_base > | txsBegin () const override | 
| std::unique_ptr< txs_type::iter_base > | txsEnd () const override | 
| bool | txExists (key_type const &key) const override | 
Returns true if a tx exists in the tx map.   | |
| tx_type | txRead (key_type const &key) const override | 
| Read a transaction from the tx map.   | |
| void | rawErase (std::shared_ptr< SLE > const &sle) override | 
| Delete an existing state item.   | |
| void | rawInsert (std::shared_ptr< SLE > const &sle) override | 
| Unconditionally insert a state item.   | |
| void | rawReplace (std::shared_ptr< SLE > const &sle) override | 
| Unconditionally replace a state item.   | |
| void | rawDestroyXRP (XRPAmount const &fee) override | 
| Destroy XRP.   | |
| void | rawTxInsert (key_type const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData) override | 
| Add a transaction to the tx map.   | |
| NetClock::time_point | parentCloseTime () const | 
| Returns the close time of the previous ledger.   | |
| LedgerIndex | seq () const | 
| Returns the sequence number of the base ledger.   | |
| virtual STAmount | balanceHook (AccountID const &account, AccountID const &issuer, STAmount const &amount) const | 
| virtual std::uint32_t | ownerCountHook (AccountID const &account, std::uint32_t count) const | 
| virtual std::unique_ptr< sles_type::iter_base > | slesUpperBound (key_type const &key) const =0 | 
Public Attributes | |
| sles_type | sles | 
| Iterable range of ledger state items.   | |
| txs_type | txs | 
Private Types | |
| using | txs_map = std::map< key_type, txData, std::less< key_type >, boost::container::pmr::polymorphic_allocator< std::pair< key_type const, txData > > > | 
Private Attributes | |
| std::unique_ptr< boost::container::pmr::monotonic_buffer_resource > | monotonic_resource_ | 
| txs_map | txs_ | 
| Rules | rules_ | 
| LedgerInfo | info_ | 
| ReadView const * | base_ | 
| detail::RawStateTable | items_ | 
| std::shared_ptr< void const > | hold_ | 
| std::size_t | baseTxCount_ = 0 | 
| In batch mode, the number of transactions already executed.   | |
| bool | open_ = true | 
Static Private Attributes | |
| static constexpr size_t | initialBufferSize = kilobytes(256) | 
Writable ledger view that accumulates state and tx changes.
Definition at line 64 of file OpenView.h.
      
  | 
  private | 
Definition at line 91 of file OpenView.h.
      
  | 
  inherited | 
Definition at line 53 of file ReadView.h.
      
  | 
  inherited | 
Definition at line 56 of file ReadView.h.
      
  | 
  inherited | 
Definition at line 58 of file ReadView.h.
      
  | 
  delete | 
      
  | 
  default | 
| ripple::OpenView::OpenView | ( | OpenView const & | rhs | ) | 
Construct a shallow copy.
Effects:
Creates a new object with a copy of the modification state table.
The objects managed by shared pointers are not duplicated but shared between instances. Since the SLEs are immutable, calls on the RawView interface cannot break invariants.
Definition at line 76 of file OpenView.cpp.
| ripple::OpenView::OpenView | ( | open_ledger_t | , | 
| ReadView const * | base, | ||
| Rules const & | rules, | ||
| std::shared_ptr< void const > | hold = nullptr  | 
        ||
| ) | 
Construct an open ledger view.
Effects:
The sequence number is set to the sequence number of parent plus one. The parentCloseTime is set to the closeTime of parent. If `hold` is not nullptr, retains ownership of a copy of `hold` until the MetaView is destroyed. Calls to rules() will return the rules provided on construction.
The tx list starts empty and will contain all newly inserted tx.
Definition at line 89 of file OpenView.cpp.
| ripple::OpenView::OpenView | ( | open_ledger_t | , | 
| Rules const & | rules, | ||
| std::shared_ptr< ReadView const > const & | base | ||
| ) | 
Definition at line 163 of file OpenView.h.
| ripple::OpenView::OpenView | ( | batch_view_t | , | 
| OpenView & | base | ||
| ) | 
Definition at line 171 of file OpenView.h.
| ripple::OpenView::OpenView | ( | ReadView const * | base, | 
| std::shared_ptr< void const > | hold = nullptr  | 
        ||
| ) | 
Construct a new last closed ledger.
Effects:
The LedgerInfo is copied from the base. The rules are inherited from the base.
The tx list starts empty and will contain all newly inserted tx.
Definition at line 109 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Returns true if this reflects an open ledger.
Implements ripple::ReadView.
Definition at line 191 of file OpenView.h.
| std::size_t ripple::OpenView::txCount | ( | ) | const | 
Return the number of tx inserted since creation.
This is used to set the "apply ordinal" when calculating transaction metadata.
Definition at line 122 of file OpenView.cpp.
| void ripple::OpenView::apply | ( | TxsRawView & | to | ) | const | 
Apply changes.
Definition at line 128 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Returns information about the ledger.
Implements ripple::ReadView.
Definition at line 138 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Returns the fees for the base ledger.
Implements ripple::ReadView.
Definition at line 144 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Returns the tx processing rules.
Implements ripple::ReadView.
Definition at line 150 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Determine if a state item exists.
true if a SLE is associated with the specified key. Implements ripple::ReadView.
Definition at line 156 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Return the key of the next state item.
This returns the key of the first state item whose key is greater than the specified key. If no such key is present, std::nullopt is returned.
If last is engaged, returns std::nullopt when the key returned would be outside the open interval (key, last). 
Implements ripple::ReadView.
Definition at line 162 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Return the state item associated with a key.
Effects: If the key exists, gives the caller ownership of the non-modifiable corresponding SLE.
const from the perspective of the caller, it can be changed by other callers through raw operations.nullptr if the key is not present or if the type does not match. Implements ripple::ReadView.
Definition at line 169 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 175 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 181 of file OpenView.cpp.
      
  | 
  override | 
Definition at line 187 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 194 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 200 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Returns true if a tx exists in the tx map. 
A tx exists in the map if it is part of the base ledger, or if it is a newly inserted tx.
Implements ripple::ReadView.
Definition at line 206 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Read a transaction from the tx map.
If the view represents an open ledger, the metadata object will be empty.
Implements ripple::ReadView.
Definition at line 212 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Delete an existing state item.
The SLE is provided so the implementation can calculate metadata.
Implements ripple::RawView.
Definition at line 231 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Unconditionally insert a state item.
Requirements: The key must not already exist.
Effects:
The key is associated with the SLE.
Implements ripple::RawView.
Definition at line 237 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Unconditionally replace a state item.
Requirements:
The key must exist.
Effects:
The key is associated with the SLE.
Implements ripple::RawView.
Definition at line 243 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Destroy XRP.
This is used to pay for transaction fees.
Implements ripple::RawView.
Definition at line 249 of file OpenView.cpp.
      
  | 
  overridevirtual | 
Add a transaction to the tx map.
Closed ledgers must have metadata, while open ledgers omit metadata.
Implements ripple::TxsRawView.
Definition at line 259 of file OpenView.cpp.
      
  | 
  inherited | 
Returns the close time of the previous ledger.
Definition at line 111 of file ReadView.h.
      
  | 
  inherited | 
Returns the sequence number of the base ledger.
Definition at line 118 of file ReadView.h.
      
  | 
  virtualinherited | 
Reimplemented in ripple::PaymentSandbox.
Definition at line 178 of file ReadView.h.
      
  | 
  virtualinherited | 
Reimplemented in ripple::PaymentSandbox.
Definition at line 192 of file ReadView.h.
      
  | 
  pure virtualinherited | 
      
  | 
  staticconstexprprivate | 
Definition at line 70 of file OpenView.h.
      
  | 
  private | 
Definition at line 101 of file OpenView.h.
      
  | 
  private | 
Definition at line 102 of file OpenView.h.
      
  | 
  private | 
Definition at line 103 of file OpenView.h.
      
  | 
  private | 
Definition at line 104 of file OpenView.h.
      
  | 
  private | 
Definition at line 105 of file OpenView.h.
      
  | 
  private | 
Definition at line 106 of file OpenView.h.
      
  | 
  private | 
Definition at line 107 of file OpenView.h.
      
  | 
  private | 
In batch mode, the number of transactions already executed.
Definition at line 110 of file OpenView.h.
      
  | 
  private | 
Definition at line 112 of file OpenView.h.
      
  | 
  inherited | 
Iterable range of ledger state items.
Definition at line 245 of file ReadView.h.
      
  | 
  inherited | 
Definition at line 248 of file ReadView.h.