mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Improve ledger replay logic
Build a replay structure holding the transactions in execution order along with the close time. Use this structure when replaying a ledger close.
This commit is contained in:
@@ -970,8 +970,21 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
|
||||
consensus_.peekStoredProposals ().clear ();
|
||||
}
|
||||
|
||||
std::uint32_t closeTime = roundCloseTime (
|
||||
mOurPosition->getCloseTime (), mCloseResolution);
|
||||
auto closeTime = mOurPosition->getCloseTime();
|
||||
|
||||
auto replay = ledgerMaster_.releaseReplay();
|
||||
|
||||
if (replay)
|
||||
{
|
||||
// If we're replaying a close, use the time the ledger
|
||||
// we're replaying closed
|
||||
closeTime = replay->closeTime_;
|
||||
|
||||
if ((replay->closeFlags_ & sLCF_NoConsensusTime) != 0)
|
||||
closeTime = 0;
|
||||
}
|
||||
|
||||
closeTime = roundCloseTime (closeTime, mCloseResolution);
|
||||
|
||||
// If we don't have a close time, then we just agree to disagree
|
||||
bool const closeTimeCorrect = (closeTime != 0);
|
||||
@@ -1018,8 +1031,18 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
|
||||
{
|
||||
OpenView accum(&*newLCL);
|
||||
assert(accum.closed());
|
||||
applyTransactions (app_, set.get(), accum,
|
||||
newLCL, retriableTxs, tapNONE);
|
||||
if (replay)
|
||||
{
|
||||
// Special case, we are replaying a ledger close
|
||||
for (auto& tx : replay->txns_)
|
||||
applyTransaction (accum, tx.second, false, tapNO_CHECK_SIGN);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal case, we are not replaying a ledger close
|
||||
applyTransactions (app_, set.get(), accum,
|
||||
newLCL, retriableTxs, tapNONE);
|
||||
}
|
||||
accum.apply(*newLCL);
|
||||
}
|
||||
|
||||
@@ -1782,14 +1805,6 @@ make_LedgerConsensus (Application& app, ConsensusImp& consensus, int previousPro
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Apply a transaction to a ledger
|
||||
|
||||
@param engine The transaction engine containing the ledger.
|
||||
@param txn The transaction to be applied to ledger.
|
||||
@param retryAssured true if the transaction should be retried on failure.
|
||||
@return One of resultSuccess, resultFail or resultRetry.
|
||||
*/
|
||||
static
|
||||
int
|
||||
applyTransaction (Application& app, OpenView& view,
|
||||
std::shared_ptr<STTx const> const& txn,
|
||||
|
||||
Reference in New Issue
Block a user