AddrMan currently doesn’t track the number of its entries by network, it only knows the total number of addresses. This PR makes AddrMan keep track of these numbers, which would be helpful for multiple things:
- Allow to specifically add fixed seeds to AddrMan of networks where we don’t have any addresses yet - even if AddrMan as a whole is not empty (partly fixing #26035). This is in particular helpful if the user abruptly changes
-onlynet
settings (such that addrs that used to be reachable are no longer and vice versa), in which case they currently could get stuck and not find any outbound peers. The second commit of this PR implements this. - (Future work): Add logic for automatic connection management with respect to networks - such as making attempts to have at least one connection to each reachable network as suggested here. This would involve requesting an address from a particular network from AddrMan, and expanding its corresponding function
AddrMan::Select()
to do this requires internal knowledge of the current number of addresses for each network and table to avoid getting stuck in endless loops. - (Future work): Perhaps display the totals to users. At least I would find this helpful to debug, the existing option (
./bitcoin-cli -addrinfo
) is rather indirect by doing the aggregation itself in each call, doesn’t distinguish between new and tried, and being based onAddrMan::GetAddr()
it’s also subject to a quality filter which we probably don’t want in this spot.