rippled
Loading...
Searching...
No Matches
PeerReservationsDel.cpp
1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/handlers/Handlers.h>
3
4#include <xrpl/json/json_value.h>
5#include <xrpl/protocol/ErrorCodes.h>
6#include <xrpl/protocol/PublicKey.h>
7#include <xrpl/protocol/RPCErr.h>
8#include <xrpl/protocol/jss.h>
9
10#include <optional>
11
12namespace xrpl {
13
16{
17 auto const& params = context.params;
18
19 // We repeat much of the parameter parsing from `doPeerReservationsAdd`.
20 if (!params.isMember(jss::public_key))
21 return RPC::missing_field_error(jss::public_key);
22 if (!params[jss::public_key].isString())
23 return RPC::expected_field_error(jss::public_key, "a string");
24
26 parseBase58<PublicKey>(TokenType::NodePublic, params[jss::public_key].asString());
27 if (!optPk)
29 PublicKey const& nodeId = *optPk;
30
31 auto const previous = context.app.getPeerReservations().erase(nodeId);
32
34 if (previous)
35 {
36 result[jss::previous] = previous->toJson();
37 }
38 return result;
39}
40
41} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
std::optional< PeerReservation > erase(PublicKey const &nodeId)
A public key.
Definition PublicKey.h:42
virtual PeerReservationTable & getPeerReservations()=0
@ objectValue
object value (collection of name/value pairs).
Definition json_value.h:26
Json::Value expected_field_error(std::string const &name, std::string const &type)
Definition ErrorCodes.h:297
Json::Value missing_field_error(std::string const &name)
Definition ErrorCodes.h:231
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
Json::Value doPeerReservationsDel(RPC::JsonContext &context)
Json::Value rpcError(error_code_i iError)
Definition RPCErr.cpp:12
@ rpcPUBLIC_MALFORMED
Definition ErrorCodes.h:97
Application & app
Definition Context.h:21
Json::Value params
Definition Context.h:43