/
applySteps.cpp
696 lines (660 loc) · 21.3 KB
/
applySteps.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/app/tx/applySteps.h>
#include <ripple/app/tx/impl/ApplyContext.h>
#include <ripple/app/tx/impl/CancelCheck.h>
#include <ripple/app/tx/impl/CancelOffer.h>
#include <ripple/app/tx/impl/CashCheck.h>
#include <ripple/app/tx/impl/Change.h>
#include <ripple/app/tx/impl/ClaimReward.h>
#include <ripple/app/tx/impl/CreateCheck.h>
#include <ripple/app/tx/impl/CreateOffer.h>
#include <ripple/app/tx/impl/CreateTicket.h>
#include <ripple/app/tx/impl/DeleteAccount.h>
#include <ripple/app/tx/impl/DepositPreauth.h>
#include <ripple/app/tx/impl/Escrow.h>
#include <ripple/app/tx/impl/GenesisMint.h>
#include <ripple/app/tx/impl/Import.h>
#include <ripple/app/tx/impl/Invoke.h>
#include <ripple/app/tx/impl/NFTokenAcceptOffer.h>
#include <ripple/app/tx/impl/NFTokenBurn.h>
#include <ripple/app/tx/impl/NFTokenCancelOffer.h>
#include <ripple/app/tx/impl/NFTokenCreateOffer.h>
#include <ripple/app/tx/impl/NFTokenMint.h>
#include <ripple/app/tx/impl/PayChan.h>
#include <ripple/app/tx/impl/Payment.h>
#include <ripple/app/tx/impl/Remit.h>
#include <ripple/app/tx/impl/SetAccount.h>
#include <ripple/app/tx/impl/SetHook.h>
#include <ripple/app/tx/impl/SetRegularKey.h>
#include <ripple/app/tx/impl/SetSignerList.h>
#include <ripple/app/tx/impl/SetTrust.h>
#include <ripple/app/tx/impl/URIToken.h>
#include <ripple/app/tx/impl/XahauGenesis.h>
namespace ripple {
// Templates so preflight does the right thing with T::ConsequencesFactory.
//
// This could be done more easily using if constexpr, but Visual Studio
// 2017 doesn't handle if constexpr correctly. So once we're no longer
// building with Visual Studio 2017 we can consider replacing the four
// templates with a single template function that uses if constexpr.
//
// For Transactor::Normal
template <
class T,
std::enable_if_t<T::ConsequencesFactory == Transactor::Normal, int> = 0>
TxConsequences
consequences_helper(PreflightContext const& ctx)
{
return TxConsequences(ctx.tx);
};
// For Transactor::Blocker
template <
class T,
std::enable_if_t<T::ConsequencesFactory == Transactor::Blocker, int> = 0>
TxConsequences
consequences_helper(PreflightContext const& ctx)
{
return TxConsequences(ctx.tx, TxConsequences::blocker);
};
// For Transactor::Custom
template <
class T,
std::enable_if_t<T::ConsequencesFactory == Transactor::Custom, int> = 0>
TxConsequences
consequences_helper(PreflightContext const& ctx)
{
return T::makeTxConsequences(ctx);
};
template <class T>
std::pair<NotTEC, TxConsequences>
invoke_preflight_helper(PreflightContext const& ctx)
{
auto const tec = T::preflight(ctx);
return {
tec,
isTesSuccess(tec) ? consequences_helper<T>(ctx) : TxConsequences{tec}};
}
static std::pair<NotTEC, TxConsequences>
invoke_preflight(PreflightContext const& ctx)
{
switch (ctx.tx.getTxnType())
{
case ttACCOUNT_DELETE:
return invoke_preflight_helper<DeleteAccount>(ctx);
case ttACCOUNT_SET:
return invoke_preflight_helper<SetAccount>(ctx);
case ttCHECK_CANCEL:
return invoke_preflight_helper<CancelCheck>(ctx);
case ttCHECK_CASH:
return invoke_preflight_helper<CashCheck>(ctx);
case ttCHECK_CREATE:
return invoke_preflight_helper<CreateCheck>(ctx);
case ttDEPOSIT_PREAUTH:
return invoke_preflight_helper<DepositPreauth>(ctx);
case ttOFFER_CANCEL:
return invoke_preflight_helper<CancelOffer>(ctx);
case ttOFFER_CREATE:
return invoke_preflight_helper<CreateOffer>(ctx);
case ttESCROW_CREATE:
return invoke_preflight_helper<EscrowCreate>(ctx);
case ttESCROW_FINISH:
return invoke_preflight_helper<EscrowFinish>(ctx);
case ttESCROW_CANCEL:
return invoke_preflight_helper<EscrowCancel>(ctx);
case ttPAYCHAN_CLAIM:
return invoke_preflight_helper<PayChanClaim>(ctx);
case ttPAYCHAN_CREATE:
return invoke_preflight_helper<PayChanCreate>(ctx);
case ttPAYCHAN_FUND:
return invoke_preflight_helper<PayChanFund>(ctx);
case ttPAYMENT:
return invoke_preflight_helper<Payment>(ctx);
case ttREGULAR_KEY_SET:
return invoke_preflight_helper<SetRegularKey>(ctx);
case ttSIGNER_LIST_SET:
return invoke_preflight_helper<SetSignerList>(ctx);
case ttTICKET_CREATE:
return invoke_preflight_helper<CreateTicket>(ctx);
case ttTRUST_SET:
return invoke_preflight_helper<SetTrust>(ctx);
case ttAMENDMENT:
case ttFEE:
case ttUNL_MODIFY:
case ttUNL_REPORT:
case ttEMIT_FAILURE:
return invoke_preflight_helper<Change>(ctx);
case ttHOOK_SET:
return invoke_preflight_helper<SetHook>(ctx);
case ttNFTOKEN_MINT:
return invoke_preflight_helper<NFTokenMint>(ctx);
case ttNFTOKEN_BURN:
return invoke_preflight_helper<NFTokenBurn>(ctx);
case ttNFTOKEN_CREATE_OFFER:
return invoke_preflight_helper<NFTokenCreateOffer>(ctx);
case ttNFTOKEN_CANCEL_OFFER:
return invoke_preflight_helper<NFTokenCancelOffer>(ctx);
case ttNFTOKEN_ACCEPT_OFFER:
return invoke_preflight_helper<NFTokenAcceptOffer>(ctx);
case ttCLAIM_REWARD:
return invoke_preflight_helper<ClaimReward>(ctx);
case ttGENESIS_MINT:
return invoke_preflight_helper<GenesisMint>(ctx);
case ttIMPORT:
return invoke_preflight_helper<Import>(ctx);
case ttINVOKE:
return invoke_preflight_helper<Invoke>(ctx);
case ttREMIT:
return invoke_preflight_helper<Remit>(ctx);
case ttURITOKEN_MINT:
case ttURITOKEN_BURN:
case ttURITOKEN_BUY:
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return invoke_preflight_helper<URIToken>(ctx);
default:
assert(false);
return {temUNKNOWN, TxConsequences{temUNKNOWN}};
}
}
/* invoke_preclaim<T> uses name hiding to accomplish
compile-time polymorphism of (presumably) static
class functions for Transactor and derived classes.
*/
template <class T>
static TER
invoke_preclaim(PreclaimContext const& ctx)
{
// If the transactor requires a valid account and the transaction doesn't
// list one, preflight will have already a flagged a failure.
auto const id = ctx.tx.getAccountID(sfAccount);
if (id != beast::zero)
{
TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j);
if (!isTesSuccess(result))
return result;
result = T::checkPriorTxAndLastLedger(ctx);
if (!isTesSuccess(result))
return result;
result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx));
if (!isTesSuccess(result))
return result;
result = T::checkSign(ctx);
if (!isTesSuccess(result))
return result;
}
return T::preclaim(ctx);
}
static TER
invoke_preclaim(PreclaimContext const& ctx)
{
switch (ctx.tx.getTxnType())
{
case ttACCOUNT_DELETE:
return invoke_preclaim<DeleteAccount>(ctx);
case ttACCOUNT_SET:
return invoke_preclaim<SetAccount>(ctx);
case ttCHECK_CANCEL:
return invoke_preclaim<CancelCheck>(ctx);
case ttCHECK_CASH:
return invoke_preclaim<CashCheck>(ctx);
case ttCHECK_CREATE:
return invoke_preclaim<CreateCheck>(ctx);
case ttDEPOSIT_PREAUTH:
return invoke_preclaim<DepositPreauth>(ctx);
case ttOFFER_CANCEL:
return invoke_preclaim<CancelOffer>(ctx);
case ttOFFER_CREATE:
return invoke_preclaim<CreateOffer>(ctx);
case ttESCROW_CREATE:
return invoke_preclaim<EscrowCreate>(ctx);
case ttESCROW_FINISH:
return invoke_preclaim<EscrowFinish>(ctx);
case ttESCROW_CANCEL:
return invoke_preclaim<EscrowCancel>(ctx);
case ttPAYCHAN_CLAIM:
return invoke_preclaim<PayChanClaim>(ctx);
case ttPAYCHAN_CREATE:
return invoke_preclaim<PayChanCreate>(ctx);
case ttPAYCHAN_FUND:
return invoke_preclaim<PayChanFund>(ctx);
case ttPAYMENT:
return invoke_preclaim<Payment>(ctx);
case ttREGULAR_KEY_SET:
return invoke_preclaim<SetRegularKey>(ctx);
case ttSIGNER_LIST_SET:
return invoke_preclaim<SetSignerList>(ctx);
case ttTICKET_CREATE:
return invoke_preclaim<CreateTicket>(ctx);
case ttTRUST_SET:
return invoke_preclaim<SetTrust>(ctx);
case ttHOOK_SET:
return invoke_preclaim<SetHook>(ctx);
case ttAMENDMENT:
case ttFEE:
case ttUNL_MODIFY:
case ttUNL_REPORT:
case ttEMIT_FAILURE:
return invoke_preclaim<Change>(ctx);
case ttNFTOKEN_MINT:
return invoke_preclaim<NFTokenMint>(ctx);
case ttNFTOKEN_BURN:
return invoke_preclaim<NFTokenBurn>(ctx);
case ttNFTOKEN_CREATE_OFFER:
return invoke_preclaim<NFTokenCreateOffer>(ctx);
case ttNFTOKEN_CANCEL_OFFER:
return invoke_preclaim<NFTokenCancelOffer>(ctx);
case ttNFTOKEN_ACCEPT_OFFER:
return invoke_preclaim<NFTokenAcceptOffer>(ctx);
case ttCLAIM_REWARD:
return invoke_preclaim<ClaimReward>(ctx);
case ttGENESIS_MINT:
return invoke_preclaim<GenesisMint>(ctx);
case ttIMPORT:
return invoke_preclaim<Import>(ctx);
case ttINVOKE:
return invoke_preclaim<Invoke>(ctx);
case ttREMIT:
return invoke_preclaim<Remit>(ctx);
case ttURITOKEN_MINT:
case ttURITOKEN_BURN:
case ttURITOKEN_BUY:
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return invoke_preclaim<URIToken>(ctx);
default:
assert(false);
return temUNKNOWN;
}
}
XRPAmount
invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
{
switch (tx.getTxnType())
{
case ttACCOUNT_DELETE:
return DeleteAccount::calculateBaseFee(view, tx);
case ttACCOUNT_SET:
return SetAccount::calculateBaseFee(view, tx);
case ttCHECK_CANCEL:
return CancelCheck::calculateBaseFee(view, tx);
case ttCHECK_CASH:
return CashCheck::calculateBaseFee(view, tx);
case ttCHECK_CREATE:
return CreateCheck::calculateBaseFee(view, tx);
case ttDEPOSIT_PREAUTH:
return DepositPreauth::calculateBaseFee(view, tx);
case ttOFFER_CANCEL:
return CancelOffer::calculateBaseFee(view, tx);
case ttOFFER_CREATE:
return CreateOffer::calculateBaseFee(view, tx);
case ttESCROW_CREATE:
return EscrowCreate::calculateBaseFee(view, tx);
case ttESCROW_FINISH:
return EscrowFinish::calculateBaseFee(view, tx);
case ttESCROW_CANCEL:
return EscrowCancel::calculateBaseFee(view, tx);
case ttPAYCHAN_CLAIM:
return PayChanClaim::calculateBaseFee(view, tx);
case ttPAYCHAN_CREATE:
return PayChanCreate::calculateBaseFee(view, tx);
case ttPAYCHAN_FUND:
return PayChanFund::calculateBaseFee(view, tx);
case ttPAYMENT:
return Payment::calculateBaseFee(view, tx);
case ttREGULAR_KEY_SET:
return SetRegularKey::calculateBaseFee(view, tx);
case ttSIGNER_LIST_SET:
return SetSignerList::calculateBaseFee(view, tx);
case ttTICKET_CREATE:
return CreateTicket::calculateBaseFee(view, tx);
case ttTRUST_SET:
return SetTrust::calculateBaseFee(view, tx);
case ttHOOK_SET:
return SetHook::calculateBaseFee(view, tx);
case ttAMENDMENT:
case ttFEE:
case ttUNL_MODIFY:
case ttUNL_REPORT:
case ttEMIT_FAILURE:
return Change::calculateBaseFee(view, tx);
case ttNFTOKEN_MINT:
return NFTokenMint::calculateBaseFee(view, tx);
case ttNFTOKEN_BURN:
return NFTokenBurn::calculateBaseFee(view, tx);
case ttNFTOKEN_CREATE_OFFER:
return NFTokenCreateOffer::calculateBaseFee(view, tx);
case ttNFTOKEN_CANCEL_OFFER:
return NFTokenCancelOffer::calculateBaseFee(view, tx);
case ttNFTOKEN_ACCEPT_OFFER:
return NFTokenAcceptOffer::calculateBaseFee(view, tx);
case ttCLAIM_REWARD:
return ClaimReward::calculateBaseFee(view, tx);
case ttGENESIS_MINT:
return GenesisMint::calculateBaseFee(view, tx);
case ttIMPORT:
return Import::calculateBaseFee(view, tx);
case ttINVOKE:
return Invoke::calculateBaseFee(view, tx);
case ttREMIT:
return Remit::calculateBaseFee(view, tx);
case ttURITOKEN_MINT:
case ttURITOKEN_BURN:
case ttURITOKEN_BUY:
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER:
return URIToken::calculateBaseFee(view, tx);
default:
return XRPAmount{0};
}
}
TxConsequences::TxConsequences(NotTEC pfresult)
: isBlocker_(false)
, fee_(beast::zero)
, potentialSpend_(beast::zero)
, seqProx_(SeqProxy::sequence(0))
, sequencesConsumed_(0)
{
assert(!isTesSuccess(pfresult));
}
TxConsequences::TxConsequences(STTx const& tx)
: isBlocker_(false)
, fee_(
tx[sfFee].native() && !tx[sfFee].negative() ? tx[sfFee].xrp()
: beast::zero)
, potentialSpend_(beast::zero)
, seqProx_(tx.getSeqProxy())
, sequencesConsumed_(tx.getSeqProxy().isSeq() ? 1 : 0)
{
}
TxConsequences::TxConsequences(STTx const& tx, Category category)
: TxConsequences(tx)
{
isBlocker_ = (category == blocker);
}
TxConsequences::TxConsequences(STTx const& tx, XRPAmount potentialSpend)
: TxConsequences(tx)
{
potentialSpend_ = potentialSpend;
}
TxConsequences::TxConsequences(STTx const& tx, std::uint32_t sequencesConsumed)
: TxConsequences(tx)
{
sequencesConsumed_ = sequencesConsumed;
}
static std::pair<TER, bool>
invoke_apply(ApplyContext& ctx)
{
switch (ctx.tx.getTxnType())
{
case ttACCOUNT_DELETE: {
DeleteAccount p(ctx);
return p();
}
case ttACCOUNT_SET: {
SetAccount p(ctx);
return p();
}
case ttCHECK_CANCEL: {
CancelCheck p(ctx);
return p();
}
case ttCHECK_CASH: {
CashCheck p(ctx);
return p();
}
case ttCHECK_CREATE: {
CreateCheck p(ctx);
return p();
}
case ttDEPOSIT_PREAUTH: {
DepositPreauth p(ctx);
return p();
}
case ttOFFER_CANCEL: {
CancelOffer p(ctx);
return p();
}
case ttOFFER_CREATE: {
CreateOffer p(ctx);
return p();
}
case ttESCROW_CREATE: {
EscrowCreate p(ctx);
return p();
}
case ttESCROW_FINISH: {
EscrowFinish p(ctx);
return p();
}
case ttESCROW_CANCEL: {
EscrowCancel p(ctx);
return p();
}
case ttPAYCHAN_CLAIM: {
PayChanClaim p(ctx);
return p();
}
case ttPAYCHAN_CREATE: {
PayChanCreate p(ctx);
return p();
}
case ttPAYCHAN_FUND: {
PayChanFund p(ctx);
return p();
}
case ttPAYMENT: {
Payment p(ctx);
return p();
}
case ttREGULAR_KEY_SET: {
SetRegularKey p(ctx);
return p();
}
case ttSIGNER_LIST_SET: {
SetSignerList p(ctx);
return p();
}
case ttTICKET_CREATE: {
CreateTicket p(ctx);
return p();
}
case ttTRUST_SET: {
SetTrust p(ctx);
return p();
}
case ttHOOK_SET: {
SetHook p(ctx);
return p();
}
case ttAMENDMENT:
case ttFEE:
case ttUNL_MODIFY:
case ttUNL_REPORT:
case ttEMIT_FAILURE: {
Change p(ctx);
return p();
}
case ttNFTOKEN_MINT: {
NFTokenMint p(ctx);
return p();
}
case ttNFTOKEN_BURN: {
NFTokenBurn p(ctx);
return p();
}
case ttNFTOKEN_CREATE_OFFER: {
NFTokenCreateOffer p(ctx);
return p();
}
case ttNFTOKEN_CANCEL_OFFER: {
NFTokenCancelOffer p(ctx);
return p();
}
case ttNFTOKEN_ACCEPT_OFFER: {
NFTokenAcceptOffer p(ctx);
return p();
}
case ttCLAIM_REWARD: {
ClaimReward p(ctx);
return p();
}
case ttGENESIS_MINT: {
GenesisMint p(ctx);
return p();
}
case ttIMPORT: {
Import p(ctx);
return p();
}
case ttINVOKE: {
Invoke p(ctx);
return p();
}
case ttREMIT: {
Remit p(ctx);
return p();
}
case ttURITOKEN_MINT:
case ttURITOKEN_BURN:
case ttURITOKEN_BUY:
case ttURITOKEN_CREATE_SELL_OFFER:
case ttURITOKEN_CANCEL_SELL_OFFER: {
URIToken p(ctx);
return p();
}
default:
assert(false);
return {temUNKNOWN, false};
}
}
PreflightResult
preflight(
Application& app,
Rules const& rules,
STTx const& tx,
ApplyFlags flags,
beast::Journal j)
{
PreflightContext const pfctx(app, tx, rules, flags, j);
#ifndef DEBUG
try
{
#endif
return {pfctx, invoke_preflight(pfctx)};
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(j.fatal()) << "apply: " << e.what();
return {pfctx, {tefEXCEPTION, TxConsequences{tx}}};
}
#endif
}
PreclaimResult
preclaim(
PreflightResult const& preflightResult,
Application& app,
OpenView const& view)
{
std::optional<PreclaimContext const> ctx;
if (preflightResult.rules != view.rules())
{
auto secondFlight = preflight(
app,
view.rules(),
preflightResult.tx,
preflightResult.flags,
preflightResult.j);
ctx.emplace(
app,
view,
secondFlight.ter,
secondFlight.tx,
secondFlight.flags,
secondFlight.j);
}
else
{
ctx.emplace(
app,
view,
preflightResult.ter,
preflightResult.tx,
preflightResult.flags,
preflightResult.j);
}
#ifndef DEBUG
try
{
#endif
if (!isTesSuccess(ctx->preflightResult))
return {*ctx, ctx->preflightResult};
return {*ctx, invoke_preclaim(*ctx)};
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(ctx->j.fatal()) << "apply: " << e.what();
return {*ctx, tefEXCEPTION};
}
#endif
}
XRPAmount
calculateBaseFee(ReadView const& view, STTx const& tx)
{
return invoke_calculateBaseFee(view, tx);
}
XRPAmount
calculateDefaultBaseFee(ReadView const& view, STTx const& tx)
{
return Transactor::calculateBaseFee(view, tx);
}
std::pair<TER, bool>
doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view)
{
if (preclaimResult.view.seq() != view.seq())
{
// Logic error from the caller. Don't have enough
// info to recover.
return {tefEXCEPTION, false};
}
#ifndef DEBUG
try
{
#endif
if (!preclaimResult.likelyToClaimFee)
return {preclaimResult.ter, false};
ApplyContext ctx(
app,
view,
preclaimResult.tx,
preclaimResult.ter,
calculateBaseFee(view, preclaimResult.tx),
preclaimResult.flags,
preclaimResult.j);
return invoke_apply(ctx);
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(preclaimResult.j.fatal()) << "apply: " << e.what();
return {tefEXCEPTION, false};
}
#endif
}
} // namespace ripple