cli, refactor: simplify public-only classes with structs

and run clang-format on it
This commit is contained in:
Jon Atack 2025-02-16 09:41:32 -06:00
parent fdbfd250fb
commit e99e41b307

View file

@ -130,14 +130,10 @@ static void libevent_log_cb(int severity, const char *msg)
// Exception thrown on connection error. This error is used to determine // Exception thrown on connection error. This error is used to determine
// when to wait if -rpcwait is given. // when to wait if -rpcwait is given.
// //
class CConnectionFailed : public std::runtime_error struct CConnectionFailed : std::runtime_error {
{
public:
explicit inline CConnectionFailed(const std::string& msg) : explicit inline CConnectionFailed(const std::string& msg) :
std::runtime_error(msg) std::runtime_error(msg)
{} {}
}; };
// //
@ -267,21 +263,17 @@ static int8_t NetworkStringToId(const std::string& str)
return UNKNOWN_NETWORK; return UNKNOWN_NETWORK;
} }
/** Class that handles the conversion from a command-line to a JSON-RPC request, /** Handle the conversion from a command-line to a JSON-RPC request,
* as well as converting back to a JSON object that can be shown as result. * as well as converting back to a JSON object that can be shown as result.
*/ */
class BaseRequestHandler struct BaseRequestHandler {
{
public:
virtual ~BaseRequestHandler() = default; virtual ~BaseRequestHandler() = default;
virtual UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) = 0; virtual UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) = 0;
virtual UniValue ProcessReply(const UniValue &batch_in) = 0; virtual UniValue ProcessReply(const UniValue &batch_in) = 0;
}; };
/** Process addrinfo requests */ /** Process addrinfo requests */
class AddrinfoRequestHandler : public BaseRequestHandler struct AddrinfoRequestHandler : BaseRequestHandler {
{
public:
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
{ {
if (!args.empty()) { if (!args.empty()) {
@ -320,9 +312,7 @@ public:
}; };
/** Process getinfo requests */ /** Process getinfo requests */
class GetinfoRequestHandler: public BaseRequestHandler struct GetinfoRequestHandler : BaseRequestHandler {
{
public:
const int ID_NETWORKINFO = 0; const int ID_NETWORKINFO = 0;
const int ID_BLOCKCHAININFO = 1; const int ID_BLOCKCHAININFO = 1;
const int ID_WALLETINFO = 2; const int ID_WALLETINFO = 2;
@ -767,8 +757,7 @@ protected:
}; };
/** Process default single requests */ /** Process default single requests */
class DefaultRequestHandler: public BaseRequestHandler { struct DefaultRequestHandler : BaseRequestHandler {
public:
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
{ {
UniValue params; UniValue params;