20#include <xrpld/app/ledger/InboundLedgers.h> 
   21#include <xrpld/app/ledger/LedgerCleaner.h> 
   22#include <xrpld/app/ledger/LedgerMaster.h> 
   23#include <xrpld/app/misc/LoadFeeTrack.h> 
   25#include <xrpl/beast/core/CurrentThreadName.h> 
   26#include <xrpl/protocol/jss.h> 
   83            LogicError(
"LedgerCleanerImp::stop not called.");
 
 
   95        JLOG(
j_.
info()) << 
"Stopping";
 
 
  116            map[
"status"] = 
"idle";
 
  119            map[
"status"] = 
"running";
 
  122            map[
"check_nodes"] = 
checkNodes_ ? 
"true" : 
"false";
 
  123            map[
"fix_txns"] = 
fixTxns_ ? 
"true" : 
"false";
 
 
  190            if (params.
isMember(jss::max_ledger))
 
  193            if (params.
isMember(jss::min_ledger))
 
  202            if (params.
isMember(jss::check_nodes))
 
 
  237                    "ripple::LedgerCleanerImp::run : is cleaning");
 
 
  255                << 
"Ledger #" << ledger->info().seq << 
": " << mn.
what();
 
  261        return hash ? *hash : beast::zero;  
 
 
  282            JLOG(
j_.
debug()) << 
"Ledger " << ledgerIndex << 
" not available";
 
  290        if (!dbLedger || (dbLedger->info().hash != ledgerHash) ||
 
  291            (dbLedger->info().parentHash != nodeLedger->info().parentHash))
 
  295                << 
"Ledger " << ledgerIndex << 
" mismatches SQL DB";
 
  302                << 
"ledger " << ledgerIndex << 
" had wrong entry in history";
 
  306        if (doNodes && !nodeLedger->walkLedger(
app_.
journal(
"Ledger")))
 
  308            JLOG(
j_.
debug()) << 
"Ledger " << ledgerIndex << 
" is missing nodes";
 
  317            JLOG(
j_.
debug()) << 
"Failed to save ledger " << ledgerIndex;
 
 
  336        if (!referenceLedger || (referenceLedger->info().seq < ledgerIndex))
 
  339            if (!referenceLedger)
 
  341                JLOG(
j_.
warn()) << 
"No validated ledger";
 
  346        if (referenceLedger->info().seq >= ledgerIndex)
 
  361                    "ripple::LedgerCleanerImp::getHash : nonzero hash");
 
  375            JLOG(
j_.
warn()) << 
"Validated ledger is prior to target ledger";
 
 
  384        auto shouldExit = [
this] {
 
  391        while (!shouldExit())
 
  400                JLOG(
j_.
debug()) << 
"Waiting for load to subside";
 
  418            ledgerHash = 
getHash(ledgerIndex, goodLedger);
 
  424                    << 
"Unable to get hash for ledger " << ledgerIndex;
 
  427            else if (!
doLedger(ledgerIndex, ledgerHash, doNodes, doTxns))
 
  429                JLOG(
j_.
info()) << 
"Failed to process ledger " << ledgerIndex;
 
 
 
bool isMember(char const *key) const
Return true if the object has a member named key.
 
A generic endpoint for log messages.
 
virtual LoadFeeTrack & getFeeTrack()=0
 
virtual beast::Journal journal(std::string const &name)=0
 
virtual InboundLedgers & getInboundLedgers()=0
 
virtual LedgerMaster & getLedgerMaster()=0
 
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
 
LedgerHash getLedgerHash(std::shared_ptr< ReadView const > &ledger, LedgerIndex index)
 
void clean(Json::Value const ¶ms) override
Start a long running task to clean the ledger.
 
~LedgerCleanerImp() override
 
LedgerCleanerImp(Application &app, beast::Journal journal)
 
void doLedgerCleaner()
Run the ledger cleaner.
 
std::condition_variable wakeup_
 
bool doLedger(LedgerIndex const &ledgerIndex, LedgerHash const &ledgerHash, bool doNodes, bool doTxns)
Process a single ledger.
 
void onWrite(beast::PropertyStream::Map &map) override
Subclass override.
 
LedgerHash getHash(LedgerIndex const &ledgerIndex, std::shared_ptr< ReadView const > &referenceLedger)
Returns the hash of the specified ledger.
 
Check the ledger/transaction databases to make sure they have continuity.
 
std::shared_ptr< Ledger const > getValidatedLedger()
 
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
 
void clearLedger(std::uint32_t seq)
 
bool getFullValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
 
bool isLoadedLocal() const
 
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
std::unique_ptr< LedgerCleaner > make_LedgerCleaner(Application &app, beast::Journal journal)
 
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Application &app, bool acquire)
 
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
 
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
 
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
 
bool pendSaveValidated(Application &app, std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
Save, or arrange to save, a fully-validated ledger Returns false on error.