rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
xrpl::detail::CachedViewImpl Class Referenceabstract

#include <CachedView.h>

Inheritance diagram for xrpl::detail::CachedViewImpl:
Inheritance graph
[legend]
Collaboration diagram for xrpl::detail::CachedViewImpl:
Collaboration graph
[legend]

Public Types

using digest_type = uint256
 
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

 CachedViewImpl ()=delete
 
 CachedViewImpl (CachedViewImpl const &)=delete
 
CachedViewImploperator= (CachedViewImpl const &)=delete
 
 CachedViewImpl (DigestAwareReadView const *base, CachedSLEs &cache)
 
bool exists (Keylet const &k) const override
 Determine if a state item exists.
 
std::shared_ptr< SLE const > read (Keylet const &k) const override
 Return the state item associated with a key.
 
bool open () const override
 Returns true if this reflects an open ledger.
 
LedgerHeader const & header () 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.
 
std::optional< key_typesucc (key_type const &key, std::optional< key_type > const &last=std::nullopt) const override
 Return the key of the next state item.
 
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.
 
std::optional< digest_typedigest (key_type const &key) const override
 Return the digest associated with the key.
 
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 Attributes

DigestAwareReadView const & base_
 
CachedSLEscache_
 
std::mutex mutex_
 
std::unordered_map< key_type, uint256, hardened_hash<> > map_
 

Detailed Description

Definition at line 14 of file CachedView.h.

Member Typedef Documentation

◆ digest_type

Definition at line 231 of file ReadView.h.

◆ tx_type

Definition at line 33 of file ReadView.h.

◆ key_type

using xrpl::ReadView::key_type = uint256
inherited

Definition at line 35 of file ReadView.h.

◆ mapped_type

Definition at line 37 of file ReadView.h.

Constructor & Destructor Documentation

◆ CachedViewImpl() [1/3]

xrpl::detail::CachedViewImpl::CachedViewImpl ( )
delete

◆ CachedViewImpl() [2/3]

xrpl::detail::CachedViewImpl::CachedViewImpl ( CachedViewImpl const &  )
delete

◆ CachedViewImpl() [3/3]

xrpl::detail::CachedViewImpl::CachedViewImpl ( DigestAwareReadView const *  base,
CachedSLEs cache 
)

Definition at line 28 of file CachedView.h.

Member Function Documentation

◆ operator=()

CachedViewImpl & xrpl::detail::CachedViewImpl::operator= ( CachedViewImpl const &  )
delete

◆ exists()

bool xrpl::detail::CachedViewImpl::exists ( Keylet const &  k) const
overridevirtual

Determine if a state item exists.

Note
This can be more efficient than calling read.
Returns
true if a SLE is associated with the specified key.

Implements xrpl::ReadView.

Definition at line 8 of file CachedView.cpp.

◆ read()

std::shared_ptr< SLE const > xrpl::detail::CachedViewImpl::read ( Keylet const &  k) const
overridevirtual

Return the state item associated with a key.

Effects: If the key exists, gives the caller ownership of the non-modifiable corresponding SLE.

Note
While the returned SLE is const from the perspective of the caller, it can be changed by other callers through raw operations.
Returns
nullptr if the key is not present or if the type does not match.

Implements xrpl::ReadView.

Definition at line 14 of file CachedView.cpp.

◆ open()

bool xrpl::detail::CachedViewImpl::open ( ) const
overridevirtual

Returns true if this reflects an open ledger.

Implements xrpl::ReadView.

Definition at line 43 of file CachedView.h.

◆ header()

LedgerHeader const & xrpl::detail::CachedViewImpl::header ( ) const
overridevirtual

Returns information about the ledger.

Implements xrpl::ReadView.

Definition at line 49 of file CachedView.h.

◆ fees()

Fees const & xrpl::detail::CachedViewImpl::fees ( ) const
overridevirtual

Returns the fees for the base ledger.

Implements xrpl::ReadView.

Definition at line 55 of file CachedView.h.

◆ rules()

Rules const & xrpl::detail::CachedViewImpl::rules ( ) const
overridevirtual

Returns the tx processing rules.

Implements xrpl::ReadView.

Definition at line 61 of file CachedView.h.

◆ succ()

std::optional< key_type > xrpl::detail::CachedViewImpl::succ ( key_type const &  key,
std::optional< key_type > const &  last = std::nullopt 
) const
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 xrpl::ReadView.

