xrpld
Loading...
Searching...
No Matches
xrpl::LedgerMaster Class Reference

Tracks the current ledger and any ledgers in the process of closing. More...

#include <LedgerMaster.h>

Inheritance diagram for xrpl::LedgerMaster:
Collaboration diagram for xrpl::LedgerMaster:

Classes

struct  Stats
 Ledger-age gauges reported to the insight collector. More...

Public Member Functions

 LedgerMaster (Application &app, Stopwatch &stopwatch, beast::insight::Collector::Ptr const &collector, beast::Journal journal)
 Constructs the tracker; reads history and fetch limits from the config.
 ~LedgerMaster () override=default
 Destroys the tracker.
LedgerIndex getCurrentLedgerIndex ()
LedgerIndex getValidLedgerIndex ()
bool isCompatible (ReadView const &, beast::Journal::Stream, char const *reason)
 Tests whether a view can belong to the same chain as what we validated.
std::recursive_mutex & peekMutex ()
 Exposes mutex_.
std::shared_ptr< ReadView const > getCurrentLedger ()
 The current ledger is the ledger we believe new transactions should go in.
std::shared_ptr< Ledger const > getClosedLedger ()
 The finalized ledger is the last closed/accepted ledger.
std::shared_ptr< Ledger const > getValidatedLedger ()
 The validated ledger is the last fully validated ledger.
Rules getValidatedRules ()
 The Rules are in the last fully validated ledger if there is one.
std::shared_ptr< ReadView const > getPublishedLedger ()
 This is the last ledger we published to clients and can lag the validated ledger.
std::chrono::seconds getPublishedLedgerAge ()
std::chrono::seconds getValidatedLedgerAge ()
bool isCaughtUp (std::string &reason)
 Decides whether the node is close enough to the network to serve clients.
std::uint32_t getEarliestFetch ()
 Get the earliest ledger we will let peers fetch.
bool storeLedger (std::shared_ptr< Ledger const > ledger)
 Adds a ledger to the history cache.
