mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add comments to LedgerHistory
This commit is contained in:
@@ -86,6 +86,7 @@ Ledger::pointer LedgerHistory::getLedgerBySeq (std::uint32_t index)
|
||||
assert (ret->getLedgerSeq () == index);
|
||||
|
||||
{
|
||||
// Add this ledger to the local tracking by index
|
||||
LedgersByHash::ScopedLockType sl (m_ledgers_by_hash.peekMutex ());
|
||||
|
||||
assert (ret->isImmutable ());
|
||||
@@ -127,7 +128,7 @@ void LedgerHistory::builtLedger (Ledger::ref ledger)
|
||||
ConsensusValidated::ScopedLockType sl (
|
||||
m_consensus_validated.peekMutex());
|
||||
|
||||
boost::shared_ptr< std::pair< LedgerHash, LedgerHash > > entry = boost::make_shared<std::pair< LedgerHash, LedgerHash >>();
|
||||
auto entry = boost::make_shared<std::pair< LedgerHash, LedgerHash >>();
|
||||
m_consensus_validated.canonicalize(index, entry, false);
|
||||
|
||||
if (entry->first != hash)
|
||||
|
||||
@@ -23,35 +23,70 @@
|
||||
namespace ripple {
|
||||
|
||||
// VFALCO TODO Rename to OldLedgers ?
|
||||
|
||||
/** Retains historical ledgers. */
|
||||
class LedgerHistory : beast::LeakChecked <LedgerHistory>
|
||||
{
|
||||
public:
|
||||
LedgerHistory ();
|
||||
|
||||
/** Track a ledger
|
||||
@return `true` if the ledger was already tracked
|
||||
*/
|
||||
bool addLedger (Ledger::pointer ledger, bool validated);
|
||||
|
||||
/** Get the ledgers_by_hash cache hit rate
|
||||
@return the hit rate
|
||||
*/
|
||||
float getCacheHitRate ()
|
||||
{
|
||||
return m_ledgers_by_hash.getHitRate ();
|
||||
}
|
||||
|
||||
/** Get a ledger given its squence number
|
||||
@param ledgerIndex The sequence number of the desired ledger
|
||||
*/
|
||||
Ledger::pointer getLedgerBySeq (LedgerIndex ledgerIndex);
|
||||
|
||||
/** Get a ledger's hash given its sequence number
|
||||
@param ledgerIndex The sequence number of the desired ledger
|
||||
@return The hash of the specified ledger
|
||||
*/
|
||||
LedgerHash getLedgerHash (LedgerIndex ledgerIndex);
|
||||
|
||||
/** Retrieve a ledger given its hash
|
||||
@param ledgerHash The hash of the requested ledger
|
||||
@return The ledger requested
|
||||
*/
|
||||
Ledger::pointer getLedgerByHash (LedgerHash const& ledgerHash);
|
||||
|
||||
/** Set the history cache's paramters
|
||||
@param size The target size of the cache
|
||||
@param age The target age of the cache, in seconds
|
||||
*/
|
||||
void tune (int size, int age);
|
||||
|
||||
/** Remove stale cache entries
|
||||
*/
|
||||
void sweep ()
|
||||
{
|
||||
m_ledgers_by_hash.sweep ();
|
||||
m_consensus_validated.sweep ();
|
||||
}
|
||||
|
||||
/** Report that we have locally built a particular ledger
|
||||
*/
|
||||
void builtLedger (Ledger::ref);
|
||||
|
||||
/** Report that we have validated a particular ledger
|
||||
*/
|
||||
void validatedLedger (Ledger::ref);
|
||||
|
||||
/** Repair a hash to index mapping
|
||||
@param ledgerIndex The index whose mapping is to be repaired
|
||||
@param ledgerHash The hash it is to be mapped to
|
||||
@return `true` if the mapping was repaired
|
||||
*/
|
||||
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash);
|
||||
|
||||
private:
|
||||
@@ -59,7 +94,10 @@ private:
|
||||
|
||||
LedgersByHash m_ledgers_by_hash;
|
||||
|
||||
//typedef std::pair <LedgerHash, LedgerHash>
|
||||
// Maps ledger indexes to the corresponding hashes
|
||||
// For debug and logging purposes
|
||||
// 1) The hash of a ledger with that index we build
|
||||
// 2) The hash of a ledger with that index we validated
|
||||
typedef TaggedCache <LedgerIndex,
|
||||
std::pair< LedgerHash, LedgerHash >> ConsensusValidated;
|
||||
ConsensusValidated m_consensus_validated;
|
||||
|
||||
Reference in New Issue
Block a user