xrpld
Loading...
Searching...
No Matches
LoanBrokerInvariant.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/STLedgerEntry.h>
7#include <xrpl/protocol/STTx.h>
8#include <xrpl/protocol/TER.h>
9#include <xrpl/protocol/XRPAmount.h>
10
11#include <map>
12#include <vector>
13
14namespace xrpl {
15
30{
31 // Not all of these elements will necessarily be populated. Remaining items
32 // will be looked up as needed.
34 {
36 // After is used for most of the checks, except
37 // those that check changed values.
39 };
40 // Collect all the LoanBrokers found directly or indirectly through
41 // pseudo-accounts. Key is the brokerID / index. It will be used to find the
42 // LoanBroker object if brokerBefore and brokerAfter are nullptr
44 // The broker whose ledger entry was deleted by this transaction, if any.
45 // Only ttLOAN_BROKER_DELETE removes a broker, and it removes exactly one.
46 // This is the pre-transaction state, which is what LoanBrokerDelete::preclaim
47 // reads when it decides whether the broker may be deleted, so the deletion invariants inspect
48 // the same DebtTotal and OwnerCount that the transactor did.
50 // Set if visitEntry observes more than one ltLOAN_BROKER deletion in the
51 // same transaction. Enforced as its own invariant in finalize.
53 // Collect all the modified trust lines. Their high and low accounts will be
54 // loaded to look for LoanBroker pseudo-accounts.
56 // Collect all the modified MPTokens. Their accounts will be loaded to look
57 // for LoanBroker pseudo-accounts.
59
60 static bool
61 goodZeroDirectory(ReadView const& view, SLE::ConstRef dir, beast::Journal const& j);
62
63public:
64 void
66
67 bool
68 finalize(STTx const&, TER const, XRPAmount const, ReadView const&, beast::Journal const&);
69};
70
71} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & ConstRef
std::shared_ptr< STLedgerEntry const > const_pointer
Invariants: Loan brokers are internally consistent.
static bool goodZeroDirectory(ReadView const &view, SLE::ConstRef dir, beast::Journal const &j)
std::map< UInt256, BrokerInfo > brokers_
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
SLE::const_pointer deletedBroker_
std::vector< SLE::const_pointer > mpts_
std::vector< SLE::const_pointer > lines_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToTER > TER
Definition TER.h:654