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 
135 // For historical reasons the up-vote and down-vote integer representations
136 // are unintuitive.
137 enum class AmendmentVote : int { up = 0, down = 1 };
138 
145 void
147  soci::session& session,
148  std::function<void(
149  boost::optional<std::string> amendment_hash,
150  boost::optional<std::string> amendment_name,
151  boost::optional<AmendmentVote> vote)> const& callback);
152 
160 void
162  soci::session& session,
163  uint256 const& amendment,
164  std::string const& name,
165  AmendmentVote vote);
166 
167 /* State DB */
168 
170 {
174 };
175 
182 void
184  soci::session& session,
185  BasicConfig const& config,
186  std::string const& dbName);
187 
194 getCanDelete(soci::session& session);
195 
203 setCanDelete(soci::session& session, LedgerIndex canDelete);
204 
212 getSavedState(soci::session& session);
213 
220 void
221 setSavedState(soci::session& session, SavedState const& state);
222 
228 void
229 setLastRotated(soci::session& session, LedgerIndex seq);
230 
231 /* DatabaseBody DB */
232 
243  DatabaseCon::Setup const& setup,
244  boost::filesystem::path const& path);
245 
259  soci::session& session,
260  std::string const& data,
261  std::string const& path,
262  std::uint64_t fileSize,
263  std::uint64_t part,
264  std::uint16_t maxRowSizePad);
265 
271 void
272 databaseBodyFinish(soci::session& session, std::ofstream& fout);
273 
274 /* Vacuum DB */
275 
281 bool
282 doVacuumDB(DatabaseCon::Setup const& setup);
283 
284 /* PeerFinder DB */
285 
292 void
294  soci::session& session,
295  BasicConfig const& config,
296  beast::Journal j);
297 
304 void
306  soci::session& session,
307  int currentSchemaVersion,
308  beast::Journal j);
309 
316 void
318  soci::session& session,
319  std::function<void(std::string const&, int)> const& func);
320 
326 void
328  soci::session& session,
330 
331 } // namespace ripple
332 
333 #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:375
ripple::AmendmentVote::up
@ up
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:590
std::unordered_set
STL class.
std::pair
ripple::setSavedState
void setSavedState(soci::session &session, SavedState const &state)
setSavedState Saves given state.
Definition: RelationalDBInterface_global.cpp:395
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:626
ripple::SavedState::writableDb
std::string writableDb
Definition: RelationalDBInterface_global.h:171
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::AmendmentVote::down
@ down
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:782
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::readAmendments
void readAmendments(soci::session &session, std::function< void(boost::optional< std::string > amendment_hash, boost::optional< std::string > amendment_name, boost::optional< AmendmentVote > vote)> const &callback)
readAmendments Read all amendments from FeatureVotes table.
Definition: RelationalDBInterface_global.cpp:256
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:309
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:383
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:456
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:407
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:172
ripple::getCanDelete
LedgerIndex getCanDelete(soci::session &session)
getCanDelete Returns ledger sequence which can be deleted.
Definition: RelationalDBInterface_global.cpp:365
ripple::voteAmendment
void voteAmendment(soci::session &session, uint256 const &amendment, std::string const &name, AmendmentVote vote)
voteAmendment Set veto value for particular amendment.
Definition: RelationalDBInterface_global.cpp:289
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:173
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:804
ripple::AmendmentVote
AmendmentVote
Definition: RelationalDBInterface_global.h:137
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:417
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:533
ripple::doVacuumDB
bool doVacuumDB(DatabaseCon::Setup const &setup)
doVacuumDB Creates, initialises DB, and performs its cleanup.
Definition: RelationalDBInterface_global.cpp:546
std::unique_ptr
STL class.
ripple::SavedState
Definition: RelationalDBInterface_global.h:169
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