xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
tx
invariants
FreezeInvariant.h
1
#pragma once
2
3
#include <xrpl/beast/utility/Journal.h>
4
#include <xrpl/ledger/ReadView.h>
5
#include <xrpl/ledger/helpers/LendingHelpers.h>
6
#include <xrpl/protocol/AccountID.h>
7
#include <xrpl/protocol/Issue.h>
8
#include <xrpl/protocol/STAmount.h>
9
#include <xrpl/protocol/STLedgerEntry.h>
10
#include <xrpl/protocol/STTx.h>
11
#include <xrpl/protocol/TER.h>
12
#include <xrpl/protocol/XRPAmount.h>
13
14
#include <
map
>
15
#include <
optional
>
16
#include <
vector
>
17
18
namespace
xrpl
{
19
26
class
TransfersNotFrozen
27
{
28
struct
BalanceChange
29
{
30
SLE::const_pointer
const
line
;
31
int
const
balanceChangeSign
;
32
};
33
34
struct
IssuerChanges
35
{
36
std::vector<BalanceChange>
senders
;
37
std::vector<BalanceChange>
receivers
;
38
};
39
40
using
ByIssuer
=
std::map<Issue, IssuerChanges>
;
41
ByIssuer
balanceChanges_
;
42
43
std::map<AccountID, SLE::const_pointer const>
possibleIssuers_
;
44
45
public
:
46
void
47
visitEntry
(
bool
,
SLE::ConstRef
,
SLE::ConstRef
);
48
49
bool
50
finalize
(
STTx
const
&,
TER
const
,
XRPAmount
const
,
ReadView
const
&,
beast::Journal
const
&);
51
52
private
:
53
bool
54
isValidEntry
(
SLE::ConstRef
before,
SLE::ConstRef
after
);
55
56
static
STAmount
57
calculateBalanceChange
(
SLE::ConstRef
before,
SLE::ConstRef
after
,
bool
isDelete);
58
59
void
60
recordBalance
(
Issue
const
& issue,
BalanceChange
change);
61
62
void
63
recordBalanceChanges
(
SLE::ConstRef
after
,
STAmount
const
& balanceChange);
64
65
SLE::const_pointer
66
findIssuer
(
AccountID
const
& issuerID,
ReadView
const
& view);
67
68
static
bool
69
validateIssuerChanges
(
70
SLE::ConstRef
issuer,
71
IssuerChanges
const
& changes,
72
STTx
const
& tx,
73
beast::Journal
const
& j,
74
bool
enforce,
75
bool
fixOverrideFreeze,
76
std::optional<LoanDefaultFreezeExemptAccounts>
const
& loanDefaultAccounts);
77
78
static
bool
79
validateFrozenState
(
80
BalanceChange
const
& change,
81
bool
high,
82
STTx
const
& tx,
83
beast::Journal
const
& j,
84
bool
enforce,
85
bool
globalFreeze,
86
bool
fixOverrideFreeze,
87
std::optional<LoanDefaultFreezeExemptAccounts>
const
& loanDefaultAccounts);
88
};
89
90
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
xrpl::Issue
A currency issued by an account.
Definition
Issue.h:18
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::STAmount
Definition
STAmount.h:46
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::TransfersNotFrozen
Invariant: frozen trust line balance change is not allowed.
Definition
FreezeInvariant.h:27
xrpl::TransfersNotFrozen::recordBalance
void recordBalance(Issue const &issue, BalanceChange change)
Definition
FreezeInvariant.cpp:167
xrpl::TransfersNotFrozen::recordBalanceChanges
void recordBalanceChanges(SLE::ConstRef after, STAmount const &balanceChange)
Definition
FreezeInvariant.cpp:185
xrpl::TransfersNotFrozen::possibleIssuers_
std::map< AccountID, SLE::const_pointer const > possibleIssuers_
Definition
FreezeInvariant.h:43
xrpl::TransfersNotFrozen::visitEntry
void visitEntry(bool, SLE::ConstRef, SLE::ConstRef)
Definition
FreezeInvariant.cpp:28
xrpl::TransfersNotFrozen::finalize
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)
Definition
FreezeInvariant.cpp:55
xrpl::TransfersNotFrozen::validateIssuerChanges
static bool validateIssuerChanges(SLE::ConstRef issuer, IssuerChanges const &changes, STTx const &tx, beast::Journal const &j, bool enforce, bool fixOverrideFreeze, std::optional< LoanDefaultFreezeExemptAccounts > const &loanDefaultAccounts)
Definition
FreezeInvariant.cpp:213
xrpl::TransfersNotFrozen::isValidEntry
bool isValidEntry(SLE::ConstRef before, SLE::ConstRef after)
Definition
FreezeInvariant.cpp:117
xrpl::TransfersNotFrozen::findIssuer
SLE::const_pointer findIssuer(AccountID const &issuerID, ReadView const &view)
Definition
FreezeInvariant.cpp:202
xrpl::TransfersNotFrozen::calculateBalanceChange
static STAmount calculateBalanceChange(SLE::ConstRef before, SLE::ConstRef after, bool isDelete)
Definition
FreezeInvariant.cpp:142
xrpl::TransfersNotFrozen::balanceChanges_
ByIssuer balanceChanges_
Definition
FreezeInvariant.h:41
xrpl::TransfersNotFrozen::ByIssuer
std::map< Issue, IssuerChanges > ByIssuer
Definition
FreezeInvariant.h:40
xrpl::TransfersNotFrozen::validateFrozenState
static bool validateFrozenState(BalanceChange const &change, bool high, STTx const &tx, beast::Journal const &j, bool enforce, bool globalFreeze, bool fixOverrideFreeze, std::optional< LoanDefaultFreezeExemptAccounts > const &loanDefaultAccounts)
Definition
FreezeInvariant.cpp:264
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::after
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition
View.cpp:644
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
optional
xrpl::TransfersNotFrozen::BalanceChange
Definition
FreezeInvariant.h:29
xrpl::TransfersNotFrozen::BalanceChange::line
SLE::const_pointer const line
Definition
FreezeInvariant.h:30
xrpl::TransfersNotFrozen::BalanceChange::balanceChangeSign
int const balanceChangeSign
Definition
FreezeInvariant.h:31
xrpl::TransfersNotFrozen::IssuerChanges
Definition
FreezeInvariant.h:35
xrpl::TransfersNotFrozen::IssuerChanges::senders
std::vector< BalanceChange > senders
Definition
FreezeInvariant.h:36
xrpl::TransfersNotFrozen::IssuerChanges::receivers
std::vector< BalanceChange > receivers
Definition
FreezeInvariant.h:37
vector
Generated by
1.17.0