This is part 1 of #19315, which enables the ability to test outbound and block-relay-only connections from the functional tests. Please see that PR for more information of overall functionality.
This PR simplifies how we manage different connection types. It introduces an enum with the various types of connections so we can explicitly define the connection type. The existing system relies on a series of independent flags, then has asserts scattered around to ensure that conflicting flags are not enabled at the same time. I find this approach to be both brittle and confusing. While making these changes, I found a small bug due to the silent assumptions.
This PR also proposes a rename from OneShot to AddrFetch. I find the name OneShot to be very confusing, especially when we also have onetry manual connections. Everyone I’ve talked to offline has agreed that the name is confusing, so I propose a potential alternative. I think this is a good opportunity for a rename since I’m creating an enum to explicitly define the connection types.
(some context for the unfamiliar: oneshot or addrfetch connections are short-lived connections created on startup. They connect to the seed peers, send a getaddr to solicit addresses, then close the connection.)
Overview of this PR:
- rename oneshottoaddrfetch
- introduce ConnectionTypeenum
- one by one, add different connection types to the enum
- expose the conn_typeon CNode, and use this to reduce reliance on flags (& asserts)
- fix the bug in counting different type of connections
- some additional cleanup to simplify logic and make expectations explicit/inclusive rather than implicit/exclusive.