rippled
Wallet.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2021 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_APP_RDB_WALLET_H_INCLUDED
21 #define RIPPLE_APP_RDB_WALLET_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 
30 namespace ripple {
31 
38 makeWalletDB(DatabaseCon::Setup const& setup);
39 
47 makeTestWalletDB(DatabaseCon::Setup const& setup, std::string const& dbname);
48 
58 void
60  soci::session& session,
61  std::string const& dbTable,
62  ManifestCache& mCache,
63  beast::Journal j);
64 
73 void
75  soci::session& session,
76  std::string const& dbTable,
77  std::function<bool(PublicKey const&)> const& isTrusted,
78  hash_map<PublicKey, Manifest> const& map,
79  beast::Journal j);
80 
87 void
88 addValidatorManifest(soci::session& session, std::string const& serialized);
89 
91 void
92 clearNodeIdentity(soci::session& session);
93 
105 getNodeIdentity(soci::session& session);
106 
114 getPeerReservationTable(soci::session& session, beast::Journal j);
115 
122 void
124  soci::session& session,
125  PublicKey const& nodeId,
126  std::string const& description);
127 
134 void
135 deletePeerReservation(soci::session& session, PublicKey const& nodeId);
136 
142 bool
143 createFeatureVotes(soci::session& session);
144 
145 // For historical reasons the up-vote and down-vote integer representations
146 // are unintuitive.
147 enum class AmendmentVote : int { obsolete = -1, up = 0, down = 1 };
148 
155 void
157  soci::session& session,
158  std::function<void(
159  boost::optional<std::string> amendment_hash,
160  boost::optional<std::string> amendment_name,
161  boost::optional<AmendmentVote> vote)> const& callback);
162 
170 void
172  soci::session& session,
173  uint256 const& amendment,
174  std::string const& name,
175  AmendmentVote vote);
176 
177 } // namespace ripple
178 
179 #endif
ripple::AmendmentVote::up
@ up
std::string
STL class.
ripple::AmendmentVote::obsolete
@ obsolete
std::unordered_set
STL class.
std::pair
ripple::createFeatureVotes
bool createFeatureVotes(soci::session &session)
createFeatureVotes Creates the FeatureVote table if it does not exist.
Definition: Wallet.cpp:224
ripple::addValidatorManifest
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
Definition: Wallet.cpp:115
std::function
ripple::makeTestWalletDB
std::unique_ptr< DatabaseCon > makeTestWalletDB(DatabaseCon::Setup const &setup, std::string const &dbname)
makeTestWalletDB Opens a test wallet database with an arbitrary name.
Definition: Wallet.cpp:34
ripple::uint256
base_uint< 256 > uint256
Definition: base_uint.h:550
ripple::AmendmentVote::down
@ down
ripple::getManifests
void getManifests(soci::session &session, std::string const &dbTable, ManifestCache &mCache, beast::Journal j)
getManifests Loads a manifest from the wallet database and stores it in the cache.
Definition: Wallet.cpp:42
ripple::insertPeerReservation
void insertPeerReservation(soci::session &session, PublicKey const &nodeId, std::string const &description)
insertPeerReservation Adds an entry to the peer reservation table.
Definition: Wallet.cpp:203
ripple::deletePeerReservation
void deletePeerReservation(soci::session &session, PublicKey const &nodeId)
deletePeerReservation Deletes an entry from the peer reservation table.
Definition: Wallet.cpp:217
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 Reads all amendments from the FeatureVotes table.
Definition: Wallet.cpp:248
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::getPeerReservationTable
std::unordered_set< PeerReservation, beast::uhash<>, KeyEqual > getPeerReservationTable(soci::session &session, beast::Journal j)
getPeerReservationTable Returns the peer reservation table.
Definition: Wallet.cpp:166
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::voteAmendment
void voteAmendment(soci::session &session, uint256 const &amendment, std::string const &name, AmendmentVote vote)
voteAmendment Set the veto value for a particular amendment.
Definition: Wallet.cpp:284
ripple::makeWalletDB
std::unique_ptr< DatabaseCon > makeWalletDB(DatabaseCon::Setup const &setup)
makeWalletDB Opens the wallet database and returns it.
Definition: Wallet.cpp:26
ripple::AmendmentVote
AmendmentVote
Definition: Wallet.h:147
ripple::getNodeIdentity
std::pair< PublicKey, SecretKey > getNodeIdentity(Application &app, boost::program_options::variables_map const &cmdline)
The cryptographic credentials identifying this server instance.
Definition: NodeIdentity.cpp:30
std::unique_ptr
STL class.
ripple::clearNodeIdentity
void clearNodeIdentity(soci::session &session)
Delete any saved public/private key associated with this node.
Definition: Wallet.cpp:123
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 the database.
Definition: Wallet.cpp:90