rippled
Loading...
Searching...
No Matches
LedgerHistory.h
1#pragma once
2
3#include <xrpld/app/main/Application.h>
4
5#include <xrpl/beast/insight/Collector.h>
6#include <xrpl/ledger/Ledger.h>
7#include <xrpl/protocol/RippleLedgerHash.h>
8
9#include <optional>
10
11namespace xrpl {
12
13// VFALCO TODO Rename to OldLedgers ?
14
17{
18public:
20
24 bool
25 insert(std::shared_ptr<Ledger const> const& ledger, bool validated);
26
30 float
35
38 getLedgerBySeq(LedgerIndex ledgerIndex);
39
42 getLedgerByHash(LedgerHash const& ledgerHash);
43
49 getLedgerHash(LedgerIndex ledgerIndex);
50
53 void
59
61 void
62 builtLedger(std::shared_ptr<Ledger const> const&, uint256 const& consensusHash, Json::Value);
63
65 void
68 std::optional<uint256> const& consensusHash);
69
75 bool
76 fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
77
78 void
80
81private:
92 void
94 LedgerHash const& built,
95 LedgerHash const& valid,
96 std::optional<uint256> const& builtConsensusHash,
97 std::optional<uint256> const& validatedConsensusHash,
98 Json::Value const& consensus);
99
103
105
107
108 // Maps ledger indexes to the corresponding hashes
109 // For debug and logging purposes
110 struct cv_entry
111 {
112 // Hash of locally built ledger
114 // Hash of the validated ledger
116 // Hash of locally accepted consensus transaction set
118 // Hash of validated consensus transaction set
120 // Consensus metadata of built ledger
122 };
125
126 // Maps ledger indexes to the corresponding hash.
128
130};
131
132} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
A generic endpoint for log messages.
Definition Journal.h:40
A metric for measuring an integral value.
Definition Counter.h:19
Retains historical ledgers.
std::map< LedgerIndex, LedgerHash > mLedgersByIndex
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
beast::insight::Collector::ptr collector_
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 insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
float getCacheHitRate()
Get the ledgers_by_hash cache hit rate.
LedgerHash getLedgerHash(LedgerIndex ledgerIndex)
Get a ledger's hash given its sequence number.
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.
ConsensusValidated m_consensus_validated
void sweep()
Remove stale cache entries.
LedgersByHash m_ledgers_by_hash
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
beast::insight::Counter mismatch_counter_
std::shared_ptr< Ledger const > getLedgerBySeq(LedgerIndex ledgerIndex)
Get a ledger given its sequence number.
beast::Journal j_
void clearLedgerCachePrior(LedgerIndex seq)
Map/cache combination.
Definition TaggedCache.h:42
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.
Definition algorithm.h:5
std::optional< Json::Value > consensus
std::optional< LedgerHash > validated
std::optional< uint256 > validatedConsensusHash
std::optional< uint256 > builtConsensusHash
std::optional< LedgerHash > built