Files
rippled/include/xrpl/server/State.h
2026-04-01 15:46:14 +00:00

72 lines
2.0 KiB
C++

#pragma once
#include <xrpl/protocol/Protocol.h>
#include <xrpl/rdb/DatabaseCon.h>
#include <xrpl/server/Manifest.h>
#include <boost/filesystem.hpp>
namespace xrpl {
struct SavedState
{
std::string writableDb;
std::string archiveDb;
LedgerIndex lastRotated{};
};
/**
* @brief initStateDB Opens a session with the State database.
* @param session Provides a session with the database.
* @param config Path to the database and other opening parameters.
* @param dbName Name of the database.
*/
void
initStateDB(soci::session& session, BasicConfig const& config, std::string const& dbName);
/**
* @brief getCanDelete Returns the ledger sequence which can be deleted.
* @param session Session with the database.
* @return Ledger sequence.
*/
LedgerIndex
getCanDelete(soci::session& session);
/**
* @brief setCanDelete Updates the ledger sequence which can be deleted.
* @param session Session with the database.
* @param canDelete Ledger sequence to save.
* @return Previous value of the ledger sequence which can be deleted.
*/
LedgerIndex
setCanDelete(soci::session& session, LedgerIndex canDelete);
/**
* @brief getSavedState Returns the saved state.
* @param session Session with the database.
* @return The SavedState structure which contains the names of the writable
* database, the archive database and the last rotated ledger sequence.
*/
SavedState
getSavedState(soci::session& session);
/**
* @brief setSavedState Saves the given state.
* @param session Session with the database.
* @param state The SavedState structure which contains the names of the
* writable database, the archive database and the last rotated ledger
* sequence.
*/
void
setSavedState(soci::session& session, SavedState const& state);
/**
* @brief setLastRotated Updates the last rotated ledger sequence.
* @param session Session with the database.
* @param seq New value of the last rotated ledger sequence.
*/
void
setLastRotated(soci::session& session, LedgerIndex seq);
} // namespace xrpl