rippled
RelationalDBInterface_shards.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2020 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/ledger/AcceptedLedger.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/ledger/LedgerToJson.h>
23 #include <ripple/app/rdb/RelationalDBInterface.h>
24 #include <ripple/app/rdb/RelationalDBInterface_shards.h>
25 #include <ripple/basics/BasicConfig.h>
26 #include <ripple/basics/StringUtilities.h>
27 #include <ripple/core/DatabaseCon.h>
28 #include <ripple/core/SociDB.h>
29 #include <ripple/json/to_string.h>
30 #include <boost/algorithm/string.hpp>
31 #include <boost/range/adaptor/transformed.hpp>
32 
33 namespace ripple {
34 
35 DatabasePair
37  Config const& config,
38  DatabaseCon::Setup const& setup,
39  DatabaseCon::CheckpointerSetup const& checkpointerSetup)
40 {
41  // ledger meta database
42  auto lgrMetaDB{std::make_unique<DatabaseCon>(
43  setup,
47  checkpointerSetup)};
48 
49  if (config.useTxTables())
50  {
51  // transaction meta database
52  auto txMetaDB{std::make_unique<DatabaseCon>(
53  setup,
57  checkpointerSetup)};
58 
59  return {std::move(lgrMetaDB), std::move(txMetaDB)};
60  }
61 
62  return {std::move(lgrMetaDB), nullptr};
63 }
64 
65 bool
67  std::shared_ptr<Ledger const> const& ledger,
68  Application& app,
69  soci::session& lgrMetaSession,
70  soci::session& txnMetaSession,
71  std::uint32_t const shardIndex)
72 {
73  std::string_view constexpr lgrSQL =
74  R"sql(INSERT OR REPLACE INTO LedgerMeta VALUES
75  (:ledgerHash,:shardIndex);)sql";
76 
77  auto const hash = to_string(ledger->info().hash);
78  lgrMetaSession << lgrSQL, soci::use(hash), soci::use(shardIndex);
79 
80  if (app.config().useTxTables())
81  {
82  auto const aLedger = [&app,
83  ledger]() -> std::shared_ptr<AcceptedLedger> {
84  try
85  {
86  auto aLedger =
87  app.getAcceptedLedgerCache().fetch(ledger->info().hash);
88  if (!aLedger)
89  {
90  aLedger = std::make_shared<AcceptedLedger>(ledger, app);
91  app.getAcceptedLedgerCache().canonicalize_replace_client(
92  ledger->info().hash, aLedger);
93  }
94 
95  return aLedger;
96  }
97  catch (std::exception const&)
98  {
99  JLOG(app.journal("Ledger").warn())
100  << "An accepted ledger was missing nodes";
101  }
102 
103  return {};
104  }();
105 
106  if (!aLedger)
107  return false;
108 
109  soci::transaction tr(txnMetaSession);
110 
111  for (auto const& acceptedLedgerTx : *aLedger)
112  {
113  std::string_view constexpr txnSQL =
114  R"sql(INSERT OR REPLACE INTO TransactionMeta VALUES
115  (:transactionID,:shardIndex);)sql";
116 
117  auto const transactionID =
118  to_string(acceptedLedgerTx->getTransactionID());
119 
120  txnMetaSession << txnSQL, soci::use(transactionID),
121  soci::use(shardIndex);
122  }
123 
124  tr.commit();
125  }
126 
127  return true;
128 }
129 
131 getShardIndexforLedger(soci::session& session, LedgerHash const& hash)
132 {
133  std::uint32_t shardIndex;
134  session << "SELECT ShardIndex FROM LedgerMeta WHERE LedgerHash = '" << hash
135  << "';",
136  soci::into(shardIndex);
137 
138  if (!session.got_data())
139  return std::nullopt;
140 
141  return shardIndex;
142 }
143 
145 getShardIndexforTransaction(soci::session& session, TxID const& id)
146 {
147  std::uint32_t shardIndex;
148  session << "SELECT ShardIndex FROM TransactionMeta WHERE TransID = '" << id
149  << "';",
150  soci::into(shardIndex);
151 
152  if (!session.got_data())
153  return std::nullopt;
154 
155  return shardIndex;
156 }
157 
160  Config const& config,
161  DatabaseCon::Setup const& setup)
162 {
163  auto tx{std::make_unique<DatabaseCon>(
165  tx->getSession() << boost::str(
166  boost::format("PRAGMA cache_size=-%d;") %
167  kilobytes(config.getValueFor(SizedItem::txnDBCache, std::nullopt)));
168 
169  auto lgr{std::make_unique<DatabaseCon>(
171  lgr->getSession() << boost::str(
172  boost::format("PRAGMA cache_size=-%d;") %
173  kilobytes(config.getValueFor(SizedItem::lgrDBCache, std::nullopt)));
174 
175  return {std::move(lgr), std::move(tx)};
176 }
177 
180  Config const& config,
181  DatabaseCon::Setup const& setup,
182  DatabaseCon::CheckpointerSetup const& checkpointerSetup)
183 {
184  // transaction database
185  auto tx{std::make_unique<DatabaseCon>(
186  setup, TxDBName, TxDBPragma, TxDBInit, checkpointerSetup)};
187  tx->getSession() << boost::str(
188  boost::format("PRAGMA cache_size=-%d;") %
190 
191  // ledger database
192  auto lgr{std::make_unique<DatabaseCon>(
193  setup, LgrDBName, LgrDBPragma, LgrDBInit, checkpointerSetup)};
194  lgr->getSession() << boost::str(
195  boost::format("PRAGMA cache_size=-%d;") %
197 
198  return {std::move(lgr), std::move(tx)};
199 }
200 
201 bool
203  soci::session& txsession,
204  soci::session& lgrsession,
205  std::shared_ptr<Ledger const> const& ledger,
206  std::uint32_t index,
207  std::atomic<bool>& stop,
208  beast::Journal j)
209 {
210  auto const ledgerSeq{ledger->info().seq};
211 
212  // Update the transactions database
213  {
214  auto& session{txsession};
215  soci::transaction tr(session);
216 
217  session << "DELETE FROM Transactions "
218  "WHERE LedgerSeq = :seq;",
219  soci::use(ledgerSeq);
220  session << "DELETE FROM AccountTransactions "
221  "WHERE LedgerSeq = :seq;",
222  soci::use(ledgerSeq);
223 
224  if (ledger->info().txHash.isNonZero())
225  {
226  auto const sSeq{std::to_string(ledgerSeq)};
227  if (!ledger->txMap().isValid())
228  {
229  JLOG(j.error())
230  << "shard " << index << " has an invalid transaction map"
231  << " on sequence " << sSeq;
232  return false;
233  }
234 
235  for (auto const& item : ledger->txs)
236  {
237  if (stop)
238  return false;
239 
240  auto const txID{item.first->getTransactionID()};
241  auto const sTxID{to_string(txID)};
242  auto const txMeta{std::make_shared<TxMeta>(
243  txID, ledger->seq(), *item.second)};
244 
245  session << "DELETE FROM AccountTransactions "
246  "WHERE TransID = :txID;",
247  soci::use(sTxID);
248 
249  auto const& accounts = txMeta->getAffectedAccounts();
250  if (!accounts.empty())
251  {
252  auto const sTxnSeq{std::to_string(txMeta->getIndex())};
253  auto const s{boost::str(
254  boost::format("('%s','%s',%s,%s)") % sTxID % "%s" %
255  sSeq % sTxnSeq)};
256  std::string sql;
257  sql.reserve((accounts.size() + 1) * 128);
258  sql =
259  "INSERT INTO AccountTransactions "
260  "(TransID, Account, LedgerSeq, TxnSeq) VALUES ";
261  sql += boost::algorithm::join(
262  accounts |
263  boost::adaptors::transformed(
264  [&](AccountID const& accountID) {
265  return boost::str(
266  boost::format(s) %
267  ripple::toBase58(accountID));
268  }),
269  ",");
270  sql += ';';
271  session << sql;
272 
273  JLOG(j.trace())
274  << "shard " << index << " account transaction: " << sql;
275  }
276  else if (!isPseudoTx(*item.first))
277  {
278  // It's okay for pseudo transactions to not affect any
279  // accounts. But otherwise...
280  JLOG(j.warn())
281  << "shard " << index << " transaction in ledger "
282  << sSeq << " affects no accounts";
283  }
284 
285  Serializer s;
286  item.second->add(s);
287  session
289  item.first->getMetaSQL(
290  ledgerSeq, sqlBlobLiteral(s.modData())) +
291  ';');
292  }
293  }
294 
295  tr.commit();
296  }
297 
298  auto const sHash{to_string(ledger->info().hash)};
299 
300  // Update the ledger database
301  {
302  auto& session{lgrsession};
303  soci::transaction tr(session);
304 
305  auto const sParentHash{to_string(ledger->info().parentHash)};
306  auto const sDrops{to_string(ledger->info().drops)};
307  auto const sAccountHash{to_string(ledger->info().accountHash)};
308  auto const sTxHash{to_string(ledger->info().txHash)};
309 
310  session << "DELETE FROM Ledgers "
311  "WHERE LedgerSeq = :seq;",
312  soci::use(ledgerSeq);
313  session << "INSERT OR REPLACE INTO Ledgers ("
314  "LedgerHash, LedgerSeq, PrevHash, TotalCoins, ClosingTime,"
315  "PrevClosingTime, CloseTimeRes, CloseFlags, AccountSetHash,"
316  "TransSetHash)"
317  "VALUES ("
318  ":ledgerHash, :ledgerSeq, :prevHash, :totalCoins,"
319  ":closingTime, :prevClosingTime, :closeTimeRes,"
320  ":closeFlags, :accountSetHash, :transSetHash);",
321  soci::use(sHash), soci::use(ledgerSeq), soci::use(sParentHash),
322  soci::use(sDrops),
323  soci::use(ledger->info().closeTime.time_since_epoch().count()),
324  soci::use(
325  ledger->info().parentCloseTime.time_since_epoch().count()),
326  soci::use(ledger->info().closeTimeResolution.count()),
327  soci::use(ledger->info().closeFlags), soci::use(sAccountHash),
328  soci::use(sTxHash);
329 
330  tr.commit();
331  }
332 
333  return true;
334 }
335 
336 /* Shard acquire db */
337 
340  DatabaseCon::Setup const& setup,
341  DatabaseCon::CheckpointerSetup const& checkpointerSetup)
342 {
343  return std::make_unique<DatabaseCon>(
344  setup,
348  checkpointerSetup);
349 }
350 
351 void
352 insertAcquireDBIndex(soci::session& session, std::uint32_t index)
353 {
354  session << "INSERT INTO Shard (ShardIndex) "
355  "VALUES (:shardIndex);",
356  soci::use(index);
357 }
358 
360 selectAcquireDBLedgerSeqs(soci::session& session, std::uint32_t index)
361 {
362  // resIndex and must be boost::optional (not std) because that's
363  // what SOCI expects in its interface.
364  boost::optional<std::uint32_t> resIndex;
365  soci::blob sociBlob(session);
366  soci::indicator blobPresent;
367 
368  session << "SELECT ShardIndex, StoredLedgerSeqs "
369  "FROM Shard "
370  "WHERE ShardIndex = :index;",
371  soci::into(resIndex), soci::into(sociBlob, blobPresent),
372  soci::use(index);
373 
374  if (!resIndex || index != resIndex)
375  return {false, {}};
376 
377  if (blobPresent != soci::i_ok)
378  return {true, {}};
379 
380  std::string s;
381  convert(sociBlob, s);
382 
383  return {true, s};
384 }
385 
387 selectAcquireDBLedgerSeqsHash(soci::session& session, std::uint32_t index)
388 {
389  // resIndex and sHash0 must be boost::optional (not std) because that's
390  // what SOCI expects in its interface.
391  boost::optional<std::uint32_t> resIndex;
392  boost::optional<std::string> sHash0;
393  soci::blob sociBlob(session);
394  soci::indicator blobPresent;
395 
396  session << "SELECT ShardIndex, LastLedgerHash, StoredLedgerSeqs "
397  "FROM Shard "
398  "WHERE ShardIndex = :index;",
399  soci::into(resIndex), soci::into(sHash0),
400  soci::into(sociBlob, blobPresent), soci::use(index);
401 
403  (sHash0 ? *sHash0 : std::optional<std::string>());
404 
405  if (!resIndex || index != resIndex)
406  return {false, {{}, {}}};
407 
408  if (blobPresent != soci::i_ok)
409  return {true, {{}, sHash}};
410 
411  std::string s;
412  convert(sociBlob, s);
413 
414  return {true, {s, sHash}};
415 }
416 
417 void
419  soci::session& session,
420  std::shared_ptr<Ledger const> const& ledger,
421  std::uint32_t index,
422  std::uint32_t lastSeq,
423  std::optional<std::string> const& seqs)
424 {
425  soci::blob sociBlob(session);
426  auto const sHash{to_string(ledger->info().hash)};
427 
428  if (seqs)
429  convert(*seqs, sociBlob);
430 
431  if (ledger->info().seq == lastSeq)
432  {
433  // Store shard's last ledger hash
434  session << "UPDATE Shard "
435  "SET LastLedgerHash = :lastLedgerHash,"
436  "StoredLedgerSeqs = :storedLedgerSeqs "
437  "WHERE ShardIndex = :shardIndex;",
438  soci::use(sHash), soci::use(sociBlob), soci::use(index);
439  }
440  else
441  {
442  session << "UPDATE Shard "
443  "SET StoredLedgerSeqs = :storedLedgerSeqs "
444  "WHERE ShardIndex = :shardIndex;",
445  soci::use(sociBlob), soci::use(index);
446  }
447 }
448 
449 /* Archive DB */
450 
452 makeArchiveDB(boost::filesystem::path const& dir, std::string const& dbName)
453 {
454  return std::make_unique<DatabaseCon>(
456 }
457 
458 void
460  DatabaseCon& db,
461  std::function<void(std::string const&, int)> const& func)
462 {
463  soci::rowset<soci::row> rs =
464  (db.getSession().prepare << "SELECT * FROM State;");
465 
466  for (auto it = rs.begin(); it != rs.end(); ++it)
467  {
468  func(it->get<std::string>(1), it->get<int>(0));
469  }
470 }
471 
472 void
474  DatabaseCon& db,
475  std::uint32_t shardIndex,
476  std::string const& url)
477 {
478  db.getSession() << "INSERT INTO State VALUES (:index, :url);",
479  soci::use(shardIndex), soci::use(url);
480 }
481 
482 void
484 {
485  db.getSession() << "DELETE FROM State WHERE ShardIndex = :index;",
486  soci::use(shardIndex);
487 }
488 
489 void
491 {
492  db.getSession() << "DROP TABLE State;";
493 }
494 
495 } // namespace ripple
ripple::AcquireShardDBPragma
constexpr std::array< char const *, 1 > AcquireShardDBPragma
Definition: DBInit.h:168
ripple::Application
Definition: Application.h:115
ripple::AcquireShardDBName
constexpr auto AcquireShardDBName
Definition: DBInit.h:166
ripple::SHAMap::isValid
bool isValid() const
Definition: SHAMap.h:617
ripple::makeAcquireDB
std::unique_ptr< DatabaseCon > makeAcquireDB(DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeAcquireDB Opens shard acquire DB and returns its descriptor.
Definition: RelationalDBInterface_shards.cpp:337
ripple::Application::getAcceptedLedgerCache
virtual TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache()=0
std::string
STL class.
std::shared_ptr
STL class.
ripple::LedgerInfo::parentHash
uint256 parentHash
Definition: ReadView.h:103
std::exception
STL class.
ripple::base_uint::isNonZero
bool isNonZero() const
Definition: base_uint.h:530
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:84
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:309
ripple::LgrMetaDBInit
constexpr std::array< char const *, 3 > LgrMetaDBInit
Definition: DBInit.h:129
std::string_view
STL class.
ripple::Serializer::modData
Blob & modData()
Definition: Serializer.h:178
std::pair
std::string::reserve
T reserve(T... args)
ripple::LedgerInfo::hash
uint256 hash
Definition: ReadView.h:100
ripple::convert
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
Definition: SociDB.cpp:154
ripple::selectAcquireDBLedgerSeqsHash
std::pair< bool, AcquireShardSeqsHash > selectAcquireDBLedgerSeqsHash(soci::session &session, std::uint32_t index)
selectAcquireDBLedgerSeqsHash Returns set of acquired ledgers and hash for given shard.
Definition: RelationalDBInterface_shards.cpp:385
ripple::insertAcquireDBIndex
void insertAcquireDBIndex(soci::session &session, std::uint32_t index)
insertAcquireDBIndex Adds new shard index to shard acquire DB.
Definition: RelationalDBInterface_shards.cpp:350
ripple::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition: AccountID.cpp:29
ripple::DatabaseCon::CheckpointerSetup
Definition: DatabaseCon.h:107
beast::Journal::warn
Stream warn() const
Definition: Journal.h:327
ripple::kilobytes
constexpr auto kilobytes(T value) noexcept
Definition: ByteUtilities.h:27
ripple::AcquireShardDBInit
constexpr std::array< char const *, 1 > AcquireShardDBInit
Definition: DBInit.h:171
ripple::ShardArchiveHandlerDBInit
static constexpr std::array< char const *, 3 > ShardArchiveHandlerDBInit
Definition: DBInit.h:228
ripple::STTx::getMetaSQLInsertReplaceHeader
static std::string const & getMetaSQLInsertReplaceHeader()
Definition: STTx.cpp:248
std::function
ripple::LedgerInfo::seq
LedgerIndex seq
Definition: ReadView.h:92
ripple::LedgerInfo::txHash
uint256 txHash
Definition: ReadView.h:101
ripple::LgrDBInit
constexpr std::array< char const *, 5 > LgrDBInit
Definition: DBInit.h:48
ripple::TxMetaDBPragma
constexpr std::array TxMetaDBPragma
Definition: DBInit.h:145
ripple::LgrMetaDBName
constexpr auto LgrMetaDBName
Definition: DBInit.h:118
ripple::LedgerInfo::closeTime
NetClock::time_point closeTime
Definition: ReadView.h:123
ripple::DownloaderDBPragma
static constexpr std::array< char const *, 2 > DownloaderDBPragma
Definition: DBInit.h:225
ripple::TxDBName
constexpr auto TxDBName
Definition: DBInit.h:73
ripple::base_uint< 256 >
ripple::updateAcquireDB
void updateAcquireDB(soci::session &session, std::shared_ptr< Ledger const > const &ledger, std::uint32_t index, std::uint32_t lastSeq, std::optional< std::string > const &seqs)
updateAcquireDB Updates information in acquire DB.
Definition: RelationalDBInterface_shards.cpp:416
ripple::Ledger::info
LedgerInfo const & info() const override
Returns information about the ledger.
Definition: Ledger.h:148
std::chrono::time_point::time_since_epoch
T time_since_epoch(T... args)
ripple::isPseudoTx
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
Definition: STTx.cpp:554
ripple::Config::getValueFor
int getValueFor(SizedItem item, std::optional< std::size_t > node=std::nullopt) const
Retrieve the default value for the item at the specified node size.
Definition: Config.cpp:990
ripple::TxMetaDBName
constexpr auto TxMetaDBName
Definition: DBInit.h:142
ripple::LgrDBPragma
constexpr std::array< char const *, 1 > LgrDBPragma
Definition: DBInit.h:45
ripple::Config
Definition: Config.h:68
ripple::deleteFromArchiveDB
void deleteFromArchiveDB(DatabaseCon &db, std::uint32_t shardIndex)
deleteFromArchiveDB Deletes entry from shard archive DB.
Definition: RelationalDBInterface_shards.cpp:481
ripple::Application::config
virtual Config & config()=0
ripple::Config::useTxTables
bool useTxTables() const
Definition: Config.h:322
ripple::LedgerInfo::closeFlags
int closeFlags
Definition: ReadView.h:114
std::to_string
T to_string(T... args)
ripple::dropArchiveDB
void dropArchiveDB(DatabaseCon &db)
dropArchiveDB Removes table in shard archive DB.
Definition: RelationalDBInterface_shards.cpp:488
beast::Journal::error
Stream error() const
Definition: Journal.h:333
ripple::TxMetaDBInit
constexpr std::array< char const *, 3 > TxMetaDBInit
Definition: DBInit.h:153
ripple::SizedItem::lgrDBCache
@ lgrDBCache
ripple::HashPrefix::transactionID
@ transactionID
transaction plus signature to give transaction ID
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
std::atomic< bool >
ripple::DatabasePair
Definition: RelationalDBInterface_shards.h:31
ripple::SizedItem::txnDBCache
@ txnDBCache
ripple::FinalShardDBPragma
constexpr std::array< char const *, 2 > FinalShardDBPragma
Definition: DBInit.h:182
ripple::LedgerInfo::drops
XRPAmount drops
Definition: ReadView.h:105
ripple::Serializer
Definition: Serializer.h:39
ripple::DatabaseCon::getSession
soci::session & getSession()
Definition: DatabaseCon.h:172
ripple::Ledger::txMap
SHAMap const & txMap() const
Definition: Ledger.h:319
ripple::updateLedgerDBs
bool updateLedgerDBs(soci::session &txsession, soci::session &lgrsession, std::shared_ptr< Ledger const > const &ledger, std::uint32_t index, std::atomic< bool > &stop, beast::Journal j)
updateLedgerDBs Save given ledger to shard databases.
Definition: RelationalDBInterface_shards.cpp:200
ripple::LgrMetaDBPragma
constexpr std::array LgrMetaDBPragma
Definition: DBInit.h:121
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::readArchiveDB
void readArchiveDB(DatabaseCon &db, std::function< void(std::string const &, int)> const &func)
readArchiveDB Read entries from shard archive database and calls fiven callback for each entry.
Definition: RelationalDBInterface_shards.cpp:457
ripple::ReadView::seq
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Definition: ReadView.h:260
ripple::LedgerInfo::closeTimeResolution
NetClock::duration closeTimeResolution
Definition: ReadView.h:117
ripple::makeMetaDBs
DatabasePair makeMetaDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeMetaDBs Opens ledger and transaction 'meta' databases which map ledger hashes and transaction IDs...
Definition: RelationalDBInterface_shards.cpp:36
ripple::DatabaseCon
Definition: DatabaseCon.h:81
ripple::TxDBPragma
constexpr std::array TxDBPragma
Definition: DBInit.h:76
std::chrono::duration::count
T count(T... args)
ripple::saveLedgerMeta
bool saveLedgerMeta(std::shared_ptr< Ledger const > const &ledger, Application &app, soci::session &lgrMetaSession, soci::session &txnMetaSession, std::uint32_t const shardIndex)
saveLedgerMeta Stores (transaction ID -> shard index) and (ledger hash -> shard index) mappings in th...
Definition: RelationalDBInterface_shards.cpp:66
ripple::makeShardIncompleteLedgerDBs
DatabasePair makeShardIncompleteLedgerDBs(Config const &config, DatabaseCon::Setup const &setup, DatabaseCon::CheckpointerSetup const &checkpointerSetup)
makeShardIncompleteLedgerDBs Opens shard databases for not fully downloaded or verified shard and ret...
Definition: RelationalDBInterface_shards.cpp:177
std::optional< std::uint32_t >
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
ripple::insertArchiveDB
void insertArchiveDB(DatabaseCon &db, std::uint32_t shardIndex, std::string const &url)
insertArchiveDB Adds entry to shard archive database.
Definition: RelationalDBInterface_shards.cpp:471
ripple::selectAcquireDBLedgerSeqs
std::pair< bool, std::optional< std::string > > selectAcquireDBLedgerSeqs(soci::session &session, std::uint32_t index)
selectAcquireDBLedgerSeqs Returns set of acquired ledgers for given shard.
Definition: RelationalDBInterface_shards.cpp:358
ripple::TxDBInit
constexpr std::array< char const *, 8 > TxDBInit
Definition: DBInit.h:84
ripple::makeArchiveDB
std::unique_ptr< DatabaseCon > makeArchiveDB(boost::filesystem::path const &dir, std::string const &dbName)
makeArchiveDB Opens shard archive DB and returns its descriptor.
Definition: RelationalDBInterface_shards.cpp:450
ripple::getShardIndexforTransaction
std::optional< std::uint32_t > getShardIndexforTransaction(soci::session &session, TxID const &id)
getShardIndexforTransaction Queries the transaction meta database to retrieve the index of the shard ...
Definition: RelationalDBInterface_shards.cpp:143
std::unique_ptr
STL class.
ripple::sqlBlobLiteral
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".
Definition: StringUtilities.cpp:33
ripple::LedgerInfo::accountHash
uint256 accountHash
Definition: ReadView.h:102
ripple::ReadView::txs
txs_type txs
Definition: ReadView.h:390
ripple::makeShardCompleteLedgerDBs
DatabasePair makeShardCompleteLedgerDBs(Config const &config, DatabaseCon::Setup const &setup)
makeShardCompleteLedgerDBs Opens shard databases for already verified shard and returns its descripto...
Definition: RelationalDBInterface_shards.cpp:157
ripple::LedgerInfo::parentCloseTime
NetClock::time_point parentCloseTime
Definition: ReadView.h:93
ripple::LgrDBName
constexpr auto LgrDBName
Definition: DBInit.h:43
ripple::getShardIndexforLedger
std::optional< std::uint32_t > getShardIndexforLedger(soci::session &session, LedgerHash const &hash)
getShardIndexforLedger Queries the ledger meta database to retrieve the index of the shard that conta...
Definition: RelationalDBInterface_shards.cpp:129