1#include <xrpl/tx/invariants/DirectoryInvariant.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/Feature.h>
7#include <xrpl/protocol/Indexes.h>
8#include <xrpl/protocol/LedgerFormats.h>
9#include <xrpl/protocol/SField.h>
10#include <xrpl/protocol/STLedgerEntry.h>
11#include <xrpl/protocol/STTx.h>
12#include <xrpl/protocol/TER.h>
13#include <xrpl/protocol/XRPAmount.h>
22isRootBookDirectory(
SLE const& dir)
25 return dir.isFieldPresent(sfExchangeRate) || dir.isFieldPresent(sfTakerPaysCurrency) ||
26 dir.isFieldPresent(sfTakerPaysIssuer) || dir.isFieldPresent(sfTakerPaysMPT) ||
27 dir.isFieldPresent(sfTakerGetsCurrency) || dir.isFieldPresent(sfTakerGetsIssuer) ||
28 dir.isFieldPresent(sfTakerGetsMPT) || dir.isFieldPresent(sfDomainID);
32badExchangeRate(
SLE const& dir)
34 return isRootBookDirectory(dir) &&
35 (!dir.isFieldPresent(sfExchangeRate) ||
36 dir.getFieldU64(sfExchangeRate) !=
getQuality(dir.key()));
57 auto const rootIndex =
after->getFieldH256(sfRootIndex);
61 if (before && before->getFieldH256(sfRootIndex) == rootIndex)
86 JLOG(j.
fatal()) <<
"Invariant failed: book directory exchange rate "
87 "does not match directory quality";
96 JLOG(j.
fatal()) <<
"Invariant failed: book directory root missing";
A generic endpoint for log messages.
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
hash_set< uint256 > rootIndexes_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::uint64_t getQuality(uint256 const &uBase)
Number root(Number f, unsigned d)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
TERSubset< CanCvtToTER > TER
A pair of SHAMap key and LedgerEntryType.