Skip to content

Commit e773396

Browse files
committed
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
2 parents 0528cfd + bbb68ff commit e773396

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/httprpc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <crypto/hmac_sha256.h>
99
#include <httpserver.h>
1010
#include <logging.h>
11+
#include <netaddress.h>
1112
#include <rpc/protocol.h>
1213
#include <rpc/server.h>
1314
#include <util/strencodings.h>

src/rest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <txmempool.h>
2727
#include <util/any.h>
2828
#include <util/check.h>
29+
#include <util/strencodings.h>
2930
#include <validation.h>
3031
#include <version.h>
3132

src/rpc/mempool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <univalue.h>
2222
#include <util/fs.h>
2323
#include <util/moneystr.h>
24+
#include <util/strencodings.h>
2425
#include <util/time.h>
2526

2627
#include <utility>

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>
@@ -98,6 +99,18 @@ static RPCHelpMan ping()
9899
};
99100
}
100101

102+
/** Returns, given services flags, a list of humanly readable (known) network services */
103+
static UniValue GetServicesNames(ServiceFlags services)
104+
{
105+
UniValue servicesNames(UniValue::VARR);
106+
107+
for (const auto& flag : serviceFlagsToStr(services)) {
108+
servicesNames.push_back(flag);
109+
}
110+
111+
return servicesNames;
112+
}
113+
101114
static RPCHelpMan getpeerinfo()
102115
{
103116
return RPCHelpMan{

src/rpc/util.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,17 +1304,6 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
13041304
return ret;
13051305
}
13061306

1307-
UniValue GetServicesNames(ServiceFlags services)
1308-
{
1309-
UniValue servicesNames(UniValue::VARR);
1310-
1311-
for (const auto& flag : serviceFlagsToStr(services)) {
1312-
servicesNames.push_back(flag);
1313-
}
1314-
1315-
return servicesNames;
1316-
}
1317-
13181307
/** Convert a vector of bilingual strings to a UniValue::VARR containing their original untranslated values. */
13191308
[[nodiscard]] static UniValue BilingualStringsToUniValue(const std::vector<bilingual_str>& bilingual_strings)
13201309
{

src/rpc/util.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <consensus/amount.h>
1010
#include <node/transaction.h>
1111
#include <outputtype.h>
12-
#include <protocol.h>
1312
#include <pubkey.h>
1413
#include <rpc/protocol.h>
1514
#include <rpc/request.h>
@@ -60,7 +59,6 @@ extern const std::string UNIX_EPOCH_TIME;
6059
extern const std::string EXAMPLE_ADDRESS[2];
6160

6261
class FillableSigningProvider;
63-
class CPubKey;
6462
class CScript;
6563
struct Sections;
6664

@@ -133,9 +131,6 @@ std::pair<int64_t, int64_t> ParseDescriptorRange(const UniValue& value);
133131
/** Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range of 1000. */
134132
std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, FlatSigningProvider& provider, const bool expand_priv = false);
135133

136-
/** Returns, given services flags, a list of humanly readable (known) network services */
137-
UniValue GetServicesNames(ServiceFlags services);
138-
139134
/**
140135
* Serializing JSON objects depends on the outer type. Only arrays and
141136
* dictionaries can be nested in json. The top-level outer type is "NONE".

0 commit comments

Comments
 (0)