rippled
ripple
app
tx
impl
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 <ripple/app/ledger/Ledger.h>
24
#include <ripple/app/tx/impl/Transactor.h>
25
#include <ripple/basics/Log.h>
26
#include <ripple/protocol/Indexes.h>
27
28
namespace
ripple
{
29
30
class
CreateTicket
:
public
Transactor
31
{
32
public
:
33
static
constexpr
ConsequencesFactoryType
ConsequencesFactory
{
Custom
};
34
35
constexpr
static
std::uint32_t
minValidCount
= 1;
36
37
// A note on how the maxValidCount was determined. The goal is for
38
// a single TicketCreate transaction to not use more compute power than
39
// a single compute-intensive Payment.
40
//
41
// Timing was performed using a MacBook Pro laptop and a release build
42
// with asserts off. 20 measurements were taken of each of the Payment
43
// and TicketCreate transactions and averaged to get timings.
44
//
45
// For the example compute-intensive Payment a Discrepancy unit test
46
// unit test Payment with 3 paths was chosen. With all the latest
47
// amendments enabled, that Payment::doApply() operation took, on
48
// average, 1.25 ms.
49
//
50
// Using that same test set up creating 250 Tickets in a single
51
// CreateTicket::doApply() in a unit test took, on average, 1.21 ms.
52
//
53
// So, for the moment, a single transaction creating 250 Tickets takes
54
// about the same compute time as a single compute-intensive payment.
55
//
56
// October 2018.
57
constexpr
static
std::uint32_t
maxValidCount
= 250;
58
59
// The maximum number of Tickets an account may hold. If a
60
// TicketCreate would cause an account to own more than this many
61
// tickets, then the TicketCreate will fail.
62
//
63
// The number was chosen arbitrarily and is an effort toward avoiding
64
// ledger-stuffing with Tickets.
65
constexpr
static
std::uint32_t
maxTicketThreshold
= 250;
66
67
explicit
CreateTicket
(
ApplyContext
& ctx) :
Transactor
(ctx)
68
{
69
}
70
71
static
TxConsequences
72
makeTxConsequences
(
PreflightContext
const
& ctx);
73
75
static
NotTEC
76
preflight
(
PreflightContext
const
& ctx);
77
79
static
TER
80
preclaim
(
PreclaimContext
const
& ctx);
81
83
TER
84
doApply
()
override
;
85
};
86
87
}
// namespace ripple
88
89
#endif
ripple::CreateTicket::maxValidCount
constexpr static std::uint32_t maxValidCount
Definition:
CreateTicket.h:57
ripple::Transactor
Definition:
Transactor.h:85
ripple::CreateTicket::makeTxConsequences
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
Definition:
CreateTicket.cpp:31
ripple::CreateTicket::CreateTicket
CreateTicket(ApplyContext &ctx)
Definition:
CreateTicket.h:67
ripple::Transactor::ConsequencesFactoryType
ConsequencesFactoryType
Definition:
Transactor.h:101
ripple::TERSubset
Definition:
TER.h:340
ripple::CreateTicket::preclaim
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
Definition:
CreateTicket.cpp:57
ripple::CreateTicket::maxTicketThreshold
constexpr static std::uint32_t maxTicketThreshold
Definition:
CreateTicket.h:65
ripple::ApplyContext
State information when applying a tx.
Definition:
ApplyContext.h:35
std::uint32_t
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition:
Transactor.h:52
ripple::Transactor::Custom
@ Custom
Definition:
Transactor.h:101
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::CreateTicket::preflight
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
Definition:
CreateTicket.cpp:38
ripple::CreateTicket
Definition:
CreateTicket.h:30
ripple::PreflightContext
State information when preflighting a tx.
Definition:
Transactor.h:31
ripple::CreateTicket::ConsequencesFactory
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition:
CreateTicket.h:33
ripple::TxConsequences
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition:
applySteps.h:45
ripple::CreateTicket::doApply
TER doApply() override
Precondition: fee collection is likely.
Definition:
CreateTicket.cpp:85
ripple::CreateTicket::minValidCount
constexpr static std::uint32_t minValidCount
Definition:
CreateTicket.h:35
Generated by
1.8.17