xrpld
Loading...
Searching...
No Matches
InvariantRunner.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ReadView.h>
5#include <xrpl/protocol/STLedgerEntry.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
11#include <functional>
12#include <optional>
13
14namespace xrpl {
15
62{
63public:
64 virtual ~TxInvariantCheck() = default;
65
77 virtual void
78 visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) = 0;
79
91 [[nodiscard]] virtual bool
93 STTx const& tx,
94 TER result,
95 XRPAmount fee,
96 ReadView const& view,
97 beast::Journal const& j) = 0;
98};
99
127[[nodiscard]] TER
129 ApplyContext& ctx,
130 TER result,
131 XRPAmount fee,
133
134[[nodiscard]] inline TER
136{
137 return checkInvariants(ctx, result, fee, std::nullopt);
138}
139
140} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
State information when applying a tx.
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & ConstRef
Runtime interface for a transaction-specific invariant check.
virtual bool finalize(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j)=0
Called after all entries have been visited.
virtual ~TxInvariantCheck()=default
virtual void visitEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after)=0
Called for each ledger entry modified by the transaction.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TER checkInvariants(ApplyContext &ctx, TER result, XRPAmount fee, std::optional< std::reference_wrapper< TxInvariantCheck > > txCheck)
Run all protocol invariant checks plus the transaction-specific check in a single pass over the modif...
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:644
TERSubset< CanCvtToTER > TER
Definition TER.h:654