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