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>
10#include <soci/boost-optional.h>
12#include <soci/session.h>
24 open(session, config, dbName);
26 session <<
"PRAGMA synchronous=FULL;";
28 session <<
"CREATE TABLE IF NOT EXISTS DbState ("
29 " Key INTEGER PRIMARY KEY,"
32 " LastRotatedLedger INTEGER"
35 session <<
"CREATE TABLE IF NOT EXISTS CanDelete ("
36 " Key INTEGER PRIMARY KEY,"
37 " CanDeleteSeq INTEGER"
43 boost::optional<std::int64_t> countO;
44 session <<
"SELECT COUNT(Key) FROM DbState WHERE Key = 1;", soci::into(countO);
52 session <<
"INSERT INTO DbState VALUES (1, '', '', 0);";
57 boost::optional<std::int64_t> countO;
58 session <<
"SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;", soci::into(countO);
66 session <<
"INSERT INTO CanDelete VALUES (1, 0);";
74 session <<
"SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;", soci::into(seq);
82 session <<
"UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;",
91 session <<
"SELECT WritableDb, ArchiveDb, LastRotatedLedger"
92 " FROM DbState WHERE Key = 1;",
101 session <<
"UPDATE DbState"
102 " SET WritableDb = :writableDb,"
103 " ArchiveDb = :archiveDb,"
104 " LastRotatedLedger = :lastRotated"
112 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.