I think the relation between connections opening order (anchors -> regular outbounds) and the enforcement of peer diversity should be underscored better. With this patchset, I believe outbound peer diversity is enforced by the fact that OUTBOUND_FULL_RELAY/BLOCK_RELAY are opened after anchors and thus those regular outbound addresses will be checked against the anchor ones.
It could be better to exist this loop normally to let other checks happening while avoiding to call AddrMan::Select thanks to the newanchor
flag ? And add a comment above the connection type selection loop underscoring the order importance to avoid future work modifying it. E.g opening an OUTBOUND_FULL_RELAY may evict inadvertently an anchor in the same netgroup, thus diminishing effectiveness of anchors.
It would also enforce HasDesirableServiceFlags()
on anchors. It’s unlikely we learn change of their services before we connect to them but our desirability may have changed between a restart. Further, in case of a buggy/malicious anchors.dat
we should check network groups distinctness of anchors among themselves.