Skip to content

Commit e99e41b

Browse files
committed
cli, refactor: simplify public-only classes with structs
and run clang-format on it
1 parent fdbfd25 commit e99e41b

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

src/bitcoin-cli.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,10 @@ static void libevent_log_cb(int severity, const char *msg)
130130
// Exception thrown on connection error. This error is used to determine
131131
// when to wait if -rpcwait is given.
132132
//
133-
class CConnectionFailed : public std::runtime_error
134-
{
135-
public:
136-
133+
struct CConnectionFailed : std::runtime_error {
137134
explicit inline CConnectionFailed(const std::string& msg) :
138135
std::runtime_error(msg)
139136
{}
140-
141137
};
142138

143139
//
@@ -267,21 +263,17 @@ static int8_t NetworkStringToId(const std::string& str)
267263
return UNKNOWN_NETWORK;
268264
}
269265

270-
/** Class that handles the conversion from a command-line to a JSON-RPC request,
266+
/** Handle the conversion from a command-line to a JSON-RPC request,
271267
* as well as converting back to a JSON object that can be shown as result.
272268
*/
273-
class BaseRequestHandler
274-
{
275-
public:
269+
struct BaseRequestHandler {
276270
virtual ~BaseRequestHandler() = default;
277271
virtual UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) = 0;
278272
virtual UniValue ProcessReply(const UniValue &batch_in) = 0;
279273
};
280274

281275
/** Process addrinfo requests */
282-
class AddrinfoRequestHandler : public BaseRequestHandler
283-
{
284-
public:
276+
struct AddrinfoRequestHandler : BaseRequestHandler {
285277
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
286278
{
287279
if (!args.empty()) {
@@ -320,9 +312,7 @@ class AddrinfoRequestHandler : public BaseRequestHandler
320312
};
321313

322314
/** Process getinfo requests */
323-
class GetinfoRequestHandler: public BaseRequestHandler
324-
{
325-
public:
315+
struct GetinfoRequestHandler : BaseRequestHandler {
326316
const int ID_NETWORKINFO = 0;
327317
const int ID_BLOCKCHAININFO = 1;
328318
const int ID_WALLETINFO = 2;
@@ -767,8 +757,7 @@ class GenerateToAddressRequestHandler : public BaseRequestHandler
767757
};
768758

769759
/** Process default single requests */
770-
class DefaultRequestHandler: public BaseRequestHandler {
771-
public:
760+
struct DefaultRequestHandler : BaseRequestHandler {
772761
UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) override
773762
{
774763
UniValue params;

0 commit comments

Comments
 (0)