3#include <xrpld/app/main/Application.h>
5#include <xrpl/basics/Mutex.hpp>
6#include <xrpl/basics/TaggedCache.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/beast/insight/Collector.h>
9#include <xrpl/beast/insight/Counter.h>
10#include <xrpl/beast/utility/Journal.h>
11#include <xrpl/json/json_value.h>
12#include <xrpl/ledger/Ledger.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/RippleLedgerHash.h>
47 return lockedMaps->byHash->getHitRate();
76 auto*
const byHash = [
this] {
78 return lockedMaps->byHash.get();
A generic endpoint for log messages.
std::shared_ptr< Collector > Ptr
A metric for measuring an integral value.
xrpl::Mutex< LedgerMaps > ledgerMaps_
ConsensusValidated consensusValidated_
beast::insight::Collector::Ptr collector_
bool insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
float getCacheHitRate()
Get the byHash cache hit rate.
LedgerHash getLedgerHash(LedgerIndex ledgerIndex)
Get a ledger's hash given its sequence number.
void handleMismatch(LedgerHash const &built, LedgerHash const &valid, std::optional< UInt256 > const &builtConsensusHash, std::optional< UInt256 > const &validatedConsensusHash, json::Value const &consensus)
Log details in the case where we build one ledger but validate a different one.
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
Repair a hash to index mapping.
std::shared_ptr< Ledger const > getLedgerByHash(LedgerHash const &ledgerHash)
Retrieve a ledger given its hash.
void builtLedger(std::shared_ptr< Ledger const > const &, UInt256 const &consensusHash, json::Value)
Report that we have locally built a particular ledger.
void sweep()
Remove stale cache entries.
LedgerHistory(beast::insight::Collector::Ptr const &collector, Application &app)
beast::insight::Counter mismatchCounter_
std::shared_ptr< Ledger const > getLedgerBySeq(LedgerIndex ledgerIndex)
Get a ledger given its sequence number.
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< UInt256 > const &consensusHash)
Report that we have validated a particular ledger.
void clearLedgerCachePrior(LedgerIndex seq)
TaggedCache< LedgerIndex, CvEntry > ConsensusValidated
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::uint32_t LedgerIndex
A ledger index.
std::optional< LedgerHash > validated
std::optional< LedgerHash > built
std::optional< UInt256 > validatedConsensusHash
std::optional< json::Value > consensus
std::optional< UInt256 > builtConsensusHash
std::map< LedgerIndex, LedgerHash > byIndex
TaggedCache< LedgerHash, Ledger const > LedgersByHash
std::unique_ptr< LedgersByHash > byHash