rippled
Loading...
Searching...
No Matches
LedgerHistory.h
1#ifndef XRPL_APP_LEDGER_LEDGERHISTORY_H_INCLUDED
2#define XRPL_APP_LEDGER_LEDGERHISTORY_H_INCLUDED
3
4#include <xrpld/app/ledger/Ledger.h>
5#include <xrpld/app/main/Application.h>
6
7#include <xrpl/beast/insight/Collector.h>
8#include <xrpl/protocol/RippleLedgerHash.h>
9
10#include <optional>
11
12namespace ripple {
13
14// VFALCO TODO Rename to OldLedgers ?
15
18{
19public:
21 beast::insight::Collector::ptr const& collector,
22 Application& app);
23
27 bool
28 insert(std::shared_ptr<Ledger const> const& ledger, bool validated);
29
33 float
38
41 getLedgerBySeq(LedgerIndex ledgerIndex);
42
45 getLedgerByHash(LedgerHash const& ledgerHash);
46
52 getLedgerHash(LedgerIndex ledgerIndex);
53
56 void
62
64 void
67 uint256 const& consensusHash,
69
71 void
74 std::optional<uint256> const& consensusHash);
75
81 bool
82 fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
83
84 void
86
87private:
98 void
100 LedgerHash const& built,
101 LedgerHash const& valid,
102 std::optional<uint256> const& builtConsensusHash,
103 std::optional<uint256> const& validatedConsensusHash,
104 Json::Value const& consensus);
105
109
111
113
114 // Maps ledger indexes to the corresponding hashes
115 // For debug and logging purposes
116 struct cv_entry
117 {
118 // Hash of locally built ledger
120 // Hash of the validated ledger
122 // Hash of locally accepted consensus transaction set
124 // Hash of validated consensus transaction set
126 // Consensus metadata of built ledger
128 };
131
132 // Maps ledger indexes to the corresponding hash.
134
136};
137
138} // namespace ripple
139
140#endif
Represents a JSON value.
Definition json_value.h:130
A generic endpoint for log messages.
Definition Journal.h:41
A metric for measuring an integral value.
Definition Counter.h:20
Retains historical ledgers.
std::map< LedgerIndex, LedgerHash > mLedgersByIndex
float getCacheHitRate()
Get the ledgers_by_hash cache hit rate.
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.
LedgersByHash m_ledgers_by_hash
ConsensusValidated m_consensus_validated
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.
LedgerHash getLedgerHash(LedgerIndex ledgerIndex)
Get a ledger's hash given its sequence number.
void clearLedgerCachePrior(LedgerIndex seq)
beast::insight::Collector::ptr collector_
std::shared_ptr< Ledger const > getLedgerBySeq(LedgerIndex ledgerIndex)
Get a ledger given its sequence number.
beast::insight::Counter mismatch_counter_
bool insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
Repair a hash to index mapping.
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
std::shared_ptr< Ledger const > getLedgerByHash(LedgerHash const &ledgerHash)
Retrieve a ledger given its hash.
Map/cache combination.
Definition TaggedCache.h:43
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:6
std::optional< LedgerHash > built
std::optional< uint256 > validatedConsensusHash
std::optional< Json::Value > consensus
std::optional< uint256 > builtConsensusHash
std::optional< LedgerHash > validated