void setFullLedger (std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
 A new ledger has been accepted as part of the trusted chain: mark it validated and full, record it as resident, persist it, and repair the chain behind it if the parent turns out to disagree.
bool canBeCurrent (std::shared_ptr< Ledger const > const &ledger)
 Check the sequence number and parent close time of a ledger against our clock and last validated ledger to see if it can be the network's current ledger.
void switchLCL (std::shared_ptr< Ledger const > const &lastClosed)
 Adopts a ledger as the last closed ledger, then either accepts it directly (standalone) or tests it for validation (networked).
void failedSave (std::uint32_t seq, UInt256 const &hash)
 Marks a ledger no longer resident after its save failed, and starts fetching it again.
std::string getCompleteLedgers () const
std::size_t missingFromCompleteLedgerRange (LedgerIndex first, LedgerIndex last) const
 Counts gaps in a closed sequence interval.
void applyHeldTransactions ()
 Apply held transactions to the open ledger This is normally called as we close the ledger.
std::shared_ptr< STTx const > popAcctTransaction (std::shared_ptr< STTx const > const &tx)
 Get the next transaction held for a particular account if any.
UInt256 getHashBySeq (std::uint32_t index)
 Get a ledger's hash by sequence number using the cache.
std::optional< LedgerHash > walkHashBySeq (std::uint32_t index, InboundLedger::Reason reason)
 Walk to a ledger's hash using the skip list.
std::optional< LedgerHash > walkHashBySeq (std::uint32_t index, std::shared_ptr< ReadView const > const &referenceLedger, InboundLedger::Reason reason)
 Walk the chain of ledger hashes to determine the hash of the ledger with the specified index.
std::shared_ptr< Ledger const > getLedgerBySeq (std::uint32_t index)
 Finds a ledger by sequence, preferring the validated chain.
std::shared_ptr< Ledger const > getLedgerByHash (UInt256 const &hash)
void setLedgerRangePresent (std::uint32_t minV, std::uint32_t maxV)
 Records a closed range of sequences as resident.
std::optional< NetClock::time_point > getCloseTimeBySeq (LedgerIndex ledgerIndex)
std::optional< NetClock::time_point > getCloseTimeByHash (LedgerHash const &ledgerHash, LedgerIndex ledgerIndex)
 Reads a close time straight out of the serialized header in the node store.
void addHeldTransaction (std::shared_ptr< Transaction > const &trans)
 Defers a transaction to the next open ledger.
void fixMismatch (ReadView const &ledger)
 Walks back from a ledger, dropping every resident ledger it cannot confirm against that ledger's skip list: a mismatch, one it cannot load, or one too far back to look up.
bool haveLedger (std::uint32_t seq) const
void clearLedger (std::uint32_t seq)
 Marks a ledger no longer resident.
bool isValidated (ReadView const &ledger)
 Tests whether a ledger is on the validated chain, using the skip list when the ledger does not already say so.
bool getValidatedRange (std::uint32_t &minVal, std::uint32_t &maxVal)
 Returns Ledgers we have all the nodes for and are indexed: a contiguous part of getFullValidatedRange() with no ledger still being saved.
bool getFullValidatedRange (std::uint32_t &minVal, std::uint32_t &maxVal)
 Returns Ledgers we have all the nodes for: the contiguous resident range ending at the published ledger.
void sweep ()
 Expires stale entries from the ledger history and fetch-pack caches.
float getCacheHitRate ()
void checkAccept (std::shared_ptr< Ledger const > const &ledger)
 If the ledger passes canBeCurrent(), is newer than the validated ledger and has a quorum, makes it the last fully validated ledger.
void checkAccept (UInt256 const &hash, std::uint32_t seq)
 Check if the specified ledger can become the new last fully-validated ledger, fetching it if it is not resident.
void consensusBuilt (std::shared_ptr< Ledger const > const &ledger, UInt256 const &consensusHash, json::Value consensus)
 Report that the consensus process built a particular ledger.
void setBuildingLedger (LedgerIndex index)
 Records which ledger consensus is currently building, so validations for it are not chased separately.
void tryAdvance ()
 Signals that the ledger stream may be able to make progress.
bool newPathRequest ()
 Notes a new pathfinding request and dispatches a worker if one is due.
bool isNewPathRequest ()
bool newOrderBookDB ()
 If the order book is radically updated, we need to reprocess all pathfinding requests.
bool fixIndex (LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
 Corrects the cached sequence-to-hash mapping for one ledger.
void clearPriorLedgers (LedgerIndex seq)
 Forgets that we hold any ledger below a sequence, without touching the cached ledgers themselves.
void clearLedgerCachePrior (LedgerIndex seq)
 Drops cached ledgers below a sequence.
void takeReplay (std::unique_ptr< LedgerReplay > replay)
 Stores a transaction set to replay when the next ledger closes.
std::unique_ptr< LedgerReplay > releaseReplay ()
void gotFetchPack (bool progress, std::uint32_t seq)
 Signals that fetch-pack data arrived, so waiting acquires can use it.
void addFetchPack (UInt256 const &hash, std::shared_ptr< Blob > data)
 Caches one fetch-pack node received from a peer.
std::optional< Blob > getFetchPack (UInt256 const &hash) override
 Consumes one cached fetch-pack node.
void makeFetchPack (std::weak_ptr< Peer > const &wPeer, std::shared_ptr< protocol::TMGetObjectByHash > const &request, UInt256 haveLedgerHash, UptimeClock::time_point uptime)
 Builds a fetch pack of the ledgers preceding the one a peer says it has, and sends it.
std::size_t getFetchPackCacheSize () const
bool haveValidated ()
 Whether we have ever fully validated a ledger.
std::optional< LedgerIndex > minSqlSeq ()
 Returns the minimum ledger sequence in SQL database, if any.
std::optional< UInt256 > txnIdFromIndex (uint32_t ledgerSeq, uint32_t txnIndex)
 Iff a txn exists at the specified ledger and offset then return its txnid.

Private Member Functions

void setValidLedger (std::shared_ptr< Ledger const > const &l)
 Adopts a ledger as the last validated one and tells the rest of the server, including the amendment-support checks that can block the node.
void setPubLedger (std::shared_ptr< Ledger const > const &l)
 Records how far publication has reached.
void tryFill (std::shared_ptr< Ledger const > ledger)
 Walks back from a ledger through the SQL index, marking each ancestor resident until the chain breaks or a known ledger is reached.
void getFetchPack (LedgerIndex missing, InboundLedger::Reason reason)
 Request a fetch pack to get to the specified ledger.
std::optional< LedgerHash > getLedgerHashForHistory (LedgerIndex index, InboundLedger::Reason reason)
 Finds the hash of a ledger the history back-fill wants, preferring the last back-filled ledger as the reference to walk from.
std::size_t getNeededValidations ()
 Determines how many validations are needed to fully validate a ledger.
void fetchForHistory (std::uint32_t missing, bool &progress, InboundLedger::Reason reason, std::unique_lock< std::recursive_mutex > &)
 Starts acquiring one missing historical ledger.
void doAdvance (std::unique_lock< std::recursive_mutex > &)
 Try to publish ledgers, acquire missing ledgers.
std::vector< std::shared_ptr< Ledger const > > findNewLedgersToPublish (std::unique_lock< std::recursive_mutex > &)
 Collects the next run of validated ledgers to publish, acquiring or replaying the ones that are missing.
void updatePaths ()
 Runs one pathfinding pass per new validated ledger or new request, and exits when neither is new, even if requests are still pending.
bool newPFWork (char const *name, std::unique_lock< std::recursive_mutex > &)
 A thread needs to be dispatched to handle pathfinding work of some kind.
void collectMetrics ()
 Samples both ledger ages into the gauges.

Private Attributes

Application & app_
 Owning application, the route to every other subsystem.
beast::Journal journal_
 Log sink for this component.
std::recursive_mutex mutex_
 Guards pubLedger_, pathLedger_, lastValidLedger_, the held transactions and the job flags other than the atomic gotFetchPackThread_.
LedgerHolder closedLedger_
 The ledger that most recently closed.
LedgerHolder validLedger_
 The highest-sequence ledger we have fully accepted.
std::shared_ptr< Ledger const > pubLedger_
 The last ledger we have published.
std::shared_ptr< Ledger const > pathLedger_
 The last ledger we did pathfinding against.
std::shared_ptr< Ledger const > histLedger_
 The last ledger we handled fetching history.
std::pair< UInt256, LedgerIndex > lastValidLedger_ {UInt256(), 0}
 Fully validated ledger, whether or not we have the ledger resident.
LedgerHistory ledgerHistory_
 Cache of ledgers by hash and of validated sequence-to-hash mappings.
CanonicalTXSet heldTransactions_ {UInt256()}
 Transactions deferred to the next open ledger, in canonical order.
std::unique_ptr< LedgerReplay > replayData_
 A set of transactions to replay during the next close.
std::recursive_mutex completeLock_
 Guards completeLedgers_ only.
RangeSet< std::uint32_t > completeLedgers_
 Sequences of the ledgers this node believes it holds in full.
bool advanceThread_ {false}
 An AdvanceLedger job is queued or running.
bool advanceWork_ {false}
 Publish thread has work to do.
int fillInProgress_ {0}
 Sequence a tryFill() job is currently walking back from, or 0 when no fill is running.
int pathFindThread_ {0}
 Pathfinding jobs queued or running.
bool pathFindNewRequest_ {false}
 A pathfinding request arrived and has not been picked up yet.
std::atomic_flag gotFetchPackThread_ = ATOMIC_FLAG_INIT
 Set while a GotFetchPack job is outstanding, so only one ever is.
std::atomic< std::uint32_t > pubLedgerClose_ {0}
 Close time of pubLedger_, in seconds since the network epoch; 0 if none.
std::atomic< LedgerIndex > pubLedgerSeq_ {0}
 Sequence of pubLedger_; 0 if nothing has been published.
std::atomic< std::uint32_t > validLedgerSign_ {0}
 Sign time of validLedger_, in seconds since the network epoch: the median of its trusted validations, or its close time when those were too few.
std::atomic< LedgerIndex > validLedgerSeq_ {0}
 Sequence of validLedger_; 0 if nothing is validated.
std::atomic< LedgerIndex > buildingLedgerSeq_ {0}
 Sequence consensus is building; 0 once it is built.
bool const standalone_
 The server is in standalone mode.
std::uint32_t const fetchDepth_
 How many ledgers before the closed ledger do we allow peers to request?
std::uint32_t const ledgerHistorySize_
 How much history do we want to keep.
std::uint32_t const ledgerFetchSize_
 Cap on ledgers acquired in one publication or prefetch pass.
TaggedCache< UInt256, Blob > fetchPacks_
 Fetch-pack nodes keyed by node hash.
std::uint32_t fetchSeq_ {0}
 Sequence of the last fetch-pack attempt, so the same one is not tried twice in a row.
LedgerIndex const maxLedgerDifference_ {1000000}
 Try to keep a validator from switching from test to live network without first wiping the database.
TimeKeeper::time_point upgradeWarningPrevTime_
 Time that the previous upgrade warning was issued.
Stats stats_
 The gauges and the collector hook that samples them.

Detailed Description

Tracks the current ledger and any ledgers in the process of closing.

Tracks ledger history. Tracks held transactions.

Four ledgers are tracked, and they can all differ:

current open ledger new transactions go into (owned by OpenLedger)
closed most recently closed ledger; may already be validated
validated highest ledger accepted as fully validated; standalone needs no quorum
published highest ledger publication has reached; can lag validated
RCLConsensus ──switchLCL/consensusBuilt──> LedgerMaster
RCLValidations ─────────────checkAccept──> │
PeerImp ──────gotFetchPack/makeFetchPack─> │
├─> LedgerHistory (cache)
├─> InboundLedgers (acquire)
├─> NetworkOPs (publish)
├─> PathRequestManager
├─> LedgerReplayer
└─> Application (everything else)
Manages the lifetime of inbound ledgers.
Retains historical ledgers.
LedgerMaster(Application &app, Stopwatch &stopwatch, beast::insight::Collector::Ptr const &collector, beast::Journal journal)
Constructs the tracker; reads history and fetch limits from the config.
Manages the lifetime of ledger replay tasks.
Provides server functionality for clients.
Definition NetworkOPs.h:82
Represents the open ledger.
Definition OpenLedger.h:43
Manages the generic consensus algorithm for use by the RCL.
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.
Definition SociDB.cpp:91
Validations< RCLValidationsAdaptor > RCLValidations
Alias for RCL-specific instantiation of generic Validations.

Advancing the stream is a state machine run on a JobQueue thread. Callers only ever poke it with tryAdvance(); the loop decides what to do next:

│ (one AdvanceLedger job at a time)
v
doAdvance() ──> findNewLedgersToPublish()
^ │
│ has ledgers? ──yes──> setFullLedger, setPubLedger,
│ │ NetworkOPs::pubLedger, newPFWork
│ no
│ v
│ caught up and idle? ──no──> stop
│ │ yes
│ v
│ fetchForHistory(newest gap below pubLedger) ──> tryFill()
└──────── repeat while progress was made or tryAdvance() was called
void tryFill(std::shared_ptr< Ledger const > ledger)
Walks back from a ledger through the SQL index, marking each ancestor resident until the chain breaks...
void setPubLedger(std::shared_ptr< Ledger const > const &l)
Records how far publication has reached.
bool newPFWork(char const *name, std::unique_lock< std::recursive_mutex > &)
A thread needs to be dispatched to handle pathfinding work of some kind.
void setFullLedger(std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
A new ledger has been accepted as part of the trusted chain: mark it validated and full,...
std::vector< std::shared_ptr< Ledger const > > findNewLedgersToPublish(std::unique_lock< std::recursive_mutex > &)
Collects the next run of validated ledgers to publish, acquiring or replaying the ones that are missi...
void fetchForHistory(std::uint32_t missing, bool &progress, InboundLedger::Reason reason, std::unique_lock< std::recursive_mutex > &)
Starts acquiring one missing historical ledger.
void tryAdvance()
Signals that the ledger stream may be able to make progress.
void doAdvance(std::unique_lock< std::recursive_mutex > &)
Try to publish ledgers, acquire missing ledgers.
// Read the validated ledger, if the node has one yet.
if (auto const ledger = ledgerMaster.getValidatedLedger())
JLOG(j.info()) << "validated " << ledger->header().seq;
// After consensus builds a ledger: report it, then adopt it. No need to
// call tryAdvance(): checkAccept() calls it once the ledger has a quorum;
// in standalone, switchLCL() calls it at once.
ledgerMaster.consensusBuilt(built, txSetId, std::move(consensusJson));
ledgerMaster.switchLCL(built);
// Edge case: on a node that has never validated, the age accessors report
// two weeks rather than zero, so "stale" checks fail closed.
ledgerMaster.getValidatedLedgerAge(); // 2 weeks
Note
Thread-safe, except takeReplay() and releaseReplay(), which take no lock: startup stores the replay before consensus reads it. Also except the two age accessors, whose unlocked static only limits repeat log lines. The closed and validated ledgers have their own lock for reads, and change only under mutex_. Two recursive mutexes guard the rest: mutex_ for the published, path and last-valid ledgers, held transactions and job flags; completeLock_ for completeLedgers_ only. When both are needed, mutex_ is taken first. The sequence numbers and gotFetchPackThread_ are atomics and are used without either lock.
Several accessors can be slow: anything that reaches InboundLedgers::acquire() may read the node store from disk, and anything walking a skip list may throw SHAMapMissingNode. acquire() never waits for peers; it starts a fetch and returns null until the ledger is local.
The published stream is best-effort. If it falls more than 100 ledgers behind, the gap is abandoned and publication jumps to the validated ledger.

Definition at line 121 of file LedgerMaster.h.

Constructor & Destructor Documentation

◆ LedgerMaster()

xrpl::LedgerMaster::LedgerMaster ( Application & app,
Stopwatch & stopwatch,
beast::insight::Collector::Ptr const & collector,
beast::Journal journal )
explicit

Constructs the tracker; reads history and fetch limits from the config.

Parameters
appOwning application, used to reach every other subsystem.
stopwatchClock driving expiry of the fetch-pack cache.
collectorSink for the ledger-age gauges and the history cache's mismatch counter.
journalLog sink.

Definition at line 147 of file LedgerMaster.cpp.

◆ ~LedgerMaster()

xrpl::LedgerMaster::~LedgerMaster ( )
overridedefault

Destroys the tracker.

Outstanding JobQueue work must already have been drained, since those jobs capture this.

Member Function Documentation

◆ getCurrentLedgerIndex()

LedgerIndex xrpl::LedgerMaster::getCurrentLedgerIndex ( )
Returns
Sequence of the open ledger transactions are being applied to.

Definition at line 170 of file LedgerMaster.cpp.

◆ getValidLedgerIndex()

LedgerIndex xrpl::LedgerMaster::getValidLedgerIndex ( )
Returns
Sequence of the last fully validated ledger, or 0 if there is none.

Definition at line 176 of file LedgerMaster.cpp.

◆ isCompatible()

bool xrpl::LedgerMaster::isCompatible ( ReadView const & view,
beast::Journal::Stream s,
char const * reason )

Tests whether a view can belong to the same chain as what we validated.

Parameters
viewLedger view to test.
sStream the reason for a mismatch is logged to.
reasonCaller-supplied label for that log line.
Returns
false when the view conflicts with the validated ledger or with the highest ledger known to have a validation quorum.

Definition at line 182 of file LedgerMaster.cpp.

◆ peekMutex()

std::recursive_mutex & xrpl::LedgerMaster::peekMutex ( )

Exposes mutex_.

Holding it across several calls keeps the closed, validated and published ledgers from changing; the open ledger is not covered.

Returns
The recursive mutex. Callers must not keep it past a blocking call.

Definition at line 1587 of file LedgerMaster.cpp.

◆ getCurrentLedger()

std::shared_ptr< ReadView const > xrpl::LedgerMaster::getCurrentLedger ( )

The current ledger is the ledger we believe new transactions should go in.

Returns
The open ledger.

Definition at line 1594 of file LedgerMaster.cpp.

◆ getClosedLedger()

std::shared_ptr< Ledger const > xrpl::LedgerMaster::getClosedLedger ( )

The finalized ledger is the last closed/accepted ledger.

Returns
That ledger, or null before the first close.

Definition at line 193 of file LedgerMaster.h.

◆ getValidatedLedger()

std::shared_ptr< Ledger const > xrpl::LedgerMaster::getValidatedLedger ( )

The validated ledger is the last fully validated ledger.

Returns
That ledger, or null until the first ledger is validated. It may not be in the resident set yet.

Definition at line 1600 of file LedgerMaster.cpp.

◆ getValidatedRules()

Rules xrpl::LedgerMaster::getValidatedRules ( )

The Rules are in the last fully validated ledger if there is one.

Returns
Those Rules, or ones built from the configured amendments when nothing is validated yet.

Definition at line 1606 of file LedgerMaster.cpp.

◆ getPublishedLedger()

std::shared_ptr< ReadView const > xrpl::LedgerMaster::getPublishedLedger ( )

This is the last ledger we published to clients and can lag the validated ledger.

Returns
That ledger, or null until one is recorded. The first one recorded is a starting point and is not sent to clients.

Definition at line 1621 of file LedgerMaster.cpp.

◆ getPublishedLedgerAge()

std::chrono::seconds xrpl::LedgerMaster::getPublishedLedgerAge ( )
Returns
Seconds between network time and the close time of the last published ledger; two weeks when nothing has been published, and never negative.

Definition at line 205 of file LedgerMaster.cpp.

◆ getValidatedLedgerAge()

std::chrono::seconds xrpl::LedgerMaster::getValidatedLedgerAge ( )
Returns
Seconds between network time and the validation sign time of the last validated ledger (its close time when trusted validations were too few); two weeks when nothing is validated.

Definition at line 229 of file LedgerMaster.cpp.

◆ isCaughtUp()

bool xrpl::LedgerMaster::isCaughtUp ( std::string & reason)

Decides whether the node is close enough to the network to serve clients.

Parameters
reasonSet to a human-readable explanation when the answer is false.
Returns
false when nothing has been published, the published ledger is over three minutes old, or validation leads publication by over 90s.

Definition at line 254 of file LedgerMaster.cpp.

◆ getEarliestFetch()

std::uint32_t xrpl::LedgerMaster::getEarliestFetch ( )

Get the earliest ledger we will let peers fetch.

Returns
fetchDepth_ behind the closed ledger, floored at zero.
Note
Requires a closed ledger to exist; do not call this before the first ledger has closed.

Definition at line 653 of file LedgerMaster.cpp.

◆ storeLedger()

bool xrpl::LedgerMaster::storeLedger ( std::shared_ptr< Ledger const > ledger)

Adds a ledger to the history cache.

Does not itself validate the ledger, but honours the flag the ledger already carries: a ledger marked validated is also indexed by sequence.

Parameters
ledgerImmutable ledger to cache.
Returns
true if we already had the ledger.

Definition at line 476 of file LedgerMaster.cpp.

◆ setFullLedger()

void xrpl::LedgerMaster::setFullLedger ( std::shared_ptr< Ledger const > const & ledger,
bool isSynchronous,
bool isCurrent )

A new ledger has been accepted as part of the trusted chain: mark it validated and full, record it as resident, persist it, and repair the chain behind it if the parent turns out to disagree.

It also becomes the validated ledger if newer, and the published one if none is set.

Parameters
ledgerLedger to accept.
isSynchronoustrue to write it to the database before returning.
isCurrenttrue adds the ledger to the in-memory sequence index and saves it as a current ledger, at the higher job priority. Only the publish path passes true; standalone, startup and back-fill pass false.

Definition at line 844 of file LedgerMaster.cpp.

◆ canBeCurrent()

bool xrpl::LedgerMaster::canBeCurrent ( std::shared_ptr< Ledger const > const & ledger)

Check the sequence number and parent close time of a ledger against our clock and last validated ledger to see if it can be the network's current ledger.

Parameters
ledgerCandidate ledger; must not be null.
Returns
false when the candidate precedes the validated ledger, its parent close time is over five minutes from network time (checked once a ledger is validated or the sequence is past 10), or its sequence runs further ahead of the validated ledger than elapsed time could explain.

Definition at line 379 of file LedgerMaster.cpp.

◆ switchLCL()

void xrpl::LedgerMaster::switchLCL ( std::shared_ptr< Ledger const > const & lastClosed)

Adopts a ledger as the last closed ledger, then either accepts it directly (standalone) or tests it for validation (networked).

Parameters
lastClosedClosed, immutable ledger. Passing an open or mutable ledger is a logic error and terminates the process.

Definition at line 444 of file LedgerMaster.cpp.

◆ failedSave()

void xrpl::LedgerMaster::failedSave ( std::uint32_t seq,
UInt256 const & hash )

Marks a ledger no longer resident after its save failed, and starts fetching it again.

Parameters
seqSequence of the ledger that failed to save.
hashHash of that ledger, used to re-acquire it.

Definition at line 905 of file LedgerMaster.cpp.

◆ getCompleteLedgers()

std::string xrpl::LedgerMaster::getCompleteLedgers ( ) const
Returns
Resident ledger sequences as ranges, e.g. "3-8,10", or "empty".

Definition at line 1628 of file LedgerMaster.cpp.

◆ missingFromCompleteLedgerRange()

std::size_t xrpl::LedgerMaster::missingFromCompleteLedgerRange ( LedgerIndex first,
LedgerIndex last ) const

Counts gaps in a closed sequence interval.

Parameters
firstLowest sequence to test; must not exceed last.
lastHighest sequence to test.
Returns
How many sequences in [first, last] are not resident.

Definition at line 1635 of file LedgerMaster.cpp.

◆ applyHeldTransactions()

void xrpl::LedgerMaster::applyHeldTransactions ( )

Apply held transactions to the open ledger This is normally called as we close the ledger.

The open ledger remains open to handle new transactions until a new open ledger is built.

Definition at line 490 of file LedgerMaster.cpp.

◆ popAcctTransaction()

std::shared_ptr< STTx const > xrpl::LedgerMaster::popAcctTransaction ( std::shared_ptr< STTx const > const & tx)

Get the next transaction held for a particular account if any.

This is normally called when a transaction for that account is successfully applied to the open ledger so the next transaction can be resubmitted without waiting for ledger close.

Parameters
txTransaction that was just applied; its account and sequence select the successor.
Returns
The held transaction that directly follows tx (sequence + 1, or one using a ticket), removed from the held set; null if none.

Definition at line 506 of file LedgerMaster.cpp.

◆ getHashBySeq()

UInt256 xrpl::LedgerMaster::getHashBySeq ( std::uint32_t index)

Get a ledger's hash by sequence number using the cache.

Parameters
indexLedger sequence to look up.
Returns
The hash, or zero when neither the cache nor the SQL index has it.

Definition at line 1685 of file LedgerMaster.cpp.

◆ walkHashBySeq() [1/2]

std::optional< LedgerHash > xrpl::LedgerMaster::walkHashBySeq ( std::uint32_t index,
InboundLedger::Reason reason )

Walk to a ledger's hash using the skip list.

Parameters
indexLedger sequence wanted.
reasonWhy the ledger is needed, for any acquire this triggers.
Returns
The hash, or nullopt when there is no validated ledger to walk back from, or when the walk itself cannot produce it.

Definition at line 1696 of file LedgerMaster.cpp.

◆ walkHashBySeq() [2/2]

std::optional< LedgerHash > xrpl::LedgerMaster::walkHashBySeq ( std::uint32_t index,
std::shared_ptr< ReadView const > const & referenceLedger,
InboundLedger::Reason reason )

Walk the chain of ledger hashes to determine the hash of the ledger with the specified index.

The referenceLedger is used as the base of the chain and should be fully validated and must not precede the target index. This function may throw if nodes from the reference ledger or any prior ledger are not present in the node store.

Parameters
indexLedger sequence wanted.
referenceLedgerLedger to walk back from.
reasonWhy the ledger is needed, for any acquire this triggers.
Returns
The hash, or nullopt when the reference ledger is null or precedes index, when the intervening hash page is missing, or when the intermediate ledger is not local yet. A fetch is then started, so a later call may succeed.

Definition at line 1707 of file LedgerMaster.cpp.

◆ getLedgerBySeq()

std::shared_ptr< Ledger const > xrpl::LedgerMaster::getLedgerBySeq ( std::uint32_t index)

Finds a ledger by sequence, preferring the validated chain.

The history cache loads it from the database on a miss.

Parameters
indexLedger sequence wanted.
Returns
The ledger, or null. A miss drops index from the resident set only when the validated ledger's skip list cannot name its hash.

Definition at line 1762 of file LedgerMaster.cpp.

◆ getLedgerByHash()

std::shared_ptr< Ledger const > xrpl::LedgerMaster::getLedgerByHash ( UInt256 const & hash)
Parameters
hashLedger hash wanted.
Returns
The ledger from the history cache (loaded from the database on a miss) or the closed ledger; null if neither has it.

Definition at line 1798 of file LedgerMaster.cpp.

◆ setLedgerRangePresent()

void xrpl::LedgerMaster::setLedgerRangePresent ( std::uint32_t minV,
std::uint32_t maxV )

Records a closed range of sequences as resident.

Parameters
minVLowest sequence now present.
maxVHighest sequence now present.

Definition at line 1811 of file LedgerMaster.cpp.

◆ getCloseTimeBySeq()

std::optional< NetClock::time_point > xrpl::LedgerMaster::getCloseTimeBySeq ( LedgerIndex ledgerIndex)
Parameters
ledgerIndexLedger sequence wanted.
Returns
Its close time, or nullopt when the hash or the stored header cannot be found.

Definition at line 1659 of file LedgerMaster.cpp.

◆ getCloseTimeByHash()

std::optional< NetClock::time_point > xrpl::LedgerMaster::getCloseTimeByHash ( LedgerHash const & ledgerHash,
LedgerIndex ledgerIndex )

Reads a close time straight out of the serialized header in the node store.

Parameters
ledgerHashHash of the ledger wanted.
ledgerIndexIts sequence, used as the node-store lookup hint.
Returns
Its close time, or nullopt when the object is absent, too short, or not a ledger header.

Definition at line 1666 of file LedgerMaster.cpp.

◆ addHeldTransaction()

void xrpl::LedgerMaster::addHeldTransaction ( std::shared_ptr< Transaction > const & trans)

Defers a transaction to the next open ledger.

Parameters
transTransaction to hold.

Definition at line 369 of file LedgerMaster.cpp.

◆ fixMismatch()

void xrpl::LedgerMaster::fixMismatch ( ReadView const & ledger)

Walks back from a ledger, dropping every resident ledger it cannot confirm against that ledger's skip list: a mismatch, one it cannot load, or one too far back to look up.

Stops at the first confirmed match or read error.

Parameters
ledgerLedger whose chain is taken as correct.

Definition at line 792 of file LedgerMaster.cpp.

◆ haveLedger()

bool xrpl::LedgerMaster::haveLedger ( std::uint32_t seq) const
Parameters
seqLedger sequence to test.
Returns
true when seq is in the resident set. This is what the node believes it holds; it is not re-checked here.

Definition at line 520 of file LedgerMaster.cpp.

◆ clearLedger()

void xrpl::LedgerMaster::clearLedger ( std::uint32_t seq)

Marks a ledger no longer resident.

Parameters
seqLedger sequence to drop.

Definition at line 527 of file LedgerMaster.cpp.

◆ isValidated()

bool xrpl::LedgerMaster::isValidated ( ReadView const & ledger)

Tests whether a ledger is on the validated chain, using the skip list when the ledger does not already say so.

Parameters
ledgerLedger to test; open ledgers are never validated.
Returns
true when the ledger is part of the validated chain. A true answer is cached in the ledger header; a false one is recomputed on every call. When the validated chain names a different ledger at this sequence but the SQL index names this one, the sequence is dropped from the resident set.

Definition at line 534 of file LedgerMaster.cpp.

◆ getValidatedRange()

bool xrpl::LedgerMaster::getValidatedRange ( std::uint32_t & minVal,
std::uint32_t & maxVal )

Returns Ledgers we have all the nodes for and are indexed: a contiguous part of getFullValidatedRange() with no ledger still being saved.

Pending saves at either end are trimmed first. Each remaining one then drops the part between it and the nearer end, so this is a best effort and not always the largest such part.

Parameters
minValSet to the lowest usable sequence, or 0 if none remains. Unchanged when the call returns false.
maxValSet to the highest usable sequence, or 0 if none remains or the call returns false.
Returns
false when nothing has been published yet.

Definition at line 608 of file LedgerMaster.cpp.

◆ getFullValidatedRange()

bool xrpl::LedgerMaster::getFullValidatedRange ( std::uint32_t & minVal,
std::uint32_t & maxVal )

Returns Ledgers we have all the nodes for: the contiguous resident range ending at the published ledger.

The published ledger itself is assumed present, not checked.

Parameters
minValSet to the lowest sequence of that range.
maxValSet to the published sequence.
Returns
false when nothing has been published yet.

Definition at line 579 of file LedgerMaster.cpp.

◆ sweep()

void xrpl::LedgerMaster::sweep ( )

Expires stale entries from the ledger history and fetch-pack caches.

Definition at line 1818 of file LedgerMaster.cpp.

◆ getCacheHitRate()

float xrpl::LedgerMaster::getCacheHitRate ( )
Returns
Hit rate of the ledger-by-hash cache, as a percentage.

Definition at line 1825 of file LedgerMaster.cpp.

◆ checkAccept() [1/2]

void xrpl::LedgerMaster::checkAccept ( std::shared_ptr< Ledger const > const & ledger)

If the ledger passes canBeCurrent(), is newer than the validated ledger and has a quorum, makes it the last fully validated ledger.

Then sets the remote fee to the median load fee of trusted full validations of this ledger and its parent (a missing load fee counts as the base fee; no validations give the base fee), and pokes the stream.

Parameters
ledgerCandidate ledger.

Definition at line 974 of file LedgerMaster.cpp.

◆ checkAccept() [2/2]

void xrpl::LedgerMaster::checkAccept ( UInt256 const & hash,
std::uint32_t seq )

Check if the specified ledger can become the new last fully-validated ledger, fetching it if it is not resident.

Parameters
hashHash of the candidate ledger.
seqIts sequence. Zero means the sequence is unknown, which skips the staleness checks.

Definition at line 914 of file LedgerMaster.cpp.

◆ consensusBuilt()

void xrpl::LedgerMaster::consensusBuilt ( std::shared_ptr< Ledger const > const & ledger,
UInt256 const & consensusHash,
json::Value consensus )

Report that the consensus process built a particular ledger.

In standalone this only clears the building sequence. Otherwise it records the built ledger and tries to accept it. If that does not advance the validated ledger, it checks the highest newer ledger with more than a quorum of current trusted validations, which may not be this one.

Parameters
ledgerLedger consensus just built.
consensusHashHash of the consensus transaction set.
consensusConsensus metadata for this round, kept only so a built-versus-validated mismatch can be logged.

Definition at line 1115 of file LedgerMaster.cpp.

◆ setBuildingLedger()

void xrpl::LedgerMaster::setBuildingLedger ( LedgerIndex index)

Records which ledger consensus is currently building, so validations for it are not chased separately.

Parameters
indexSequence being built; 0 when none is.

Definition at line 514 of file LedgerMaster.cpp.

◆ tryAdvance()

void xrpl::LedgerMaster::tryAdvance ( )

Signals that the ledger stream may be able to make progress.

Starts the advance job if it is not already running and a validated ledger exists; otherwise it only records the request. Cheap to call often.

Definition at line 1400 of file LedgerMaster.cpp.

◆ newPathRequest()

bool xrpl::LedgerMaster::newPathRequest ( )

Notes a new pathfinding request and dispatches a worker if one is due.

Returns
true if path request successfully placed.

Definition at line 1540 of file LedgerMaster.cpp.

◆ isNewPathRequest()

bool xrpl::LedgerMaster::isNewPathRequest ( )
Returns
true if a new pathfinding request arrived since the last call. Reading the flag clears it.

Definition at line 1548 of file LedgerMaster.cpp.

◆ newOrderBookDB()

bool xrpl::LedgerMaster::newOrderBookDB ( )

If the order book is radically updated, we need to reprocess all pathfinding requests.

Returns
true if able to fulfill request.

Definition at line 1559 of file LedgerMaster.cpp.

◆ fixIndex()

bool xrpl::LedgerMaster::fixIndex ( LedgerIndex ledgerIndex,
LedgerHash const & ledgerHash )

Corrects the cached sequence-to-hash mapping for one ledger.

Parameters
ledgerIndexSequence to correct.
ledgerHashHash that sequence really has.
Returns
false when a different hash was cached, meaning the caller's view of history just changed; true when it already matched or was absent.

Definition at line 470 of file LedgerMaster.cpp.

◆ clearPriorLedgers()

void xrpl::LedgerMaster::clearPriorLedgers ( LedgerIndex seq)

Forgets that we hold any ledger below a sequence, without touching the cached ledgers themselves.

Parameters
seqFirst sequence to keep.

Definition at line 1831 of file LedgerMaster.cpp.

◆ clearLedgerCachePrior()

void xrpl::LedgerMaster::clearLedgerCachePrior ( LedgerIndex seq)

Drops cached ledgers below a sequence.

Parameters
seqFirst sequence to keep.

Definition at line 1839 of file LedgerMaster.cpp.

◆ takeReplay()

void xrpl::LedgerMaster::takeReplay ( std::unique_ptr< LedgerReplay > replay)

Stores a transaction set to replay when the next ledger closes.

Parameters
replaySet to replay; replaces any set already held.

Definition at line 1845 of file LedgerMaster.cpp.

◆ releaseReplay()

std::unique_ptr< LedgerReplay > xrpl::LedgerMaster::releaseReplay ( )
Returns
The stored replay set, transferring ownership; null if none.

Definition at line 1851 of file LedgerMaster.cpp.

◆ gotFetchPack()

void xrpl::LedgerMaster::gotFetchPack ( bool progress,
std::uint32_t seq )

Signals that fetch-pack data arrived, so waiting acquires can use it.

At most one handler job is queued at a time.

Parameters
progressUnused by the current implementation.
seqUnused by the current implementation.

Definition at line 2066 of file LedgerMaster.cpp.

◆ addFetchPack()

void xrpl::LedgerMaster::addFetchPack ( UInt256 const & hash,
std::shared_ptr< Blob > data )

Caches one fetch-pack node received from a peer.

Parameters
hashHash of the node, which is its key.
dataSerialized node.

Definition at line 2047 of file LedgerMaster.cpp.

◆ getFetchPack() [1/2]

std::optional< Blob > xrpl::LedgerMaster::getFetchPack ( UInt256 const & hash)
override

Consumes one cached fetch-pack node.

Parameters
hashHash of the node wanted.
Returns
The node, or nullopt when it is absent or its contents do not hash to the key. Either way the entry is removed, so a second call for the same hash returns nothing.

Definition at line 2053 of file LedgerMaster.cpp.

◆ makeFetchPack()

void xrpl::LedgerMaster::makeFetchPack ( std::weak_ptr< Peer > const & wPeer,
std::shared_ptr< protocol::TMGetObjectByHash > const & request,
UInt256 haveLedgerHash,
UptimeClock::time_point uptime )

Builds a fetch pack of the ledgers preceding the one a peer says it has, and sends it.

Silently declines when the node is too loaded, too far behind, or the request is over a second old.

Parameters
wPeerPeer to reply to; nothing is sent if it has gone away.
requestOriginating request, whose ledger hash is echoed back.
haveLedgerHashNewest ledger the peer claims to have. Its parent is the first one packed.
uptimeTime the request was received, used as the deadline base.

Definition at line 2135 of file LedgerMaster.cpp.

◆ getFetchPackCacheSize()

std::size_t xrpl::LedgerMaster::getFetchPackCacheSize ( ) const
Returns
Number of nodes currently held in the fetch-pack cache.

Definition at line 2256 of file LedgerMaster.cpp.

◆ haveValidated()

bool xrpl::LedgerMaster::haveValidated ( )

Whether we have ever fully validated a ledger.

Definition at line 725 of file LedgerMaster.h.

◆ minSqlSeq()

std::optional< LedgerIndex > xrpl::LedgerMaster::minSqlSeq ( )

Returns the minimum ledger sequence in SQL database, if any.

Returns
That sequence, or nullopt when the database holds no ledgers.

Definition at line 2263 of file LedgerMaster.cpp.

◆ txnIdFromIndex()

std::optional< UInt256 > xrpl::LedgerMaster::txnIdFromIndex ( uint32_t ledgerSeq,
uint32_t txnIndex )

Iff a txn exists at the specified ledger and offset then return its txnid.

Parameters
ledgerSeqLedger to search. Not a precondition: a sequence above the validated range yields nullopt rather than an error.
txnIndexPosition of the transaction within that ledger.
Returns
The transaction ID, or nullopt when the ledger is unavailable or holds no transaction at that position.

Definition at line 2269 of file LedgerMaster.cpp.

◆ setValidLedger()

void xrpl::LedgerMaster::setValidLedger ( std::shared_ptr< Ledger const > const & l)
private

Adopts a ledger as the last validated one and tells the rest of the server, including the amendment-support checks that can block the node.

Parameters
lLedger to adopt. Its recorded sign time is the median of the trusted validations, or its own close time when there are too few.

Definition at line 279 of file LedgerMaster.cpp.

◆ setPubLedger()

void xrpl::LedgerMaster::setPubLedger ( std::shared_ptr< Ledger const > const & l)
private

Records how far publication has reached.

The first ledger recorded is a starting point and is not sent to clients.

Parameters
lLedger just published.

Definition at line 361 of file LedgerMaster.cpp.

◆ tryFill()

void xrpl::LedgerMaster::tryFill ( std::shared_ptr< Ledger const > ledger)
private

Walks back from a ledger through the SQL index, marking each ancestor resident until the chain breaks or a known ledger is reached.

Runs as a job, and clears fillInProgress_ when it finishes, unless the server is stopping.

Parameters
ledgerLedger to walk back from.

Definition at line 671 of file LedgerMaster.cpp.

◆ getFetchPack() [2/2]

void xrpl::LedgerMaster::getFetchPack ( LedgerIndex missing,
InboundLedger::Reason reason )
private

Request a fetch pack to get to the specified ledger.

Parameters
missingSequence we lack; the request is keyed on its successor.
reasonWhy the ledger is needed, for any hash walk this triggers.

Definition at line 743 of file LedgerMaster.cpp.

◆ getLedgerHashForHistory()

std::optional< LedgerHash > xrpl::LedgerMaster::getLedgerHashForHistory ( LedgerIndex index,
InboundLedger::Reason reason )
private

Finds the hash of a ledger the history back-fill wants, preferring the last back-filled ledger as the reference to walk from.

Parameters
indexLedger sequence wanted.
reasonWhy the ledger is needed, for any acquire this triggers.
Returns
The hash, or nullopt if no reference ledger yields it.

Definition at line 1239 of file LedgerMaster.cpp.

◆ getNeededValidations()

std::size_t xrpl::LedgerMaster::getNeededValidations ( )
private

Determines how many validations are needed to fully validate a ledger.

Returns
Number of validations needed

Definition at line 968 of file LedgerMaster.cpp.

◆ fetchForHistory()

void xrpl::LedgerMaster::fetchForHistory ( std::uint32_t missing,
bool & progress,
InboundLedger::Reason reason,
std::unique_lock< std::recursive_mutex > & sl )
private

Starts acquiring one missing historical ledger.

If it is not local yet, also asks a peer for a fetch pack and prefetches up to ledgerFetchSize_ ledgers from missing downward.

Parameters
missingSequence to acquire.
progressSet to true when the ledger was stored, or when no hash was found; in that case missing + 1 is dropped from the resident set. true makes the caller run another pass at once.
reasonWhy the ledger is needed, passed to the acquire.
slLock on mutex_, released for the whole call.

Definition at line 1857 of file LedgerMaster.cpp.

◆ doAdvance()

void xrpl::LedgerMaster::doAdvance ( std::unique_lock< std::recursive_mutex > & sl)
private

Try to publish ledgers, acquire missing ledgers.

Always called with mutex_ locked. The passed lock is a reminder to callers.

Publishing takes priority; history is only back-filled when the node is caught up, unloaded and idle. Loops while it makes progress or tryAdvance() posts new work.

Parameters
slLock on mutex_, released around publication and network work.

Definition at line 1958 of file LedgerMaster.cpp.

◆ findNewLedgersToPublish()

std::vector< std::shared_ptr< Ledger const > > xrpl::LedgerMaster::findNewLedgersToPublish ( std::unique_lock< std::recursive_mutex > & sl)
private

Collects the next run of validated ledgers to publish, acquiring or replaying the ones that are missing.

Parameters
slLock on mutex_, released while ledgers are fetched.
Returns
Ledgers to publish in ascending order, empty when there is nothing to do. A gap of over 100 ledgers is skipped rather than filled, and the validated ledger alone is returned.

Definition at line 1259 of file LedgerMaster.cpp.

◆ updatePaths()

void xrpl::LedgerMaster::updatePaths ( )
private

Runs one pathfinding pass per new validated ledger or new request, and exits when neither is new, even if requests are still pending.

Runs as a job, and decrements pathFindThread_ on each of its early returns, but not when a job-queue shutdown ends the loop, which leaves the count high for the rest of the process.

Definition at line 1434 of file LedgerMaster.cpp.

◆ newPFWork()

bool xrpl::LedgerMaster::newPFWork ( char const * name,
std::unique_lock< std::recursive_mutex > &  )
private

A thread needs to be dispatched to handle pathfinding work of some kind.

Always called with mutex_ locked. The passed lock is a reminder to callers.

Parameters
nameJob name, for the perf log.
Returns
true when a pathfinding job is queued or running and the server is not shutting down, so the caller may expect its request to be serviced.

Definition at line 1571 of file LedgerMaster.cpp.

◆ collectMetrics()

void xrpl::LedgerMaster::collectMetrics ( )
private

Samples both ledger ages into the gauges.

Called on the collector's thread.

Definition at line 1107 of file LedgerMaster.h.

Member Data Documentation

◆ app_

Application& xrpl::LedgerMaster::app_
private

Owning application, the route to every other subsystem.

Definition at line 879 of file LedgerMaster.h.

◆ journal_

beast::Journal xrpl::LedgerMaster::journal_
private

Log sink for this component.

Definition at line 884 of file LedgerMaster.h.

◆ mutex_

std::recursive_mutex xrpl::LedgerMaster::mutex_
mutableprivate

Guards pubLedger_, pathLedger_, lastValidLedger_, the held transactions and the job flags other than the atomic gotFetchPackThread_.

closedLedger_ and validLedger_ lock themselves for reads and are changed only under this lock. histLedger_ and fetchSeq_ belong to the advance job, which runs one at a time. Recursive because holders re-enter it: checkAccept() and tryFill() call tryAdvance() while holding it. Taken before completeLock_.

Definition at line 895 of file LedgerMaster.h.

◆ closedLedger_

LedgerHolder xrpl::LedgerMaster::closedLedger_
private

The ledger that most recently closed.

Definition at line 900 of file LedgerMaster.h.

◆ validLedger_

LedgerHolder xrpl::LedgerMaster::validLedger_
private

The highest-sequence ledger we have fully accepted.

Definition at line 905 of file LedgerMaster.h.

◆ pubLedger_

std::shared_ptr<Ledger const> xrpl::LedgerMaster::pubLedger_
private

The last ledger we have published.

Definition at line 910 of file LedgerMaster.h.

◆ pathLedger_

std::shared_ptr<Ledger const> xrpl::LedgerMaster::pathLedger_
private

The last ledger we did pathfinding against.

Definition at line 915 of file LedgerMaster.h.

◆ histLedger_

std::shared_ptr<Ledger const> xrpl::LedgerMaster::histLedger_
private

The last ledger we handled fetching history.

Definition at line 920 of file LedgerMaster.h.

◆ lastValidLedger_

std::pair<UInt256, LedgerIndex> xrpl::LedgerMaster::lastValidLedger_ {UInt256(), 0}
private

Fully validated ledger, whether or not we have the ledger resident.

Definition at line 925 of file LedgerMaster.h.

◆ ledgerHistory_

LedgerHistory xrpl::LedgerMaster::ledgerHistory_
private

Cache of ledgers by hash and of validated sequence-to-hash mappings.

Definition at line 930 of file LedgerMaster.h.

◆ heldTransactions_

CanonicalTXSet xrpl::LedgerMaster::heldTransactions_ {UInt256()}
private

Transactions deferred to the next open ledger, in canonical order.

One can leave earlier, when the account's previous transaction applies.

Definition at line 936 of file LedgerMaster.h.

◆ replayData_

std::unique_ptr<LedgerReplay> xrpl::LedgerMaster::replayData_
private

A set of transactions to replay during the next close.

Definition at line 941 of file LedgerMaster.h.

◆ completeLock_

std::recursive_mutex xrpl::LedgerMaster::completeLock_
mutableprivate

Guards completeLedgers_ only.

Usually taken alone; when both are held, mutex_ is taken first.

Definition at line 947 of file LedgerMaster.h.

◆ completeLedgers_

RangeSet<std::uint32_t> xrpl::LedgerMaster::completeLedgers_
private

Sequences of the ledgers this node believes it holds in full.

An entry is dropped when a lookup finds the ledger missing.

Definition at line 953 of file LedgerMaster.h.

◆ advanceThread_

bool xrpl::LedgerMaster::advanceThread_ {false}
private

An AdvanceLedger job is queued or running.

Definition at line 958 of file LedgerMaster.h.

◆ advanceWork_

bool xrpl::LedgerMaster::advanceWork_ {false}
private

Publish thread has work to do.

Definition at line 963 of file LedgerMaster.h.

◆ fillInProgress_

int xrpl::LedgerMaster::fillInProgress_ {0}
private

Sequence a tryFill() job is currently walking back from, or 0 when no fill is running.

Keeps back-fill from competing with itself.

Definition at line 969 of file LedgerMaster.h.

◆ pathFindThread_

int xrpl::LedgerMaster::pathFindThread_ {0}
private

Pathfinding jobs queued or running.

Never allowed above two, so pathfinding cannot starve other jobs.

Definition at line 975 of file LedgerMaster.h.

◆ pathFindNewRequest_

bool xrpl::LedgerMaster::pathFindNewRequest_ {false}
private

A pathfinding request arrived and has not been picked up yet.

Definition at line 980 of file LedgerMaster.h.

◆ gotFetchPackThread_

std::atomic_flag xrpl::LedgerMaster::gotFetchPackThread_ = ATOMIC_FLAG_INIT
private

Set while a GotFetchPack job is outstanding, so only one ever is.

Definition at line 985 of file LedgerMaster.h.

◆ pubLedgerClose_

std::atomic<std::uint32_t> xrpl::LedgerMaster::pubLedgerClose_ {0}
private

Close time of pubLedger_, in seconds since the network epoch; 0 if none.

Definition at line 990 of file LedgerMaster.h.

◆ pubLedgerSeq_

std::atomic<LedgerIndex> xrpl::LedgerMaster::pubLedgerSeq_ {0}
private

Sequence of pubLedger_; 0 if nothing has been published.

Definition at line 995 of file LedgerMaster.h.

◆ validLedgerSign_

std::atomic<std::uint32_t> xrpl::LedgerMaster::validLedgerSign_ {0}
private

Sign time of validLedger_, in seconds since the network epoch: the median of its trusted validations, or its close time when those were too few.

Definition at line 1001 of file LedgerMaster.h.

◆ validLedgerSeq_

std::atomic<LedgerIndex> xrpl::LedgerMaster::validLedgerSeq_ {0}
private

Sequence of validLedger_; 0 if nothing is validated.

Definition at line 1006 of file LedgerMaster.h.

◆ buildingLedgerSeq_

std::atomic<LedgerIndex> xrpl::LedgerMaster::buildingLedgerSeq_ {0}
private

Sequence consensus is building; 0 once it is built.

Can stay set if a round ends without building it.

Definition at line 1012 of file LedgerMaster.h.

◆ standalone_

bool const xrpl::LedgerMaster::standalone_
private

The server is in standalone mode.

Definition at line 1017 of file LedgerMaster.h.

◆ fetchDepth_

std::uint32_t const xrpl::LedgerMaster::fetchDepth_
private

How many ledgers before the closed ledger do we allow peers to request?

Definition at line 1022 of file LedgerMaster.h.

◆ ledgerHistorySize_

std::uint32_t const xrpl::LedgerMaster::ledgerHistorySize_
private

How much history do we want to keep.

Definition at line 1027 of file LedgerMaster.h.

◆ ledgerFetchSize_

std::uint32_t const xrpl::LedgerMaster::ledgerFetchSize_
private

Cap on ledgers acquired in one publication or prefetch pass.

Definition at line 1032 of file LedgerMaster.h.

◆ fetchPacks_

TaggedCache<UInt256, Blob> xrpl::LedgerMaster::fetchPacks_
private

Fetch-pack nodes keyed by node hash.

A node is removed once read; unread nodes expire about 45 seconds after arrival, sooner when over 65536 are held.

Definition at line 1039 of file LedgerMaster.h.

◆ fetchSeq_

std::uint32_t xrpl::LedgerMaster::fetchSeq_ {0}
private

Sequence of the last fetch-pack attempt, so the same one is not tried twice in a row.

Definition at line 1045 of file LedgerMaster.h.

◆ maxLedgerDifference_

LedgerIndex const xrpl::LedgerMaster::maxLedgerDifference_ {1000000}
private

Try to keep a validator from switching from test to live network without first wiping the database.

Definition at line 1051 of file LedgerMaster.h.

◆ upgradeWarningPrevTime_

TimeKeeper::time_point xrpl::LedgerMaster::upgradeWarningPrevTime_
private

Time that the previous upgrade warning was issued.

Definition at line 1056 of file LedgerMaster.h.

◆ stats_

Stats xrpl::LedgerMaster::stats_
private

The gauges and the collector hook that samples them.

Definition at line 1099 of file LedgerMaster.h.