1#include <xrpld/app/misc/HashRouter.h>
2#include <xrpld/app/tx/apply.h>
3#include <xrpld/app/tx/applySteps.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/protocol/Feature.h>
7#include <xrpl/protocol/TxFlags.h>
24 auto const flags = router.
getFlags(
id);
36 bool const neverValid = rules.
enabled(fixBatchInnerSigs);
57 auto const sigVerify = tx.
checkSign(rules);
108template <
typename PreflightChecks>
119 return apply(app, view, [&]()
mutable {
return preflight(app, view.
rules(), tx, flags, j); });
131 return apply(app, view, [&]()
mutable {
return preflight(app, view.
rules(), parentBatchId, tx, flags, j); });
139 "Batch transaction missing sfRawTransactions");
142 auto const mode = batchTxn.
getFlags();
144 auto applyOneTransaction = [&app, &j, &parentBatchId, &batchView](
STTx&& tx) {
147 auto const ret =
apply(app, perTxBatchView, parentBatchId, tx,
tapBATCH, j);
149 ret.applied == (
isTesSuccess(ret.ter) ||
isTecClaim(ret.ter)),
"Inner transaction should not be applied");
151 JLOG(j.
debug()) <<
"BatchTrace[" << parentBatchId <<
"]: " << tx.getTransactionID() <<
" "
152 << (ret.applied ?
"applied" :
"failure") <<
": " <<
transToken(ret.ter);
157 perTxBatchView.
apply(batchView);
166 auto const result = applyOneTransaction(
STTx{std::move(rb)});
169 "Outer Batch failure, inner transaction should not be applied");
206 auto const result =
apply(app, view, txn, flags, j);
219 wholeBatchView.
apply(view);
237 JLOG(j.
warn()) <<
"Throws: " << ex.
what();
A generic endpoint for log messages.
Routing table for objects identified by hash.
HashRouterFlags getFlags(uint256 const &key)
bool setFlags(uint256 const &key, HashRouterFlags flags)
Set the flags on a hash.
RAII class to set and restore the Number switchover.
Writable ledger view that accumulates state and tx changes.
void apply(TxsRawView &to) const
Apply changes.
Rules const & rules() const override
Returns the tx processing rules.
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
STArray const & getFieldArray(SField const &field) const
bool isFlag(std::uint32_t) const
bool isFieldPresent(SField const &field) const
std::uint32_t getFlags() const
Expected< void, std::string > checkSign(Rules const &rules) const
Check the signature.
TxType getTxnType() const
Blob getSigningPubKey() const
uint256 getTransactionID() const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr struct xrpl::batch_view_t batch_view
ApplyResult apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
Validity
Describes the pre-processing validity of a transaction.
@ SigBad
Signature is bad. Didn't do local checks.
@ Valid
Signature and local checks are good / passed.
@ SigGoodOnly
Signature is good, but local checks fail.
constexpr std::uint32_t tfInnerBatchTxn
constexpr HashRouterFlags SF_LOCALBAD
ApplyTransactionResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
PreflightResult preflight(Application &app, Rules const &rules, STTx const &tx, ApplyFlags flags, beast::Journal j)
Gate a transaction based on static information.
ApplyTransactionResult
Enum class for return value from applyTransaction
@ Success
Applied to this ledger.
@ Retry
Should be retried in this ledger.
@ Fail
Should not be retried in this ledger.
std::string transHuman(TER code)
constexpr HashRouterFlags SF_SIGBAD
constexpr std::uint32_t tfAllOrNothing
std::string transToken(TER code)
constexpr HashRouterFlags SF_SIGGOOD
bool isTefFailure(TER x) noexcept
bool passesLocalChecks(STObject const &st, std::string &)
ApplyResult doApply(PreclaimResult const &preclaimResult, Application &app, OpenView &view)
Apply a prechecked transaction to an OpenView.
constexpr HashRouterFlags SF_LOCALGOOD
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules, Config const &config)
Checks transaction signature and local checks.
constexpr std::uint32_t tfOnlyOne
bool isTelLocal(TER x) noexcept
static bool applyBatchTransactions(Application &app, OpenView &batchView, STTx const &batchTxn, beast::Journal j)
bool isTesSuccess(TER x) noexcept
PreclaimResult preclaim(PreflightResult const &preflightResult, Application &app, OpenView const &view)
Gate a transaction based on static ledger information.
constexpr std::uint32_t tfUntilFailure
bool isTecClaim(TER x) noexcept
void forceValidity(HashRouter &router, uint256 const &txid, Validity validity)
Sets the validity of a given transaction in the cache.
bool isTemMalformed(TER x) noexcept