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();
74 JLOG(j.
debug()) <<
"Flushed " << asf <<
" accounts and " << tmf
75 <<
" transaction nodes";
81 closeTime, closeResolution, closeTimeCorrect, app.
config());
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))
148 JLOG(j.
warn()) <<
"Transaction " << txid <<
" throws";
154 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
155 <<
" completed (" << changes <<
" changes)";
161 if (!changes && !certainRetry)
165 if (!changes || (pass >= LEDGER_RETRY_PASSES))
166 certainRetry =
false;
171 assert(txns.
empty() || !certainRetry);
180 const bool closeTimeCorrect,
187 JLOG(j.
debug()) <<
"Report: Transaction Set = " << txns.
key() <<
", close "
189 << (closeTimeCorrect ?
"" :
" (incorrect)");
200 <<
"Attempting to apply " << txns.
size() <<
" transactions";
206 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions; "
207 << failedTxns.
size() <<
" failed and "
208 << txns.
size() <<
" will be retried.";
210 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions.";
222 auto const& replayLedger = replayData.
replay();
224 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->info().hash;
228 replayLedger->info().closeTime,
230 replayLedger->info().closeTimeResolution,
234 for (auto& tx : replayData.orderedTxns())
235 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.
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.
static const std::uint32_t sLCF_NoConsensusTime