Skip to content

Commit 9ed20a4

Browse files
authored
Refactor: SetCron to CronSet (#609)
1 parent 89ffc19 commit 9ed20a4

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

Builds/CMake/RippledCore.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ target_sources (rippled PRIVATE
458458
src/ripple/app/tx/impl/CreateOffer.cpp
459459
src/ripple/app/tx/impl/CreateTicket.cpp
460460
src/ripple/app/tx/impl/Cron.cpp
461+
src/ripple/app/tx/impl/CronSet.cpp
461462
src/ripple/app/tx/impl/DeleteAccount.cpp
462463
src/ripple/app/tx/impl/DepositPreauth.cpp
463464
src/ripple/app/tx/impl/Escrow.cpp
@@ -475,7 +476,6 @@ target_sources (rippled PRIVATE
475476
src/ripple/app/tx/impl/Payment.cpp
476477
src/ripple/app/tx/impl/Remit.cpp
477478
src/ripple/app/tx/impl/SetAccount.cpp
478-
src/ripple/app/tx/impl/SetCron.cpp
479479
src/ripple/app/tx/impl/SetHook.cpp
480480
src/ripple/app/tx/impl/SetRemarks.cpp
481481
src/ripple/app/tx/impl/SetRegularKey.cpp
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
//==============================================================================
1919

20-
#include <ripple/app/tx/impl/SetCron.h>
20+
#include <ripple/app/tx/impl/CronSet.h>
2121
#include <ripple/basics/Log.h>
2222
#include <ripple/ledger/View.h>
2323
#include <ripple/protocol/Feature.h>
@@ -28,13 +28,13 @@
2828
namespace ripple {
2929

3030
TxConsequences
31-
SetCron::makeTxConsequences(PreflightContext const& ctx)
31+
CronSet::makeTxConsequences(PreflightContext const& ctx)
3232
{
3333
return TxConsequences{ctx.tx, TxConsequences::normal};
3434
}
3535

3636
NotTEC
37-
SetCron::preflight(PreflightContext const& ctx)
37+
CronSet::preflight(PreflightContext const& ctx)
3838
{
3939
if (!ctx.rules.enabled(featureCron))
4040
return temDISABLED;
@@ -47,7 +47,7 @@ SetCron::preflight(PreflightContext const& ctx)
4747

4848
if (tx.getFlags() & tfCronSetMask)
4949
{
50-
JLOG(j.warn()) << "SetCron: Invalid flags set.";
50+
JLOG(j.warn()) << "CronSet: Invalid flags set.";
5151
return temINVALID_FLAG;
5252
}
5353

@@ -69,7 +69,7 @@ SetCron::preflight(PreflightContext const& ctx)
6969
// delete operation
7070
if (hasDelay || hasRepeat || hasStartTime)
7171
{
72-
JLOG(j.debug()) << "SetCron: tfCronUnset flag cannot be used with "
72+
JLOG(j.debug()) << "CronSet: tfCronUnset flag cannot be used with "
7373
"DelaySeconds, RepeatCount or StartTime.";
7474
return temMALFORMED;
7575
}
@@ -81,15 +81,15 @@ SetCron::preflight(PreflightContext const& ctx)
8181
if (!hasStartTime)
8282
{
8383
JLOG(j.debug())
84-
<< "SetCron: StartTime is required. Use StartTime=0 for "
84+
<< "CronSet: StartTime is required. Use StartTime=0 for "
8585
"immediate execution, or specify a future timestamp.";
8686
return temMALFORMED;
8787
}
8888

8989
if ((!hasDelay && hasRepeat) || (hasDelay && !hasRepeat))
9090
{
9191
JLOG(j.debug())
92-
<< "SetCron: DelaySeconds and RepeatCount must both be present "
92+
<< "CronSet: DelaySeconds and RepeatCount must both be present "
9393
"for recurring crons, or both absent for one-off crons.";
9494
return temMALFORMED;
9595
}
@@ -101,7 +101,7 @@ SetCron::preflight(PreflightContext const& ctx)
101101
if (delay > 31536000UL /* 365 days in seconds */)
102102
{
103103
JLOG(j.debug())
104-
<< "SetCron: DelaySeconds was too high. (max 365 "
104+
<< "CronSet: DelaySeconds was too high. (max 365 "
105105
"days in seconds).";
106106
return temMALFORMED;
107107
}
@@ -114,16 +114,16 @@ SetCron::preflight(PreflightContext const& ctx)
114114
if (recur == 0)
115115
{
116116
JLOG(j.debug())
117-
<< "SetCron: RepeatCount must be greater than 0."
117+
<< "CronSet: RepeatCount must be greater than 0."
118118
"For one-time execution, omit DelaySeconds and "
119119
"RepeatCount.";
120120
return temMALFORMED;
121121
}
122122
if (recur > 256)
123123
{
124124
JLOG(j.debug())
125-
<< "SetCron: RepeatCount too high. Limit is 256. Issue "
126-
"new SetCron to increase.";
125+
<< "CronSet: RepeatCount too high. Limit is 256. Issue "
126+
"new CronSet to increase.";
127127
return temMALFORMED;
128128
}
129129
}
@@ -133,7 +133,7 @@ SetCron::preflight(PreflightContext const& ctx)
133133
}
134134

135135
TER
136-
SetCron::preclaim(PreclaimContext const& ctx)
136+
CronSet::preclaim(PreclaimContext const& ctx)
137137
{
138138
if (ctx.tx.isFieldPresent(sfStartTime) &&
139139
ctx.tx.getFieldU32(sfStartTime) != 0)
@@ -146,15 +146,15 @@ SetCron::preclaim(PreclaimContext const& ctx)
146146

147147
if (startTime < parentCloseTime)
148148
{
149-
JLOG(ctx.j.debug()) << "SetCron: StartTime must be in the future "
149+
JLOG(ctx.j.debug()) << "CronSet: StartTime must be in the future "
150150
"(or 0 for immediate execution)";
151151
return tecEXPIRED;
152152
}
153153

154154
if (startTime > ctx.view.parentCloseTime().time_since_epoch().count() +
155155
365 * 24 * 60 * 60)
156156
{
157-
JLOG(ctx.j.debug()) << "SetCron: StartTime is too far in the "
157+
JLOG(ctx.j.debug()) << "CronSet: StartTime is too far in the "
158158
"future (max 365 days).";
159159
return tecEXPIRED;
160160
}
@@ -163,7 +163,7 @@ SetCron::preclaim(PreclaimContext const& ctx)
163163
}
164164

165165
TER
166-
SetCron::doApply()
166+
CronSet::doApply()
167167
{
168168
auto& view = ctx_.view();
169169
auto const& tx = ctx_.tx;
@@ -205,21 +205,21 @@ SetCron::doApply()
205205
auto sleCron = view.peek(klOld);
206206
if (!sleCron)
207207
{
208-
JLOG(j_.warn()) << "SetCron: Cron object didn't exist.";
208+
JLOG(j_.warn()) << "CronSet: Cron object didn't exist.";
209209
return tefBAD_LEDGER;
210210
}
211211

212212
if (safe_cast<LedgerEntryType>(
213213
sleCron->getFieldU16(sfLedgerEntryType)) != ltCRON)
214214
{
215-
JLOG(j_.warn()) << "SetCron: sfCron pointed to non-cron object!!";
215+
JLOG(j_.warn()) << "CronSet: sfCron pointed to non-cron object!!";
216216
return tefBAD_LEDGER;
217217
}
218218

219219
if (!view.dirRemove(
220220
keylet::ownerDir(id), (*sleCron)[sfOwnerNode], klOld, false))
221221
{
222-
JLOG(j_.warn()) << "SetCron: Ownerdir bad. " << id;
222+
JLOG(j_.warn()) << "CronSet: Ownerdir bad. " << id;
223223
return tefBAD_LEDGER;
224224
}
225225

@@ -278,7 +278,7 @@ SetCron::doApply()
278278
}
279279

280280
XRPAmount
281-
SetCron::calculateBaseFee(ReadView const& view, STTx const& tx)
281+
CronSet::calculateBaseFee(ReadView const& view, STTx const& tx)
282282
{
283283
auto const baseFee = Transactor::calculateBaseFee(view, tx);
284284

@@ -290,7 +290,7 @@ SetCron::calculateBaseFee(ReadView const& view, STTx const& tx)
290290
tx.isFieldPresent(sfRepeatCount) ? tx.getFieldU32(sfRepeatCount) : 0;
291291

292292
// factor a cost based on the total number of txns expected
293-
// for RepeatCount of 0 we have this txn (SetCron) and the
293+
// for RepeatCount of 0 we have this txn (CronSet) and the
294294
// single Cron txn (2). For a RepeatCount of 1 we have this txn,
295295
// the first time the cron executes, and the second time (3).
296296
uint32_t const additionalExpectedExecutions = 1 + repeatCount;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
*/
1818
//==============================================================================
1919

20-
#ifndef RIPPLE_TX_SETCRON_H_INCLUDED
21-
#define RIPPLE_TX_SETCRON_H_INCLUDED
20+
#ifndef RIPPLE_TX_CRONSET_H_INCLUDED
21+
#define RIPPLE_TX_CRONSET_H_INCLUDED
2222

2323
#include <ripple/app/tx/impl/Transactor.h>
2424
#include <ripple/basics/Log.h>
2525
#include <ripple/protocol/Indexes.h>
2626

2727
namespace ripple {
2828

29-
class SetCron : public Transactor
29+
class CronSet : public Transactor
3030
{
3131
public:
3232
static constexpr ConsequencesFactoryType ConsequencesFactory{Custom};
3333

34-
explicit SetCron(ApplyContext& ctx) : Transactor(ctx)
34+
explicit CronSet(ApplyContext& ctx) : Transactor(ctx)
3535
{
3636
}
3737

src/ripple/app/tx/impl/applySteps.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <ripple/app/tx/impl/CreateOffer.h>
3030
#include <ripple/app/tx/impl/CreateTicket.h>
3131
#include <ripple/app/tx/impl/Cron.h>
32+
#include <ripple/app/tx/impl/CronSet.h>
3233
#include <ripple/app/tx/impl/DeleteAccount.h>
3334
#include <ripple/app/tx/impl/DepositPreauth.h>
3435
#include <ripple/app/tx/impl/Escrow.h>
@@ -44,7 +45,6 @@
4445
#include <ripple/app/tx/impl/Payment.h>
4546
#include <ripple/app/tx/impl/Remit.h>
4647
#include <ripple/app/tx/impl/SetAccount.h>
47-
#include <ripple/app/tx/impl/SetCron.h>
4848
#include <ripple/app/tx/impl/SetHook.h>
4949
#include <ripple/app/tx/impl/SetRegularKey.h>
5050
#include <ripple/app/tx/impl/SetRemarks.h>
@@ -184,7 +184,7 @@ invoke_preflight(PreflightContext const& ctx)
184184
case ttURITOKEN_CANCEL_SELL_OFFER:
185185
return invoke_preflight_helper<URIToken>(ctx);
186186
case ttCRON_SET:
187-
return invoke_preflight_helper<SetCron>(ctx);
187+
return invoke_preflight_helper<CronSet>(ctx);
188188
case ttCRON:
189189
return invoke_preflight_helper<Cron>(ctx);
190190
default:
@@ -313,7 +313,7 @@ invoke_preclaim(PreclaimContext const& ctx)
313313
case ttURITOKEN_CANCEL_SELL_OFFER:
314314
return invoke_preclaim<URIToken>(ctx);
315315
case ttCRON_SET:
316-
return invoke_preclaim<SetCron>(ctx);
316+
return invoke_preclaim<CronSet>(ctx);
317317
case ttCRON:
318318
return invoke_preclaim<Cron>(ctx);
319319
default:
@@ -404,7 +404,7 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
404404
case ttURITOKEN_CANCEL_SELL_OFFER:
405405
return URIToken::calculateBaseFee(view, tx);
406406
case ttCRON_SET:
407-
return SetCron::calculateBaseFee(view, tx);
407+
return CronSet::calculateBaseFee(view, tx);
408408
case ttCRON:
409409
return Cron::calculateBaseFee(view, tx);
410410
default:
@@ -601,7 +601,7 @@ invoke_apply(ApplyContext& ctx)
601601
return p();
602602
}
603603
case ttCRON_SET: {
604-
SetCron p(ctx);
604+
CronSet p(ctx);
605605
return p();
606606
}
607607
case ttCRON: {

0 commit comments

Comments
 (0)