20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/nodestore/impl/DatabaseRotatingImp.h>
22 #include <ripple/protocol/HashPrefix.h>
48 , writableBackend_(
std::move(writableBackend))
49 , archiveBackend_(
std::move(archiveBackend))
88 auto const backend = [&] {
99 auto const backend = [&] {
116 pCache_->canonicalize_replace_cache(hash, nObj);
118 auto const backend = [&] {
122 backend->store(nObj);
163 auto [writable, archive] = [&] {
183 writable->store(nObj);
194 auto [writable, archive] = [&] {
200 writable->for_each(f);
203 archive->for_each(f);
Holds a collection of configuration values.
void rotateWithLock(std::function< std::unique_ptr< NodeStore::Backend >(std::string const &writableBackendName)> const &f) override
Rotates the backends.
std::shared_ptr< Backend > archiveBackend_
Persistency layer for NodeObject.
bool erase(key_type const &key)
Remove the specified cache entry.
void sweep() override
Remove expired entries from the positive and negative caches.
void tune(int size, std::chrono::seconds age) override
Set the maximum number of entries and maximum cache age for both caches.
NodeObjectType
The types of node objects.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
DatabaseRotatingImp()=delete
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t seq) override
Store the object.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
std::string getName() const override
Retrieve the name associated with this backend.
void setParent(Stoppable &parent)
Set the parent of this Stoppable.
bool touch_if_exists(KeyComparable const &key)
Refresh the last access time on a key if present.
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
Provides an interface for starting and stopping.
void importInternal(Backend &dstBackend, Database &srcDB)
bool asyncFetch(uint256 const &hash, std::uint32_t seq, std::shared_ptr< NodeObject > &object) override
Fetch an object without waiting.
constexpr std::chrono::seconds cacheTargetAge
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Copies a ledger stored in a different database to this one.
void storeStats(size_t sz)
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
void sweep()
Remove stale entries from the cache.
void import(Database &source) override
Import objects from another database.
std::shared_ptr< NodeObject > fetchInternal(uint256 const &hash, std::shared_ptr< Backend > backend)
std::shared_ptr< NodeObject > fetchFrom(uint256 const &hash, std::uint32_t seq) override
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
Copies a ledger stored in a different database to this one.
void setTargetSize(size_type s)
virtual bool asyncFetch(uint256 const &hash, std::uint32_t seq, std::shared_ptr< NodeObject > &object)=0
Fetch an object without waiting.
void setTargetAge(std::chrono::seconds s)
A simple object that the Ledger uses to store entries.
Maintains a cache of keys with no associated data.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
std::shared_ptr< Backend > writableBackend_
std::shared_ptr< KeyCache< uint256 > > nCache_
std::shared_ptr< TaggedCache< uint256, NodeObject > > pCache_