| 
    rippled
    
   | 
 
A wrapper which makes credits unavailable to balances. More...
#include <PaymentSandbox.h>


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 | |
| PaymentSandbox ()=delete | |
| PaymentSandbox (PaymentSandbox const &)=delete | |
| PaymentSandbox & | operator= (PaymentSandbox &&)=delete | 
| PaymentSandbox & | operator= (PaymentSandbox const &)=delete | 
| PaymentSandbox (PaymentSandbox &&)=default | |
| PaymentSandbox (ReadView const *base, ApplyFlags flags) | |
| PaymentSandbox (ApplyView const *base) | |
| STAmount | balanceHook (AccountID const &account, AccountID const &issuer, STAmount const &amount) const override | 
| void | creditHook (AccountID const &from, AccountID const &to, STAmount const &amount, STAmount const &preCreditBalance) override | 
| void | adjustOwnerCountHook (AccountID const &account, std::uint32_t cur, std::uint32_t next) override | 
| std::uint32_t | ownerCountHook (AccountID const &account, std::uint32_t count) const override | 
| std::map< std::tuple< AccountID, AccountID, Currency >, STAmount > | balanceChanges (ReadView const &view) const | 
| XRPAmount | xrpDestroyed () const | 
| bool | open () const override | 
| Returns true if this reflects an open ledger.   | |
| 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 | 
| virtual std::unique_ptr< sles_type::iter_base > | slesUpperBound (key_type const &key) const =0 | 
| 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.   | |
| ApplyFlags | flags () const override | 
| Returns the tx apply flags.   | |
| std::shared_ptr< SLE > | peek (Keylet const &k) override | 
| Prepare to modify the SLE associated with key.   | |
| void | erase (std::shared_ptr< SLE > const &sle) override | 
| Remove a peeked SLE.   | |
| void | insert (std::shared_ptr< SLE > const &sle) override | 
| Insert a new state SLE.   | |
| void | update (std::shared_ptr< SLE > const &sle) override | 
| Indicate changes to a peeked SLE.   | |
| 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 &feeDrops) override | 
| Destroy XRP.   | |
| bool | dirDelete (Keylet const &directory, std::function< void(uint256 const &)> const &) | 
| Remove the specified directory, invoking the callback for every node.   | |
| bool | emptyDirDelete (Keylet const &directory) | 
| Remove the specified directory, if it is empty.   | |
| NetClock::time_point | parentCloseTime () const | 
| Returns the close time of the previous ledger.   | |
| LedgerIndex | seq () const | 
| Returns the sequence number of the base ledger.   | |
| PaymentSandbox (PaymentSandbox const *base) | |
| Construct on top of existing PaymentSandbox.   | |
| PaymentSandbox (PaymentSandbox *base) | |
| void | apply (RawView &to) | 
| Apply changes to base view.   | |
| void | apply (PaymentSandbox &to) | 
| std::optional< std::uint64_t > | dirAppend (Keylet const &directory, Keylet const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe) | 
| Append an entry to a directory.   | |
| std::optional< std::uint64_t > | dirInsert (Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe) | 
| Insert an entry to a directory.   | |
| std::optional< std::uint64_t > | dirInsert (Keylet const &directory, Keylet const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe) | 
| bool | dirRemove (Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot) | 
| Remove an entry from a directory.   | |
| bool | dirRemove (Keylet const &directory, std::uint64_t page, Keylet const &key, bool keepRoot) | 
Public Attributes | |
| sles_type | sles | 
| Iterable range of ledger state items.   | |
| txs_type | txs | 
Protected Attributes | |
| ApplyFlags | flags_ | 
| ReadView const * | base_ | 
| detail::ApplyStateTable | items_ | 
Private Member Functions | |
| std::optional< std::uint64_t > | dirAdd (bool preserveOrder, Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe) | 
| Add an entry to a directory using the specified insert strategy.   | |
Private Attributes | |
| detail::DeferredCredits | tab_ | 
| PaymentSandbox const * | ps_ = nullptr | 
A wrapper which makes credits unavailable to balances.
This is used for payments and pathfinding, so that consuming liquidity from a path never causes portions of that path or other paths to gain liquidity.
The behavior of certain free functions in the ApplyView API will change via the balanceHook and creditHook overrides of PaymentSandbox.
Definition at line 112 of file PaymentSandbox.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 | 
      
  | 
  delete | 
      
  | 
  default | 
