| 
    rippled
    
   | 
 
Holds a ledger. More...
#include <Ledger.h>


Classes | |
| class | sles_iter_impl | 
| class | txs_iter_impl | 
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 | |
| Ledger (Ledger const &)=delete | |
| Ledger & | operator= (Ledger const &)=delete | 
| Ledger (Ledger &&)=delete | |
| Ledger & | operator= (Ledger &&)=delete | 
| Ledger (create_genesis_t, Config const &config, std::vector< uint256 > const &amendments, Family &family) | |
| Create the Genesis ledger.   | |
| Ledger (LedgerInfo const &info, Config const &config, Family &family) | |
| Ledger (LedgerInfo const &info, bool &loaded, bool acquire, Config const &config, Family &family, beast::Journal j) | |
| Used for ledgers loaded from JSON files.   | |
| Ledger (Ledger const &previous, NetClock::time_point closeTime) | |
| Create a new ledger following a previous ledger.   | |
| Ledger (std::uint32_t ledgerSeq, NetClock::time_point closeTime, Config const &config, Family &family) | |
| ~Ledger ()=default | |
| bool | open () const override | 
| Returns true if this reflects an open ledger.   | |
| LedgerInfo const & | info () const override | 
| Returns information about the ledger.   | |
| void | setLedgerInfo (LedgerInfo const &info) | 
| 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.   | |
| bool | exists (uint256 const &key) const | 
| std::optional< uint256 > | succ (uint256 const &key, std::optional< uint256 > const &last=std::nullopt) const override | 
| 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 (uint256 const &key) const override | 
| tx_type | txRead (key_type const &key) const override | 
| Read a transaction from the tx map.   | |
| std::optional< digest_type > | digest (key_type const &key) const override | 
| Return the digest associated with the key.   | |
| 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 | rawErase (uint256 const &key) | 
| void | rawReplace (std::shared_ptr< SLE > const &sle) override | 
| Unconditionally replace a state item.   | |
| void | rawDestroyXRP (XRPAmount const &fee) override | 
| Destroy XRP.   | |
| void | rawTxInsert (uint256 const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData) override | 
| uint256 | rawTxInsertWithHash (uint256 const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData) | 
| void | setValidated () const | 
| void | setAccepted (NetClock::time_point closeTime, NetClock::duration closeResolution, bool correctCloseTime) | 
| void | setImmutable (bool rehash=true) | 
| bool | isImmutable () const | 
| void | setFull () const | 
| void | setTotalDrops (std::uint64_t totDrops) | 
| SHAMap const & | stateMap () const | 
| SHAMap & | stateMap () | 
| SHAMap const & | txMap () const | 
| SHAMap & | txMap () | 
| bool | addSLE (SLE const &sle) | 
| void | updateSkipList () | 
| bool | walkLedger (beast::Journal j, bool parallel=false) const | 
| bool | assertSensible (beast::Journal ledgerJ) const | 
| void | invariants () const | 
| void | unshare () const | 
| hash_set< PublicKey > | negativeUNL () const | 
| get Negative UNL validators' master public keys   | |
| std::optional< PublicKey > | validatorToDisable () const | 
| get the to be disabled validator's master public key if any   | |
| std::optional< PublicKey > | validatorToReEnable () const | 
| get the to be re-enabled validator's master public key if any   | |
| void | updateNegativeUNL () | 
| update the Negative UNL ledger component.   | |
| bool | isFlagLedger () const | 
| Returns true if the ledger is a flag ledger.   | |
| bool | isVotingLedger () const | 
| Returns true if the ledger directly precedes a flag ledger.   | |
| std::shared_ptr< SLE > | peek (Keylet const &k) const | 
| T | shared_from_this (T... args) | 
| T | weak_from_this (T... args) | 
| 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 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 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 | 
| virtual bool | txExists (key_type const &key) const =0 | 
Returns true if a tx exists in the tx map.   | |
| virtual void | rawTxInsert (ReadView::key_type const &key, std::shared_ptr< Serializer const > const &txn, std::shared_ptr< Serializer const > const &metaData)=0 | 
| Add a transaction to the tx map.   | |
Public Attributes | |
| sles_type | sles | 
| Iterable range of ledger state items.   | |
| txs_type | txs | 
Private Member Functions | |
| bool | setup () | 
| void | defaultFees (Config const &config) | 
Static Private Member Functions | |
| static auto & | getCounter () noexcept | 
Private Attributes | |
| bool | mImmutable | 
| SHAMap | txMap_ | 
| SHAMap | stateMap_ | 
| std::mutex | mutex_ | 
| Fees | fees_ | 
| Rules | rules_ | 
| LedgerInfo | info_ | 
| beast::Journal | j_ | 
Holds a ledger.
The ledger is composed of two SHAMaps. The state map holds all of the ledger entries such as account roots and order books. The tx map holds all of the transactions and associated metadata that made it into that particular ledger. Most of the operations on a ledger are concerned with the state map.
This can hold just the header, a partial set of data, or the entire set of data. It all depends on what is in the corresponding SHAMap entry. Various functions are provided to populate or depopulate the caches that the object holds references to.
Ledgers are constructed as either mutable or immutable.
1) If you are the sole owner of a mutable ledger, you can do whatever you want with no need for locks.
2) If you have an immutable ledger, you cannot ever change it, so no need for locks.
3) Mutable ledgers cannot be shared.
      
  | 
  inherited | 
