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();
41 XRPL_ASSERT(!accum.
open(),
"xrpl::buildLedgerImpl : valid ledger state");
42 applyTxs(accum, built);
46 built->updateSkipList();
53 JLOG(j.
debug()) <<
"Flushed " << asf <<
" accounts and " << tmf <<
" transaction nodes";
60 "xrpl::buildLedgerImpl : valid ledger fees");
61 built->setAccepted(closeTime, closeResolution, closeTimeCorrect);
85 bool certainRetry =
true;
89 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
91 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass <<
" begins (" << txns.
size()
95 auto it = txns.
begin();
97 while (it != txns.
end())
99 auto const txid = it->first.getTXID();
103 if (pass == 0 && built->txExists(txid))
127 JLOG(j.
warn()) <<
"Transaction " << txid <<
" throws: " << ex.
what();
133 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass <<
" completed (" << changes
140 if (!changes && !certainRetry)
144 if (!changes || (pass >= LEDGER_RETRY_PASSES))
145 certainRetry =
false;
150 XRPL_ASSERT(txns.
empty() || !certainRetry,
"xrpl::applyTransactions : retry transactions");
159 bool const closeTimeCorrect,
167 << (closeTimeCorrect ?
"" :
" (incorrect)");
177 JLOG(j.
debug()) <<
"Attempting to apply " << txns.
size() <<
" transactions";
182 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions; " << failedTxns.
size() <<
" failed and "
183 << txns.
size() <<
" will be retried. "
184 <<
"Total transactions in ledger (including Inner Batch): " << accum.
txCount();
186 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions. "
187 <<
"Total transactions in ledger (including Inner Batch): " << accum.
txCount();
195 auto const& replayLedger = replayData.
replay();
197 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->header().hash;
201 replayLedger->header().closeTime,
203 replayLedger->header().closeTimeResolution,
207 for (auto& tx : replayData.orderedTxns())
208 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 begin() const
const_iterator erase(const_iterator const &it)
const_iterator end() const
uint256 const & key() const
std::shared_ptr< Ledger const > const & replay() const
std::shared_ptr< Ledger const > const & parent() 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.
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
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.
ApplyTransactionResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
@ Success
Applied to this ledger.
@ Retry
Should be retried in this ledger.
@ Fail
Should not be retried in this ledger.
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.
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)
T time_since_epoch(T... args)