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);
55 assert(!accum.
open());
56 applyTxs(accum, built);
60 built->updateSkipList();
69 JLOG(j.
debug()) <<
"Flushed " << asf <<
" accounts and " << tmf
70 <<
" transaction nodes";
76 closeTime, closeResolution, closeTimeCorrect, app.
config());
100 bool certainRetry =
true;
104 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
106 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
107 <<
" begins (" << txns.
size() <<
" transactions)";
110 auto it = txns.
begin();
112 while (it != txns.
end())
114 auto const txid = it->first.getTXID();
118 if (pass == 0 && built->
txExists(txid))
125 app, view, *it->second, certainRetry,
tapNONE, j))
143 JLOG(j.
warn()) <<
"Transaction " << txid <<
" throws";
149 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
150 <<
" completed (" << changes <<
" changes)";
156 if (!changes && !certainRetry)
160 if (!changes || (pass >= LEDGER_RETRY_PASSES))
161 certainRetry =
false;
166 assert(txns.
empty() || !certainRetry);
175 const bool closeTimeCorrect,
182 JLOG(j.
debug()) <<
"Report: Transaction Set = " << txns.
key() <<
", close "
184 << (closeTimeCorrect ?
"" :
" (incorrect)");
195 <<
"Attempting to apply " << txns.
size() <<
" transactions";
201 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions; "
202 << failedTxns.
size() <<
" failed and "
203 << txns.
size() <<
" will be retried.";
205 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions.";
217 auto const& replayLedger = replayData.
replay();
219 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->info().hash;
223 replayLedger->info().closeTime,
225 replayLedger->info().closeTimeResolution,
229 for (auto& tx : replayData.orderedTxns())
230 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.
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)
virtual Config & config()=0
@ 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.
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.
static const std::uint32_t sLCF_NoConsensusTime