Skip to content

Commit 8e95d2a

Browse files
achow101vijaydasmp
authored andcommitted
Merge bitcoin#28136: refactor: move GetServicesNames from rpc/util.{h,cpp} to rpc/net.cpp
bbb68ff refactor: drop protocol.h include header in rpc/util.h (Jon Atack) 1dd62c5 refactor: move GetServicesNames from rpc/util.{h,cpp} to rpc/net.cpp (Jon Atack) Pull request description: Move `GetServicesNames()` from `rpc/util` to `rpc/net.cpp`, as it is only called from that compilation unit and there is no reason for other ones to need it. Remove the `protocol.h` include in `rpc/util.h`, as it was only needed for `GetServicesNames()`, drop an unneeded forward declaration (the other IWYU suggestions would require more extensive changes in other files), and add 3 already-missing include headers in other translation units that are needed to compile without `protocol.h` in `rpc/util.h`, as `protocol.h` includes `netaddress.h`, which in turn includes `util/strencodings.h`. ACKs for top commit: kevkevinpal: lgtm ACK [bbb68ff](bitcoin@bbb68ff) ns-xvrn: ACK bbb68ff achow101: ACK bbb68ff Tree-SHA512: fcbe195874dd4aa9e86548685b6b28595a2c46f9869b79b6e2b3835f76b49cab4bef6a59c8ad6428063a41b7bb6f687229b06ea614fbd103e0531104af7de55d
1 parent 8eeff95 commit 8e95d2a

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

src/httprpc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <crypto/hmac_sha256.h>
88
#include <httpserver.h>
9+
#include <netaddress.h>
910
#include <rpc/protocol.h>
1011
#include <rpc/server.h>
1112
#include <util/strencodings.h>

src/rest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <sync.h>
3030
#include <txmempool.h>
3131
#include <util/check.h>
32+
#include <util/strencodings.h>
3233
#include <validation.h>
3334
#include <version.h>
3435

src/rpc/mempool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <util/moneystr.h>
1919
#include <validation.h>
2020
#include <util/system.h>
21+
#include <util/strencodings.h>
2122
#include <util/time.h>
2223

2324
#include <instantsend/instantsend.h>

src/rpc/net.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <netbase.h>
1717
#include <node/context.h>
1818
#include <policy/settings.h>
19+
#include <protocol.h>
1920
#include <rpc/blockchain.h>
2021
#include <rpc/protocol.h>
2122
#include <rpc/server_util.h>
@@ -95,6 +96,18 @@ static RPCHelpMan ping()
9596
};
9697
}
9798

99+
/** Returns, given services flags, a list of humanly readable (known) network services */
100+
static UniValue GetServicesNames(ServiceFlags services)
101+
{
102+
UniValue servicesNames(UniValue::VARR);
103+
104+
for (const auto& flag : serviceFlagsToStr(services)) {
105+
servicesNames.push_back(flag);
106+
}
107+
108+
return servicesNames;
109+
}
110+
98111
static RPCHelpMan getpeerinfo()
99112
{
100113
return RPCHelpMan{

src/rpc/util.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -990,17 +990,6 @@ UniValue JSONRPCTransactionError(TransactionError terr, const std::string& err_s
990990
}
991991
}
992992

993-
UniValue GetServicesNames(ServiceFlags services)
994-
{
995-
UniValue servicesNames(UniValue::VARR);
996-
997-
for (const auto& flag : serviceFlagsToStr(services)) {
998-
servicesNames.push_back(flag);
999-
}
1000-
1001-
return servicesNames;
1002-
}
1003-
1004993
std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider)
1005994
{
1006995
std::string desc_str;

src/rpc/util.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#define BITCOIN_RPC_UTIL_H
77

88
#include <node/transaction.h>
9-
#include <protocol.h>
109
#include <pubkey.h>
1110
#include <rpc/protocol.h>
1211
#include <rpc/request.h>
@@ -44,7 +43,6 @@ extern const std::string EXAMPLE_ADDRESS[2];
4443

4544
class FillableSigningProvider;
4645
class FillableSigningProvider;
47-
class CPubKey;
4846
class CScript;
4947
struct Sections;
5048

@@ -122,8 +120,6 @@ UniValue DescribeAddress(const CTxDestination& dest);
122120
//! Parse a confirm target option and raise an RPC error if it is invalid.
123121
unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target);
124122

125-
/** Returns, given services flags, a list of humanly readable (known) network services */
126-
UniValue GetServicesNames(ServiceFlags services);
127123

128124
//! Parse a JSON range specified as int64, or [int64, int64]
129125
std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);

0 commit comments

Comments
 (0)