xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
tx
invariants
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
14
namespace
xrpl
{
15
29
class
ValidLoanBroker
30
{
31
// Not all of these elements will necessarily be populated. Remaining items
32
// will be looked up as needed.
33
struct
BrokerInfo
34
{
35
SLE::const_pointer
brokerBefore
=
nullptr
;
36
// After is used for most of the checks, except
37
// those that check changed values.
38
SLE::const_pointer
brokerAfter
=
nullptr
;
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
43
std::map<UInt256, BrokerInfo>
brokers_
;
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.
49
SLE::const_pointer
deletedBroker_
=
nullptr
;
50
// Set if visitEntry observes more than one ltLOAN_BROKER deletion in the
51
// same transaction. Enforced as its own invariant in finalize.
52
bool
multipleBrokerDeletions_
=
false
;
53
// Collect all the modified trust lines. Their high and low accounts will be
54
// loaded to look for LoanBroker pseudo-accounts.
55
std::vector<SLE::const_pointer>
lines_
;
56
// Collect all the modified MPTokens. Their accounts will be loaded to look
57
// for LoanBroker pseudo-accounts.
58
std::vector<SLE::const_pointer>
mpts_
;
59
60
static
bool
61
goodZeroDirectory
(
ReadView
const
& view,
SLE::ConstRef
dir,
beast::Journal
const
& j);
62
63
public
:
64
void
65
visitEntry
(
bool
,
SLE::ConstRef
,
SLE::ConstRef
);
66
67
bool
68
finalize
(
STTx
const
&,
TER
const
,
XRPAmount
const
,
ReadView
const
&,
beast::Journal
const
&);
69
};
70
71
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::STLedgerEntry::ConstRef
std::shared_ptr< STLedgerEntry const > const & ConstRef
Definition
STLedgerEntry.h:37
xrpl::STLedgerEntry::const_pointer
std::shared_ptr< STLedgerEntry const > const_pointer
Definition
STLedgerEntry.h:36
xrpl::STTx
Definition
STTx.h:43
xrpl::ValidLoanBroker
Invariants: Loan brokers are internally consistent.
Definition
LoanBrokerInvariant.h:30
xrpl::ValidLoanBroker::goodZeroDirectory
static bool goodZeroDirectory(ReadView const &view, SLE::ConstRef dir, beast::Journal const &j)
Definition
LoanBrokerInvariant.cpp:74
xrpl::ValidLoanBroker::brokers_
std::map< UInt256, BrokerInfo > brokers_
Definition
LoanBrokerInvariant.h:43
xrpl::ValidLoanBroker::visitEntry
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
Definition
LoanBrokerInvariant.cpp:28
xrpl::ValidLoanBroker::multipleBrokerDeletions_
bool multipleBrokerDeletions_
Definition
LoanBrokerInvariant.h:52
xrpl::ValidLoanBroker::deletedBroker_
SLE::const_pointer deletedBroker_
Definition
LoanBrokerInvariant.h:49
xrpl::ValidLoanBroker::mpts_
std::vector< SLE::const_pointer > mpts_
Definition
LoanBrokerInvariant.h:58
xrpl::ValidLoanBroker::lines_
std::vector< SLE::const_pointer > lines_
Definition
LoanBrokerInvariant.h:55
xrpl::ValidLoanBroker::finalize
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
Definition
LoanBrokerInvariant.cpp:112
xrpl::XRPAmount
Definition
XRPAmount.h:28
map
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
xrpl::ValidLoanBroker::BrokerInfo
Definition
LoanBrokerInvariant.h:34
xrpl::ValidLoanBroker::BrokerInfo::brokerBefore
SLE::const_pointer brokerBefore
Definition
LoanBrokerInvariant.h:35
xrpl::ValidLoanBroker::BrokerInfo::brokerAfter
SLE::const_pointer brokerAfter
Definition
LoanBrokerInvariant.h:38
vector
Generated by
1.17.0