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";
79 closeTime, closeResolution, closeTimeCorrect, app.
config());
103 bool certainRetry =
true;
107 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
109 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
110 <<
" begins (" << txns.
size() <<
" transactions)";
113 auto it = txns.
begin();
115 while (it != txns.
end())
117 auto const txid = it->first.getTXID();
121 if (pass == 0 && built->
txExists(txid))
128 app, view, *it->second, certainRetry,
tapNONE, j))
146 JLOG(j.
warn()) <<
"Transaction " << txid <<
" throws";
152 JLOG(j.
debug()) << (certainRetry ?
"Pass: " :
"Final pass: ") << pass
153 <<
" completed (" << changes <<
" changes)";
159 if (!changes && !certainRetry)
163 if (!changes || (pass >= LEDGER_RETRY_PASSES))
164 certainRetry =
false;
169 assert(txns.
empty() || !certainRetry);
178 const bool closeTimeCorrect,
185 JLOG(j.
debug()) <<
"Report: Transaction Set = " << txns.
key() <<
", close "
187 << (closeTimeCorrect ?
"" :
" (incorrect)");
198 <<
"Attempting to apply " << txns.
size() <<
" transactions";
204 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions; "
205 << failedTxns.
size() <<
" failed and "
206 << txns.
size() <<
" will be retried.";
208 JLOG(j.
debug()) <<
"Applied " << applied <<
" transactions.";
220 auto const& replayLedger = replayData.
replay();
222 JLOG(j.
debug()) <<
"Report: Replay Ledger " << replayLedger->info().hash;
226 replayLedger->info().closeTime,
228 replayLedger->info().closeTimeResolution,
232 for (auto& tx : replayData.orderedTxns())
233 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
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