rippled
Loading...
Searching...
No Matches
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
26namespace ripple {
27
29{
30public:
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
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
86
87} // namespace ripple
88
89#endif
State information when applying a tx.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static constexpr std::uint32_t maxValidCount
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static constexpr std::uint32_t maxTicketThreshold
CreateTicket(ApplyContext &ctx)
static constexpr ConsequencesFactoryType ConsequencesFactory
static constexpr std::uint32_t minValidCount
TER doApply() override
Precondition: fee collection is likely.
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:58
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:80
State information when preflighting a tx.
Definition Transactor.h:35