rippled
Loading...
Searching...
No Matches
libxrpl
tx
transactors
dex
OfferCancel.cpp
1
#include <xrpl/ledger/View.h>
2
#include <xrpl/ledger/helpers/OfferHelpers.h>
3
#include <xrpl/protocol/st.h>
4
#include <xrpl/tx/transactors/dex/OfferCancel.h>
5
6
namespace
xrpl
{
7
8
NotTEC
9
OfferCancel::preflight
(
PreflightContext
const
& ctx)
10
{
11
if
(ctx.
tx
[sfOfferSequence] == 0u)
12
{
13
JLOG(ctx.
j
.
trace
()) <<
"OfferCancel::preflight: missing sequence"
;
14
return
temBAD_SEQUENCE
;
15
}
16
17
return
tesSUCCESS
;
18
}
19
20
//------------------------------------------------------------------------------
21
22
TER
23
OfferCancel::preclaim
(
PreclaimContext
const
& ctx)
24
{
25
auto
const
id
= ctx.
tx
[sfAccount];
26
auto
const
offerSequence = ctx.
tx
[sfOfferSequence];
27
28
auto
const
sle = ctx.
view
.
read
(
keylet::account
(
id
));
29
if
(!sle)
30
return
terNO_ACCOUNT
;
31
32
if
((*sle)[sfSequence] <= offerSequence)
33
{
34
JLOG(ctx.
j
.
trace
()) <<
"Malformed transaction: "
35
<<
"Sequence "
<< offerSequence <<
" is invalid."
;
36
return
temBAD_SEQUENCE
;
37
}
38
39
return
tesSUCCESS
;
40
}
41
42
//------------------------------------------------------------------------------
43
44
TER
45
OfferCancel::doApply
()
46
{
47
auto
const
offerSequence =
ctx_
.
tx
[sfOfferSequence];
48
49
auto
const
sle =
view
().
read
(
keylet::account
(
account_
));
50
if
(!sle)
51
return
tefINTERNAL
;
// LCOV_EXCL_LINE
52
53
if
(
auto
sleOffer =
view
().peek(
keylet::offer
(
account_
, offerSequence)))
54
{
55
JLOG(
j_
.
debug
()) <<
"Trying to cancel offer #"
<< offerSequence;
56
return
offerDelete
(
view
(), sleOffer,
ctx_
.
registry
.get().getJournal(
"View"
));
57
}
58
59
JLOG(
j_
.
debug
()) <<
"Offer #"
<< offerSequence <<
" can't be found."
;
60
return
tesSUCCESS
;
61
}
62
63
}
// namespace xrpl
beast::Journal::debug
Stream debug() const
Definition
Journal.h:301
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition
Journal.h:295
xrpl::ApplyContext::tx
STTx const & tx
Definition
ApplyContext.h:41
xrpl::ApplyContext::registry
std::reference_wrapper< ServiceRegistry > registry
Definition
ApplyContext.h:40
xrpl::OfferCancel::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
OfferCancel.cpp:23
xrpl::OfferCancel::doApply
TER doApply() override
Definition
OfferCancel.cpp:45
xrpl::OfferCancel::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
OfferCancel.cpp:9
xrpl::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
xrpl::TERSubset< CanCvtToTER >
xrpl::Transactor::account_
AccountID const account_
Definition
Transactor.h:116
xrpl::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:114
xrpl::Transactor::view
ApplyView & view()
Definition
Transactor.h:132
xrpl::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:112
xrpl::keylet::offer
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition
Indexes.cpp:243
xrpl::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition
Indexes.cpp:165
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition
TER.h:197
xrpl::tefINTERNAL
@ tefINTERNAL
Definition
TER.h:153
xrpl::offerDelete
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition
OfferHelpers.cpp:11
xrpl::temBAD_SEQUENCE
@ temBAD_SEQUENCE
Definition
TER.h:84
xrpl::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:582
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:225
xrpl::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:57
xrpl::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:60
xrpl::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:63
xrpl::PreclaimContext::j
beast::Journal const j
Definition
Transactor.h:65
xrpl::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:14
xrpl::PreflightContext::j
beast::Journal const j
Definition
Transactor.h:21
xrpl::PreflightContext::tx
STTx const & tx
Definition
Transactor.h:17
Generated by
1.9.8