rippled
Loading...
Searching...
No Matches
LedgerHistory.h
1#pragma once
2
3#include <xrpld/app/ledger/Ledger.h>
4#include <xrpld/app/main/Application.h>
5
6#include <xrpl/beast/insight/Collector.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
67
73 bool
74 fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
75
76 void
78
79private:
90 void
92 LedgerHash const& built,
93 LedgerHash const& valid,
94 std::optional<uint256> const& builtConsensusHash,
95 std::optional<uint256> const& validatedConsensusHash,
96 Json::Value const& consensus);
97
101
103
105
106 // Maps ledger indexes to the corresponding hashes
107 // For debug and logging purposes
108 struct cv_entry
109 {
110 // Hash of locally built ledger
112 // Hash of the validated ledger
114 // Hash of locally accepted consensus transaction set
116 // Hash of validated consensus transaction set
118 // Consensus metadata of built ledger
120 };
123
124 // Maps ledger indexes to the corresponding hash.
126
128};
129
130} // 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.
Application & app_
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