20#include <xrpld/nodestore/detail/DatabaseNodeImp.h>
21#include <xrpl/protocol/HashPrefix.h>
58 callback(obj->getType() ==
hotDUMMY ?
nullptr : obj);
84 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash <<
": record not "
85 << (
cache_ ?
"cached" :
"found");
96 <<
"fetchNodeObject " << hash
97 <<
": Exception fetching from backend: " << e.
what();
107 cache_->canonicalize_replace_client(hash, nodeObject);
121 JLOG(
j_.
fatal()) <<
"fetchNodeObject " << hash
122 <<
": nodestore data is corrupted";
126 <<
"fetchNodeObject " << hash
127 <<
": backend returns unknown result " << status;
133 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash
134 <<
": record found in cache";
135 if (nodeObject->getType() ==
hotDUMMY)
150 auto const before = steady_clock::now();
155 for (
size_t i = 0; i < hashes.
size(); ++i)
157 auto const&
hash = hashes[i];
169 results[i] = nObj->getType() ==
hotDUMMY ? nullptr : nObj;
175 JLOG(
j_.
debug()) <<
"fetchBatch - cache hits = "
176 << (hashes.
size() - cacheMisses.
size())
177 <<
" - cache misses = " << cacheMisses.
size();
178 auto dbResults =
backend_->fetchBatch(cacheMisses).first;
180 for (
size_t i = 0; i < dbResults.size(); ++i)
182 auto nObj = std::move(dbResults[i]);
183 size_t index = indexMap[cacheMisses[i]];
184 auto const&
hash = hashes[index];
190 cache_->canonicalize_replace_client(
hash, nObj);
196 <<
"record not found in db or cache. hash = " <<
strHex(
hash);
205 results[index] = std::move(nObj);
208 auto fetchDurationUs =
209 std::chrono::duration_cast<std::chrono::microseconds>(
210 steady_clock::now() - before)
Stream trace() const
Severity stream access functions.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
std::shared_ptr< Backend > backend_
std::shared_ptr< TaggedCache< uint256, NodeObject > > cache_
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::vector< uint256 > const &hashes)
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override
Fetch an object without waiting.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
void sweep() override
Remove expired entries from the positive and negative caches.
void storeStats(std::uint64_t count, std::uint64_t sz)
virtual void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback)
Fetch an object without waiting.
void updateFetchMetrics(uint64_t fetches, uint64_t hits, uint64_t duration)
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
NodeObjectType
The types of node objects.
std::string strHex(FwdIt begin, FwdIt end)
void Rethrow()
Rethrow the exception currently being handled.
Contains information about a fetch operation.