1#include <xrpld/app/ledger/BuildLedger.h>
2#include <xrpld/app/ledger/Ledger.h>
3#include <xrpld/app/ledger/LedgerReplay.h>
4#include <xrpld/app/ledger/OpenLedger.h>
5#include <xrpld/app/misc/CanonicalTXSet.h>
6#include <xrpld/app/tx/apply.h>
8#include <xrpl/protocol/Feature.h>
18template <
class ApplyTxs>
23 bool const closeTimeCorrect,
31 if (built->isFlagLedger())
33 built->updateNegativeUNL();
42 !accum.
open(),
"ripple::buildLedgerImpl : valid ledger state");
43 applyTxs(accum, built);
47 built->updateSkipList();
54 JLOG(j.
debug()) <<
"Flushed " << asf <<
" accounts and " << tmf
55 <<
" transaction nodes";
63 "ripple::buildLedgerImpl : valid ledger fees");
64 built->setAccepted(closeTime, closeResolution, closeTimeCorrect);
88 bool certainRetry =
true;
92 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
94 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
95 <<
" begins (" << txns.
size() <<
" transactions)";
98 auto it = txns.
begin();
100 while (it != txns.
end())
102 auto const txid = it->first.getTXID();
106 if (pass == 0 && built->txExists(txid))
113 app, view, *it->second, certainRetry,
tapNONE, j))
132 <<
"Transaction " << txid <<
" throws: " << ex.
what();
138 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
139 <<
" completed (" << changes <<
" changes)";
145 if (!changes && !certainRetry)
149 if (!changes || (pass >= LEDGER_RETRY_PASSES))
150 certainRetry =
false;
156 txns.
empty() || !certainRetry,
157 "ripple::applyTransactions : retry transactions");
166 bool const closeTimeCorrect,
173 JLOG(j.
debug()) <<
"Report: Transaction Set = " << txns.
key() <<
", close "
175 << (closeTimeCorrect ?
"" :
" (incorrect)");
186 <<
"Attempting to apply " << txns.
size() <<
" transactions";
193 <<
"Applied " << applied <<
" transactions; "
194 << failedTxns.
size() <<
" failed and " << txns.
size()
195 <<
" will be retried. "
196 <<
"Total transactions in ledger (including Inner Batch): "
200 <<
"Applied " << applied <<
" transactions. "
201 <<
"Total transactions in ledger (including Inner Batch): "
214 auto const& replayLedger = replayData.
replay();
216 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->info().hash;
220 replayLedger->info().closeTime,
222 replayLedger->info().closeTimeResolution,
226 for (auto& tx : replayData.orderedTxns())
227 applyTransaction(app, accum, *tx.second, false, applyFlags, j);
A generic endpoint for log messages.
Holds transactions which were deferred to the next pass of consensus.
const_iterator end() const
const_iterator begin() const
const_iterator erase(const_iterator const &it)
uint256 const & key() const
std::shared_ptr< Ledger const > const & parent() const
std::shared_ptr< Ledger const > const & replay() const
Writable ledger view that accumulates state and tx changes.
std::size_t txCount() const
Return the number of tx inserted since creation.
bool open() const override
Returns true if this reflects an open ledger.
void apply(TxsRawView &to) const
Apply changes.
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t applyTransactions(Application &app, std::shared_ptr< Ledger const > const &built, CanonicalTXSet &txns, std::set< TxID > &failed, OpenView &view, beast::Journal j)
Apply a set of consensus transactions to a ledger.
std::shared_ptr< Ledger > buildLedgerImpl(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, bool const closeTimeCorrect, NetClock::duration closeResolution, Application &app, beast::Journal j, ApplyTxs &&applyTxs)
@ Success
Applied to this ledger.
@ Retry
Should be retried in this ledger.
@ Fail
Should not be retried in this ledger.
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
static std::uint32_t const sLCF_NoConsensusTime
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, bool const closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
ApplyTransactionResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
T time_since_epoch(T... args)