xrpld
Loading...
Searching...
No Matches
tx/transactors/system/TicketCreate.h
1#pragma once
2
3#include <xrpl/tx/Transactor.h>
4
5namespace xrpl {
6
7class TicketCreate : public Transactor
8{
9public:
11
12 static constexpr std::uint32_t kMinValidCount = 1;
13
14 // A note on how the maxValidCount was determined. The goal is for
15 // a single TicketCreate transaction to not use more compute power than
16 // a single compute-intensive Payment.
17 //
18 // Timing was performed using a MacBook Pro laptop and a release build
19 // with asserts off. 20 measurements were taken of each of the Payment
20 // and TicketCreate transactions and averaged to get timings.
21 //
22 // For the example compute-intensive Payment a Discrepancy unit test
23 // unit test Payment with 3 paths was chosen. With all the latest
24 // amendments enabled, that Payment::doApply() operation took, on
25 // average, 1.25 ms.
26 //
27 // Using that same test set up creating 250 Tickets in a single
28 // TicketCreate::doApply() in a unit test took, on average, 1.21 ms.
29 //
30 // So, for the moment, a single transaction creating 250 Tickets takes
31 // about the same compute time as a single compute-intensive payment.
32 //
33 // October 2018.
34 static constexpr std::uint32_t kMaxValidCount = 250;
35
36 // The maximum number of Tickets an account may hold. If a
37 // TicketCreate would cause an account to own more than this many
38 // tickets, then the TicketCreate will fail.
39 //
40 // The number was chosen arbitrarily and is an effort toward avoiding
41 // ledger-stuffing with Tickets.
42 static constexpr std::uint32_t kMaxTicketThreshold = 250;
43
44 explicit TicketCreate(ApplyContext& ctx) : Transactor(ctx)
45 {
46 }
47
48 static TxConsequences
50
52 static NotTEC
53 preflight(PreflightContext const& ctx);
54
56 static TER
57 preclaim(PreclaimContext const& ctx);
58
60 TER
61 doApply() override;
62
63 void
64 visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override;
65
66 [[nodiscard]] bool
68 STTx const& tx,
69 TER result,
70 XRPAmount fee,
71 ReadView const& view,
72 beast::Journal const& j) override;
73};
74
75} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
State information when applying a tx.
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry const > const & const_ref
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
static constexpr std::uint32_t kMinValidCount
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static constexpr std::uint32_t kMaxTicketThreshold
TER doApply() override
Precondition: fee collection is likely.
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
static constexpr auto kConsequencesFactory
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
static constexpr std::uint32_t kMaxValidCount
ApplyView & view()
Definition Transactor.h:136
Transactor(Transactor const &)=delete
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:38
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:594
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:554
TERSubset< CanCvtToTER > TER
Definition TER.h:634
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
State information when preflighting a tx.
Definition Transactor.h:18