1#include <xrpl/server/State.h>
3#include <xrpl/basics/contract.h>
4#include <xrpl/config/BasicConfig.h>
5#include <xrpl/protocol/Protocol.h>
6#include <xrpl/rdb/SociDB.h>
8#include <boost/optional/optional.hpp>
11#include <soci/session.h>
23 open(session, config, dbName);
25 session <<
"PRAGMA synchronous=FULL;";
27 session <<
"CREATE TABLE IF NOT EXISTS DbState ("
28 " Key INTEGER PRIMARY KEY,"
31 " LastRotatedLedger INTEGER"
34 session <<
"CREATE TABLE IF NOT EXISTS CanDelete ("
35 " Key INTEGER PRIMARY KEY,"
36 " CanDeleteSeq INTEGER"
42 boost::optional<std::int64_t> countO;
43 session <<
"SELECT COUNT(Key) FROM DbState WHERE Key = 1;", soci::into(countO);
51 session <<
"INSERT INTO DbState VALUES (1, '', '', 0);";
56 boost::optional<std::int64_t> countO;
57 session <<
"SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;", soci::into(countO);
65 session <<
"INSERT INTO CanDelete VALUES (1, 0);";
73 session <<
"SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;", soci::into(seq);
81 session <<
"UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;",
90 session <<
"SELECT WritableDb, ArchiveDb, LastRotatedLedger"
91 " FROM DbState WHERE Key = 1;",
100 session <<
"UPDATE DbState"
101 " SET WritableDb = :writableDb,"
102 " ArchiveDb = :archiveDb,"
103 " LastRotatedLedger = :lastRotated"
111 session <<
"UPDATE DbState SET LastRotatedLedger = :seq"
Holds unparsed configuration information.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void initStateDB(soci::session &session, BasicConfig const &config, std::string const &dbName)
initStateDB Opens a session with the State database.
void setSavedState(soci::session &session, SavedState const &state)
setSavedState Saves the given state.
std::uint32_t LedgerIndex
A ledger index.
void setLastRotated(soci::session &session, LedgerIndex seq)
setLastRotated Updates the last rotated ledger sequence.
SavedState getSavedState(soci::session &session)
getSavedState Returns the saved state.
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.
LedgerIndex setCanDelete(soci::session &session, LedgerIndex canDelete)
setCanDelete Updates the ledger sequence which can be deleted.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
LedgerIndex getCanDelete(soci::session &session)
getCanDelete Returns the ledger sequence which can be deleted.