20 #include <ripple/app/ledger/BuildLedger.h>
21 #include <ripple/app/ledger/Ledger.h>
22 #include <ripple/app/ledger/LedgerReplay.h>
23 #include <ripple/app/ledger/OpenLedger.h>
24 #include <ripple/app/main/Application.h>
25 #include <ripple/app/misc/CanonicalTXSet.h>
26 #include <ripple/app/tx/apply.h>
27 #include <ripple/protocol/Feature.h>
37 template <
class ApplyTxs>
42 const bool closeTimeCorrect,
48 auto built = std::make_shared<Ledger>(*parent, closeTime);
52 built->updateNegativeUNL();
60 assert(!accum.
open());
61 applyTxs(accum, built);
65 built->updateSkipList();
72 JLOG(j.
debug()) <<
"Flushed " << asf <<
" accounts and " << tmf
73 <<
" transaction nodes";
81 built->setAccepted(closeTime, closeResolution, closeTimeCorrect);
105 bool certainRetry =
true;
109 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
111 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
112 <<
" begins (" << txns.
size() <<
" transactions)";
115 auto it = txns.
begin();
117 while (it != txns.
end())
119 auto const txid = it->first.getTXID();
123 if (pass == 0 && built->
txExists(txid))
130 app, view, *it->second, certainRetry,
tapNONE, j))
149 <<
"Transaction " << txid <<
" throws: " << ex.
what();
155 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
156 <<
" completed (" << changes <<
" changes)";
162 if (!changes && !certainRetry)
166 if (!changes || (pass >= LEDGER_RETRY_PASSES))
167 certainRetry =
false;
172 assert(txns.
empty() || !certainRetry);
181 const bool closeTimeCorrect,
188 JLOG(j.
debug()) <<
"Report: Transaction Set = " << txns.
key() <<
", close "
190 << (closeTimeCorrect ?
"" :
" (incorrect)");
201 <<
"Attempting to apply " << txns.
size() <<
" transactions";
207 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions; "
208 << failedTxns.
size() <<
" failed and "
209 << txns.
size() <<
" will be retried.";
211 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions.";
223 auto const& replayLedger = replayData.
replay();
225 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->info().hash;
229 replayLedger->info().closeTime,
231 replayLedger->info().closeTimeResolution,
235 for (auto& tx : replayData.orderedTxns())
236 applyTransaction(app, accum, *tx.second, false, applyFlags, j);
uint256 const & key() const
void apply(TxsRawView &to) const
Apply changes.
const_iterator erase(const_iterator const &it)
Writable ledger view that accumulates state and tx changes.
ApplyResult applyTransaction(Application &app, OpenView &view, STTx const &tx, bool retryAssured, ApplyFlags flags, beast::Journal journal)
Transaction application helper.
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
Holds transactions which were deferred to the next pass of consensus.
const_iterator begin() const
T time_since_epoch(T... args)
std::shared_ptr< Ledger const > const & parent() const
bool txExists(uint256 const &key) const override
Returns true if a tx exists in the tx map.
std::shared_ptr< Ledger > buildLedgerImpl(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application &app, beast::Journal j, ApplyTxs &&applyTxs)
@ Retry
Should be retried in this ledger.
bool open() const override
Returns true if this reflects an open ledger.
A generic endpoint for log messages.
std::shared_ptr< Ledger const > const & replay() const
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.
@ Success
Applied to this ledger.
const_iterator end() const
@ Fail
Should not be retried in this ledger.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const uint256 featureNegativeUNL
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
static const std::uint32_t sLCF_NoConsensusTime