rippled
Loading...
Searching...
No Matches
xrpld
app
tx
detail
CancelOffer.cpp
1
#include <xrpld/app/tx/detail/CancelOffer.h>
2
3
#include <xrpl/basics/Log.h>
4
#include <xrpl/ledger/View.h>
5
#include <xrpl/protocol/st.h>
6
7
namespace
ripple
{
8
9
NotTEC
10
CancelOffer::preflight
(
PreflightContext
const
& ctx)
11
{
12
if
(!ctx.
tx
[sfOfferSequence])
13
{
14
JLOG(ctx.
j
.
trace
()) <<
"CancelOffer::preflight: missing sequence"
;
15
return
temBAD_SEQUENCE
;
16
}
17
18
return
tesSUCCESS
;
19
}
20
21
//------------------------------------------------------------------------------
22
23
TER
24
CancelOffer::preclaim
(
PreclaimContext
const
& ctx)
25
{
26
auto
const
id
= ctx.
tx
[sfAccount];
27
auto
const
offerSequence = ctx.
tx
[sfOfferSequence];
28
29
auto
const
sle = ctx.
view
.
read
(
keylet::account
(
id
));
30
if
(!sle)
31
return
terNO_ACCOUNT
;
32
33
if
((*sle)[sfSequence] <= offerSequence)
34
{
35
JLOG(ctx.
j
.
trace
()) <<
"Malformed transaction: "
36
<<
"Sequence "
<< offerSequence <<
" is invalid."
;
37
return
temBAD_SEQUENCE
;
38
}
39
40
return
tesSUCCESS
;
41
}
42
43
//------------------------------------------------------------------------------
44
45
TER
46
CancelOffer::doApply
()
47
{
48
auto
const
offerSequence =
ctx_
.
tx
[sfOfferSequence];
49
50
auto
const
sle =
view
().
read
(
keylet::account
(
account_
));
51
if
(!sle)
52
return
tefINTERNAL
;
// LCOV_EXCL_LINE
53
54
if
(
auto
sleOffer =
view
().peek(
keylet::offer
(
account_
, offerSequence)))
55
{
56
JLOG(
j_
.
debug
()) <<
"Trying to cancel offer #"
<< offerSequence;
57
return
offerDelete
(
view
(), sleOffer,
ctx_
.
app
.
journal
(
"View"
));
58
}
59
60
JLOG(
j_
.
debug
()) <<
"Offer #"
<< offerSequence <<
" can't be found."
;
61
return
tesSUCCESS
;
62
}
63
64
}
// namespace ripple
beast::Journal::debug
Stream debug() const
Definition
Journal.h:309
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition
Journal.h:303
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::ApplyContext::app
Application & app
Definition
ApplyContext.h:52
ripple::ApplyContext::tx
STTx const & tx
Definition
ApplyContext.h:53
ripple::CancelOffer::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
CancelOffer.cpp:24
ripple::CancelOffer::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
CancelOffer.cpp:10
ripple::CancelOffer::doApply
TER doApply() override
Definition
CancelOffer.cpp:46
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::TERSubset< CanCvtToTER >
ripple::Transactor::account_
AccountID const account_
Definition
Transactor.h:128
ripple::Transactor::view
ApplyView & view()
Definition
Transactor.h:144
ripple::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:126
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:124
ripple::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition
Indexes.cpp:165
ripple::keylet::offer
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition
Indexes.cpp:255
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:6
ripple::tefINTERNAL
@ tefINTERNAL
Definition
TER.h:154
ripple::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:226
ripple::terNO_ACCOUNT
@ terNO_ACCOUNT
Definition
TER.h:198
ripple::offerDelete
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition
View.cpp:1628
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:590
ripple::temBAD_SEQUENCE
@ temBAD_SEQUENCE
Definition
TER.h:85
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::j
beast::Journal const j
Definition
Transactor.h:23
ripple::PreflightContext::tx
STTx const & tx
Definition
Transactor.h:19
Generated by
1.9.8