| ripple::PaymentSandbox::PaymentSandbox | ( | ReadView const * | base, | 
| ApplyFlags | flags | ||
| ) | 
Definition at line 124 of file PaymentSandbox.h.
| ripple::PaymentSandbox::PaymentSandbox | ( | ApplyView const * | base | ) | 
Definition at line 129 of file PaymentSandbox.h.
      
  | 
  explicit | 
Construct on top of existing PaymentSandbox.
The changes are pushed to the parent when apply() is called.
| parent | A non-null pointer to the parent. | 
Definition at line 147 of file PaymentSandbox.h.
      
  | 
  explicit | 
Definition at line 152 of file PaymentSandbox.h.
      
  | 
  delete | 
      
  | 
  delete | 
      
  | 
  overridevirtual | 
Reimplemented from ripple::ReadView.
Definition at line 172 of file PaymentSandbox.cpp.
      
  | 
  overridevirtual | 
Reimplemented from ripple::ApplyView.
Definition at line 235 of file PaymentSandbox.cpp.
      
  | 
  overridevirtual | 
Reimplemented from ripple::ApplyView.
Definition at line 245 of file PaymentSandbox.cpp.
      
  | 
  overridevirtual | 
Reimplemented from ripple::ReadView.
Definition at line 222 of file PaymentSandbox.cpp.
| void ripple::PaymentSandbox::apply | ( | RawView & | to | ) | 
Apply changes to base view.
to must contain contents identical to the parent view passed upon construction, else undefined behavior will result. 
Definition at line 254 of file PaymentSandbox.cpp.
| void ripple::PaymentSandbox::apply | ( | PaymentSandbox & | to | ) | 
Definition at line 261 of file PaymentSandbox.cpp.
| std::map< std::tuple< AccountID, AccountID, Currency >, STAmount > ripple::PaymentSandbox::balanceChanges | ( | ReadView const & | view | ) | const | 
Definition at line 269 of file PaymentSandbox.cpp.
| XRPAmount ripple::PaymentSandbox::xrpDestroyed | ( | ) | const | 
Definition at line 394 of file PaymentSandbox.cpp.
      
  | 
  overridevirtualinherited | 
Returns true if this reflects an open ledger.
Implements ripple::ReadView.
Definition at line 33 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Returns information about the ledger.
Implements ripple::ReadView.
Definition at line 39 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Returns the fees for the base ledger.
Implements ripple::ReadView.
Definition at line 45 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Returns the tx processing rules.
Implements ripple::ReadView.
Definition at line 51 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Determine if a state item exists.
true if a SLE is associated with the specified key. Implements ripple::ReadView.
Definition at line 57 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
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 63 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
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 70 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Implements ripple::ReadView.
Definition at line 76 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Implements ripple::ReadView.
Definition at line 82 of file ApplyViewBase.cpp.
      
  | 
  overrideinherited | 
Definition at line 88 of file ApplyViewBase.cpp.
      
  | 
  pure virtualinherited | 
      
  | 
  overridevirtualinherited | 
