rippled
Loading...
Searching...
No Matches
DBInit.h
1#ifndef XRPL_APP_DATA_DBINIT_H_INCLUDED
2#define XRPL_APP_DATA_DBINIT_H_INCLUDED
3
4#include <array>
5#include <cstdint>
6
7namespace ripple {
8
10
11// These pragmas are built at startup and applied to all database
12// connections, unless otherwise noted.
13inline constexpr char const* CommonDBPragmaJournal{"PRAGMA journal_mode=%s;"};
14inline constexpr char const* CommonDBPragmaSync{"PRAGMA synchronous=%s;"};
15inline constexpr char const* CommonDBPragmaTemp{"PRAGMA temp_store=%s;"};
16// A warning will be logged if any lower-safety sqlite tuning settings
17// are used and at least this much ledger history is configured. This
18// includes full history nodes. This is because such a large amount of
19// data will be more difficult to recover if a rare failure occurs,
20// which are more likely with some of the other available tuning settings.
21inline constexpr std::uint32_t SQLITE_TUNING_CUTOFF = 10'000'000;
22
23// Ledger database holds ledgers and ledger confirmations
24inline constexpr auto LgrDBName{"ledger.db"};
25
27 {"BEGIN TRANSACTION;",
28
29 "CREATE TABLE IF NOT EXISTS Ledgers ( \
30 LedgerHash CHARACTER(64) PRIMARY KEY, \
31 LedgerSeq BIGINT UNSIGNED, \
32 PrevHash CHARACTER(64), \
33 TotalCoins BIGINT UNSIGNED, \
34 ClosingTime BIGINT UNSIGNED, \
35 PrevClosingTime BIGINT UNSIGNED, \
36 CloseTimeRes BIGINT UNSIGNED, \
37 CloseFlags BIGINT UNSIGNED, \
38 AccountSetHash CHARACTER(64), \
39 TransSetHash CHARACTER(64) \
40 );",
41 "CREATE INDEX IF NOT EXISTS SeqLedger ON Ledgers(LedgerSeq);",
42
43 // Old table and indexes no longer needed
44 "DROP TABLE IF EXISTS Validations;",
45
46 "END TRANSACTION;"}};
47
49
50// Transaction database holds transactions and public keys
51inline constexpr auto TxDBName{"transaction.db"};
52
54 {"BEGIN TRANSACTION;",
55
56 "CREATE TABLE IF NOT EXISTS Transactions ( \
57 TransID CHARACTER(64) PRIMARY KEY, \
58 TransType CHARACTER(24), \
59 FromAcct CHARACTER(35), \
60 FromSeq BIGINT UNSIGNED, \
61 LedgerSeq BIGINT UNSIGNED, \
62 Status CHARACTER(1), \
63 RawTxn BLOB, \
64 TxnMeta BLOB \
65 );",
66 "CREATE INDEX IF NOT EXISTS TxLgrIndex ON \
67 Transactions(LedgerSeq);",
68
69 "CREATE TABLE IF NOT EXISTS AccountTransactions ( \
70 TransID CHARACTER(64), \
71 Account CHARACTER(64), \
72 LedgerSeq BIGINT UNSIGNED, \
73 TxnSeq INTEGER \
74 );",
75 "CREATE INDEX IF NOT EXISTS AcctTxIDIndex ON \
76 AccountTransactions(TransID);",
77 "CREATE INDEX IF NOT EXISTS AcctTxIndex ON \
78 AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);",
79 "CREATE INDEX IF NOT EXISTS AcctLgrIndex ON \
80 AccountTransactions(LedgerSeq, Account, TransID);",
81
82 "END TRANSACTION;"}};
83
85
86inline constexpr auto WalletDBName{"wallet.db"};
87
89 {"BEGIN TRANSACTION;",
90
91 // A node's identity must be persisted, including
92 // for clustering purposes. This table holds one
93 // entry: the server's unique identity, but the
94 // value can be overriden by specifying a node
95 // identity in the config file using a [node_seed]
96 // entry.
97 "CREATE TABLE IF NOT EXISTS NodeIdentity ( \
98 PublicKey CHARACTER(53), \
99 PrivateKey CHARACTER(52) \
100 );",
101
102 // Peer reservations
103 "CREATE TABLE IF NOT EXISTS PeerReservations ( \
104 PublicKey CHARACTER(53) UNIQUE NOT NULL, \
105 Description CHARACTER(64) NOT NULL \
106 );",
107
108 // Validator Manifests
109 "CREATE TABLE IF NOT EXISTS ValidatorManifests ( \
110 RawData BLOB NOT NULL \
111 );",
112
113 "CREATE TABLE IF NOT EXISTS PublisherManifests ( \
114 RawData BLOB NOT NULL \
115 );",
116
117 "END TRANSACTION;"}};
118
119} // namespace ripple
120
121#endif
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr std::array< char const *, 8 > TxDBInit
Definition DBInit.h:53
constexpr char const * CommonDBPragmaSync
Definition DBInit.h:14
constexpr auto LgrDBName
Definition DBInit.h:24
constexpr std::array< char const *, 5 > LgrDBInit
Definition DBInit.h:26
constexpr std::array< char const *, 6 > WalletDBInit
Definition DBInit.h:88
constexpr char const * CommonDBPragmaTemp
Definition DBInit.h:15
constexpr std::uint32_t SQLITE_TUNING_CUTOFF
Definition DBInit.h:21
constexpr auto TxDBName
Definition DBInit.h:51
constexpr char const * CommonDBPragmaJournal
Definition DBInit.h:13
constexpr auto WalletDBName
Definition DBInit.h:86