Example #1
0
// Build a ledger from consensus transactions
std::shared_ptr<Ledger>
buildLedger(
    std::shared_ptr<Ledger const> const& parent,
    NetClock::time_point closeTime,
    const bool closeTimeCorrect,
    NetClock::duration closeResolution,
    SHAMap const& txs,
    Application& app,
    CanonicalTXSet& retriableTxs,
    beast::Journal j)
{
    JLOG(j.debug()) << "Report: TxSt = " << txs.getHash().as_uint256()
                    << ", close " << closeTime.time_since_epoch().count()
                    << (closeTimeCorrect ? "" : " (incorrect)");

    return buildLedgerImpl(
        parent,
        closeTime,
        closeTimeCorrect,
        closeResolution,
        app,
        j,
        [&](OpenView& accum, std::shared_ptr<Ledger> const& buildLCL) {
            retriableTxs = applyTransactions(app, txs, accum, buildLCL, j);
        });
}
Example #2
0
Work::State
CatchupWork::onSuccess()
{
    if (!hasAnyLedgersToCatchupTo())
    {
        mApp.getCatchupManager().historyCaughtup();
        asio::error_code ec = std::make_error_code(std::errc::invalid_argument);
        mProgressHandler(ec, ProgressState::FINISHED,
                         LedgerHeaderHistoryEntry{});
        return WORK_SUCCESS;
    }

    auto resolvedConfiguration =
        mCatchupConfiguration.resolve(mRemoteState.currentLedger);
    auto catchupRange =
        makeCatchupRange(mLastClosedLedgerAtReset, resolvedConfiguration,
                         mApp.getHistoryManager());
    auto ledgerRange = catchupRange.first;
    auto checkpointRange =
        CheckpointRange{ledgerRange, mApp.getHistoryManager()};

    if (downloadLedgers(checkpointRange))
    {
        return WORK_PENDING;
    }

    if (verifyLedgers(ledgerRange))
    {
        return WORK_PENDING;
    }

    if (catchupRange.second)
    {
        if (!alreadyHaveBucketsHistoryArchiveState(checkpointRange.first()))
        {
            if (downloadBucketsHistoryArchiveState(checkpointRange.first()))
            {
                return WORK_PENDING;
            }
        }
        else
        {
            mApplyBucketsRemoteState = mRemoteState;
        }

        if (downloadBuckets())
        {
            return WORK_PENDING;
        }

        if (applyBuckets())
        {
            return WORK_PENDING;
        }

        if (!mBucketsAppliedEmitted)
        {
            mProgressHandler({}, ProgressState::APPLIED_BUCKETS,
                             mFirstVerified);
            mBucketsAppliedEmitted = true;
        }
    }
    else
    {
        CLOG(INFO, "History") << "Catchup downloading history archive "
                                 "state for applying buckets at checkpoint "
                              << checkpointRange.first() << " not needed";
    }

    if (downloadTransactions(checkpointRange))
    {
        return WORK_PENDING;
    }

    if (applyTransactions(ledgerRange))
    {
        return WORK_PENDING;
    }

    mProgressHandler({}, ProgressState::APPLIED_TRANSACTIONS, mLastApplied);
    mProgressHandler({}, ProgressState::FINISHED, mLastApplied);
    mApp.getCatchupManager().historyCaughtup();
    return WORK_SUCCESS;
}