20 #include <ripple/app/rdb/State.h>
26 soci::session& session,
30 open(session, config, dbName);
32 session <<
"PRAGMA synchronous=FULL;";
34 session <<
"CREATE TABLE IF NOT EXISTS DbState ("
35 " Key INTEGER PRIMARY KEY,"
38 " LastRotatedLedger INTEGER"
41 session <<
"CREATE TABLE IF NOT EXISTS CanDelete ("
42 " Key INTEGER PRIMARY KEY,"
43 " CanDeleteSeq INTEGER"
49 boost::optional<std::int64_t> countO;
50 session <<
"SELECT COUNT(Key) FROM DbState WHERE Key = 1;",
53 Throw<std::runtime_error>(
54 "Failed to fetch Key Count from DbState.");
60 session <<
"INSERT INTO DbState VALUES (1, '', '', 0);";
65 boost::optional<std::int64_t> countO;
66 session <<
"SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;",
69 Throw<std::runtime_error>(
70 "Failed to fetch Key Count from CanDelete.");
76 session <<
"INSERT INTO CanDelete VALUES (1, 0);";
84 session <<
"SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;",
93 session <<
"UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;",
102 session <<
"SELECT WritableDb, ArchiveDb, LastRotatedLedger"
103 " FROM DbState WHERE Key = 1;",
113 session <<
"UPDATE DbState"
114 " SET WritableDb = :writableDb,"
115 " ArchiveDb = :archiveDb,"
116 " LastRotatedLedger = :lastRotated"
125 session <<
"UPDATE DbState SET LastRotatedLedger = :seq"
LedgerIndex setCanDelete(soci::session &session, LedgerIndex canDelete)
setCanDelete Updates the ledger sequence which can be deleted.
std::uint32_t LedgerIndex
A ledger index.
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.
void setLastRotated(soci::session &session, LedgerIndex seq)
setLastRotated Updates the last rotated ledger sequence.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
LedgerIndex getCanDelete(soci::session &session)
getCanDelete Returns the ledger sequence which can be deleted.
Holds unparsed configuration information.
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.