|
xrpld
|
Writeable view to a ledger, for applying a transaction. More...
#include <ApplyView.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 = SLE::const_pointer |
Public Member Functions | |
| ApplyView ()=default | |
| virtual ApplyFlags | flags () const =0 |
| Returns the tx apply flags. | |
| virtual SLE::pointer | peek (Keylet const &k)=0 |
| Prepare to modify the SLE associated with key. | |
| virtual void | erase (SLE::ref sle)=0 |
| Remove a peeked SLE. | |
| virtual void | insert (SLE::ref sle)=0 |
| Insert a new state SLE. | |
| 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. | |
| virtual LedgerHeader const & | header () const =0 |
| Returns information about the ledger. | |
| virtual bool | open () const =0 |
| Returns true if this reflects an open ledger. | |
| 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 Fees const & | fees () const =0 |
| Returns the fees for the base ledger. | |
| virtual Rules const & | rules () const =0 |
| Returns the tx processing rules. | |
| virtual bool | exists (Keylet const &k) const =0 |
| Determine if a state item exists. | |
| virtual std::optional< key_type > | succ (key_type const &key, std::optional< key_type > const &last=std::nullopt) const =0 |
| Return the key of the next state item. | |
| virtual SLE::const_pointer | read (Keylet const &k) const =0 |
| Return the state item associated with a key. | |
| virtual STAmount | balanceHookIOU (AccountID const &account, AccountID const &issuer, STAmount const &amount) const |
| virtual STAmount | balanceHookMPT (AccountID const &account, MPTIssue const &issue, std::int64_t amount) const |
| virtual STAmount | balanceHookSelfIssueMPT (MPTIssue const &issue, std::int64_t amount) const |
| virtual std::uint32_t | ownerCountHook (AccountID const &account, std::uint32_t count) const |
| virtual std::unique_ptr< SlesType::iter_base > | slesBegin () const =0 |
| virtual std::unique_ptr< SlesType::iter_base > | slesEnd () const =0 |
| virtual std::unique_ptr< SlesType::iter_base > | slesUpperBound (key_type const &key) const =0 |
| virtual std::unique_ptr< TxsType::iter_base > | txsBegin () const =0 |
| virtual std::unique_ptr< TxsType::iter_base > | txsEnd () const =0 |
| virtual bool | txExists (key_type const &key) const =0 |
| Returns true if a tx exists in the tx map. | |
| virtual tx_type | txRead (key_type const &key) const =0 |
| Read a transaction from the tx map. | |
| virtual void | update (SLE::ref sle)=0 |
| Indicate changes to a peeked SLE. | |
| virtual void | creditHookIOU (AccountID const &from, AccountID const &to, STAmount const &amount, STAmount const &preCreditBalance) |
| virtual void | creditHookMPT (AccountID const &from, AccountID const &to, STAmount const &amount, std::uint64_t preCreditBalanceHolder, std::int64_t preCreditBalanceIssuer) |
| virtual void | issuerSelfDebitHookMPT (MPTIssue const &issue, std::uint64_t amount, std::int64_t origBalance) |
| Facilitate tracking of MPT sold by an issuer owning MPT sell offer. | |
| virtual void | adjustOwnerCountHook (AccountID const &account, std::uint32_t cur, std::uint32_t next) |
| std::optional< std::uint64_t > | dirAppend (Keylet const &directory, Keylet const &key, std::function< void(SLE::ref)> const &describe) |
| Append an entry to a directory. | |
| std::optional< std::uint64_t > | dirInsert (Keylet const &directory, uint256 const &key, std::function< void(SLE::ref)> const &describe) |
| Insert an entry to a directory. | |
| std::optional< std::uint64_t > | dirInsert (Keylet const &directory, Keylet const &key, std::function< void(SLE::ref)> 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 | |
| SlesType | sles |
| Iterable range of ledger state items. | |
| TxsType | txs |
Private Member Functions | |
| std::optional< std::uint64_t > | dirAdd (bool preserveOrder, Keylet const &directory, uint256 const &key, std::function< void(SLE::ref)> const &describe) |
| Add an entry to a directory using the specified insert strategy. | |
Writeable view to a ledger, for applying a transaction.
This refinement of ReadView provides an interface where the SLE can be "checked out" for modifications and put back in an updated or removed state. Also added is an interface to provide contextual information necessary to calculate the results of transaction processing, including the metadata if the view is later applied to the parent (using an interface in the derived class). The context info also includes values from the base ledger such as sequence number and the network time.
This allows implementations to journal changes made to the state items in a ledger, with the option to apply those changes to the base or discard the changes without affecting the base.
Typical usage is to call read() for non-mutating operations.
For mutating operations the sequence is as follows:
Add a new value v.insert(sle);
Check out a value for modification sle = v.peek(k);
Indicate that changes were made v.update(sle)
Or, erase the value v.erase(sle)
The invariant is that insert, update, and erase may not be called with any SLE which belongs to different view.
Definition at line 117 of file ApplyView.h.
|
inherited |
Definition at line 33 of file ReadView.h.
|
inherited |
Definition at line 35 of file ReadView.h.
|
inherited |
Definition at line 37 of file ReadView.h.
|
default |
|
private |
Add an entry to a directory using the specified insert strategy.
Definition at line 165 of file ApplyView.cpp.
|
nodiscardpure virtual |
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).
Implemented in xrpl::detail::ApplyViewBase.
|
pure virtual |
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.
Implemented in xrpl::detail::ApplyViewBase.
|
pure virtual |
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.
Implemented in xrpl::detail::ApplyViewBase.
|
pure virtual |
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.
Implemented in xrpl::detail::ApplyViewBase.
|
pure virtual |
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
Implemented in xrpl::detail::ApplyViewBase.
|
virtual |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 218 of file ApplyView.h.
|
virtual |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 228 of file ApplyView.h.
|
virtual |
Facilitate tracking of MPT sold by an issuer owning MPT sell offer.
Unlike IOU, MPT doesn't have bi-directional relationship with an issuer, where a trustline limits an amount that can be issued to a holder. Consequently, the credit step (last MPTEndpointStep or BookStep buying MPT) might temporarily overflow OutstandingAmount. Limiting of a step's output amount in this case is delegated to the next step (in rev order). The next step always redeems when a holder account sells MPT (first MPTEndpointStep or BookStep selling MPT). In this case the holder account is only limited by the step's output and it's available funds since it's transferring the funds from one account to another account and doesn't change OutstandingAmount. This doesn't apply to an offer owned by an issuer. In this case the issuer sells or self debits and is increasing OutstandingAmount. Ability to issue is limited by the issuer originally available funds less already self sold MPT amounts (MPT sell offer). Consider an example:
Reimplemented in xrpl::PaymentSandbox.
Definition at line 271 of file ApplyView.h.
|
virtual |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 278 of file ApplyView.h.
| std::optional< std::uint64_t > xrpl::ApplyView::dirAppend | ( | Keylet const & | directory, |
| Keylet const & | key, | ||
| std::function< void(SLE::ref)> const & | describe ) |
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 301 of file ApplyView.h.
| std::optional< std::uint64_t > xrpl::ApplyView::dirInsert | ( | Keylet const & | directory, |
| uint256 const & | key, | ||
| std::function< void(SLE::ref)> const & | describe ) |
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 340 of file ApplyView.h.
| std::optional< std::uint64_t > xrpl::ApplyView::dirInsert | ( | Keylet const & | directory, |
| Keylet const & | key, | ||
| std::function< void(SLE::ref)> const & | describe ) |
Definition at line 349 of file ApplyView.h.
| bool xrpl::ApplyView::dirRemove | ( | Keylet const & | directory, |
| std::uint64_t | page, | ||
| uint256 const & | key, | ||
| bool | keepRoot ) |
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 256 of file ApplyView.cpp.
| bool xrpl::ApplyView::dirRemove | ( | Keylet const & | directory, |
| std::uint64_t | page, | ||
| Keylet const & | key, | ||
| bool | keepRoot ) |
Definition at line 378 of file ApplyView.h.
| bool xrpl::ApplyView::dirDelete | ( | Keylet const & | directory, |
| std::function< void(uint256 const &)> const & | callback ) |
Remove the specified directory, invoking the callback for every node.
Definition at line 396 of file ApplyView.cpp.
| bool xrpl::ApplyView::emptyDirDelete | ( | Keylet const & | directory | ) |
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 191 of file ApplyView.cpp.
|
nodiscardpure virtualinherited |
Returns information about the ledger.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Returns true if this reflects an open ledger.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardinherited |
Returns the close time of the previous ledger.
Definition at line 90 of file ReadView.h.
|
nodiscardinherited |
Returns the sequence number of the base ledger.
Definition at line 97 of file ReadView.h.
|
nodiscardpure virtualinherited |
Returns the fees for the base ledger.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Returns the tx processing rules.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Determine if a state item exists.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
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).
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Return the state item associated with a key.
Effects: If the key exists, gives the caller ownership of the non-modifiable corresponding SLE.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardvirtualinherited |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 155 of file ReadView.h.
|
nodiscardvirtualinherited |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 165 of file ReadView.h.
|
nodiscardvirtualinherited |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 175 of file ReadView.h.
|
nodiscardvirtualinherited |
Reimplemented in xrpl::PaymentSandbox.
Definition at line 186 of file ReadView.h.
|
nodiscardpure virtualinherited |
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
|
nodiscardpure virtualinherited |
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
nodiscardpure virtualinherited |
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.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, and xrpl::OpenView.
Read a transaction from the tx map.
If the view represents an open ledger, the metadata object will be empty.
Implemented in xrpl::detail::ApplyViewBase, xrpl::detail::CachedViewImpl, xrpl::Ledger, and xrpl::OpenView.
|
inherited |
Iterable range of ledger state items.
Definition at line 239 of file ReadView.h.
|
inherited |
Definition at line 242 of file ReadView.h.