238 | @@ -239,7 +239,9 @@ void CAddrMan::Good_(const CService& addr, bool test_before_evict, int64_t nTime
239 |
240 | // Will moving this address into tried evict another entry?
241 | if (test_before_evict && (vvTried[tried_bucket][tried_bucket_pos] != -1)) {
242 | - LogPrint(BCLog::ADDRMAN, "Collision inserting element into tried table, moving %s to m_tried_collisions=%d\n", addr.ToString(), m_tried_collisions.size());
243 | + // Output the entry we'd be colliding with, for debugging purposes
244 | + auto colliding_entry = mapInfo.find(vvTried[tried_bucket][tried_bucket_pos]);
245 | + LogPrint(BCLog::ADDRMAN, "Collision inserting element into tried table (%s), moving %s to m_tried_collisions=%d\n", colliding_entry != mapInfo.end() ? colliding_entry->second.ToString() : "", addr.ToString(), m_tried_collisions.size());
when m_tried_collisions is full we don't add the entry, so this log statement should be inside the if statement below.
Background question: why is ok that we don't add this collision to m_tried_collisions, yet also don't call MakeTried? I assume it' because when called with test_before_evict, we don't evict when in doubt.
Which line are you referring to with the statement about not adding the collision to m_tried_collisions?
I don't think it's quite as simple as "when in doubt, don't evict". I think in the case of a collision we bias ourselves towards not evicting, unless the peer we might evict can't be connected to via feeler connection.
My thought is that if m_tried_collisions is ever full, it seems like that is a scenario where we may be under attack; so not replacing things in our tried table (which we assume to have some good peers in it) is safe, even if not optimal. Maybe @EthanHeilman or @gmaxwell has a better intuition for how this works though.
I agree with your intuition.
We bias toward not evicting. The assumption is that if the tried table is contains many evil IPs we have already lost and won't hear about good IPs. Thus, we assume the tried has many good IPs and that they should not be evicted unless a particular IP in tried is offline and thus no longer provides security.