1#include <xrpld/app/ledger/LedgerPersistence.h>
3#include <xrpl/beast/utility/instrumentation.h>
4#include <xrpl/core/HashRouter.h>
5#include <xrpl/core/JobQueue.h>
6#include <xrpl/core/ServiceRegistry.h>
7#include <xrpl/json/to_string.h>
8#include <xrpl/ledger/PendingSaves.h>
9#include <xrpl/protocol/Indexes.h>
10#include <xrpl/rdb/RelationalDatabase.h>
21 auto seq = ledger->header().seq;
25 JLOG(j.debug()) <<
"Save aborted";
50 JLOG(stream) <<
"Double pend save for " << ledger->header().seq;
60 XRPL_ASSERT(ledger->isImmutable(),
"xrpl::pendSaveValidated : immutable ledger");
65 JLOG(stream) <<
"Pend save with seq in pending saves " << ledger->header().seq;
116 "xrpl::finishLoadByIndexOrHash : valid ledger fees");
117 ledger->setImmutable();
119 JLOG(j.
trace()) <<
"Loaded ledger: " <<
to_string(ledger->header().hash);
130 return {
loadLedgerHelper(*info, rules, fees, registry,
true), info->seq, info->hash};
165 !ledger || ledger->header().hash == ledgerHash,
166 "xrpl::loadByHash : ledger hash match if loaded");
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
bool setFlags(uint256 const &key, HashRouterFlags flags)
Set the flags on a hash.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
void finishWork(LedgerIndex seq)
Finish working on a ledger.
bool shouldWork(LedgerIndex seq, bool isSynchronous)
Check if a ledger should be dispatched.
bool startWork(LedgerIndex seq)
Start working on a ledger.
bool pending(LedgerIndex seq)
Return true if a ledger is in the progress of being saved.
virtual bool saveValidatedLedger(std::shared_ptr< Ledger const > const &ledger, bool current)=0
saveValidatedLedger Saves a ledger into the database.
virtual std::optional< LedgerHeader > getNewestLedgerInfo()=0
getNewestLedgerInfo Returns the info of the newest saved ledger.
virtual std::optional< LedgerHeader > getLedgerInfoByHash(uint256 const &ledgerHash)=0
getLedgerInfoByHash Returns the info of the ledger with given hash.
virtual std::optional< LedgerHeader > getLedgerInfoByIndex(LedgerIndex ledgerSeq)=0
getLedgerInfoByIndex Returns a ledger by its sequence.
Rules controlling protocol behavior.
Service registry for dependency injection.
virtual PendingSaves & getPendingSaves()=0
virtual JobQueue & getJobQueue()=0
virtual RelationalDatabase & getRelationalDatabase()=0
virtual beast::Journal getJournal(std::string const &name)=0
virtual HashRouter & getHashRouter()=0
virtual Family & getNodeFamily()=0
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static constexpr std::uint32_t XRP_LEDGER_EARLIEST_FEES
The XRP Ledger mainnet's earliest ledger with a FeeSettings object.
std::tuple< std::shared_ptr< Ledger >, std::uint32_t, uint256 > getLatestLedger(Rules const &rules, Fees const &fees, ServiceRegistry ®istry)
Fetch the ledger with the highest sequence contained in the database.
bool isCurrent(ValidationParms const &p, NetClock::time_point now, NetClock::time_point signTime, NetClock::time_point seenTime)
Whether a validation is still current.
bool pendSaveValidated(ServiceRegistry ®istry, std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
Save, or arrange to save, a fully-validated ledger.
std::string to_string(base_uint< Bits, Tag > const &a)
std::shared_ptr< Ledger > loadLedgerHelper(LedgerHeader const &info, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Make ledger using info loaded from database.
std::shared_ptr< Ledger > loadByIndex(std::uint32_t ledgerIndex, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Load a ledger by its sequence number.
@ current
This was a new validation and was added.
static bool saveValidatedLedger(ServiceRegistry ®istry, std::shared_ptr< Ledger const > const &ledger, bool current)
std::shared_ptr< Ledger > loadByHash(uint256 const &ledgerHash, Rules const &rules, Fees const &fees, ServiceRegistry ®istry, bool acquire)
Load a ledger by its hash.
static void finishLoadByIndexOrHash(std::shared_ptr< Ledger > const &ledger, beast::Journal j)
Reflects the fee settings for a particular ledger.