rippled
RelationalDBInterface_shards.h
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 #ifndef RIPPLE_CORE_RELATIONALDBINTERFACE_SHARDS_H_INCLUDED
21 #define RIPPLE_CORE_RELATIONALDBINTERFACE_SHARDS_H_INCLUDED
22 
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/app/rdb/RelationalDBInterface.h>
25 #include <ripple/core/Config.h>
26 #include <boost/filesystem.hpp>
27 
28 namespace ripple {
29 
31 {
34 };
35 
36 /* Shard DB */
37 
47  Config const& config,
48  DatabaseCon::Setup const& setup);
49 
60  Config const& config,
61  DatabaseCon::Setup const& setup,
62  DatabaseCon::CheckpointerSetup const& checkpointerSetup);
63 
74 bool
76  soci::session& txdb,
77  soci::session& lgrdb,
78  std::shared_ptr<Ledger const> const& ledger,
79  std::uint32_t index,
80  std::atomic<bool>& stop,
81  beast::Journal j);
82 
83 /* Shard acquire DB */
84 
93  DatabaseCon::Setup const& setup,
94  DatabaseCon::CheckpointerSetup const& checkpointerSetup);
95 
101 void
102 insertAcquireDBIndex(soci::session& session, std::uint32_t index);
103 
114 selectAcquireDBLedgerSeqs(soci::session& session, std::uint32_t index);
115 
117 {
120 };
121 
133 selectAcquireDBLedgerSeqsHash(soci::session& session, std::uint32_t index);
134 
143 void
145  soci::session& session,
146  std::shared_ptr<Ledger const> const& ledger,
147  std::uint32_t index,
148  std::uint32_t lastSeq,
149  std::optional<std::string> const& seqs);
150 
151 /* Archive DB */
152 
160 makeArchiveDB(boost::filesystem::path const& dir, std::string const& dbName);
161 
168 void
170  DatabaseCon& db,
171  std::function<void(std::string const&, int)> const& func);
172 
179 void
181  DatabaseCon& db,
182  std::uint32_t shardIndex,
183  std::string const& url);
184 
190 void
192 
197 void
199 
200 } // namespace ripple
201 
202 #endif
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:214
ripple::DatabasePair::transactionDb
std::unique_ptr< DatabaseCon > transactionDb
Definition: RelationalDBInterface_shards.h:33
std::string
STL class.
std::shared_ptr
STL class.
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:84
std::pair
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:262
ripple::insertAcquireDBIndex
void insertAcquireDBIndex(soci::session &session, std::uint32_t index)
insertAcquireDBIndex Adds new shard index to shard acquire DB.
Definition: RelationalDBInterface_shards.cpp:227
ripple::DatabasePair::ledgerDb
std::unique_ptr< DatabaseCon > ledgerDb
Definition: RelationalDBInterface_shards.h:32
ripple::DatabaseCon::CheckpointerSetup
Definition: DatabaseCon.h:107
std::function
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:293
ripple::Config
Definition: Config.h:67
ripple::deleteFromArchiveDB
void deleteFromArchiveDB(DatabaseCon &db, std::uint32_t shardIndex)
deleteFromArchiveDB Deletes entry from shard archive DB.
Definition: RelationalDBInterface_shards.cpp:358
ripple::dropArchiveDB
void dropArchiveDB(DatabaseCon &db)
dropArchiveDB Removes table in shard archive DB.
Definition: RelationalDBInterface_shards.cpp:365
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
std::atomic< bool >
ripple::DatabasePair
Definition: RelationalDBInterface_shards.h:30
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:79
ripple::AcquireShardSeqsHash
Definition: RelationalDBInterface_shards.h:116
ripple::AcquireShardSeqsHash::hash
std::optional< std::string > hash
Definition: RelationalDBInterface_shards.h:119
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
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:334
ripple::DatabaseCon
Definition: DatabaseCon.h:81
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:56
std::optional< std::string >
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:348
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:235
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:327
std::unique_ptr
STL class.
ripple::AcquireShardSeqsHash::sequences
std::optional< std::string > sequences
Definition: RelationalDBInterface_shards.h:118
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:36