rippled
Loading...
Searching...
No Matches
xrpld
app
tx
detail
CreateTicket.h
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2014 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#ifndef RIPPLE_TX_CREATETICKET_H_INCLUDED
21
#define RIPPLE_TX_CREATETICKET_H_INCLUDED
22
23
#include <xrpld/app/ledger/Ledger.h>
24
#include <xrpld/app/tx/detail/Transactor.h>
25
26
namespace
ripple
{
27
28
class
CreateTicket
:
public
Transactor
29
{
30
public
:
31
static
constexpr
ConsequencesFactoryType
ConsequencesFactory
{
Custom
};
32
33
constexpr
static
std::uint32_t
minValidCount
= 1;
34
35
// A note on how the maxValidCount was determined. The goal is for
36
// a single TicketCreate transaction to not use more compute power than
37
// a single compute-intensive Payment.
38
//
39
// Timing was performed using a MacBook Pro laptop and a release build
40
// with asserts off. 20 measurements were taken of each of the Payment
41
// and TicketCreate transactions and averaged to get timings.
42
//
43
// For the example compute-intensive Payment a Discrepancy unit test
44
// unit test Payment with 3 paths was chosen. With all the latest
45
// amendments enabled, that Payment::doApply() operation took, on
46
// average, 1.25 ms.
47
//
48
// Using that same test set up creating 250 Tickets in a single
49
// CreateTicket::doApply() in a unit test took, on average, 1.21 ms.
50
//
51
// So, for the moment, a single transaction creating 250 Tickets takes
52
// about the same compute time as a single compute-intensive payment.
53
//
54
// October 2018.
55
constexpr
static
std::uint32_t
maxValidCount
= 250;
56
57
// The maximum number of Tickets an account may hold. If a
58
// TicketCreate would cause an account to own more than this many
59
// tickets, then the TicketCreate will fail.
60
//
61
// The number was chosen arbitrarily and is an effort toward avoiding
62
// ledger-stuffing with Tickets.
63
constexpr
static
std::uint32_t
maxTicketThreshold
= 250;
64
65
explicit
CreateTicket
(
ApplyContext
& ctx) :
Transactor
(ctx)
66
{
67
}
68
69
static
TxConsequences
70
makeTxConsequences
(
PreflightContext
const
& ctx);
71
73
static
NotTEC
74
preflight
(
PreflightContext
const
& ctx);
75
77
static
TER
78
preclaim
(
PreclaimContext
const
& ctx);
79
81
TER
82
doApply
()
override
;
83
};
84
85
using
TicketCreate
=
CreateTicket
;
86
87
}
// namespace ripple
88
89
#endif
ripple::ApplyContext
State information when applying a tx.
Definition
ApplyContext.h:37
ripple::CreateTicket
Definition
CreateTicket.h:29
ripple::CreateTicket::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition
CreateTicket.cpp:30
ripple::CreateTicket::preflight
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
Definition
CreateTicket.cpp:37
ripple::CreateTicket::maxValidCount
static constexpr std::uint32_t maxValidCount
Definition
CreateTicket.h:55
ripple::CreateTicket::preclaim
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
Definition
CreateTicket.cpp:47
ripple::CreateTicket::maxTicketThreshold
static constexpr std::uint32_t maxTicketThreshold
Definition
CreateTicket.h:63
ripple::CreateTicket::CreateTicket
CreateTicket(ApplyContext &ctx)
Definition
CreateTicket.h:65
ripple::CreateTicket::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition
CreateTicket.h:31
ripple::CreateTicket::minValidCount
static constexpr std::uint32_t minValidCount
Definition
CreateTicket.h:33
ripple::CreateTicket::doApply
TER doApply() override
Precondition: fee collection is likely.
Definition
CreateTicket.cpp:75
ripple::TERSubset
Definition
TER.h:415
ripple::Transactor
Definition
Transactor.h:141
ripple::Transactor::ConsequencesFactoryType
ConsequencesFactoryType
Definition
Transactor.h:157
ripple::Transactor::Custom
@ Custom
Definition
Transactor.h:157
ripple::TxConsequences
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition
applySteps.h:58
std::uint32_t
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:25
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:80
ripple::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:35
Generated by
1.9.8