3#include <xrpld/app/ledger/LedgerMaster.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/app/misc/SHAMapStore.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/config/BasicConfig.h>
9#include <xrpl/ledger/Ledger.h>
10#include <xrpl/nodestore/Backend.h>
11#include <xrpl/nodestore/Database.h>
12#include <xrpl/nodestore/DatabaseRotating.h>
13#include <xrpl/nodestore/Scheduler.h>
14#include <xrpl/protocol/Protocol.h>
15#include <xrpl/rdb/DatabaseCon.h>
16#include <xrpl/server/State.h>
17#include <xrpl/shamap/FullBelowCache.h>
18#include <xrpl/shamap/SHAMapTreeNode.h>
19#include <xrpl/shamap/TreeNodeCache.h>
152 return stateDb_.getState().lastRotated;
186 template <
class CacheInstance>
192 for (
auto const& key : cache.getKeys())
A generic endpoint for log messages.
Holds unparsed configuration information.
Provides server functionality for clients.
beast::Journal const journal
void setState(SavedState const &state)
void init(BasicConfig const &config, std::string const &dbName)
LedgerIndex setCanDelete(LedgerIndex canDelete)
void setLastRotated(LedgerIndex seq)
LedgerIndex getCanDelete()
LedgerIndex getLastRotated() override
Maximum ledger that has been deleted, or will be deleted if currently in the act of online deletion.
bool copyNode(std::uint64_t &nodeCount, SHAMapTreeNode const &node)
std::uint32_t clampFetchDepth(std::uint32_t fetchDepth) const override
std::atomic< bool > working_
std::condition_variable cond_
std::uint32_t deleteBatch_
LedgerIndex setCanDelete(LedgerIndex seq) override
Highest ledger that may be deleted.
std::atomic< LedgerIndex > minimumOnline_
std::chrono::seconds recoveryWaitTime_
If the node is out of sync during an online_delete healthWait() call, sleep the thread for this time,...
FullBelowCache * fullBelowCache_
std::optional< LedgerIndex > minimumOnline() const override
The minimum ledger to try and maintain in our database.
bool advisoryDelete() const override
Whether advisory delete is enabled.
TreeNodeCache * treeNodeCache_
std::uint32_t deleteInterval_
std::unique_ptr< node_store::Database > makeNodeStore(int readThreads) override
static std::uint32_t const kMinimumDeletionIntervalSa
int fdRequired() const override
Returns the number of file descriptors that are needed.
std::chrono::milliseconds backOff_
std::atomic< LedgerIndex > canDelete_
std::shared_ptr< Ledger const > newLedger_
std::string const dbName_
void clearSql(LedgerIndex lastRotated, std::string const &tableName, std::function< std::optional< LedgerIndex >()> const &getMinSeq, std::function< void(LedgerIndex)> const &deleteBeforeSeq)
delete from sqlite table in batches to not lock the db excessively.
std::condition_variable rendezvous_
std::uint64_t const checkHealthInterval_
HealthResult healthWait()
void clearCaches(LedgerIndex validatedSeq)
std::chrono::seconds ageThreshold_
void rendezvous() const override
LedgerMaster * ledgerMaster_
beast::Journal const journal_
LedgerIndex getCanDelete() override
Highest ledger that may be deleted.
static constexpr auto kNodeStoreName
std::string const dbPrefix_
node_store::Scheduler & scheduler_
HealthResult
This is a health check for online deletion that waits until xrpld is stable before returning.
void onLedgerClosed(std::shared_ptr< Ledger const > const &ledger) override
Called by LedgerMaster every time a ledger validates.
node_store::DatabaseRotating * dbRotating_
std::unique_ptr< node_store::Backend > makeBackendRotating(std::string path=std::string())
static std::uint32_t const kMinimumDeletionInterval
SHAMapStoreImp(Application &app, node_store::Scheduler &scheduler, beast::Journal journal)
bool freshenCache(CacheInstance &cache)
void clearPrior(LedgerIndex lastRotated)
class to create database, launch online delete thread, and related SQLite database
Scheduling for asynchronous backend activity.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::uint32_t LedgerIndex
A ledger index.
detail::BasicFullBelowCache FullBelowCache
TaggedCache< uint256, SHAMapTreeNode, false, intr_ptr::SharedWeakUnionPtr< SHAMapTreeNode >, SHAMapTreeNodePtr > TreeNodeCache