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