Skip to content

Commit f9ac96b

Browse files
committed
net: decouple state independent service flags from desirable ones
This former one will be moved to the peer manager class in the following-up commit.
1 parent 97df4e3 commit f9ac96b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

contrib/seeds/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Utility to generate the seeds.txt list that is compiled into the client
44
(see [src/chainparamsseeds.h](/src/chainparamsseeds.h) and other utilities in [contrib/seeds](/contrib/seeds)).
55

66
Be sure to update `PATTERN_AGENT` in `makeseeds.py` to include the current version,
7-
and remove old versions as necessary (at a minimum when GetDesirableServiceFlags
7+
and remove old versions as necessary (at a minimum when SeedsServiceFlags()
88
changes its default return value, as those are the services which seeds are added
99
to addrman with).
1010

src/net.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static std::vector<CAddress> ConvertSeeds(const std::vector<uint8_t> &vSeedsIn)
202202
while (!s.eof()) {
203203
CService endpoint;
204204
s >> endpoint;
205-
CAddress addr{endpoint, GetDesirableServiceFlags(NODE_NONE)};
205+
CAddress addr{endpoint, SeedsServiceFlags()};
206206
addr.nTime = rng.rand_uniform_delay(Now<NodeSeconds>() - one_week, -one_week);
207207
LogPrint(BCLog::NET, "Added hardcoded seed: %s\n", addr.ToStringAddrPort());
208208
vSeedsOut.push_back(addr);
@@ -2273,7 +2273,7 @@ void CConnman::ThreadDNSAddressSeed()
22732273
AddAddrFetch(seed);
22742274
} else {
22752275
std::vector<CAddress> vAdd;
2276-
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
2276+
constexpr ServiceFlags requiredServiceBits{SeedsServiceFlags()};
22772277
std::string host = strprintf("x%x.%s", requiredServiceBits, seed);
22782278
CNetAddr resolveSource;
22792279
if (!resolveSource.SetInternal(host)) {

src/protocol.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,17 @@ std::vector<std::string> serviceFlagsToStr(uint64_t flags);
330330
* guaranteed to not change dependent on state - ie they are suitable for
331331
* use when describing peers which we know to be desirable, but for which
332332
* we do not have a confirmed set of service flags.
333-
*
334-
* If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py
335-
* should be updated appropriately to filter for the same nodes.
336333
*/
337334
ServiceFlags GetDesirableServiceFlags(ServiceFlags services);
338335

336+
/**
337+
* State independent service flags.
338+
* If the return value is changed, contrib/seeds/makeseeds.py
339+
* should be updated appropriately to filter for nodes with
340+
* desired service flags (compatible with our new flags).
341+
*/
342+
constexpr ServiceFlags SeedsServiceFlags() { return ServiceFlags(NODE_NETWORK | NODE_WITNESS); }
343+
339344
/** Set the current IBD status in order to figure out the desirable service flags */
340345
void SetServiceFlagsIBDCache(bool status);
341346

0 commit comments

Comments
 (0)