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 
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 
125 void
126 deletePeerReservation(soci::session& session, PublicKey const& nodeId);
127 
133 bool
134 createFeatureVotes(soci::session& session);
135 
136 // For historical reasons the up-vote and down-vote integer representations
137 // are unintuitive.
138 enum class AmendmentVote : int { up = 0, down = 1 };
139 
146 void
148  soci::session& session,
149  std::function<void(
150  boost::optional<std::string> amendment_hash,
151  boost::optional<std::string> amendment_name,
152  boost::optional<AmendmentVote> vote)> const& callback);
153 
161 void
163  soci::session& session,
164  uint256 const& amendment,
165  std::string const& name,
166  AmendmentVote vote);
167 
168 } // namespace ripple
169 
170 #endif
ripple::getNodeIdentity
std::pair< PublicKey, SecretKey > getNodeIdentity(Application &app)
The cryptographic credentials identifying this server instance.
Definition: NodeIdentity.cpp:32
ripple::AmendmentVote::up
@ up
std::string
STL class.
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:218
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:543
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:197
ripple::deletePeerReservation
void deletePeerReservation(soci::session &session, PublicKey const &nodeId)
deletePeerReservation Deletes an entry from the peer reservation table.
Definition: Wallet.cpp:211
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:242
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:160
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:275
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:138
std::unique_ptr
STL class.
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