Implements ripple::ReadView.
Definition at line 95 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Implements ripple::ReadView.
Definition at line 101 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
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 107 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
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 113 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Returns the tx apply flags.
Flags can affect the outcome of transaction processing. For example, transactions applied to an open ledger generate "local" failures, while transactions applied to the consensus ledger produce hard failures (and claim a fee).
Implements ripple::ApplyView.
Definition at line 121 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Prepare to modify the SLE associated with key.
Effects:
Gives the caller ownership of a modifiable SLE associated with the specified key.
The returned SLE may be used in a subsequent call to erase or update.
The SLE must not be passed to any other ApplyView.
nullptr if the key is not present Implements ripple::ApplyView.
Definition at line 127 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Remove a peeked SLE.
Requirements:
`sle` was obtained from prior call to peek() on this instance of the RawView.
Effects:
The key is no longer associated with the SLE.
Implements ripple::ApplyView.
Definition at line 133 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Insert a new state SLE.
Requirements:
`sle` was not obtained from any calls to peek() on any instances of RawView. The SLE's key must not already exist.
Effects:
The key in the state map is associated with the SLE. The RawView acquires ownership of the shared_ptr.
Implements ripple::ApplyView.
Definition at line 139 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Indicate changes to a peeked SLE.
Requirements:
The SLE's key must exist. `sle` was obtained from prior call to peek() on this instance of the RawView.
Effects:
The SLE is updated
Implements ripple::ApplyView.
Definition at line 145 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Delete an existing state item.
The SLE is provided so the implementation can calculate metadata.
Implements ripple::RawView.
Definition at line 153 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
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 159 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Unconditionally replace a state item.
Requirements:
The key must exist.
Effects:
The key is associated with the SLE.
Implements ripple::RawView.
Definition at line 165 of file ApplyViewBase.cpp.
      
  | 
  overridevirtualinherited | 
Destroy XRP.
This is used to pay for transaction fees.
Implements ripple::RawView.
Definition at line 171 of file ApplyViewBase.cpp.
      
  | 
  privateinherited | 
Add an entry to a directory using the specified insert strategy.
Definition at line 31 of file ApplyView.cpp.
      
  | 
  inherited | 
Append an entry to a directory.
Entries in the directory will be stored in order of insertion, i.e. new entries will always be added at the tail end of the last page.
| directory | the base of the directory | 
| key | the entry to insert | 
| describe | callback to add required entries to a new page | 
std::optional which, if insertion was successful, will contain the page number in which the item was stored.Definition at line 280 of file ApplyView.h.
      
  | 
  inherited | 
Insert an entry to a directory.
Entries in the directory will be stored in a semi-random order, but each page will be maintained in sorted order.
| directory | the base of the directory | 
| key | the entry to insert | 
| describe | callback to add required entries to a new page | 
std::optional which, if insertion was successful, will contain the page number in which the item was stored.Definition at line 319 of file ApplyView.h.
      
  | 
  inherited | 
Definition at line 328 of file ApplyView.h.
      
  | 
  inherited | 
Remove an entry from a directory.
| directory | the base of the directory | 
| page | the page number for this page | 
| key | the entry to remove | 
| keepRoot | if deleting the last entry, don't delete the root page (i.e. the directory itself). | 
true if the entry was found and deleted and false otherwise.keepRoot is not set and the directory is empty. Definition at line 207 of file ApplyView.cpp.
      
  | 
  inherited | 
Definition at line 361 of file ApplyView.h.
      
  | 
  inherited | 
Remove the specified directory, invoking the callback for every node.
Definition at line 356 of file ApplyView.cpp.
      
  | 
  inherited | 
Remove the specified directory, if it is empty.
| directory | the identifier of the directory node to be deleted | 
true if the directory was found and was successfully deleted false otherwise.Definition at line 141 of file ApplyView.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.
      
  | 
  private | 
Definition at line 206 of file PaymentSandbox.h.
      
  | 
  private | 
Definition at line 207 of file PaymentSandbox.h.
      
  | 
  protectedinherited | 
Definition at line 122 of file ApplyViewBase.h.
      
  | 
  protectedinherited | 
Definition at line 123 of file ApplyViewBase.h.
      
  | 
  protectedinherited | 
Definition at line 124 of file ApplyViewBase.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.