rippled
Loading...
Searching...
No Matches
xrpld
app
tx
detail
AMMDelete.cpp
1
#include <xrpld/app/misc/AMMUtils.h>
2
#include <xrpld/app/tx/detail/AMMDelete.h>
3
4
#include <xrpl/ledger/Sandbox.h>
5
#include <xrpl/protocol/AMMCore.h>
6
#include <xrpl/protocol/TER.h>
7
#include <xrpl/protocol/TxFlags.h>
8
9
namespace
ripple
{
10
11
bool
12
AMMDelete::checkExtraFeatures
(
PreflightContext
const
& ctx)
13
{
14
return
ammEnabled
(ctx.
rules
);
15
}
16
17
NotTEC
18
AMMDelete::preflight
(
PreflightContext
const
& ctx)
19
{
20
return
tesSUCCESS
;
21
}
22
23
TER
24
AMMDelete::preclaim
(
PreclaimContext
const
& ctx)
25
{
26
auto
const
ammSle =
27
ctx.
view
.
read
(
keylet::amm
(ctx.
tx
[sfAsset], ctx.
tx
[sfAsset2]));
28
if
(!ammSle)
29
{
30
JLOG(ctx.
j
.
debug
()) <<
"AMM Delete: Invalid asset pair."
;
31
return
terNO_AMM
;
32
}
33
34
auto
const
lpTokensBalance = (*ammSle)[sfLPTokenBalance];
35
if
(lpTokensBalance != beast::zero)
36
return
tecAMM_NOT_EMPTY
;
37
38
return
tesSUCCESS
;
39
}
40
41
TER
42
AMMDelete::doApply
()
43
{
44
// This is the ledger view that we work against. Transactions are applied
45
// as we go on processing transactions.
46
Sandbox
sb(&
ctx_
.
view
());
47
48
auto
const
ter =
deleteAMMAccount
(
49
sb,
ctx_
.
tx
[sfAsset].get<
Issue
>(),
ctx_
.
tx
[sfAsset2].get<
Issue
>(),
j_
);
50
if
(ter ==
tesSUCCESS
|| ter ==
tecINCOMPLETE
)
51
sb.
apply
(
ctx_
.
rawView
());
52
53
return
ter;
54
}
55
56
}
// namespace ripple
beast::Journal::debug
Stream debug() const
Definition
Journal.h:309
ripple::AMMDelete::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
AMMDelete.cpp:18
ripple::AMMDelete::doApply
TER doApply() override
Definition
AMMDelete.cpp:42
ripple::AMMDelete::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
AMMDelete.cpp:24
ripple::AMMDelete::checkExtraFeatures
static bool checkExtraFeatures(PreflightContext const &ctx)
Definition
AMMDelete.cpp:12
ripple::ApplyContext::rawView
RawView & rawView()
Definition
ApplyContext.h:72
ripple::ApplyContext::view
ApplyView & view()
Definition
ApplyContext.h:59
ripple::ApplyContext::tx
STTx const & tx
Definition
ApplyContext.h:53
ripple::Issue
A currency issued by an account.
Definition
Issue.h:14
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::Sandbox
Discardable, editable view to a ledger.
Definition
Sandbox.h:16
ripple::Sandbox::apply
void apply(RawView &to)
Definition
Sandbox.h:36
ripple::TERSubset
Definition
TER.h:396
ripple::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:126
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:124
ripple::keylet::amm
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition
Indexes.cpp:427
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:6
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition
AMMUtils.cpp:264
ripple::ammEnabled
bool ammEnabled(Rules const &)
Return true if required AMM amendments are enabled.
Definition
AMMCore.cpp:110
ripple::tecINCOMPLETE
@ tecINCOMPLETE
Definition
TER.h:317
ripple::tecAMM_NOT_EMPTY
@ tecAMM_NOT_EMPTY
Definition
TER.h:315
ripple::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:226
ripple::terNO_AMM
@ terNO_AMM
Definition
TER.h:208
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:61
ripple::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:64
ripple::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:67
ripple::PreclaimContext::j
beast::Journal const j
Definition
Transactor.h:69
ripple::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:16
ripple::PreflightContext::rules
Rules const rules
Definition
Transactor.h:20
Generated by
1.9.8