20 #ifndef RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED
23 #include <ripple/basics/TaggedCache.h>
24 #include <ripple/basics/chrono.h>
25 #include <ripple/nodestore/Database.h>
44 :
Database(scheduler, readThreads, config, j)
49 if (config.
exists(
"cache_size"))
51 cacheSize = get<int>(config,
"cache_size");
52 if (cacheSize.
value() < 0)
54 Throw<std::runtime_error>(
55 "Specified negative value for cache_size");
59 if (config.
exists(
"cache_age"))
61 cacheAge = get<int>(config,
"cache_age");
62 if (cacheAge.
value() < 0)
64 Throw<std::runtime_error>(
65 "Specified negative value for cache_age");
69 if (cacheSize != 0 || cacheAge != 0)
71 cache_ = std::make_shared<TaggedCache<uint256, NodeObject>>(
152 bool duplicate)
override;
Holds a collection of configuration values.
std::shared_ptr< Backend > backend_
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
void importDatabase(Database &source) override
Import objects from another database.
Persistency layer for NodeObject.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
NodeObjectType
The types of node objects.
bool exists(std::string const &name) const
Returns true if a key with the given name exists.
Contains information about a fetch operation.
std::optional< Backend::Counters< std::uint64_t > > getCounters() const override
Retrieve backend read and write stats.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void importInternal(Backend &dstBackend, Database &srcDB)
std::shared_ptr< TaggedCache< uint256, NodeObject > > cache_
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
DatabaseNodeImp & operator=(DatabaseNodeImp const &)=delete
bool isSameDB(std::uint32_t, std::uint32_t) override
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger)=0
Store a ledger from a different database.
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Store a ledger from a different database.
void sweep() override
Remove expired entries from the positive and negative caches.
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::vector< uint256 > const &hashes)
DatabaseNodeImp(Scheduler &scheduler, int readThreads, std::shared_ptr< Backend > backend, Section const &config, beast::Journal j)
std::string getName() const override
Retrieve the name associated with this backend.
void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override
Fetch an object without waiting.