Definition at line 67 of file CachedView.h.

◆ slesBegin()

std::unique_ptr< sles_type::iter_base > xrpl::detail::CachedViewImpl::slesBegin ( ) const
overridevirtual

Implements xrpl::ReadView.

Definition at line 73 of file CachedView.h.

◆ slesEnd()

std::unique_ptr< sles_type::iter_base > xrpl::detail::CachedViewImpl::slesEnd ( ) const
overridevirtual

Implements xrpl::ReadView.

Definition at line 79 of file CachedView.h.

◆ slesUpperBound() [1/2]

std::unique_ptr< sles_type::iter_base > xrpl::detail::CachedViewImpl::slesUpperBound ( uint256 const &  key) const
override

Definition at line 85 of file CachedView.h.

◆ txsBegin()

std::unique_ptr< txs_type::iter_base > xrpl::detail::CachedViewImpl::txsBegin ( ) const
overridevirtual

Implements xrpl::ReadView.

Definition at line 91 of file CachedView.h.

◆ txsEnd()

std::unique_ptr< txs_type::iter_base > xrpl::detail::CachedViewImpl::txsEnd ( ) const
overridevirtual

Implements xrpl::ReadView.

Definition at line 97 of file CachedView.h.

◆ txExists()

bool xrpl::detail::CachedViewImpl::txExists ( key_type const &  key) const
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 xrpl::ReadView.

Definition at line 103 of file CachedView.h.

◆ txRead()

tx_type xrpl::detail::CachedViewImpl::txRead ( key_type const &  key) const
overridevirtual

Read a transaction from the tx map.

If the view represents an open ledger, the metadata object will be empty.

Returns
A pair of nullptr if the key is not found in the tx map.

Implements xrpl::ReadView.

Definition at line 109 of file CachedView.h.

◆ digest()

std::optional< digest_type > xrpl::detail::CachedViewImpl::digest ( key_type const &  key) const
overridevirtual

Return the digest associated with the key.

Returns
std::nullopt if the item does not exist.

Implements xrpl::DigestAwareReadView.

Definition at line 119 of file CachedView.h.

◆ parentCloseTime()

NetClock::time_point xrpl::ReadView::parentCloseTime ( ) const
inherited

Returns the close time of the previous ledger.

Definition at line 90 of file ReadView.h.

◆ seq()

LedgerIndex xrpl::ReadView::seq ( ) const
inherited

Returns the sequence number of the base ledger.

Definition at line 97 of file ReadView.h.

◆ balanceHook()

virtual STAmount xrpl::ReadView::balanceHook ( AccountID const &  account,
AccountID const &  issuer,
STAmount const &  amount 
) const
virtualinherited

Reimplemented in xrpl::PaymentSandbox.

Definition at line 155 of file ReadView.h.

◆ ownerCountHook()

virtual std::uint32_t xrpl::ReadView::ownerCountHook ( AccountID const &  account,
std::uint32_t  count 
) const
virtualinherited

Reimplemented in xrpl::PaymentSandbox.

Definition at line 166 of file ReadView.h.

◆ slesUpperBound() [2/2]

virtual std::unique_ptr< sles_type::iter_base > xrpl::ReadView::slesUpperBound ( key_type const &  key) const
pure virtualinherited

Member Data Documentation

◆ base_

DigestAwareReadView const& xrpl::detail::CachedViewImpl::base_
private

Definition at line 17 of file CachedView.h.

◆ cache_

CachedSLEs& xrpl::detail::CachedViewImpl::cache_
private

Definition at line 18 of file CachedView.h.

◆ mutex_

std::mutex xrpl::detail::CachedViewImpl::mutex_
mutableprivate

Definition at line 19 of file CachedView.h.

◆ map_

std::unordered_map<key_type, uint256, hardened_hash<> > xrpl::detail::CachedViewImpl::map_
mutableprivate

Definition at line 20 of file CachedView.h.

◆ sles

sles_type xrpl::ReadView::sles
inherited

Iterable range of ledger state items.

Note
Visiting each state entry in the ledger can become quite expensive as the ledger grows.

Definition at line 219 of file ReadView.h.

◆ txs

txs_type xrpl::ReadView::txs
inherited

Definition at line 222 of file ReadView.h.