1#include <xrpld/app/rdb/State.h>
8 open(session, config, dbName);
10 session <<
"PRAGMA synchronous=FULL;";
12 session <<
"CREATE TABLE IF NOT EXISTS DbState ("
13 " Key INTEGER PRIMARY KEY,"
16 " LastRotatedLedger INTEGER"
19 session <<
"CREATE TABLE IF NOT EXISTS CanDelete ("
20 " Key INTEGER PRIMARY KEY,"
21 " CanDeleteSeq INTEGER"
27 boost::optional<std::int64_t> countO;
28 session <<
"SELECT COUNT(Key) FROM DbState WHERE Key = 1;", soci::into(countO);
30 Throw<std::runtime_error>(
"Failed to fetch Key Count from DbState.");
36 session <<
"INSERT INTO DbState VALUES (1, '', '', 0);";
41 boost::optional<std::int64_t> countO;
42 session <<
"SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;", soci::into(countO);
44 Throw<std::runtime_error>(
"Failed to fetch Key Count from CanDelete.");
50 session <<
"INSERT INTO CanDelete VALUES (1, 0);";
58 session <<
"SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;", soci::into(seq);
66 session <<
"UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;", soci::use(canDelete);
74 session <<
"SELECT WritableDb, ArchiveDb, LastRotatedLedger"
75 " FROM DbState WHERE Key = 1;",
84 session <<
"UPDATE DbState"
85 " SET WritableDb = :writableDb,"
86 " ArchiveDb = :archiveDb,"
87 " LastRotatedLedger = :lastRotated"
95 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 setLastRotated(soci::session &session, LedgerIndex seq)
setLastRotated Updates the last rotated ledger sequence.
void setSavedState(soci::session &session, SavedState const &state)
setSavedState Saves the given state.
void initStateDB(soci::session &session, BasicConfig const &config, std::string const &dbName)
initStateDB Opens a session with the State database.
SavedState getSavedState(soci::session &session)
getSavedState Returns the saved state.
std::uint32_t LedgerIndex
A ledger index.
@ open
We haven't closed our ledger yet, but others might have.
LedgerIndex setCanDelete(soci::session &session, LedgerIndex canDelete)
setCanDelete Updates the ledger sequence which can be deleted.
LedgerIndex getCanDelete(soci::session &session)
getCanDelete Returns the ledger sequence which can be deleted.