20 #include <ripple/app/ledger/AcceptedLedger.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/rdb/backend/detail/Shard.h>
23 #include <ripple/basics/StringUtilities.h>
24 #include <ripple/core/DatabaseCon.h>
25 #include <ripple/core/SociDB.h>
26 #include <ripple/json/to_string.h>
38 auto lgrMetaDB{std::make_unique<DatabaseCon>(
46 return {std::move(lgrMetaDB),
nullptr};
49 auto txMetaDB{std::make_unique<DatabaseCon>(
52 return {std::move(lgrMetaDB), std::move(txMetaDB)};
59 soci::session& lgrMetaSession,
60 soci::session& txnMetaSession,
64 R
"sql(INSERT OR REPLACE INTO LedgerMeta VALUES
65 (:ledgerHash,:shardIndex);)sql";
67 auto const hash =
to_string(ledger->info().hash);
68 lgrMetaSession << lgrSQL, soci::use(hash), soci::use(shardIndex);
80 aLedger = std::make_shared<AcceptedLedger>(ledger, app);
82 ledger->info().hash, aLedger);
90 <<
"An accepted ledger was missing nodes";
99 soci::transaction tr(txnMetaSession);
101 for (
auto const& acceptedLedgerTx : *aLedger)
104 R
"sql(INSERT OR REPLACE INTO TransactionMeta VALUES
105 (:transactionID,:shardIndex);)sql";
108 to_string(acceptedLedgerTx->getTransactionID());
111 soci::use(shardIndex);
122 session <<
"SELECT ShardIndex FROM LedgerMeta WHERE LedgerHash = '" << hash
124 soci::into(shardIndex);
126 if (!session.got_data())
136 session <<
"SELECT ShardIndex FROM TransactionMeta WHERE TransID = '" <<
id
138 soci::into(shardIndex);
140 if (!session.got_data())
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 ...
virtual TaggedCache< uint256, AcceptedLedger > & getAcceptedLedgerCache()=0
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...
constexpr std::array< char const *, 3 > LgrMetaDBInit
static std::string to_string(TableType type)
to_string Returns the name of a table according to its TableType.
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...
constexpr auto LgrMetaDBName
constexpr auto TxMetaDBName
virtual Config & config()=0
constexpr std::array< char const *, 3 > TxMetaDBInit
constexpr std::array< char const *, 4 > LgrMetaDBPragma
@ transactionID
transaction plus signature to give transaction ID
constexpr std::array< char const *, 4 > TxMetaDBPragma
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...
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual beast::Journal journal(std::string const &name)=0