20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/main/Application.h>
22 #include <ripple/app/main/Tuning.h>
23 #include <ripple/nodestore/DatabaseShard.h>
24 #include <ripple/shamap/ShardFamily.h>
29 static NodeStore::Database&
41 , j_(app.journal(
"ShardFamily"))
56 auto fbCache{std::make_shared<FullBelowCache>(
57 "Shard family full below cache shard " +
std::to_string(shardIndex),
63 return fbCache_.emplace(shardIndex, std::move(fbCache)).first->second;
72 sz += e.second->size();
85 auto tnCache{std::make_shared<TreeNodeCache>(
86 "Shard family tree node cache shard " +
std::to_string(shardIndex),
91 return tnCache_.emplace(shardIndex, std::move(tnCache)).first->second;
102 cacheSz += e.second->getCacheSize();
103 trackSz += e.second->getTrackSize();
105 return {cacheSz, trackSz};
118 if (it->second->size() == 0)
131 if (it->second->getTrackSize() == 0)
158 std::ignore = nodeHash;
159 JLOG(
j_.
error()) <<
"Missing node in ledger sequence " << seq;
std::shared_ptr< TreeNodeCache > getTreeNodeCache(std::uint32_t ledgerSeq) override
Return a pointer to the Family Tree Node Cache.
Provides the beast::insight::Collector service.
virtual NodeStore::DatabaseShard * getShardStore()=0
Stopwatch & stopwatch()
Returns an instance of a wall clock.
constexpr std::chrono::seconds fullBelowExpiration
std::unordered_map< std::uint32_t, std::shared_ptr< FullBelowCache > > fbCache_
virtual InboundLedgers & getInboundLedgers()=0
void acquire(uint256 const &hash, std::uint32_t seq)
std::shared_ptr< FullBelowCache > getFullBelowCache(std::uint32_t ledgerSeq) override
Return a pointer to the Family Full Below Cache.
virtual LedgerMaster & getLedgerMaster()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
std::unordered_map< std::uint32_t, std::shared_ptr< TreeNodeCache > > tnCache_
int getFullBelowCacheSize()
Return the number of entries in the cache.
constexpr std::size_t fullBelowTargetSize
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::pair< int, int > getTreeNodeCacheSize()
Return a pair where the first item is the number of items cached and the second item is the number of...
const std::chrono::seconds tnTargetAge_
std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept
Calculates the shard index for a given ledger sequence.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
virtual beast::insight::Collector::ptr const & collector()=0
void missingNodeAcquireBySeq(std::uint32_t seq, uint256 const &nodeHash) override
Acquire ledger that has a missing node by ledger sequence.
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
static NodeStore::Database & getShardStore(Application &app)