20 #include <ripple/overlay/PeerReservationTable.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/core/DatabaseCon.h>
24 #include <ripple/json/json_value.h>
25 #include <ripple/protocol/PublicKey.h>
26 #include <ripple/protocol/jss.h>
28 #include <boost/optional.hpp>
77 boost::optional<std::string> valPubKey, valDesc;
82 (db->prepare <<
"SELECT PublicKey, Description FROM PeerReservations;",
83 soci::into(valPubKey),
88 if (!valPubKey || !valDesc)
94 auto const optNodeId =
98 JLOG(
journal_.
warn()) <<
"load: not a public key: " << valPubKey;
110 -> boost::optional<PeerReservation>
112 boost::optional<PeerReservation> previous;
116 auto hint = table_.find(reservation);
117 if (hint != table_.end()) {
130 auto const deleteme = hint;
132 table_.erase(deleteme);
134 table_.insert(hint, reservation);
136 auto db = connection_->checkoutDb();
137 *db <<
"INSERT INTO PeerReservations (PublicKey, Description) "
138 "VALUES (:nodeId, :desc) "
139 "ON CONFLICT (PublicKey) DO UPDATE SET "
140 "Description=excluded.Description",
142 soci::use(reservation.description);
149 -> boost::optional<PeerReservation>
151 boost::optional<PeerReservation> previous;
155 auto const it = table_.find({nodeId});
156 if (it != table_.end())
160 auto db = connection_->checkoutDb();
161 *db <<
"DELETE FROM PeerReservations WHERE PublicKey = :nodeId",