rippled
RelationalDBInterface_global.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_GLOBAL_H_INCLUDED
21 #define RIPPLE_CORE_RELATIONALDBINTERFACE_GLOBAL_H_INCLUDED
22 
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/app/misc/Manifest.h>
25 #include <ripple/core/Config.h>
26 #include <ripple/core/DatabaseCon.h>
27 #include <ripple/overlay/PeerReservationTable.h>
28 #include <ripple/peerfinder/impl/Store.h>
29 #include <boost/filesystem.hpp>
30 
31 namespace ripple {
32 
33 /* Wallet DB */
34 
41 makeWalletDB(DatabaseCon::Setup const& setup);
42 
50 makeTestWalletDB(DatabaseCon::Setup const& setup, std::string const& dbname);
51 
59 void
61  soci::session& session,
62  std::string const& dbTable,
63  ManifestCache& mCache,
64  beast::Journal j);
65 
74 void
76  soci::session& session,
77  std::string const& dbTable,
78  std::function<bool(PublicKey const&)> const& isTrusted,
79  hash_map<PublicKey, Manifest> const& map,
80  beast::Journal j);
81 
87 void
88 addValidatorManifest(soci::session& session, std::string const& serialized);
89 
96 getNodeIdentity(soci::session& session);
97 
105 getPeerReservationTable(soci::session& session, beast::Journal j);
106 
113 void
115  soci::session& session,
116  PublicKey const& nodeId,
117  std::string const& description);
118 
124 void
125 deletePeerReservation(soci::session& session, PublicKey const& nodeId);
126 
132 bool
133 createFeatureVotes(soci::session& session);
134 
141 void
143  soci::session& session,
144  std::function<void(
145  boost::optional<std::string> amendment_hash,
146  boost::optional<std::string> amendment_name,
147  boost::optional<int> vote_to_veto)> const& callback);
148 
156 void
158  soci::session& session,
159  uint256 const& amendment,
160  std::string const& name,
161  bool vote_to_veto);
162 
163 /* State DB */
164 
166 {
170 };
171 
178 void
180  soci::session& session,
181  BasicConfig const& config,
182  std::string const& dbName);
183 
190 getCanDelete(soci::session& session);
191 
199 setCanDelete(soci::session& session, LedgerIndex canDelete);
200 
208 getSavedState(soci::session& session);
209 
216 void
217 setSavedState(soci::session& session, SavedState const& state);
218 
224 void
225 setLastRotated(soci::session& session, LedgerIndex seq);
226 
227 /* DatabaseBody DB */
228 
239  DatabaseCon::Setup const& setup,
240  boost::filesystem::path const& path);
241 
255  soci::session& session,
256  std::string const& data,
257  std::string const& path,
258  std::uint64_t fileSize,
259  std::uint64_t part,
260  std::uint16_t maxRowSizePad);
261 
267 void
268 databaseBodyFinish(soci::session& session, std::ofstream& fout);
269 
270 /* Vacuum DB */
271 
277 bool
278 doVacuumDB(DatabaseCon::Setup const& setup);
279 
280 /* PeerFinder DB */
281 
288 void
290  soci::session& session,
291  BasicConfig const& config,
292  beast::Journal j);
293 
300 void
302  soci::session& session,
303  int currentSchemaVersion,
304  beast::Journal j);
305 
312 void
314  soci::session& session,
315  std::function<void(std::string const&, int)> const& func);
316 
322 void
324  soci::session& session,
326 
327 } // namespace ripple
328 
329 #endif
ripple::getNodeIdentity
std::pair< PublicKey, SecretKey > getNodeIdentity(Application &app)
The cryptographic credentials identifying this server instance.
Definition: NodeIdentity.cpp:32
ripple::setCanDelete
LedgerIndex setCanDelete(soci::session &session, LedgerIndex canDelete)
setCanDelete Updates ledger sequence which can be deleted.
Definition: RelationalDBInterface_global.cpp:369
std::string
STL class.
ripple::DatabaseCon::Setup
Definition: DatabaseCon.h:84
ripple::initPeerFinderDB
void initPeerFinderDB(soci::session &session, BasicConfig const &config, beast::Journal j)
initPeerFinderDB Opens session with peer finder database.
Definition: RelationalDBInterface_global.cpp:584
std::unordered_set
STL class.
ripple::readAmendments
void readAmendments(soci::session &session, std::function< void(boost::optional< std::string > amendment_hash, boost::optional< std::string > amendment_name, boost::optional< int > vote_to_veto)> const &callback)
readAmendments Read all amendments from FeatureVotes table.
Definition: RelationalDBInterface_global.cpp:256
std::pair
ripple::setSavedState
void setSavedState(soci::session &session, SavedState const &state)
setSavedState Saves given state.
Definition: RelationalDBInterface_global.cpp:389
ripple::createFeatureVotes
bool createFeatureVotes(soci::session &session)
createFeatureVotes Creates FeatureVote table if it is not exists.
Definition: RelationalDBInterface_global.cpp:232
std::vector
STL class.
ripple::updatePeerFinderDB
void updatePeerFinderDB(soci::session &session, int currentSchemaVersion, beast::Journal j)
updatePeerFinderDB Update peer finder DB to new version.
Definition: RelationalDBInterface_global.cpp:620
ripple::SavedState::writableDb
std::string writableDb
Definition: RelationalDBInterface_global.h:167
ripple::addValidatorManifest
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves manifest of validator to database.
Definition: RelationalDBInterface_global.cpp:129
std::function
ripple::makeTestWalletDB
std::unique_ptr< DatabaseCon > makeTestWalletDB(DatabaseCon::Setup const &setup, std::string const &dbname)
makeTestWalletDB Opens test wallet DB with arbitrary name.
Definition: RelationalDBInterface_global.cpp:48
ripple::uint256
base_uint< 256 > uint256
Definition: base_uint.h:529
ripple::voteAmendment
void voteAmendment(soci::session &session, uint256 const &amendment, std::string const &name, bool vote_to_veto)
voteAmendment Set veto value for particular amendment.
Definition: RelationalDBInterface_global.cpp:283
std::ofstream
STL class.
ripple::readPeerFinderDB
void readPeerFinderDB(soci::session &session, std::function< void(std::string const &, int)> const &func)
readPeerFinderDB Read all entries from peer finder DB and call given callback for each entry.
Definition: RelationalDBInterface_global.cpp:776
ripple::getManifests
void getManifests(soci::session &session, std::string const &dbTable, ManifestCache &mCache, beast::Journal j)
getManifests Loads manifest from wallet DB and stores it in the cache.
Definition: RelationalDBInterface_global.cpp:56
ripple::insertPeerReservation
void insertPeerReservation(soci::session &session, PublicKey const &nodeId, std::string const &description)
insertPeerReservation Adds entry to peer reservation table.
Definition: RelationalDBInterface_global.cpp:211
ripple::deletePeerReservation
void deletePeerReservation(soci::session &session, PublicKey const &nodeId)
deletePeerReservation Deletes entry from peer reservation table.
Definition: RelationalDBInterface_global.cpp:225
ripple::initStateDB
void initStateDB(soci::session &session, BasicConfig const &config, std::string const &dbName)
initStateDB Opens DB session with State DB.
Definition: RelationalDBInterface_global.cpp:303
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
ripple::getSavedState
SavedState getSavedState(soci::session &session)
getSavedState Returns saved state.
Definition: RelationalDBInterface_global.cpp:377
ripple::databaseBodyDoPut
std::uint64_t databaseBodyDoPut(soci::session &session, std::string const &data, std::string const &path, std::uint64_t fileSize, std::uint64_t part, std::uint16_t maxRowSizePad)
databaseBodyDoPut Saves new fragment of downloaded file.
Definition: RelationalDBInterface_global.cpp:450
ripple::getPeerReservationTable
std::unordered_set< PeerReservation, beast::uhash<>, KeyEqual > getPeerReservationTable(soci::session &session, beast::Journal j)
getPeerReservationTable Returns peer reservation table.
Definition: RelationalDBInterface_global.cpp:174
ripple::setLastRotated
void setLastRotated(soci::session &session, LedgerIndex seq)
setLastRotated Updates last rotated ledger sequence.
Definition: RelationalDBInterface_global.cpp:401
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::SavedState::archiveDb
std::string archiveDb
Definition: RelationalDBInterface_global.h:168
ripple::getCanDelete
LedgerIndex getCanDelete(soci::session &session)
getCanDelete Returns ledger sequence which can be deleted.
Definition: RelationalDBInterface_global.cpp:359
ripple::makeWalletDB
std::unique_ptr< DatabaseCon > makeWalletDB(DatabaseCon::Setup const &setup)
makeWalletDB Opens wallet DB and returns it.
Definition: RelationalDBInterface_global.cpp:40
ripple::SavedState::lastRotated
LedgerIndex lastRotated
Definition: RelationalDBInterface_global.h:169
ripple::savePeerFinderDB
void savePeerFinderDB(soci::session &session, std::vector< PeerFinder::Store::Entry > const &v)
savePeerFinderDB Save new entry to peer finder DB.
Definition: RelationalDBInterface_global.cpp:798
ripple::openDatabaseBodyDb
std::pair< std::unique_ptr< DatabaseCon >, std::optional< std::uint64_t > > openDatabaseBodyDb(DatabaseCon::Setup const &setup, boost::filesystem::path const &path)
openDatabaseBodyDb Opens file download DB and returns its descriptor.
Definition: RelationalDBInterface_global.cpp:411
std::optional
ripple::databaseBodyFinish
void databaseBodyFinish(soci::session &session, std::ofstream &fout)
databaseBodyFinish Finishes download process and writes file to disk.
Definition: RelationalDBInterface_global.cpp:527
ripple::doVacuumDB
bool doVacuumDB(DatabaseCon::Setup const &setup)
doVacuumDB Creates, initialises DB, and performs its cleanup.
Definition: RelationalDBInterface_global.cpp:540
std::unique_ptr
STL class.
ripple::SavedState
Definition: RelationalDBInterface_global.h:165
ripple::saveManifests
void saveManifests(soci::session &session, std::string const &dbTable, std::function< bool(PublicKey const &)> const &isTrusted, hash_map< PublicKey, Manifest > const &map, beast::Journal j)
saveManifests Saves all given manifests to database.
Definition: RelationalDBInterface_global.cpp:104
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215