xrpld
Loading...
Searching...
No Matches
tx/transactors/system/Batch.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/TxFormats.h>
9#include <xrpl/protocol/XRPAmount.h>
10#include <xrpl/tx/ApplyContext.h>
11#include <xrpl/tx/Transactor.h>
12
13#include <array>
14#include <cstdint>
15#include <optional>
16
17namespace xrpl {
18
19class Batch : public Transactor
20{
21public:
23
24 explicit Batch(ApplyContext& ctx) : Transactor(ctx)
25 {
26 }
27
28 static XRPAmount
29 calculateBaseFee(ReadView const& view, STTx const& tx);
30
31 static std::uint32_t
33
34 static NotTEC
35 preflight(PreflightContext const& ctx);
36
37 static NotTEC
39
40 static NotTEC
41 checkSign(PreclaimContext const& ctx);
42
43 static TER
44 preclaim(PreclaimContext const& ctx);
45
46 TER
47 doApply() override;
48
49 void
50 visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override;
51
52 [[nodiscard]] bool
54 STTx const& tx,
55 TER result,
56 XRPAmount fee,
57 ReadView const& view,
58 beast::Journal const& j) override;
59
60 static constexpr auto kDisabledTxTypes = std::to_array<TxType>({
61 ttVAULT_CREATE,
62 ttVAULT_SET,
63 ttVAULT_DELETE,
64 ttVAULT_DEPOSIT,
65 ttVAULT_WITHDRAW,
66 ttVAULT_CLAWBACK,
67 ttLOAN_BROKER_SET,
68 ttLOAN_BROKER_DELETE,
69 ttLOAN_BROKER_COVER_DEPOSIT,
70 ttLOAN_BROKER_COVER_WITHDRAW,
71 ttLOAN_BROKER_COVER_CLAWBACK,
72 ttLOAN_SET,
73 ttLOAN_DELETE,
74 ttLOAN_MANAGE,
75 ttLOAN_PAY,
76 });
77
78private:
79 // Skips signature verification for inner txns, so keep it private: it must
80 // only be reached through Batch::checkSign.
81 static NotTEC
83
84 // nullopt on overflow or oversized signer arrays.
86 calculateBaseFeeImpl(ReadView const& view, STTx const& tx);
87};
88
89} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
State information when applying a tx.
static TER preclaim(PreclaimContext const &ctx)
Definition Batch.cpp:161
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
Definition Batch.cpp:574
Batch(ApplyContext &ctx)
static std::optional< XRPAmount > calculateBaseFeeImpl(ReadView const &view, STTx const &tx)
Calculates the total base fee for a batch transaction.
Definition Batch.cpp:53
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Definition Batch.cpp:151
static NotTEC preflight(PreflightContext const &ctx)
Performs preflight validation checks for a Batch transaction.
Definition Batch.cpp:208
static NotTEC checkBatchSign(PreclaimContext const &ctx)
Definition Batch.cpp:501
static NotTEC checkSign(PreclaimContext const &ctx)
Checks the validity of signatures for a batch transaction.
Definition Batch.cpp:543
TER doApply() override
Applies the outer batch transaction.
Definition Batch.cpp:568
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 Batch.cpp:580
static constexpr auto kConsequencesFactory
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
Definition Batch.cpp:169
static constexpr auto kDisabledTxTypes
static NotTEC preflightSigValidated(PreflightContext const &ctx)
Definition Batch.cpp:405
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & const_ref
ApplyView & view()
Definition Transactor.h:175
Transactor(Transactor const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:607
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:572
TERSubset< CanCvtToTER > TER
Definition TER.h:647
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:83
State information when preflighting a tx.
Definition Transactor.h:38