user132147: What does the bitcoin protocol do to handle collisions when adding addresses to the new table?

user131606: In case of a collision of addrs in the new table, the existing address will normally stay (and nothing changes) - unless

the existing entry is already present somewhere else in the new table (an address can be in up to 8 different buckets/positions at the same time), or
if the existing entry is of bad quality ("terrible")

In these two cases the existing entry will be replaced by the new one.
There are several criteria by which a node can be terrible, roughly:

if its timestamp is too far in the future or too far in the past from the current time.
if we unsuccessfully tried to connect to it too often in the past

See Addrman::IsTerrible() for details / exact limits.
It may also be worth to mention that the behavior in case of collisions in the tried table is very different from this ("test before evict").

132147: <p>What does the bitcoin protocol do to handle collisions when adding addresses to the new table?</p>
 131606: <p>In case of a collision of addrs in the new table, the existing address will normally stay (and nothing changes) - unless</p>
<ul>
<li>the existing entry is already present somewhere else in the new table (an address can be in up to 8 different buckets/positions at the same time), or</li>
<li>if the existing entry is of bad quality (&quot;terrible&quot;)</li>
</ul>
<p>In these two cases the existing entry will be replaced by the new one.
There are several criteria by which a node can be terrible, roughly:</p>
<ul>
<li>if its timestamp is too far in the future or too far in the past from the current time.</li>
<li>if we unsuccessfully tried to connect to it too often in the past</li>
</ul>
<p>See <a href="https://github.com/bitcoin/bitcoin/blob/aa6fb37accc6445855c81b6b236e574586df9c28/src/addrman.cpp#L67" rel="nofollow noreferrer">Addrman::IsTerrible()</a> for details / exact limits.
It may also be worth to mention that the behavior in case of collisions in the tried table is very different from this (&quot;test before evict&quot;).</p>