Definition at line 257 of file ReadView.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 | 
| ripple::Ledger::Ledger | ( | create_genesis_t | , | 
| Config const & | config, | ||
| std::vector< uint256 > const & | amendments, | ||
| Family & | family | ||
| ) | 
Create the Genesis ledger.
The Genesis ledger contains a single account whose AccountID is generated with a Generator using the seed computed from the string "masterpassphrase" and ordinal zero.
The account has an XRP balance equal to the total amount of XRP in the system. No more XRP than the amount which starts in this account can ever exist, with amounts used to pay fees being destroyed.
Amendments specified are enabled in the genesis ledger
Definition at line 168 of file Ledger.cpp.
| ripple::Ledger::Ledger | ( | LedgerInfo const & | info, | 
| Config const & | config, | ||
| Family & | family | ||
| ) | 
Definition at line 307 of file Ledger.cpp.
| ripple::Ledger::Ledger | ( | LedgerInfo const & | info, | 
| bool & | loaded, | ||
| bool | acquire, | ||
| Config const & | config, | ||
| Family & | family, | ||
| beast::Journal | j | ||
| ) | 
Used for ledgers loaded from JSON files.
| acquire | If true, acquires the ledger if not found locally | 
Definition at line 231 of file Ledger.cpp.
| ripple::Ledger::Ledger | ( | Ledger const & | previous, | 
| NetClock::time_point | closeTime | ||
| ) | 
Create a new ledger following a previous ledger.
The ledger will have the sequence number that follows previous, and have parentCloseTime == previous.closeTime.
Definition at line 277 of file Ledger.cpp.
| ripple::Ledger::Ledger | ( | std::uint32_t | ledgerSeq, | 
| NetClock::time_point | closeTime, | ||
| Config const & | config, | ||
| Family & | family | ||
| ) | 
Definition at line 318 of file Ledger.cpp.
      
  | 
  default | 
      
  | 
  overridevirtual | 
Returns true if this reflects an open ledger.
Implements ripple::ReadView.
      
  | 
  overridevirtual | 
Returns information about the ledger.
Implements ripple::ReadView.
| void ripple::Ledger::setLedgerInfo | ( | LedgerInfo const & | info | ) | 
      
  | 
  overridevirtual | 
Returns the fees for the base ledger.
Implements ripple::ReadView.
      
  | 
  overridevirtual | 
Returns the tx processing rules.
Implements ripple::ReadView.
      
  | 
  overridevirtual | 
Determine if a state item exists.
true if a SLE is associated with the specified key. Implements ripple::ReadView.
Definition at line 408 of file Ledger.cpp.
| bool ripple::Ledger::exists | ( | uint256 const & | key | ) | const | 
Definition at line 415 of file Ledger.cpp.
      
  | 
  override | 
Definition at line 421 of file Ledger.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 432 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 453 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 459 of file Ledger.cpp.
      
  | 
  override | 
Definition at line 465 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 472 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Implements ripple::ReadView.
Definition at line 478 of file Ledger.cpp.
      
  | 
  override | 
Definition at line 484 of file Ledger.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 490 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Return the digest associated with the key.
Implements ripple::DigestAwareReadView.
Definition at line 504 of file Ledger.cpp.
      
  | 
  overridevirtual | 
