3#include <xrpld/app/ledger/AbstractFetchPackContainer.h>
4#include <xrpld/app/ledger/InboundLedgers.h>
5#include <xrpld/app/ledger/LedgerHistory.h>
6#include <xrpld/app/ledger/LedgerHolder.h>
7#include <xrpld/app/ledger/LedgerReplay.h>
8#include <xrpld/app/main/Application.h>
9#include <xrpld/core/TimeKeeper.h>
11#include <xrpl/basics/RangeSet.h>
12#include <xrpl/basics/UptimeClock.h>
13#include <xrpl/basics/chrono.h>
14#include <xrpl/beast/insight/Collector.h>
15#include <xrpl/ledger/CanonicalTXSet.h>
16#include <xrpl/ledger/Ledger.h>
17#include <xrpl/protocol/Protocol.h>
18#include <xrpl/protocol/RippleLedgerHash.h>
19#include <xrpl/protocol/messages.h>
371 template <
class Handler>
373 :
hook(collector->makeHook(handler))
NetClock::time_point time_point
Provide a light-weight way to check active() before string formatting.
A generic endpoint for log messages.
std::shared_ptr< Collector > ptr
A metric for measuring an integral value.
A reference to a handler for performing polled collection.
An interface facilitating retrieval of fetch packs without an application or ledgermaster object.
Holds transactions which were deferred to the next pass of consensus.
Retains historical ledgers.
Hold a ledger in a thread-safe way.
std::optional< LedgerIndex > minSqlSeq()
LedgerIndex const maxLedgerDifference_
std::atomic_flag gotFetchPackThread_
bool haveLedger(std::uint32_t seq)
std::size_t getNeededValidations()
Determines how many validations are needed to fully validate a ledger.
bool isCompatible(ReadView const &, beast::Journal::Stream, char const *reason)
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
Get the next transaction held for a particular account if any.
void setValidLedger(std::shared_ptr< Ledger const > const &l)
void switchLCL(std::shared_ptr< Ledger const > const &lastClosed)
std::recursive_mutex & peekMutex()
std::chrono::seconds getValidatedLedgerAge()
TimeKeeper::time_point upgradeWarningPrevTime_
std::uint32_t const ledgerFetchSize_
std::atomic< std::uint32_t > pubLedgerClose_
LedgerIndex getCurrentLedgerIndex()
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
bool getValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
void applyHeldTransactions()
Apply held transactions to the open ledger This is normally called as we close the ledger.
bool storeLedger(std::shared_ptr< Ledger const > ledger)
void gotFetchPack(bool progress, std::uint32_t seq)
void tryFill(std::shared_ptr< Ledger const > ledger)
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
bool haveValidated()
Whether we have ever fully validated a ledger.
void setPubLedger(std::shared_ptr< Ledger const > const &l)
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)
std::atomic< LedgerIndex > pubLedgerSeq_
void clearPriorLedgers(LedgerIndex seq)
void setBuildingLedger(LedgerIndex index)
bool isCaughtUp(std::string &reason)
std::size_t getFetchPackCacheSize() const
std::optional< Blob > getFetchPack(uint256 const &hash) override
std::vector< std::shared_ptr< Ledger const > > findNewLedgersToPublish(std::unique_lock< std::recursive_mutex > &)
std::atomic< LedgerIndex > buildingLedgerSeq_
std::optional< NetClock::time_point > getCloseTimeByHash(LedgerHash const &ledgerHash, LedgerIndex ledgerIndex)
~LedgerMaster() override=default
void clearLedger(std::uint32_t seq)
void clearLedgerCachePrior(LedgerIndex seq)
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
std::unique_ptr< LedgerReplay > replayData_
void consensusBuilt(std::shared_ptr< Ledger const > const &ledger, uint256 const &consensusHash, json::Value consensus)
Report that the consensus process built a particular ledger.
std::atomic< LedgerIndex > validLedgerSeq_
std::shared_ptr< Ledger const > getClosedLedger()
void setLedgerRangePresent(std::uint32_t minV, std::uint32_t maxV)
std::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
std::string getCompleteLedgers()
std::shared_ptr< Ledger const > getValidatedLedger()
void fetchForHistory(std::uint32_t missing, bool &progress, InboundLedger::Reason reason, std::unique_lock< std::recursive_mutex > &)
bool isValidated(ReadView const &ledger)
void fixMismatch(ReadView const &ledger)
void makeFetchPack(std::weak_ptr< Peer > const &wPeer, std::shared_ptr< protocol::TMGetObjectByHash > const &request, uint256 haveLedgerHash, UptimeClock::time_point uptime)
LedgerIndex getValidLedgerIndex()
LedgerHolder validLedger_
CanonicalTXSet heldTransactions_
std::shared_ptr< Ledger const > pathLedger_
std::shared_ptr< Ledger const > pubLedger_
std::shared_ptr< ReadView const > getPublishedLedger()
std::uint32_t const fetchDepth_
std::recursive_mutex mutex_
std::pair< uint256, LedgerIndex > lastValidLedger_
Rules getValidatedRules()
LedgerHistory ledgerHistory_
std::optional< LedgerHash > walkHashBySeq(std::uint32_t index, InboundLedger::Reason reason)
Walk to a ledger's hash using the skip list.
LedgerMaster(Application &app, Stopwatch &stopwatch, beast::insight::Collector::ptr const &collector, beast::Journal journal)
std::chrono::seconds getPublishedLedgerAge()
std::optional< uint256 > txnIdFromIndex(uint32_t ledgerSeq, uint32_t txnIndex)
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 ledg...
LedgerHolder closedLedger_
void addFetchPack(uint256 const &hash, std::shared_ptr< Blob > data)
bool getFullValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
std::optional< LedgerHash > getLedgerHashForHistory(LedgerIndex index, InboundLedger::Reason reason)
RangeSet< std::uint32_t > completeLedgers_
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
std::uint32_t const ledgerHistorySize_
std::atomic< std::uint32_t > validLedgerSign_
void doAdvance(std::unique_lock< std::recursive_mutex > &)
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
std::shared_ptr< ReadView const > getCurrentLedger()
std::recursive_mutex completeLock_
void takeReplay(std::unique_ptr< LedgerReplay > replay)
std::unique_ptr< LedgerReplay > releaseReplay()
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
std::uint32_t getEarliestFetch()
std::shared_ptr< Ledger const > histLedger_
TaggedCache< uint256, Blob > fetchPacks_
void failedSave(std::uint32_t seq, uint256 const &hash)
Represents a peer connection in the overlay.
Rules controlling protocol behavior.
std::chrono::time_point< UptimeClock > time_point
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::AbstractClock< std::chrono::steady_clock > Stopwatch
A clock for measuring elapsed time.
bool isCurrent(ValidationParms const &p, NetClock::time_point now, NetClock::time_point signTime, NetClock::time_point seenTime)
Whether a validation is still current.
std::uint32_t LedgerIndex
A ledger index.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)
beast::insight::Hook hook
beast::insight::Gauge publishedLedgerAge
beast::insight::Gauge validatedLedgerAge