Delete an existing state item.
The SLE is provided so the implementation can calculate metadata.
Implements ripple::RawView.
Definition at line 517 of file Ledger.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 531 of file Ledger.cpp.
| void ripple::Ledger::rawErase | ( | uint256 const & | key | ) | 
Definition at line 524 of file Ledger.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 542 of file Ledger.cpp.
      
  | 
  overridevirtual | 
      
  | 
  override | 
Definition at line 553 of file Ledger.cpp.
| uint256 ripple::Ledger::rawTxInsertWithHash | ( | uint256 const & | key, | 
| std::shared_ptr< Serializer const > const & | txn, | ||
| std::shared_ptr< Serializer const > const & | metaData | ||
| ) | 
Definition at line 571 of file Ledger.cpp.
| void ripple::Ledger::setAccepted | ( | NetClock::time_point | closeTime, | 
| NetClock::duration | closeResolution, | ||
| bool | correctCloseTime | ||
| ) | 
Definition at line 357 of file Ledger.cpp.
| void ripple::Ledger::setImmutable | ( | bool | rehash = true | ) | 
Definition at line 337 of file Ledger.cpp.
| void ripple::Ledger::setTotalDrops | ( | std::uint64_t | totDrops | ) | 
| bool ripple::Ledger::addSLE | ( | SLE const & | sle | ) | 
Definition at line 372 of file Ledger.cpp.
| void ripple::Ledger::updateSkipList | ( | ) | 
Definition at line 882 of file Ledger.cpp.
| bool ripple::Ledger::walkLedger | ( | beast::Journal | j, | 
| bool | parallel = false  | 
        ||
| ) | const | 
Definition at line 805 of file Ledger.cpp.
| bool ripple::Ledger::assertSensible | ( | beast::Journal | ledgerJ | ) | const | 
Definition at line 856 of file Ledger.cpp.
| void ripple::Ledger::invariants | ( | ) | const | 
Definition at line 1054 of file Ledger.cpp.
| void ripple::Ledger::unshare | ( | ) | const | 
Definition at line 1047 of file Ledger.cpp.
get Negative UNL validators' master public keys
Definition at line 698 of file Ledger.cpp.
| std::optional< PublicKey > ripple::Ledger::validatorToDisable | ( | ) | const | 
get the to be disabled validator's master public key if any
Definition at line 724 of file Ledger.cpp.
| std::optional< PublicKey > ripple::Ledger::validatorToReEnable | ( | ) | const | 
get the to be re-enabled validator's master public key if any
Definition at line 739 of file Ledger.cpp.
| void ripple::Ledger::updateNegativeUNL | ( | ) | 
update the Negative UNL ledger component.
Definition at line 754 of file Ledger.cpp.
| bool ripple::Ledger::isFlagLedger | ( | ) | const | 
Returns true if the ledger is a flag ledger.
Definition at line 950 of file Ledger.cpp.
| bool ripple::Ledger::isVotingLedger | ( | ) | const | 
Returns true if the ledger directly precedes a flag ledger.
Definition at line 955 of file Ledger.cpp.
| std::shared_ptr< SLE > ripple::Ledger::peek | ( | Keylet const & | k | ) | const | 
Definition at line 686 of file Ledger.cpp.
      
  | 
  private | 
Definition at line 593 of file Ledger.cpp.
      
  | 
  private | 
Definition at line 672 of file Ledger.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.
      
  | 
  pure 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 ripple::detail::CachedViewImpl, ripple::detail::ApplyViewBase, and ripple::OpenView.
      
  | 
  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 | 
      
  | 
  pure 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 ripple::detail::CachedViewImpl, ripple::detail::ApplyViewBase, and ripple::OpenView.
      
  | 
  pure virtualinherited | 
Add a transaction to the tx map.
Closed ledgers must have metadata, while open ledgers omit metadata.
Implemented in ripple::OpenView.
      
  | 
  staticprivatenoexceptinherited | 
Definition at line 129 of file CountedObject.h.
      
  | 
  mutableprivate | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  inherited | 
Iterable range of ledger state items.
Definition at line 245 of file ReadView.h.
      
  | 
  inherited | 
Definition at line 248 of file ReadView.h.